@tenphi/tasty 0.7.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/definitions.js +1 -2
- package/dist/chunks/definitions.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/parser/classify.js.map +1 -1
- package/dist/pipeline/materialize.js +59 -47
- package/dist/pipeline/materialize.js.map +1 -1
- package/dist/pipeline/parseStateKey.js +18 -5
- package/dist/pipeline/parseStateKey.js.map +1 -1
- package/dist/styles/predefined.d.ts +0 -2
- package/dist/styles/predefined.js +0 -3
- package/dist/styles/predefined.js.map +1 -1
- package/dist/styles/scrollbar.d.ts +9 -5
- package/dist/styles/scrollbar.js +25 -89
- package/dist/styles/scrollbar.js.map +1 -1
- package/dist/styles/types.d.ts +10 -13
- package/dist/tasty.d.ts +2 -3
- package/dist/utils/selector-transform.js +32 -0
- package/dist/utils/selector-transform.js.map +1 -0
- package/dist/utils/styles.d.ts +1 -2
- package/dist/utils/styles.js +1 -22
- package/dist/utils/styles.js.map +1 -1
- package/docs/styles.md +19 -12
- package/docs/usage.md +53 -1
- package/package.json +1 -1
- package/dist/styles/styledScrollbar.d.ts +0 -47
- package/dist/styles/styledScrollbar.js +0 -38
- package/dist/styles/styledScrollbar.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"materialize.js","names":[],"sources":["../../src/pipeline/materialize.ts"],"sourcesContent":["/**\n * CSS Materialization\n *\n * Converts condition trees into CSS selectors and at-rules.\n * This is the final stage that produces actual CSS output.\n */\n\nimport { Lru } from '../parser/lru';\n\nimport type {\n ConditionNode,\n ContainerCondition,\n MediaCondition,\n ModifierCondition,\n PseudoCondition,\n StateCondition,\n SupportsCondition,\n} from './conditions';\nimport { getConditionUniqueId, not } from './conditions';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Parsed media condition for structured analysis and combination\n */\nexport interface ParsedMediaCondition {\n /** Subtype for structured analysis */\n subtype: 'dimension' | 'feature' | 'type';\n /** Whether this is a negated condition */\n negated: boolean;\n /** The condition part for CSS output (e.g., \"(width < 600px)\", \"print\") */\n condition: string;\n /** For dimension queries: dimension name */\n dimension?: 'width' | 'height' | 'inline-size' | 'block-size';\n /** For dimension queries: lower bound value */\n lowerBound?: {\n value: string;\n valueNumeric: number | null;\n inclusive: boolean;\n };\n /** For dimension queries: upper bound value */\n upperBound?: {\n value: string;\n valueNumeric: number | null;\n inclusive: boolean;\n };\n /** For feature queries: feature name */\n feature?: string;\n /** For feature queries: feature value */\n featureValue?: string;\n /** For type queries: media type */\n mediaType?: 'print' | 'screen' | 'all' | 'speech';\n}\n\n/**\n * Parsed container condition for structured analysis and combination\n */\nexport interface ParsedContainerCondition {\n /** Container name (undefined = unnamed/nearest container) */\n name?: string;\n /** The condition part (e.g., \"(width < 600px)\" or \"style(--variant: danger)\") */\n condition: string;\n /** Whether this is a negated condition */\n negated: boolean;\n /** Subtype for structured analysis */\n subtype: 'dimension' | 'style' | 'raw';\n /** For style queries: property name (without --) */\n property?: string;\n /** For style queries: property value (undefined = existence check) */\n propertyValue?: string;\n}\n\n/**\n * Parsed supports condition for structured analysis and combination\n */\nexport interface ParsedSupportsCondition {\n /** Subtype: 'feature' for property support, 'selector' for selector() support */\n subtype: 'feature' | 'selector';\n /** The condition string (e.g., \"display: grid\" or \":has(*)\") */\n condition: string;\n /** Whether this is a negated condition */\n negated: boolean;\n}\n\n/**\n * Parsed modifier condition for structured analysis\n */\nexport interface ParsedModifierCondition {\n /** Attribute name (e.g., 'data-hovered', 'data-size') */\n attribute: string;\n /** Value if present (e.g., 'large', 'danger') */\n value?: string;\n /** Operator for value matching (default '=') */\n operator?: '=' | '^=' | '$=' | '*=';\n /** Whether this is negated (:not(...)) */\n negated: boolean;\n}\n\n/**\n * Parsed pseudo-class condition for structured analysis\n */\nexport interface ParsedPseudoCondition {\n /** The pseudo-class (e.g., ':hover', ':focus-visible', ':has(> Icon)') */\n pseudo: string;\n /** Whether this is negated (:not(...)) */\n negated: boolean;\n}\n\n/** Modifier or pseudo condition (shared across own/root/parent) */\ntype ParsedSelectorCondition = ParsedModifierCondition | ParsedPseudoCondition;\n\n/**\n * A group of parent conditions originating from a single @parent() call.\n * Each group produces its own :is() wrapper in the final CSS.\n * Separate @parent() calls = separate groups = can match different ancestors.\n * @parent(a & b) = one group with two conditions = same ancestor must match both.\n */\nexport interface ParentGroup {\n conditions: ParsedSelectorCondition[];\n direct: boolean;\n negated: boolean;\n}\n\n/**\n * A single selector variant (one term in a DNF expression)\n */\nexport interface SelectorVariant {\n /** Structured modifier conditions */\n modifierConditions: ParsedModifierCondition[];\n\n /** Structured pseudo conditions */\n pseudoConditions: ParsedPseudoCondition[];\n\n /** Structured own conditions (for sub-element states) */\n ownConditions: ParsedSelectorCondition[];\n\n /** Parsed media conditions for structured combination */\n mediaConditions: ParsedMediaCondition[];\n\n /** Parsed container conditions for structured combination */\n containerConditions: ParsedContainerCondition[];\n\n /** Parsed supports conditions for @supports at-rules */\n supportsConditions: ParsedSupportsCondition[];\n\n /** Root conditions (modifier/pseudo applied to :root) */\n rootConditions: ParsedSelectorCondition[];\n\n /** Parent condition groups — each @parent() call is a separate group */\n parentGroups: ParentGroup[];\n\n /** Whether to wrap in @starting-style */\n startingStyle: boolean;\n}\n\n/**\n * CSS output components extracted from a condition\n * Supports multiple variants for OR conditions (DNF form)\n */\nexport interface CSSComponents {\n /** Selector variants - OR means multiple variants, AND means single variant with combined selectors */\n variants: SelectorVariant[];\n\n /** Whether condition is impossible (should skip) */\n isImpossible: boolean;\n}\n\n/**\n * Final CSS rule output\n */\nexport interface CSSRule {\n /** Single selector or array of selector fragments (for OR conditions) */\n selector: string | string[];\n declarations: string;\n atRules?: string[];\n rootPrefix?: string;\n}\n\n// ============================================================================\n// Caching\n// ============================================================================\n\nconst conditionCache = new Lru<string, CSSComponents>(3000);\n\n// ============================================================================\n// Main Functions\n// ============================================================================\n\n/**\n * Convert a condition tree to CSS components\n */\nexport function conditionToCSS(node: ConditionNode): CSSComponents {\n // Check cache\n const key = getConditionUniqueId(node);\n const cached = conditionCache.get(key);\n if (cached) {\n return cached;\n }\n\n const result = conditionToCSSInner(node);\n\n // Cache result\n conditionCache.set(key, result);\n\n return result;\n}\n\n/**\n * Clear the condition cache (for testing)\n */\nexport function clearConditionCache(): void {\n conditionCache.clear();\n}\n\n// ============================================================================\n// Inner Implementation\n// ============================================================================\n\nfunction emptyVariant(): SelectorVariant {\n return {\n modifierConditions: [],\n pseudoConditions: [],\n ownConditions: [],\n mediaConditions: [],\n containerConditions: [],\n supportsConditions: [],\n rootConditions: [],\n parentGroups: [],\n startingStyle: false,\n };\n}\n\nfunction conditionToCSSInner(node: ConditionNode): CSSComponents {\n // Base case: TRUE condition - single empty variant (matches everything)\n if (node.kind === 'true') {\n return {\n variants: [emptyVariant()],\n isImpossible: false,\n };\n }\n\n // Base case: FALSE condition - no variants (matches nothing)\n if (node.kind === 'false') {\n return {\n variants: [],\n isImpossible: true,\n };\n }\n\n // State condition\n if (node.kind === 'state') {\n return stateToCSS(node);\n }\n\n // Compound condition\n if (node.kind === 'compound') {\n if (node.operator === 'AND') {\n return andToCSS(node.children);\n } else {\n return orToCSS(node.children);\n }\n }\n\n // Fallback - single empty variant\n return {\n variants: [emptyVariant()],\n isImpossible: false,\n };\n}\n\n/**\n * Convert a state condition to CSS\n */\nfunction stateToCSS(state: StateCondition): CSSComponents {\n switch (state.type) {\n case 'media': {\n const mediaResults = mediaToParsed(state);\n const variants = mediaResults.map((mediaCond) => {\n const v = emptyVariant();\n v.mediaConditions.push(mediaCond);\n return v;\n });\n return { variants, isImpossible: false };\n }\n\n case 'root':\n return innerConditionToVariants(\n state.innerCondition,\n state.negated ?? false,\n 'rootConditions',\n );\n\n case 'parent':\n return parentConditionToVariants(\n state.innerCondition,\n state.negated ?? false,\n state.direct,\n );\n\n case 'own':\n return innerConditionToVariants(\n state.innerCondition,\n state.negated ?? false,\n 'ownConditions',\n );\n\n case 'modifier': {\n const v = emptyVariant();\n v.modifierConditions.push(modifierToParsed(state));\n return { variants: [v], isImpossible: false };\n }\n\n case 'pseudo': {\n const v = emptyVariant();\n v.pseudoConditions.push(pseudoToParsed(state));\n return { variants: [v], isImpossible: false };\n }\n\n case 'container': {\n const v = emptyVariant();\n v.containerConditions.push(containerToParsed(state));\n return { variants: [v], isImpossible: false };\n }\n\n case 'supports': {\n const v = emptyVariant();\n v.supportsConditions.push(supportsToParsed(state));\n return { variants: [v], isImpossible: false };\n }\n\n case 'starting': {\n const v = emptyVariant();\n v.startingStyle = !state.negated;\n return { variants: [v], isImpossible: false };\n }\n }\n}\n\n/**\n * Convert modifier condition to parsed structure\n */\nfunction modifierToParsed(state: ModifierCondition): ParsedModifierCondition {\n return {\n attribute: state.attribute,\n value: state.value,\n operator: state.operator,\n negated: state.negated ?? false,\n };\n}\n\n/**\n * Convert parsed modifier to CSS selector string (for final output)\n */\nexport function modifierToCSS(mod: ParsedModifierCondition): string {\n let selector: string;\n\n if (mod.value !== undefined) {\n // Value attribute: [data-attr=\"value\"]\n const op = mod.operator || '=';\n selector = `[${mod.attribute}${op}\"${mod.value}\"]`;\n } else {\n // Boolean attribute: [data-attr]\n selector = `[${mod.attribute}]`;\n }\n\n if (mod.negated) {\n return `:not(${selector})`;\n }\n return selector;\n}\n\n/**\n * Convert pseudo condition to parsed structure\n */\nfunction pseudoToParsed(state: PseudoCondition): ParsedPseudoCondition {\n return {\n pseudo: state.pseudo,\n negated: state.negated ?? false,\n };\n}\n\n/**\n * Convert parsed pseudo to CSS selector string (for final output)\n */\nexport function pseudoToCSS(pseudo: ParsedPseudoCondition): string {\n if (pseudo.negated) {\n // Wrap in :not() if not already\n if (pseudo.pseudo.startsWith(':not(')) {\n // Double negation - remove :not()\n return pseudo.pseudo.slice(5, -1);\n }\n return `:not(${pseudo.pseudo})`;\n }\n return pseudo.pseudo;\n}\n\n/**\n * Convert media condition to parsed structure(s)\n * Returns an array because negated ranges produce OR branches (two separate conditions)\n */\nfunction mediaToParsed(state: MediaCondition): ParsedMediaCondition[] {\n if (state.subtype === 'type') {\n // @media:print → @media print (or @media not print)\n const mediaType = state.mediaType || 'all';\n return [\n {\n subtype: 'type',\n negated: state.negated ?? false,\n condition: mediaType,\n mediaType: state.mediaType,\n },\n ];\n } else if (state.subtype === 'feature') {\n // @media(prefers-contrast: high) → @media (prefers-contrast: high)\n let condition: string;\n if (state.featureValue) {\n condition = `(${state.feature}: ${state.featureValue})`;\n } else {\n condition = `(${state.feature})`;\n }\n return [\n {\n subtype: 'feature',\n negated: state.negated ?? false,\n condition,\n feature: state.feature,\n featureValue: state.featureValue,\n },\n ];\n } else {\n // Dimension query - negation is handled by inverting the condition\n // because \"not (width < x)\" doesn't work reliably in browsers\n return dimensionToMediaParsed(\n state.dimension || 'width',\n state.lowerBound,\n state.upperBound,\n state.negated ?? false,\n );\n }\n}\n\n/**\n * Convert dimension bounds to parsed media condition(s)\n * Uses CSS Media Queries Level 4 `not (condition)` syntax for negation.\n */\nfunction dimensionToMediaParsed(\n dimension: 'width' | 'height' | 'inline-size' | 'block-size',\n lowerBound?: {\n value: string;\n valueNumeric: number | null;\n inclusive: boolean;\n },\n upperBound?: {\n value: string;\n valueNumeric: number | null;\n inclusive: boolean;\n },\n negated?: boolean,\n): ParsedMediaCondition[] {\n // Build the condition string\n let condition: string;\n if (lowerBound && upperBound) {\n const lowerOp = lowerBound.inclusive ? '<=' : '<';\n const upperOp = upperBound.inclusive ? '<=' : '<';\n condition = `(${lowerBound.value} ${lowerOp} ${dimension} ${upperOp} ${upperBound.value})`;\n } else if (upperBound) {\n const op = upperBound.inclusive ? '<=' : '<';\n condition = `(${dimension} ${op} ${upperBound.value})`;\n } else if (lowerBound) {\n const op = lowerBound.inclusive ? '>=' : '>';\n condition = `(${dimension} ${op} ${lowerBound.value})`;\n } else {\n condition = `(${dimension})`;\n }\n\n // For negation, we use CSS `not (condition)` syntax in buildAtRulesFromVariant\n return [\n {\n subtype: 'dimension',\n negated: negated ?? false,\n condition,\n dimension,\n lowerBound,\n upperBound,\n },\n ];\n}\n\n/**\n * Convert container condition to parsed structure\n * This enables structured analysis for contradiction detection and condition combining\n */\nfunction containerToParsed(\n state: ContainerCondition,\n): ParsedContainerCondition {\n let condition: string;\n\n if (state.subtype === 'style') {\n // Style query: style(--prop: value)\n if (state.propertyValue) {\n condition = `style(--${state.property}: ${state.propertyValue})`;\n } else {\n condition = `style(--${state.property})`;\n }\n } else if (state.subtype === 'raw') {\n // Raw function query: passed through verbatim (e.g., scroll-state(stuck: top))\n condition = state.rawCondition!;\n } else {\n // Dimension query\n condition = dimensionToContainerCondition(\n state.dimension || 'width',\n state.lowerBound,\n state.upperBound,\n );\n }\n\n return {\n name: state.containerName,\n condition,\n negated: state.negated ?? false,\n subtype: state.subtype,\n property: state.property,\n propertyValue: state.propertyValue,\n };\n}\n\n/**\n * Convert dimension bounds to container query condition (single string)\n * Container queries support \"not (condition)\", so no need to invert manually\n */\nfunction dimensionToContainerCondition(\n dimension: string,\n lowerBound?: { value: string; inclusive: boolean },\n upperBound?: { value: string; inclusive: boolean },\n): string {\n if (lowerBound && upperBound) {\n const lowerOp = lowerBound.inclusive ? '<=' : '<';\n const upperOp = upperBound.inclusive ? '<=' : '<';\n return `(${lowerBound.value} ${lowerOp} ${dimension} ${upperOp} ${upperBound.value})`;\n } else if (upperBound) {\n const op = upperBound.inclusive ? '<=' : '<';\n return `(${dimension} ${op} ${upperBound.value})`;\n } else if (lowerBound) {\n const op = lowerBound.inclusive ? '>=' : '>';\n return `(${dimension} ${op} ${lowerBound.value})`;\n }\n return '(width)'; // Fallback\n}\n\n/**\n * Convert supports condition to parsed structure\n */\nfunction supportsToParsed(state: SupportsCondition): ParsedSupportsCondition {\n return {\n subtype: state.subtype,\n condition: state.condition,\n negated: state.negated ?? false,\n };\n}\n\n/**\n * Collect all modifier and pseudo conditions from a variant as a flat array.\n */\nfunction collectSelectorConditions(\n variant: SelectorVariant,\n): ParsedSelectorCondition[] {\n return [...variant.modifierConditions, ...variant.pseudoConditions];\n}\n\n/**\n * Convert an inner condition tree into SelectorVariants.\n * Each inner OR branch becomes a separate variant, preserving disjunction.\n * Shared by @root() and @own().\n */\nfunction innerConditionToVariants(\n innerCondition: ConditionNode,\n negated: boolean,\n target: 'rootConditions' | 'ownConditions',\n): CSSComponents {\n // For @root/@own, negation is applied upfront via De Morgan: !(A | B) = !A & !B.\n // This is safe because the negated conditions are appended directly to the same\n // selector (e.g. :root:not([a]):not([b])), so collapsing OR branches is correct.\n //\n // @parent uses a different strategy (parentConditionToVariants) because each OR\n // branch must become its own :not(... *) wrapper — the * combinator scopes to a\n // specific ancestor, so branches cannot be merged into one selector.\n const effectiveCondition = negated ? not(innerCondition) : innerCondition;\n const innerCSS = conditionToCSS(effectiveCondition);\n\n if (innerCSS.isImpossible || innerCSS.variants.length === 0) {\n return { variants: [], isImpossible: true };\n }\n\n const variants: SelectorVariant[] = [];\n\n for (const innerVariant of innerCSS.variants) {\n const conditions = collectSelectorConditions(innerVariant);\n\n if (conditions.length > 0) {\n const v = emptyVariant();\n v[target].push(...conditions);\n variants.push(v);\n }\n }\n\n if (variants.length === 0) {\n return { variants: [emptyVariant()], isImpossible: false };\n }\n\n return { variants, isImpossible: false };\n}\n\n/**\n * Convert a @parent() inner condition into SelectorVariants with ParentGroups.\n *\n * Positive: each inner OR branch becomes a separate variant with one :is() group.\n * Negated: !(A | B) = !A & !B — all branches become :not() groups collected\n * into a single variant so they produce :not([a] *):not([b] *) on one element.\n */\nfunction parentConditionToVariants(\n innerCondition: ConditionNode,\n negated: boolean,\n direct: boolean,\n): CSSComponents {\n const innerCSS = conditionToCSS(innerCondition);\n\n if (innerCSS.isImpossible || innerCSS.variants.length === 0) {\n return { variants: [], isImpossible: true };\n }\n\n if (negated) {\n // Collect all OR branches into one variant as separate :not() groups.\n const v = emptyVariant();\n\n for (const innerVariant of innerCSS.variants) {\n const conditions = collectSelectorConditions(innerVariant);\n\n if (conditions.length > 0) {\n v.parentGroups.push({ conditions, direct, negated: true });\n }\n }\n\n if (v.parentGroups.length === 0) {\n return { variants: [emptyVariant()], isImpossible: false };\n }\n\n return { variants: [v], isImpossible: false };\n }\n\n // Positive: each OR branch is a separate variant\n const variants: SelectorVariant[] = [];\n\n for (const innerVariant of innerCSS.variants) {\n const conditions = collectSelectorConditions(innerVariant);\n\n if (conditions.length > 0) {\n const v = emptyVariant();\n v.parentGroups.push({ conditions, direct, negated: false });\n variants.push(v);\n }\n }\n\n if (variants.length === 0) {\n return { variants: [emptyVariant()], isImpossible: false };\n }\n\n return { variants, isImpossible: false };\n}\n\n/**\n * Convert parsed root conditions to CSS selector prefix (for final output)\n */\nexport function rootConditionsToCSS(\n roots: ParsedSelectorCondition[],\n): string | undefined {\n if (roots.length === 0) return undefined;\n\n let prefix = ':root';\n for (const cond of roots) {\n prefix += selectorConditionToCSS(cond);\n }\n return prefix;\n}\n\n/**\n * Convert parent groups to CSS selector fragments (for final output).\n * Each group produces its own :is() wrapper.\n */\nexport function parentGroupsToCSS(groups: ParentGroup[]): string {\n let result = '';\n for (const group of groups) {\n const combinator = group.direct ? ' > *' : ' *';\n let parts = '';\n for (const cond of group.conditions) {\n parts += selectorConditionToCSS(cond);\n }\n const wrapper = group.negated ? ':not' : ':is';\n result += `${wrapper}(${parts}${combinator})`;\n }\n return result;\n}\n\n/**\n * Convert a modifier or pseudo condition to a CSS selector fragment\n */\nexport function selectorConditionToCSS(cond: ParsedSelectorCondition): string {\n if ('attribute' in cond) {\n return modifierToCSS(cond);\n }\n return pseudoToCSS(cond);\n}\n\n/**\n * Get unique key for a modifier condition\n */\nfunction getModifierKey(mod: ParsedModifierCondition): string {\n const base = mod.value\n ? `${mod.attribute}${mod.operator || '='}${mod.value}`\n : mod.attribute;\n return mod.negated ? `!${base}` : base;\n}\n\n/**\n * Get unique key for a pseudo condition\n */\nfunction getPseudoKey(pseudo: ParsedPseudoCondition): string {\n return pseudo.negated ? `!${pseudo.pseudo}` : pseudo.pseudo;\n}\n\n/**\n * Get unique key for any selector condition (modifier or pseudo)\n */\nfunction getSelectorConditionKey(cond: ParsedSelectorCondition): string {\n return 'attribute' in cond\n ? `mod:${getModifierKey(cond)}`\n : `pseudo:${getPseudoKey(cond)}`;\n}\n\n/**\n * Deduplicate selector conditions (modifiers or pseudos).\n * Shared by root, parent, and own conditions.\n */\nfunction dedupeSelectorConditions(\n conditions: ParsedSelectorCondition[],\n): ParsedSelectorCondition[] {\n // Pass 1: exact-key dedup\n const seen = new Set<string>();\n let result: ParsedSelectorCondition[] = [];\n for (const c of conditions) {\n const key = getSelectorConditionKey(c);\n if (!seen.has(key)) {\n seen.add(key);\n result.push(c);\n }\n }\n\n // Pass 2: remove negated value modifiers subsumed by other modifiers.\n // :not([data-attr]) subsumes :not([data-attr=\"value\"])\n // [data-attr=\"X\"] implies :not([data-attr=\"Y\"]) is redundant\n // This implication only holds for exact-match (=) operators; substring\n // operators (^=, $=, *=) don't imply exclusivity between values.\n const negatedBooleanAttrs = new Set<string>();\n const positiveExactValuesByAttr = new Map<string, Set<string>>();\n\n for (const c of result) {\n if (!('attribute' in c)) continue;\n if (c.negated && c.value === undefined) {\n negatedBooleanAttrs.add(c.attribute);\n }\n const op = c.operator ?? '=';\n if (!c.negated && c.value !== undefined && op === '=') {\n let values = positiveExactValuesByAttr.get(c.attribute);\n if (!values) {\n values = new Set();\n positiveExactValuesByAttr.set(c.attribute, values);\n }\n values.add(c.value);\n }\n }\n\n result = result.filter((c) => {\n if (!('attribute' in c) || !c.negated || c.value === undefined) {\n return true;\n }\n if (negatedBooleanAttrs.has(c.attribute)) {\n return false;\n }\n const op = c.operator ?? '=';\n if (op !== '=') return true;\n const positiveValues = positiveExactValuesByAttr.get(c.attribute);\n if (\n positiveValues !== undefined &&\n positiveValues.size === 1 &&\n !positiveValues.has(c.value)\n ) {\n return false;\n }\n return true;\n });\n\n return result;\n}\n\n/**\n * Check for modifier contradiction: same attribute with opposite negation\n */\nfunction hasModifierContradiction(\n conditions: ParsedModifierCondition[],\n): boolean {\n const byKey = new Map<string, boolean>(); // base key -> isPositive\n\n for (const mod of conditions) {\n const baseKey = mod.value\n ? `${mod.attribute}${mod.operator || '='}${mod.value}`\n : mod.attribute;\n const existing = byKey.get(baseKey);\n if (existing !== undefined && existing !== !mod.negated) {\n return true; // Same attribute with opposite negation\n }\n byKey.set(baseKey, !mod.negated);\n }\n return false;\n}\n\n/**\n * Check for pseudo contradiction: same pseudo with opposite negation\n */\nfunction hasPseudoContradiction(conditions: ParsedPseudoCondition[]): boolean {\n const byKey = new Map<string, boolean>(); // pseudo -> isPositive\n\n for (const pseudo of conditions) {\n const existing = byKey.get(pseudo.pseudo);\n if (existing !== undefined && existing !== !pseudo.negated) {\n return true; // Same pseudo with opposite negation\n }\n byKey.set(pseudo.pseudo, !pseudo.negated);\n }\n return false;\n}\n\n/**\n * Check for selector condition contradiction (modifier or pseudo with opposite negation).\n * Shared by root, parent, and own conditions.\n */\nfunction hasSelectorConditionContradiction(\n conditions: ParsedSelectorCondition[],\n): boolean {\n const modifiers: ParsedModifierCondition[] = [];\n const pseudos: ParsedPseudoCondition[] = [];\n\n for (const c of conditions) {\n if ('attribute' in c) {\n modifiers.push(c);\n } else {\n pseudos.push(c);\n }\n }\n\n return hasModifierContradiction(modifiers) || hasPseudoContradiction(pseudos);\n}\n\n/**\n * Check for parent group contradiction: same target (direct + conditions)\n * with opposite negation. E.g. :not([data-hovered] *) and :is([data-hovered] *)\n * in the same variant is impossible.\n */\nfunction hasParentGroupContradiction(groups: ParentGroup[]): boolean {\n const byBaseKey = new Map<string, boolean>();\n\n for (const g of groups) {\n const baseKey = `${g.direct ? '>' : ''}(${g.conditions.map(getSelectorConditionKey).sort().join(',')})`;\n const existing = byBaseKey.get(baseKey);\n if (existing !== undefined && existing !== !g.negated) {\n return true;\n }\n byBaseKey.set(baseKey, !g.negated);\n }\n return false;\n}\n\n/**\n * Merge two selector variants (AND operation)\n * Deduplicates conditions and checks for contradictions\n */\nfunction mergeVariants(\n a: SelectorVariant,\n b: SelectorVariant,\n): SelectorVariant | null {\n // Merge media conditions and check for contradictions\n const mergedMedia = dedupeMediaConditions([\n ...a.mediaConditions,\n ...b.mediaConditions,\n ]);\n if (hasMediaContradiction(mergedMedia)) {\n return null; // Impossible variant\n }\n\n // Merge root conditions and check for contradictions\n const mergedRoots = dedupeSelectorConditions([\n ...a.rootConditions,\n ...b.rootConditions,\n ]);\n if (hasSelectorConditionContradiction(mergedRoots)) {\n return null; // Impossible variant\n }\n\n // Merge modifier and pseudo conditions separately, then cross-check\n const mergedModifiers = dedupeSelectorConditions([\n ...a.modifierConditions,\n ...b.modifierConditions,\n ]) as ParsedModifierCondition[];\n const mergedPseudos = dedupeSelectorConditions([\n ...a.pseudoConditions,\n ...b.pseudoConditions,\n ]) as ParsedPseudoCondition[];\n if (\n hasSelectorConditionContradiction([...mergedModifiers, ...mergedPseudos])\n ) {\n return null; // Impossible variant\n }\n\n // Concatenate parent groups (each group is an independent :is() wrapper)\n const mergedParentGroups = [...a.parentGroups, ...b.parentGroups];\n if (hasParentGroupContradiction(mergedParentGroups)) {\n return null; // Impossible variant\n }\n\n // Merge own conditions and check for contradictions\n const mergedOwn = dedupeSelectorConditions([\n ...a.ownConditions,\n ...b.ownConditions,\n ]);\n if (hasSelectorConditionContradiction(mergedOwn)) {\n return null; // Impossible variant\n }\n\n // Merge container conditions and check for contradictions\n const mergedContainers = dedupeContainerConditions([\n ...a.containerConditions,\n ...b.containerConditions,\n ]);\n if (hasContainerStyleContradiction(mergedContainers)) {\n return null; // Impossible variant\n }\n\n // Merge supports conditions and check for contradictions\n const mergedSupports = dedupeSupportsConditions([\n ...a.supportsConditions,\n ...b.supportsConditions,\n ]);\n if (hasSupportsContradiction(mergedSupports)) {\n return null; // Impossible variant\n }\n\n return {\n modifierConditions: mergedModifiers,\n pseudoConditions: mergedPseudos,\n ownConditions: mergedOwn,\n mediaConditions: mergedMedia,\n containerConditions: mergedContainers,\n supportsConditions: mergedSupports,\n rootConditions: mergedRoots,\n parentGroups: mergedParentGroups,\n startingStyle: a.startingStyle || b.startingStyle,\n };\n}\n\n/**\n * Generic deduplication by a key extraction function.\n * Preserves insertion order, keeping the first occurrence of each key.\n */\nfunction dedupeByKey<T>(items: T[], getKey: (item: T) => string): T[] {\n const seen = new Set<string>();\n const result: T[] = [];\n for (const item of items) {\n const key = getKey(item);\n if (!seen.has(key)) {\n seen.add(key);\n result.push(item);\n }\n }\n return result;\n}\n\nfunction dedupeMediaConditions(\n conditions: ParsedMediaCondition[],\n): ParsedMediaCondition[] {\n return dedupeByKey(\n conditions,\n (c) => `${c.subtype}|${c.condition}|${c.negated}`,\n );\n}\n\nfunction dedupeContainerConditions(\n conditions: ParsedContainerCondition[],\n): ParsedContainerCondition[] {\n return dedupeByKey(\n conditions,\n (c) => `${c.name ?? ''}|${c.condition}|${c.negated}`,\n );\n}\n\nfunction dedupeSupportsConditions(\n conditions: ParsedSupportsCondition[],\n): ParsedSupportsCondition[] {\n return dedupeByKey(\n conditions,\n (c) => `${c.subtype}|${c.condition}|${c.negated}`,\n );\n}\n\n/**\n * Check if supports conditions contain contradictions\n * e.g., @supports(display: grid) AND NOT @supports(display: grid)\n */\nfunction hasSupportsContradiction(\n conditions: ParsedSupportsCondition[],\n): boolean {\n const conditionMap = new Map<string, boolean>(); // key -> isPositive\n\n for (const cond of conditions) {\n const key = `${cond.subtype}|${cond.condition}`;\n const existing = conditionMap.get(key);\n if (existing !== undefined && existing !== !cond.negated) {\n return true; // Contradiction: positive AND negated\n }\n conditionMap.set(key, !cond.negated);\n }\n\n return false;\n}\n\n/**\n * Check if a set of media conditions contains contradictions\n * e.g., (prefers-color-scheme: light) AND NOT (prefers-color-scheme: light)\n * or (width >= 900px) AND (width < 600px)\n *\n * Uses parsed media conditions for efficient analysis without regex parsing.\n */\nfunction hasMediaContradiction(conditions: ParsedMediaCondition[]): boolean {\n // Track conditions by their key (condition string) to detect A and NOT A\n const featureConditions = new Map<string, boolean>(); // key -> isPositive\n const typeConditions = new Map<string, boolean>(); // mediaType -> isPositive\n const dimensionConditions = new Map<string, boolean>(); // condition -> isPositive\n\n // Track dimension conditions for range contradiction detection (non-negated only)\n const dimensionsByDim = new Map<\n string,\n { lowerBound: number | null; upperBound: number | null }\n >();\n\n for (const cond of conditions) {\n if (cond.subtype === 'type') {\n // Type query: check for direct contradiction (print AND NOT print)\n const key = cond.mediaType || 'all';\n const existing = typeConditions.get(key);\n if (existing !== undefined && existing !== !cond.negated) {\n return true; // Contradiction: positive AND negated\n }\n typeConditions.set(key, !cond.negated);\n } else if (cond.subtype === 'feature') {\n // Feature query: check for direct contradiction\n const key = cond.condition;\n const existing = featureConditions.get(key);\n if (existing !== undefined && existing !== !cond.negated) {\n return true; // Contradiction: positive AND negated\n }\n featureConditions.set(key, !cond.negated);\n } else if (cond.subtype === 'dimension') {\n // First, check for direct contradiction: (width < 600px) AND NOT (width < 600px)\n const condKey = cond.condition;\n const existing = dimensionConditions.get(condKey);\n if (existing !== undefined && existing !== !cond.negated) {\n return true; // Contradiction: positive AND negated\n }\n dimensionConditions.set(condKey, !cond.negated);\n\n // For range analysis, only consider non-negated conditions\n // Negated conditions are handled via the direct contradiction check above\n if (!cond.negated) {\n const dim = cond.dimension || 'width';\n let bounds = dimensionsByDim.get(dim);\n if (!bounds) {\n bounds = { lowerBound: null, upperBound: null };\n dimensionsByDim.set(dim, bounds);\n }\n\n // Track the effective bounds\n if (cond.lowerBound?.valueNumeric != null) {\n const value = cond.lowerBound.valueNumeric;\n if (bounds.lowerBound === null || value > bounds.lowerBound) {\n bounds.lowerBound = value;\n }\n }\n if (cond.upperBound?.valueNumeric != null) {\n const value = cond.upperBound.valueNumeric;\n if (bounds.upperBound === null || value < bounds.upperBound) {\n bounds.upperBound = value;\n }\n }\n\n // Check for impossible range\n if (\n bounds.lowerBound !== null &&\n bounds.upperBound !== null &&\n bounds.lowerBound >= bounds.upperBound\n ) {\n return true;\n }\n }\n }\n }\n\n return false;\n}\n\n/**\n * Check if container conditions contain contradictions in style queries\n * e.g., style(--variant: danger) and style(--variant: success) together\n * Same property with different values = always false\n *\n * Uses parsed container conditions for efficient analysis without regex parsing.\n */\nfunction hasContainerStyleContradiction(\n conditions: ParsedContainerCondition[],\n): boolean {\n // Track style queries by property name\n // key: property name, value: { hasExistence: boolean, values: Set<string>, hasNegatedExistence: boolean }\n const styleQueries = new Map<\n string,\n { hasExistence: boolean; values: Set<string>; hasNegatedExistence: boolean }\n >();\n\n for (const cond of conditions) {\n // Only analyze style queries\n if (cond.subtype !== 'style' || !cond.property) {\n continue;\n }\n\n const property = cond.property;\n const value = cond.propertyValue;\n\n if (!styleQueries.has(property)) {\n styleQueries.set(property, {\n hasExistence: false,\n values: new Set(),\n hasNegatedExistence: false,\n });\n }\n\n const entry = styleQueries.get(property)!;\n\n if (cond.negated) {\n if (value === undefined) {\n // not style(--prop) - negated existence check\n entry.hasNegatedExistence = true;\n }\n // Negated value checks don't contradict positive value checks directly\n // They just mean \"not this value\"\n } else {\n if (value === undefined) {\n // style(--prop) - existence check\n entry.hasExistence = true;\n } else {\n // style(--prop: value) - value check\n entry.values.add(value);\n }\n }\n }\n\n // Check for contradictions\n for (const [, entry] of styleQueries) {\n // Contradiction: existence check + negated existence check\n if (entry.hasExistence && entry.hasNegatedExistence) {\n return true;\n }\n\n // Contradiction: multiple different values for same property\n // style(--variant: danger) AND style(--variant: success) is impossible\n if (entry.values.size > 1) {\n return true;\n }\n\n // Contradiction: negated existence + value check\n // not style(--variant) AND style(--variant: danger) is impossible\n if (entry.hasNegatedExistence && entry.values.size > 0) {\n return true;\n }\n }\n\n return false;\n}\n\nconst variantKeyCache = new WeakMap<SelectorVariant, string>();\n\n/**\n * Get a unique key for a variant (for deduplication).\n * Cached via WeakMap since variants are compared multiple times during\n * deduplication and sorting.\n */\nfunction getVariantKey(v: SelectorVariant): string {\n const cached = variantKeyCache.get(v);\n if (cached !== undefined) return cached;\n const modifierKey = v.modifierConditions.map(getModifierKey).sort().join('|');\n const pseudoKey = v.pseudoConditions.map(getPseudoKey).sort().join('|');\n const ownKey = v.ownConditions.map(getSelectorConditionKey).sort().join('|');\n const containerKey = v.containerConditions\n .map((c) => `${c.name ?? ''}:${c.negated ? '!' : ''}${c.condition}`)\n .sort()\n .join('|');\n const mediaKey = v.mediaConditions\n .map((c) => `${c.subtype}:${c.negated ? '!' : ''}${c.condition}`)\n .sort()\n .join('|');\n const supportsKey = v.supportsConditions\n .map((c) => `${c.subtype}:${c.negated ? '!' : ''}${c.condition}`)\n .sort()\n .join('|');\n const rootKey = v.rootConditions\n .map(getSelectorConditionKey)\n .sort()\n .join('|');\n const parentKey = v.parentGroups.map(getParentGroupKey).sort().join('|');\n const key = [\n modifierKey,\n pseudoKey,\n ownKey,\n mediaKey,\n containerKey,\n supportsKey,\n rootKey,\n parentKey,\n v.startingStyle ? '1' : '0',\n ].join('###');\n variantKeyCache.set(v, key);\n return key;\n}\n\n/**\n * Check if variant A is a superset of variant B (A is more restrictive)\n *\n * If A has all of B's conditions plus more, then A is redundant\n * because B already covers the same cases (and more).\n *\n * Example:\n * A: :not([size=large]):not([size=medium]):not([size=small])\n * B: :not([size=large])\n * A is a superset of B, so A is redundant when B exists.\n */\nfunction isVariantSuperset(a: SelectorVariant, b: SelectorVariant): boolean {\n // Must have same context\n if (a.startingStyle !== b.startingStyle) return false;\n\n // Check if a.rootConditions is superset of b.rootConditions\n if (!isSelectorConditionsSuperset(a.rootConditions, b.rootConditions))\n return false;\n\n // Check if a.mediaConditions is superset of b.mediaConditions\n if (!isMediaConditionsSuperset(a.mediaConditions, b.mediaConditions))\n return false;\n\n // Check if a.containerConditions is superset of b.containerConditions\n if (\n !isContainerConditionsSuperset(a.containerConditions, b.containerConditions)\n )\n return false;\n\n // Check if a.supportsConditions is superset of b.supportsConditions\n if (!isSupportsConditionsSuperset(a.supportsConditions, b.supportsConditions))\n return false;\n\n // Check if a.modifierConditions is superset of b.modifierConditions\n if (!isModifierConditionsSuperset(a.modifierConditions, b.modifierConditions))\n return false;\n\n // Check if a.pseudoConditions is superset of b.pseudoConditions\n if (!isPseudoConditionsSuperset(a.pseudoConditions, b.pseudoConditions))\n return false;\n\n // Check if a.ownConditions is superset of b.ownConditions\n if (!isSelectorConditionsSuperset(a.ownConditions, b.ownConditions))\n return false;\n\n // Check if a.parentGroups is superset of b.parentGroups\n if (!isParentGroupsSuperset(a.parentGroups, b.parentGroups)) return false;\n\n // A is a superset if it has all of B's items (possibly more)\n // and at least one category has strictly more items\n const parentConditionCount = (groups: ParentGroup[]) =>\n groups.reduce((sum, g) => sum + g.conditions.length, 0);\n const aTotal =\n a.mediaConditions.length +\n a.containerConditions.length +\n a.supportsConditions.length +\n a.modifierConditions.length +\n a.pseudoConditions.length +\n a.rootConditions.length +\n parentConditionCount(a.parentGroups) +\n a.ownConditions.length;\n const bTotal =\n b.mediaConditions.length +\n b.containerConditions.length +\n b.supportsConditions.length +\n b.modifierConditions.length +\n b.pseudoConditions.length +\n b.rootConditions.length +\n parentConditionCount(b.parentGroups) +\n b.ownConditions.length;\n\n return aTotal > bTotal;\n}\n\n/**\n * Generic superset check: true if every item in B has a matching key in A.\n */\nfunction isConditionsSuperset<T>(\n a: T[],\n b: T[],\n getKey: (item: T) => string,\n): boolean {\n const aKeys = new Set(a.map(getKey));\n return b.every((c) => aKeys.has(getKey(c)));\n}\n\nfunction isMediaConditionsSuperset(\n a: ParsedMediaCondition[],\n b: ParsedMediaCondition[],\n): boolean {\n return isConditionsSuperset(\n a,\n b,\n (c) => `${c.subtype}|${c.condition}|${c.negated}`,\n );\n}\n\nfunction isContainerConditionsSuperset(\n a: ParsedContainerCondition[],\n b: ParsedContainerCondition[],\n): boolean {\n return isConditionsSuperset(\n a,\n b,\n (c) => `${c.name ?? ''}|${c.condition}|${c.negated}`,\n );\n}\n\nfunction isSupportsConditionsSuperset(\n a: ParsedSupportsCondition[],\n b: ParsedSupportsCondition[],\n): boolean {\n return isConditionsSuperset(\n a,\n b,\n (c) => `${c.subtype}|${c.condition}|${c.negated}`,\n );\n}\n\nfunction isModifierConditionsSuperset(\n a: ParsedModifierCondition[],\n b: ParsedModifierCondition[],\n): boolean {\n return isConditionsSuperset(a, b, getModifierKey);\n}\n\nfunction isPseudoConditionsSuperset(\n a: ParsedPseudoCondition[],\n b: ParsedPseudoCondition[],\n): boolean {\n return isConditionsSuperset(a, b, getPseudoKey);\n}\n\nfunction isSelectorConditionsSuperset(\n a: ParsedSelectorCondition[],\n b: ParsedSelectorCondition[],\n): boolean {\n return isConditionsSuperset(a, b, getSelectorConditionKey);\n}\n\n/**\n * Check if parent groups A is a superset of B.\n * Each group in B must have a matching group in A.\n */\nfunction isParentGroupsSuperset(a: ParentGroup[], b: ParentGroup[]): boolean {\n if (a.length < b.length) return false;\n return isConditionsSuperset(a, b, getParentGroupKey);\n}\n\nfunction getParentGroupKey(g: ParentGroup): string {\n return `${g.negated ? '!' : ''}${g.direct ? '>' : ''}(${g.conditions.map(getSelectorConditionKey).sort().join(',')})`;\n}\n\n/**\n * Deduplicate variants\n *\n * Removes:\n * 1. Exact duplicates (same key)\n * 2. Superset variants (more restrictive selectors that are redundant)\n */\nfunction dedupeVariants(variants: SelectorVariant[]): SelectorVariant[] {\n // First pass: exact deduplication\n const seen = new Set<string>();\n const result: SelectorVariant[] = [];\n\n for (const v of variants) {\n const key = getVariantKey(v);\n if (!seen.has(key)) {\n seen.add(key);\n result.push(v);\n }\n }\n\n // Second pass: remove supersets (more restrictive variants)\n // Sort by total condition count (fewer conditions = less restrictive = keep)\n const variantConditionCount = (v: SelectorVariant) =>\n v.modifierConditions.length +\n v.pseudoConditions.length +\n v.ownConditions.length +\n v.mediaConditions.length +\n v.containerConditions.length +\n v.supportsConditions.length +\n v.rootConditions.length +\n v.parentGroups.reduce((sum, g) => sum + g.conditions.length, 0);\n result.sort((a, b) => variantConditionCount(a) - variantConditionCount(b));\n\n // Remove variants that are supersets of earlier (less restrictive) variants\n const filtered: SelectorVariant[] = [];\n for (const candidate of result) {\n let isRedundant = false;\n for (const kept of filtered) {\n if (isVariantSuperset(candidate, kept)) {\n isRedundant = true;\n break;\n }\n }\n if (!isRedundant) {\n filtered.push(candidate);\n }\n }\n\n return filtered;\n}\n\n/**\n * Combine AND conditions into CSS\n *\n * AND of conditions means cartesian product of variants:\n * (A1 | A2) & (B1 | B2) = A1&B1 | A1&B2 | A2&B1 | A2&B2\n *\n * Variants that result in contradictions (e.g., conflicting media rules)\n * are filtered out.\n */\nfunction andToCSS(children: ConditionNode[]): CSSComponents {\n // Start with a single empty variant\n let currentVariants: SelectorVariant[] = [emptyVariant()];\n\n for (const child of children) {\n const childCSS = conditionToCSSInner(child);\n\n if (childCSS.isImpossible || childCSS.variants.length === 0) {\n return { variants: [], isImpossible: true };\n }\n\n // Cartesian product: each current variant × each child variant\n const newVariants: SelectorVariant[] = [];\n for (const current of currentVariants) {\n for (const childVariant of childCSS.variants) {\n const merged = mergeVariants(current, childVariant);\n // Skip impossible variants (contradictions detected during merge)\n if (merged !== null) {\n newVariants.push(merged);\n }\n }\n }\n\n if (newVariants.length === 0) {\n return { variants: [], isImpossible: true };\n }\n\n // Deduplicate after each step to prevent exponential blowup\n currentVariants = dedupeVariants(newVariants);\n }\n\n return {\n variants: currentVariants,\n isImpossible: false,\n };\n}\n\n/**\n * Combine OR conditions into CSS\n *\n * OR in CSS means multiple selector variants (DNF).\n * Each variant becomes a separate selector in the comma-separated list,\n * or multiple CSS rules if they have different at-rules.\n *\n * Note: OR exclusivity is handled at the pipeline level (expandOrConditions),\n * so here we just collect all variants. Any remaining ORs in the condition\n * tree (e.g., from De Morgan expansion) are handled as simple alternatives.\n */\nfunction orToCSS(children: ConditionNode[]): CSSComponents {\n const allVariants: SelectorVariant[] = [];\n\n for (const child of children) {\n const childCSS = conditionToCSSInner(child);\n if (childCSS.isImpossible) continue;\n\n allVariants.push(...childCSS.variants);\n }\n\n if (allVariants.length === 0) {\n return { variants: [], isImpossible: true };\n }\n\n // Deduplicate variants\n return {\n variants: dedupeVariants(allVariants),\n isImpossible: false,\n };\n}\n\n// ============================================================================\n// Utility Functions\n// ============================================================================\n\n/**\n * Build at-rules array from a variant\n */\nexport function buildAtRulesFromVariant(variant: SelectorVariant): string[] {\n const atRules: string[] = [];\n\n // Add media rules - combine all conditions with \"and\"\n if (variant.mediaConditions.length > 0) {\n const conditionParts = variant.mediaConditions.map((c) => {\n if (c.subtype === 'type') {\n // Media type: print, screen, etc.\n return c.negated ? `not ${c.condition}` : c.condition;\n } else {\n // Feature or dimension: use not (condition) syntax for negation\n // MQ Level 4 requires parentheses around the condition for negation\n return c.negated ? `(not ${c.condition})` : c.condition;\n }\n });\n atRules.push(`@media ${conditionParts.join(' and ')}`);\n }\n\n // Add container rules - group by container name and combine with \"and\"\n if (variant.containerConditions.length > 0) {\n // Group conditions by container name (undefined = unnamed/nearest)\n const byName = new Map<string | undefined, ParsedContainerCondition[]>();\n for (const cond of variant.containerConditions) {\n const group = byName.get(cond.name) || [];\n group.push(cond);\n byName.set(cond.name, group);\n }\n\n // Build one @container rule per container name\n for (const [name, conditions] of byName) {\n // CSS Container Query syntax requires parentheses around negated conditions:\n // @container (not style(--x)) and style(--y) - NOT @container not style(--x) and style(--y)\n const conditionParts = conditions.map((c) =>\n c.negated ? `(not ${c.condition})` : c.condition,\n );\n const namePrefix = name ? `${name} ` : '';\n atRules.push(`@container ${namePrefix}${conditionParts.join(' and ')}`);\n }\n }\n\n // Add supports rules - combine all conditions with \"and\"\n if (variant.supportsConditions.length > 0) {\n const conditionParts = variant.supportsConditions.map((c) => {\n // Build the condition based on subtype\n // feature: (display: grid) or (not (display: grid))\n // selector: selector(:has(*)) or (not selector(:has(*)))\n if (c.subtype === 'selector') {\n const selectorCond = `selector(${c.condition})`;\n return c.negated ? `(not ${selectorCond})` : selectorCond;\n } else {\n const featureCond = `(${c.condition})`;\n return c.negated ? `(not ${featureCond})` : featureCond;\n }\n });\n atRules.push(`@supports ${conditionParts.join(' and ')}`);\n }\n\n // Add starting-style\n if (variant.startingStyle) {\n atRules.push('@starting-style');\n }\n\n return atRules;\n}\n"],"mappings":";;;;;;;;;;AAwLA,MAAM,iBAAiB,IAAI,IAA2B,IAAK;;;;AAS3D,SAAgB,eAAe,MAAoC;CAEjE,MAAM,MAAM,qBAAqB,KAAK;CACtC,MAAM,SAAS,eAAe,IAAI,IAAI;AACtC,KAAI,OACF,QAAO;CAGT,MAAM,SAAS,oBAAoB,KAAK;AAGxC,gBAAe,IAAI,KAAK,OAAO;AAE/B,QAAO;;AAcT,SAAS,eAAgC;AACvC,QAAO;EACL,oBAAoB,EAAE;EACtB,kBAAkB,EAAE;EACpB,eAAe,EAAE;EACjB,iBAAiB,EAAE;EACnB,qBAAqB,EAAE;EACvB,oBAAoB,EAAE;EACtB,gBAAgB,EAAE;EAClB,cAAc,EAAE;EAChB,eAAe;EAChB;;AAGH,SAAS,oBAAoB,MAAoC;AAE/D,KAAI,KAAK,SAAS,OAChB,QAAO;EACL,UAAU,CAAC,cAAc,CAAC;EAC1B,cAAc;EACf;AAIH,KAAI,KAAK,SAAS,QAChB,QAAO;EACL,UAAU,EAAE;EACZ,cAAc;EACf;AAIH,KAAI,KAAK,SAAS,QAChB,QAAO,WAAW,KAAK;AAIzB,KAAI,KAAK,SAAS,WAChB,KAAI,KAAK,aAAa,MACpB,QAAO,SAAS,KAAK,SAAS;KAE9B,QAAO,QAAQ,KAAK,SAAS;AAKjC,QAAO;EACL,UAAU,CAAC,cAAc,CAAC;EAC1B,cAAc;EACf;;;;;AAMH,SAAS,WAAW,OAAsC;AACxD,SAAQ,MAAM,MAAd;EACE,KAAK,QAOH,QAAO;GAAE,UANY,cAAc,MAAM,CACX,KAAK,cAAc;IAC/C,MAAM,IAAI,cAAc;AACxB,MAAE,gBAAgB,KAAK,UAAU;AACjC,WAAO;KACP;GACiB,cAAc;GAAO;EAG1C,KAAK,OACH,QAAO,y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AI,EAAE;AACzC,SAAM,KAAK,KAAK;AAChB,UAAO,IAAI,KAAK,MAAM,MAAM;;AAI9B,OAAK,MAAM,CAAC,MAAM,eAAe,QAAQ;GAGvC,MAAM,iBAAiB,WAAW,KAAK,MACrC,EAAE,UAAU,QAAQ,EAAE,UAAU,KAAK,EAAE,UACxC;GACD,MAAM,aAAa,OAAO,GAAG,KAAK,KAAK;AACvC,WAAQ,KAAK,cAAc,aAAa,eAAe,KAAK,QAAQ,GAAG;;;AAK3E,KAAI,QAAQ,mBAAmB,SAAS,GAAG;EACzC,MAAM,iBAAiB,QAAQ,mBAAmB,KAAK,MAAM;AAI3D,OAAI,EAAE,YAAY,YAAY;IAC5B,MAAM,eAAe,YAAY,EAAE,UAAU;AAC7C,WAAO,EAAE,UAAU,QAAQ,aAAa,KAAK;UACxC;IACL,MAAM,cAAc,IAAI,EAAE,UAAU;AACpC,WAAO,EAAE,UAAU,QAAQ,YAAY,KAAK;;IAE9C;AACF,UAAQ,KAAK,aAAa,eAAe,KAAK,QAAQ,GAAG;;AAI3D,KAAI,QAAQ,cACV,SAAQ,KAAK,kBAAkB;AAGjC,QAAO"}
|
|
1
|
+
{"version":3,"file":"materialize.js","names":[],"sources":["../../src/pipeline/materialize.ts"],"sourcesContent":["/**\n * CSS Materialization\n *\n * Converts condition trees into CSS selectors and at-rules.\n * This is the final stage that produces actual CSS output.\n */\n\nimport { Lru } from '../parser/lru';\n\nimport type {\n ConditionNode,\n ContainerCondition,\n MediaCondition,\n ModifierCondition,\n PseudoCondition,\n StateCondition,\n SupportsCondition,\n} from './conditions';\nimport { getConditionUniqueId, not } from './conditions';\n\n// ============================================================================\n// Types\n// ============================================================================\n\n/**\n * Parsed media condition for structured analysis and combination\n */\nexport interface ParsedMediaCondition {\n /** Subtype for structured analysis */\n subtype: 'dimension' | 'feature' | 'type';\n /** Whether this is a negated condition */\n negated: boolean;\n /** The condition part for CSS output (e.g., \"(width < 600px)\", \"print\") */\n condition: string;\n /** For dimension queries: dimension name */\n dimension?: 'width' | 'height' | 'inline-size' | 'block-size';\n /** For dimension queries: lower bound value */\n lowerBound?: {\n value: string;\n valueNumeric: number | null;\n inclusive: boolean;\n };\n /** For dimension queries: upper bound value */\n upperBound?: {\n value: string;\n valueNumeric: number | null;\n inclusive: boolean;\n };\n /** For feature queries: feature name */\n feature?: string;\n /** For feature queries: feature value */\n featureValue?: string;\n /** For type queries: media type */\n mediaType?: 'print' | 'screen' | 'all' | 'speech';\n}\n\n/**\n * Parsed container condition for structured analysis and combination\n */\nexport interface ParsedContainerCondition {\n /** Container name (undefined = unnamed/nearest container) */\n name?: string;\n /** The condition part (e.g., \"(width < 600px)\" or \"style(--variant: danger)\") */\n condition: string;\n /** Whether this is a negated condition */\n negated: boolean;\n /** Subtype for structured analysis */\n subtype: 'dimension' | 'style' | 'raw';\n /** For style queries: property name (without --) */\n property?: string;\n /** For style queries: property value (undefined = existence check) */\n propertyValue?: string;\n}\n\n/**\n * Parsed supports condition for structured analysis and combination\n */\nexport interface ParsedSupportsCondition {\n /** Subtype: 'feature' for property support, 'selector' for selector() support */\n subtype: 'feature' | 'selector';\n /** The condition string (e.g., \"display: grid\" or \":has(*)\") */\n condition: string;\n /** Whether this is a negated condition */\n negated: boolean;\n}\n\n/**\n * Parsed modifier condition for structured analysis\n */\nexport interface ParsedModifierCondition {\n /** Attribute name (e.g., 'data-hovered', 'data-size') */\n attribute: string;\n /** Value if present (e.g., 'large', 'danger') */\n value?: string;\n /** Operator for value matching (default '=') */\n operator?: '=' | '^=' | '$=' | '*=';\n /** Whether this is negated (:not(...)) */\n negated: boolean;\n}\n\n/**\n * Parsed pseudo-class condition for structured analysis\n */\nexport interface ParsedPseudoCondition {\n /** The pseudo-class (e.g., ':hover', ':focus-visible', ':has(> Icon)') */\n pseudo: string;\n /** Whether this is negated (:not(...)) */\n negated: boolean;\n}\n\n/** Modifier or pseudo condition (shared across own/root/parent) */\ntype ParsedSelectorCondition = ParsedModifierCondition | ParsedPseudoCondition;\n\n/**\n * A group of parent conditions originating from a single @parent() call.\n * Each group produces its own :is()/:not() wrapper in the final CSS.\n * Separate @parent() calls = separate groups = can match different ancestors.\n *\n * Each branch is an AND conjunction of conditions (one selector fragment).\n * Multiple branches are OR'd together inside the :is()/:not() wrapper.\n * Example: @parent(hovered & pressed | active)\n * branches: [[hovered, pressed], [active]]\n * renders: :is([data-hovered][data-pressed] *, [data-active] *)\n */\nexport interface ParentGroup {\n branches: ParsedSelectorCondition[][];\n direct: boolean;\n negated: boolean;\n}\n\n/**\n * A single selector variant (one term in a DNF expression)\n */\nexport interface SelectorVariant {\n /** Structured modifier conditions */\n modifierConditions: ParsedModifierCondition[];\n\n /** Structured pseudo conditions */\n pseudoConditions: ParsedPseudoCondition[];\n\n /** Structured own conditions (for sub-element states) */\n ownConditions: ParsedSelectorCondition[];\n\n /** Parsed media conditions for structured combination */\n mediaConditions: ParsedMediaCondition[];\n\n /** Parsed container conditions for structured combination */\n containerConditions: ParsedContainerCondition[];\n\n /** Parsed supports conditions for @supports at-rules */\n supportsConditions: ParsedSupportsCondition[];\n\n /** Root conditions (modifier/pseudo applied to :root) */\n rootConditions: ParsedSelectorCondition[];\n\n /** Parent condition groups — each @parent() call is a separate group */\n parentGroups: ParentGroup[];\n\n /** Whether to wrap in @starting-style */\n startingStyle: boolean;\n}\n\n/**\n * CSS output components extracted from a condition\n * Supports multiple variants for OR conditions (DNF form)\n */\nexport interface CSSComponents {\n /** Selector variants - OR means multiple variants, AND means single variant with combined selectors */\n variants: SelectorVariant[];\n\n /** Whether condition is impossible (should skip) */\n isImpossible: boolean;\n}\n\n/**\n * Final CSS rule output\n */\nexport interface CSSRule {\n /** Single selector or array of selector fragments (for OR conditions) */\n selector: string | string[];\n declarations: string;\n atRules?: string[];\n rootPrefix?: string;\n}\n\n// ============================================================================\n// Caching\n// ============================================================================\n\nconst conditionCache = new Lru<string, CSSComponents>(3000);\n\n// ============================================================================\n// Main Functions\n// ============================================================================\n\n/**\n * Convert a condition tree to CSS components\n */\nexport function conditionToCSS(node: ConditionNode): CSSComponents {\n // Check cache\n const key = getConditionUniqueId(node);\n const cached = conditionCache.get(key);\n if (cached) {\n return cached;\n }\n\n const result = conditionToCSSInner(node);\n\n // Cache result\n conditionCache.set(key, result);\n\n return result;\n}\n\n/**\n * Clear the condition cache (for testing)\n */\nexport function clearConditionCache(): void {\n conditionCache.clear();\n}\n\n// ============================================================================\n// Inner Implementation\n// ============================================================================\n\nfunction emptyVariant(): SelectorVariant {\n return {\n modifierConditions: [],\n pseudoConditions: [],\n ownConditions: [],\n mediaConditions: [],\n containerConditions: [],\n supportsConditions: [],\n rootConditions: [],\n parentGroups: [],\n startingStyle: false,\n };\n}\n\nfunction conditionToCSSInner(node: ConditionNode): CSSComponents {\n // Base case: TRUE condition - single empty variant (matches everything)\n if (node.kind === 'true') {\n return {\n variants: [emptyVariant()],\n isImpossible: false,\n };\n }\n\n // Base case: FALSE condition - no variants (matches nothing)\n if (node.kind === 'false') {\n return {\n variants: [],\n isImpossible: true,\n };\n }\n\n // State condition\n if (node.kind === 'state') {\n return stateToCSS(node);\n }\n\n // Compound condition\n if (node.kind === 'compound') {\n if (node.operator === 'AND') {\n return andToCSS(node.children);\n } else {\n return orToCSS(node.children);\n }\n }\n\n // Fallback - single empty variant\n return {\n variants: [emptyVariant()],\n isImpossible: false,\n };\n}\n\n/**\n * Convert a state condition to CSS\n */\nfunction stateToCSS(state: StateCondition): CSSComponents {\n switch (state.type) {\n case 'media': {\n const mediaResults = mediaToParsed(state);\n const variants = mediaResults.map((mediaCond) => {\n const v = emptyVariant();\n v.mediaConditions.push(mediaCond);\n return v;\n });\n return { variants, isImpossible: false };\n }\n\n case 'root':\n return innerConditionToVariants(\n state.innerCondition,\n state.negated ?? false,\n 'rootConditions',\n );\n\n case 'parent':\n return parentConditionToVariants(\n state.innerCondition,\n state.negated ?? false,\n state.direct,\n );\n\n case 'own':\n return innerConditionToVariants(\n state.innerCondition,\n state.negated ?? false,\n 'ownConditions',\n );\n\n case 'modifier': {\n const v = emptyVariant();\n v.modifierConditions.push(modifierToParsed(state));\n return { variants: [v], isImpossible: false };\n }\n\n case 'pseudo': {\n const v = emptyVariant();\n v.pseudoConditions.push(pseudoToParsed(state));\n return { variants: [v], isImpossible: false };\n }\n\n case 'container': {\n const v = emptyVariant();\n v.containerConditions.push(containerToParsed(state));\n return { variants: [v], isImpossible: false };\n }\n\n case 'supports': {\n const v = emptyVariant();\n v.supportsConditions.push(supportsToParsed(state));\n return { variants: [v], isImpossible: false };\n }\n\n case 'starting': {\n const v = emptyVariant();\n v.startingStyle = !state.negated;\n return { variants: [v], isImpossible: false };\n }\n }\n}\n\n/**\n * Convert modifier condition to parsed structure\n */\nfunction modifierToParsed(state: ModifierCondition): ParsedModifierCondition {\n return {\n attribute: state.attribute,\n value: state.value,\n operator: state.operator,\n negated: state.negated ?? false,\n };\n}\n\n/**\n * Convert parsed modifier to CSS selector string (for final output)\n */\nexport function modifierToCSS(mod: ParsedModifierCondition): string {\n let selector: string;\n\n if (mod.value !== undefined) {\n // Value attribute: [data-attr=\"value\"]\n const op = mod.operator || '=';\n selector = `[${mod.attribute}${op}\"${mod.value}\"]`;\n } else {\n // Boolean attribute: [data-attr]\n selector = `[${mod.attribute}]`;\n }\n\n if (mod.negated) {\n return `:not(${selector})`;\n }\n return selector;\n}\n\n/**\n * Convert pseudo condition to parsed structure\n */\nfunction pseudoToParsed(state: PseudoCondition): ParsedPseudoCondition {\n return {\n pseudo: state.pseudo,\n negated: state.negated ?? false,\n };\n}\n\n/**\n * Convert parsed pseudo to CSS selector string (for final output).\n *\n * :not() is normalized to negated :is() at parse time, so pseudo.pseudo\n * never starts with ':not(' here. When negated:\n * - :is(X) → :not(X) (unwrap :is)\n * - :where(X) → :not(X) (unwrap :where)\n * - :has(X) → :not(:has(X))\n * - other → :not(other)\n *\n * When not negated, single-argument :is()/:where() is unwrapped when the\n * inner content is a simple compound selector that can safely append to\n * the base selector (this happens after double-negation of :not()).\n */\nexport function pseudoToCSS(pseudo: ParsedPseudoCondition): string {\n const p = pseudo.pseudo;\n\n if (pseudo.negated) {\n if (p.startsWith(':is(') || p.startsWith(':where(')) {\n return `:not(${p.slice(p.indexOf('(') + 1, -1)})`;\n }\n return `:not(${p})`;\n }\n\n if ((p.startsWith(':is(') || p.startsWith(':where(')) && !p.includes(',')) {\n const inner = p.slice(p.indexOf('(') + 1, -1);\n const ch = inner[0];\n\n // Only unwrap when the inner content is a simple compound selector:\n // must start with a compoundable character and contain no whitespace\n // (whitespace implies combinators like `>`, `+`, `~`, or descendant).\n if (\n (ch === ':' || ch === '.' || ch === '[' || ch === '#') &&\n !/\\s/.test(inner)\n ) {\n return inner;\n }\n }\n\n return p;\n}\n\n/**\n * Convert media condition to parsed structure(s)\n * Returns an array because negated ranges produce OR branches (two separate conditions)\n */\nfunction mediaToParsed(state: MediaCondition): ParsedMediaCondition[] {\n if (state.subtype === 'type') {\n // @media:print → @media print (or @media not print)\n const mediaType = state.mediaType || 'all';\n return [\n {\n subtype: 'type',\n negated: state.negated ?? false,\n condition: mediaType,\n mediaType: state.mediaType,\n },\n ];\n } else if (state.subtype === 'feature') {\n // @media(prefers-contrast: high) → @media (prefers-contrast: high)\n let condition: string;\n if (state.featureValue) {\n condition = `(${state.feature}: ${state.featureValue})`;\n } else {\n condition = `(${state.feature})`;\n }\n return [\n {\n subtype: 'feature',\n negated: state.negated ?? false,\n condition,\n feature: state.feature,\n featureValue: state.featureValue,\n },\n ];\n } else {\n // Dimension query - negation is handled by inverting the condition\n // because \"not (width < x)\" doesn't work reliably in browsers\n return dimensionToMediaParsed(\n state.dimension || 'width',\n state.lowerBound,\n state.upperBound,\n state.negated ?? false,\n );\n }\n}\n\n/**\n * Convert dimension bounds to parsed media condition(s)\n * Uses CSS Media Queries Level 4 `not (condition)` syntax for negation.\n */\nfunction dimensionToMediaParsed(\n dimension: 'width' | 'height' | 'inline-size' | 'block-size',\n lowerBound?: {\n value: string;\n valueNumeric: number | null;\n inclusive: boolean;\n },\n upperBound?: {\n value: string;\n valueNumeric: number | null;\n inclusive: boolean;\n },\n negated?: boolean,\n): ParsedMediaCondition[] {\n // Build the condition string\n let condition: string;\n if (lowerBound && upperBound) {\n const lowerOp = lowerBound.inclusive ? '<=' : '<';\n const upperOp = upperBound.inclusive ? '<=' : '<';\n condition = `(${lowerBound.value} ${lowerOp} ${dimension} ${upperOp} ${upperBound.value})`;\n } else if (upperBound) {\n const op = upperBound.inclusive ? '<=' : '<';\n condition = `(${dimension} ${op} ${upperBound.value})`;\n } else if (lowerBound) {\n const op = lowerBound.inclusive ? '>=' : '>';\n condition = `(${dimension} ${op} ${lowerBound.value})`;\n } else {\n condition = `(${dimension})`;\n }\n\n // For negation, we use CSS `not (condition)` syntax in buildAtRulesFromVariant\n return [\n {\n subtype: 'dimension',\n negated: negated ?? false,\n condition,\n dimension,\n lowerBound,\n upperBound,\n },\n ];\n}\n\n/**\n * Convert container condition to parsed structure\n * This enables structured analysis for contradiction detection and condition combining\n */\nfunction containerToParsed(\n state: ContainerCondition,\n): ParsedContainerCondition {\n let condition: string;\n\n if (state.subtype === 'style') {\n // Style query: style(--prop: value)\n if (state.propertyValue) {\n condition = `style(--${state.property}: ${state.propertyValue})`;\n } else {\n condition = `style(--${state.property})`;\n }\n } else if (state.subtype === 'raw') {\n // Raw function query: passed through verbatim (e.g., scroll-state(stuck: top))\n condition = state.rawCondition!;\n } else {\n // Dimension query\n condition = dimensionToContainerCondition(\n state.dimension || 'width',\n state.lowerBound,\n state.upperBound,\n );\n }\n\n return {\n name: state.containerName,\n condition,\n negated: state.negated ?? false,\n subtype: state.subtype,\n property: state.property,\n propertyValue: state.propertyValue,\n };\n}\n\n/**\n * Convert dimension bounds to container query condition (single string)\n * Container queries support \"not (condition)\", so no need to invert manually\n */\nfunction dimensionToContainerCondition(\n dimension: string,\n lowerBound?: { value: string; inclusive: boolean },\n upperBound?: { value: string; inclusive: boolean },\n): string {\n if (lowerBound && upperBound) {\n const lowerOp = lowerBound.inclusive ? '<=' : '<';\n const upperOp = upperBound.inclusive ? '<=' : '<';\n return `(${lowerBound.value} ${lowerOp} ${dimension} ${upperOp} ${upperBound.value})`;\n } else if (upperBound) {\n const op = upperBound.inclusive ? '<=' : '<';\n return `(${dimension} ${op} ${upperBound.value})`;\n } else if (lowerBound) {\n const op = lowerBound.inclusive ? '>=' : '>';\n return `(${dimension} ${op} ${lowerBound.value})`;\n }\n return '(width)'; // Fallback\n}\n\n/**\n * Convert supports condition to parsed structure\n */\nfunction supportsToParsed(state: SupportsCondition): ParsedSupportsCondition {\n return {\n subtype: state.subtype,\n condition: state.condition,\n negated: state.negated ?? false,\n };\n}\n\n/**\n * Collect all modifier and pseudo conditions from a variant as a flat array.\n */\nfunction collectSelectorConditions(\n variant: SelectorVariant,\n): ParsedSelectorCondition[] {\n return [...variant.modifierConditions, ...variant.pseudoConditions];\n}\n\n/**\n * Convert an inner condition tree into SelectorVariants.\n * Each inner OR branch becomes a separate variant, preserving disjunction.\n * Shared by @root() and @own().\n */\nfunction innerConditionToVariants(\n innerCondition: ConditionNode,\n negated: boolean,\n target: 'rootConditions' | 'ownConditions',\n): CSSComponents {\n // For @root/@own, negation is applied upfront via De Morgan: !(A | B) = !A & !B.\n // This is safe because the negated conditions are appended directly to the same\n // selector (e.g. :root:not([a]):not([b])), so collapsing OR branches is correct.\n //\n // @parent uses a different strategy (parentConditionToVariants) because\n // conditions are scoped to ancestors via the * combinator. OR branches are\n // kept inside a single ParentGroup and rendered as comma-separated arguments\n // in :is()/:not(), e.g. :is([a] *, [b] *). Negation just swaps :is for :not.\n const effectiveCondition = negated ? not(innerCondition) : innerCondition;\n const innerCSS = conditionToCSS(effectiveCondition);\n\n if (innerCSS.isImpossible || innerCSS.variants.length === 0) {\n return { variants: [], isImpossible: true };\n }\n\n const variants: SelectorVariant[] = [];\n\n for (const innerVariant of innerCSS.variants) {\n const conditions = collectSelectorConditions(innerVariant);\n\n if (conditions.length > 0) {\n const v = emptyVariant();\n v[target].push(...conditions);\n variants.push(v);\n }\n }\n\n if (variants.length === 0) {\n return { variants: [emptyVariant()], isImpossible: false };\n }\n\n return { variants, isImpossible: false };\n}\n\n/**\n * Convert a @parent() inner condition into a single SelectorVariant with\n * one ParentGroup whose branches represent the inner OR alternatives.\n *\n * Both positive and negated cases produce one variant with one group.\n * Negation simply sets the `negated` flag, which swaps :is() for :not()\n * in the final CSS output — no structural transformation is needed.\n */\nfunction parentConditionToVariants(\n innerCondition: ConditionNode,\n negated: boolean,\n direct: boolean,\n): CSSComponents {\n const innerCSS = conditionToCSS(innerCondition);\n\n if (innerCSS.isImpossible || innerCSS.variants.length === 0) {\n return { variants: [], isImpossible: true };\n }\n\n const branches: ParsedSelectorCondition[][] = [];\n\n for (const innerVariant of innerCSS.variants) {\n const conditions = collectSelectorConditions(innerVariant);\n\n if (conditions.length > 0) {\n branches.push(conditions);\n }\n }\n\n if (branches.length === 0) {\n return { variants: [emptyVariant()], isImpossible: false };\n }\n\n const v = emptyVariant();\n v.parentGroups.push({ branches, direct, negated });\n\n return { variants: [v], isImpossible: false };\n}\n\n/**\n * Convert parsed root conditions to CSS selector prefix (for final output)\n */\nexport function rootConditionsToCSS(\n roots: ParsedSelectorCondition[],\n): string | undefined {\n if (roots.length === 0) return undefined;\n\n let prefix = ':root';\n for (const cond of roots) {\n prefix += selectorConditionToCSS(cond);\n }\n return prefix;\n}\n\n/**\n * Convert parent groups to CSS selector fragments (for final output).\n * Each group produces its own :is() wrapper.\n */\nexport function parentGroupsToCSS(groups: ParentGroup[]): string {\n let result = '';\n for (const group of groups) {\n const combinator = group.direct ? ' > *' : ' *';\n const selectorArgs = group.branches.map((branch) => {\n let parts = '';\n for (const cond of branch) {\n parts += selectorConditionToCSS(cond);\n }\n return parts + combinator;\n });\n const wrapper = group.negated ? ':not' : ':is';\n result += `${wrapper}(${selectorArgs.join(', ')})`;\n }\n return result;\n}\n\n/**\n * Convert a modifier or pseudo condition to a CSS selector fragment\n */\nexport function selectorConditionToCSS(cond: ParsedSelectorCondition): string {\n if ('attribute' in cond) {\n return modifierToCSS(cond);\n }\n return pseudoToCSS(cond);\n}\n\n/**\n * Get unique key for a modifier condition\n */\nfunction getModifierKey(mod: ParsedModifierCondition): string {\n const base = mod.value\n ? `${mod.attribute}${mod.operator || '='}${mod.value}`\n : mod.attribute;\n return mod.negated ? `!${base}` : base;\n}\n\n/**\n * Get unique key for a pseudo condition\n */\nfunction getPseudoKey(pseudo: ParsedPseudoCondition): string {\n return pseudo.negated ? `!${pseudo.pseudo}` : pseudo.pseudo;\n}\n\n/**\n * Get unique key for any selector condition (modifier or pseudo)\n */\nfunction getSelectorConditionKey(cond: ParsedSelectorCondition): string {\n return 'attribute' in cond\n ? `mod:${getModifierKey(cond)}`\n : `pseudo:${getPseudoKey(cond)}`;\n}\n\n/**\n * Deduplicate selector conditions (modifiers or pseudos).\n * Shared by root, parent, and own conditions.\n */\nfunction dedupeSelectorConditions(\n conditions: ParsedSelectorCondition[],\n): ParsedSelectorCondition[] {\n // Pass 1: exact-key dedup\n const seen = new Set<string>();\n let result: ParsedSelectorCondition[] = [];\n for (const c of conditions) {\n const key = getSelectorConditionKey(c);\n if (!seen.has(key)) {\n seen.add(key);\n result.push(c);\n }\n }\n\n // Pass 2: remove negated value modifiers subsumed by other modifiers.\n // :not([data-attr]) subsumes :not([data-attr=\"value\"])\n // [data-attr=\"X\"] implies :not([data-attr=\"Y\"]) is redundant\n // This implication only holds for exact-match (=) operators; substring\n // operators (^=, $=, *=) don't imply exclusivity between values.\n const negatedBooleanAttrs = new Set<string>();\n const positiveExactValuesByAttr = new Map<string, Set<string>>();\n\n for (const c of result) {\n if (!('attribute' in c)) continue;\n if (c.negated && c.value === undefined) {\n negatedBooleanAttrs.add(c.attribute);\n }\n const op = c.operator ?? '=';\n if (!c.negated && c.value !== undefined && op === '=') {\n let values = positiveExactValuesByAttr.get(c.attribute);\n if (!values) {\n values = new Set();\n positiveExactValuesByAttr.set(c.attribute, values);\n }\n values.add(c.value);\n }\n }\n\n result = result.filter((c) => {\n if (!('attribute' in c) || !c.negated || c.value === undefined) {\n return true;\n }\n if (negatedBooleanAttrs.has(c.attribute)) {\n return false;\n }\n const op = c.operator ?? '=';\n if (op !== '=') return true;\n const positiveValues = positiveExactValuesByAttr.get(c.attribute);\n if (\n positiveValues !== undefined &&\n positiveValues.size === 1 &&\n !positiveValues.has(c.value)\n ) {\n return false;\n }\n return true;\n });\n\n return result;\n}\n\n/**\n * Check for modifier contradiction: same attribute with opposite negation\n */\nfunction hasModifierContradiction(\n conditions: ParsedModifierCondition[],\n): boolean {\n const byKey = new Map<string, boolean>(); // base key -> isPositive\n\n for (const mod of conditions) {\n const baseKey = mod.value\n ? `${mod.attribute}${mod.operator || '='}${mod.value}`\n : mod.attribute;\n const existing = byKey.get(baseKey);\n if (existing !== undefined && existing !== !mod.negated) {\n return true; // Same attribute with opposite negation\n }\n byKey.set(baseKey, !mod.negated);\n }\n return false;\n}\n\n/**\n * Check for pseudo contradiction: same pseudo with opposite negation\n */\nfunction hasPseudoContradiction(conditions: ParsedPseudoCondition[]): boolean {\n const byKey = new Map<string, boolean>(); // pseudo -> isPositive\n\n for (const pseudo of conditions) {\n const existing = byKey.get(pseudo.pseudo);\n if (existing !== undefined && existing !== !pseudo.negated) {\n return true; // Same pseudo with opposite negation\n }\n byKey.set(pseudo.pseudo, !pseudo.negated);\n }\n return false;\n}\n\n/**\n * Check for selector condition contradiction (modifier or pseudo with opposite negation).\n * Shared by root, parent, and own conditions.\n */\nfunction hasSelectorConditionContradiction(\n conditions: ParsedSelectorCondition[],\n): boolean {\n const modifiers: ParsedModifierCondition[] = [];\n const pseudos: ParsedPseudoCondition[] = [];\n\n for (const c of conditions) {\n if ('attribute' in c) {\n modifiers.push(c);\n } else {\n pseudos.push(c);\n }\n }\n\n return hasModifierContradiction(modifiers) || hasPseudoContradiction(pseudos);\n}\n\n/**\n * Check for parent group contradiction: same target (direct + conditions)\n * with opposite negation. E.g. :not([data-hovered] *) and :is([data-hovered] *)\n * in the same variant is impossible.\n */\nfunction getBranchesKey(branches: ParsedSelectorCondition[][]): string {\n if (branches.length === 1) {\n const b = branches[0];\n if (b.length === 1) return getSelectorConditionKey(b[0]);\n return b.map(getSelectorConditionKey).sort().join('+');\n }\n return branches\n .map((b) => b.map(getSelectorConditionKey).sort().join('+'))\n .sort()\n .join(',');\n}\n\nfunction hasParentGroupContradiction(groups: ParentGroup[]): boolean {\n const byBaseKey = new Map<string, boolean>();\n\n for (const g of groups) {\n const baseKey = `${g.direct ? '>' : ''}(${getBranchesKey(g.branches)})`;\n const existing = byBaseKey.get(baseKey);\n if (existing !== undefined && existing !== !g.negated) {\n return true;\n }\n byBaseKey.set(baseKey, !g.negated);\n }\n return false;\n}\n\n/**\n * Merge two selector variants (AND operation)\n * Deduplicates conditions and checks for contradictions\n */\nfunction mergeVariants(\n a: SelectorVariant,\n b: SelectorVariant,\n): SelectorVariant | null {\n // Merge media conditions and check for contradictions\n const mergedMedia = dedupeMediaConditions([\n ...a.mediaConditions,\n ...b.mediaConditions,\n ]);\n if (hasMediaContradiction(mergedMedia)) {\n return null; // Impossible variant\n }\n\n // Merge root conditions and check for contradictions\n const mergedRoots = dedupeSelectorConditions([\n ...a.rootConditions,\n ...b.rootConditions,\n ]);\n if (hasSelectorConditionContradiction(mergedRoots)) {\n return null; // Impossible variant\n }\n\n // Merge modifier and pseudo conditions separately, then cross-check\n const mergedModifiers = dedupeSelectorConditions([\n ...a.modifierConditions,\n ...b.modifierConditions,\n ]) as ParsedModifierCondition[];\n const mergedPseudos = dedupeSelectorConditions([\n ...a.pseudoConditions,\n ...b.pseudoConditions,\n ]) as ParsedPseudoCondition[];\n if (\n hasSelectorConditionContradiction([...mergedModifiers, ...mergedPseudos])\n ) {\n return null; // Impossible variant\n }\n\n // Concatenate parent groups (each group is an independent :is() wrapper)\n const mergedParentGroups = [...a.parentGroups, ...b.parentGroups];\n if (hasParentGroupContradiction(mergedParentGroups)) {\n return null; // Impossible variant\n }\n\n // Merge own conditions and check for contradictions\n const mergedOwn = dedupeSelectorConditions([\n ...a.ownConditions,\n ...b.ownConditions,\n ]);\n if (hasSelectorConditionContradiction(mergedOwn)) {\n return null; // Impossible variant\n }\n\n // Merge container conditions and check for contradictions\n const mergedContainers = dedupeContainerConditions([\n ...a.containerConditions,\n ...b.containerConditions,\n ]);\n if (hasContainerStyleContradiction(mergedContainers)) {\n return null; // Impossible variant\n }\n\n // Merge supports conditions and check for contradictions\n const mergedSupports = dedupeSupportsConditions([\n ...a.supportsConditions,\n ...b.supportsConditions,\n ]);\n if (hasSupportsContradiction(mergedSupports)) {\n return null; // Impossible variant\n }\n\n return {\n modifierConditions: mergedModifiers,\n pseudoConditions: mergedPseudos,\n ownConditions: mergedOwn,\n mediaConditions: mergedMedia,\n containerConditions: mergedContainers,\n supportsConditions: mergedSupports,\n rootConditions: mergedRoots,\n parentGroups: mergedParentGroups,\n startingStyle: a.startingStyle || b.startingStyle,\n };\n}\n\n/**\n * Generic deduplication by a key extraction function.\n * Preserves insertion order, keeping the first occurrence of each key.\n */\nfunction dedupeByKey<T>(items: T[], getKey: (item: T) => string): T[] {\n const seen = new Set<string>();\n const result: T[] = [];\n for (const item of items) {\n const key = getKey(item);\n if (!seen.has(key)) {\n seen.add(key);\n result.push(item);\n }\n }\n return result;\n}\n\nfunction dedupeMediaConditions(\n conditions: ParsedMediaCondition[],\n): ParsedMediaCondition[] {\n return dedupeByKey(\n conditions,\n (c) => `${c.subtype}|${c.condition}|${c.negated}`,\n );\n}\n\nfunction dedupeContainerConditions(\n conditions: ParsedContainerCondition[],\n): ParsedContainerCondition[] {\n return dedupeByKey(\n conditions,\n (c) => `${c.name ?? ''}|${c.condition}|${c.negated}`,\n );\n}\n\nfunction dedupeSupportsConditions(\n conditions: ParsedSupportsCondition[],\n): ParsedSupportsCondition[] {\n return dedupeByKey(\n conditions,\n (c) => `${c.subtype}|${c.condition}|${c.negated}`,\n );\n}\n\n/**\n * Check if supports conditions contain contradictions\n * e.g., @supports(display: grid) AND NOT @supports(display: grid)\n */\nfunction hasSupportsContradiction(\n conditions: ParsedSupportsCondition[],\n): boolean {\n const conditionMap = new Map<string, boolean>(); // key -> isPositive\n\n for (const cond of conditions) {\n const key = `${cond.subtype}|${cond.condition}`;\n const existing = conditionMap.get(key);\n if (existing !== undefined && existing !== !cond.negated) {\n return true; // Contradiction: positive AND negated\n }\n conditionMap.set(key, !cond.negated);\n }\n\n return false;\n}\n\n/**\n * Check if a set of media conditions contains contradictions\n * e.g., (prefers-color-scheme: light) AND NOT (prefers-color-scheme: light)\n * or (width >= 900px) AND (width < 600px)\n *\n * Uses parsed media conditions for efficient analysis without regex parsing.\n */\nfunction hasMediaContradiction(conditions: ParsedMediaCondition[]): boolean {\n // Track conditions by their key (condition string) to detect A and NOT A\n const featureConditions = new Map<string, boolean>(); // key -> isPositive\n const typeConditions = new Map<string, boolean>(); // mediaType -> isPositive\n const dimensionConditions = new Map<string, boolean>(); // condition -> isPositive\n\n // Track dimension conditions for range contradiction detection (non-negated only)\n const dimensionsByDim = new Map<\n string,\n { lowerBound: number | null; upperBound: number | null }\n >();\n\n for (const cond of conditions) {\n if (cond.subtype === 'type') {\n // Type query: check for direct contradiction (print AND NOT print)\n const key = cond.mediaType || 'all';\n const existing = typeConditions.get(key);\n if (existing !== undefined && existing !== !cond.negated) {\n return true; // Contradiction: positive AND negated\n }\n typeConditions.set(key, !cond.negated);\n } else if (cond.subtype === 'feature') {\n // Feature query: check for direct contradiction\n const key = cond.condition;\n const existing = featureConditions.get(key);\n if (existing !== undefined && existing !== !cond.negated) {\n return true; // Contradiction: positive AND negated\n }\n featureConditions.set(key, !cond.negated);\n } else if (cond.subtype === 'dimension') {\n // First, check for direct contradiction: (width < 600px) AND NOT (width < 600px)\n const condKey = cond.condition;\n const existing = dimensionConditions.get(condKey);\n if (existing !== undefined && existing !== !cond.negated) {\n return true; // Contradiction: positive AND negated\n }\n dimensionConditions.set(condKey, !cond.negated);\n\n // For range analysis, only consider non-negated conditions\n // Negated conditions are handled via the direct contradiction check above\n if (!cond.negated) {\n const dim = cond.dimension || 'width';\n let bounds = dimensionsByDim.get(dim);\n if (!bounds) {\n bounds = { lowerBound: null, upperBound: null };\n dimensionsByDim.set(dim, bounds);\n }\n\n // Track the effective bounds\n if (cond.lowerBound?.valueNumeric != null) {\n const value = cond.lowerBound.valueNumeric;\n if (bounds.lowerBound === null || value > bounds.lowerBound) {\n bounds.lowerBound = value;\n }\n }\n if (cond.upperBound?.valueNumeric != null) {\n const value = cond.upperBound.valueNumeric;\n if (bounds.upperBound === null || value < bounds.upperBound) {\n bounds.upperBound = value;\n }\n }\n\n // Check for impossible range\n if (\n bounds.lowerBound !== null &&\n bounds.upperBound !== null &&\n bounds.lowerBound >= bounds.upperBound\n ) {\n return true;\n }\n }\n }\n }\n\n return false;\n}\n\n/**\n * Check if container conditions contain contradictions in style queries\n * e.g., style(--variant: danger) and style(--variant: success) together\n * Same property with different values = always false\n *\n * Uses parsed container conditions for efficient analysis without regex parsing.\n */\nfunction hasContainerStyleContradiction(\n conditions: ParsedContainerCondition[],\n): boolean {\n // Track style queries by property name\n // key: property name, value: { hasExistence: boolean, values: Set<string>, hasNegatedExistence: boolean }\n const styleQueries = new Map<\n string,\n { hasExistence: boolean; values: Set<string>; hasNegatedExistence: boolean }\n >();\n\n for (const cond of conditions) {\n // Only analyze style queries\n if (cond.subtype !== 'style' || !cond.property) {\n continue;\n }\n\n const property = cond.property;\n const value = cond.propertyValue;\n\n if (!styleQueries.has(property)) {\n styleQueries.set(property, {\n hasExistence: false,\n values: new Set(),\n hasNegatedExistence: false,\n });\n }\n\n const entry = styleQueries.get(property)!;\n\n if (cond.negated) {\n if (value === undefined) {\n // not style(--prop) - negated existence check\n entry.hasNegatedExistence = true;\n }\n // Negated value checks don't contradict positive value checks directly\n // They just mean \"not this value\"\n } else {\n if (value === undefined) {\n // style(--prop) - existence check\n entry.hasExistence = true;\n } else {\n // style(--prop: value) - value check\n entry.values.add(value);\n }\n }\n }\n\n // Check for contradictions\n for (const [, entry] of styleQueries) {\n // Contradiction: existence check + negated existence check\n if (entry.hasExistence && entry.hasNegatedExistence) {\n return true;\n }\n\n // Contradiction: multiple different values for same property\n // style(--variant: danger) AND style(--variant: success) is impossible\n if (entry.values.size > 1) {\n return true;\n }\n\n // Contradiction: negated existence + value check\n // not style(--variant) AND style(--variant: danger) is impossible\n if (entry.hasNegatedExistence && entry.values.size > 0) {\n return true;\n }\n }\n\n return false;\n}\n\nconst variantKeyCache = new WeakMap<SelectorVariant, string>();\n\n/**\n * Get a unique key for a variant (for deduplication).\n * Cached via WeakMap since variants are compared multiple times during\n * deduplication and sorting.\n */\nfunction getVariantKey(v: SelectorVariant): string {\n const cached = variantKeyCache.get(v);\n if (cached !== undefined) return cached;\n const modifierKey = v.modifierConditions.map(getModifierKey).sort().join('|');\n const pseudoKey = v.pseudoConditions.map(getPseudoKey).sort().join('|');\n const ownKey = v.ownConditions.map(getSelectorConditionKey).sort().join('|');\n const containerKey = v.containerConditions\n .map((c) => `${c.name ?? ''}:${c.negated ? '!' : ''}${c.condition}`)\n .sort()\n .join('|');\n const mediaKey = v.mediaConditions\n .map((c) => `${c.subtype}:${c.negated ? '!' : ''}${c.condition}`)\n .sort()\n .join('|');\n const supportsKey = v.supportsConditions\n .map((c) => `${c.subtype}:${c.negated ? '!' : ''}${c.condition}`)\n .sort()\n .join('|');\n const rootKey = v.rootConditions\n .map(getSelectorConditionKey)\n .sort()\n .join('|');\n const parentKey = v.parentGroups.map(getParentGroupKey).sort().join('|');\n const key = [\n modifierKey,\n pseudoKey,\n ownKey,\n mediaKey,\n containerKey,\n supportsKey,\n rootKey,\n parentKey,\n v.startingStyle ? '1' : '0',\n ].join('###');\n variantKeyCache.set(v, key);\n return key;\n}\n\n/**\n * Total number of leaf conditions in a variant (for superset / dedup comparisons).\n */\nfunction variantConditionCount(v: SelectorVariant): number {\n return (\n v.modifierConditions.length +\n v.pseudoConditions.length +\n v.ownConditions.length +\n v.mediaConditions.length +\n v.containerConditions.length +\n v.supportsConditions.length +\n v.rootConditions.length +\n v.parentGroups.reduce(\n (sum, g) => sum + g.branches.reduce((s, b) => s + b.length, 0),\n 0,\n )\n );\n}\n\n/**\n * Check if variant A is a superset of variant B (A is more restrictive)\n *\n * If A has all of B's conditions plus more, then A is redundant\n * because B already covers the same cases (and more).\n *\n * Example:\n * A: :not([size=large]):not([size=medium]):not([size=small])\n * B: :not([size=large])\n * A is a superset of B, so A is redundant when B exists.\n */\nfunction isVariantSuperset(a: SelectorVariant, b: SelectorVariant): boolean {\n // Must have same context\n if (a.startingStyle !== b.startingStyle) return false;\n\n // Check if a.rootConditions is superset of b.rootConditions\n if (!isSelectorConditionsSuperset(a.rootConditions, b.rootConditions))\n return false;\n\n // Check if a.mediaConditions is superset of b.mediaConditions\n if (!isMediaConditionsSuperset(a.mediaConditions, b.mediaConditions))\n return false;\n\n // Check if a.containerConditions is superset of b.containerConditions\n if (\n !isContainerConditionsSuperset(a.containerConditions, b.containerConditions)\n )\n return false;\n\n // Check if a.supportsConditions is superset of b.supportsConditions\n if (!isSupportsConditionsSuperset(a.supportsConditions, b.supportsConditions))\n return false;\n\n // Check if a.modifierConditions is superset of b.modifierConditions\n if (!isModifierConditionsSuperset(a.modifierConditions, b.modifierConditions))\n return false;\n\n // Check if a.pseudoConditions is superset of b.pseudoConditions\n if (!isPseudoConditionsSuperset(a.pseudoConditions, b.pseudoConditions))\n return false;\n\n // Check if a.ownConditions is superset of b.ownConditions\n if (!isSelectorConditionsSuperset(a.ownConditions, b.ownConditions))\n return false;\n\n // Check if a.parentGroups is superset of b.parentGroups\n if (!isParentGroupsSuperset(a.parentGroups, b.parentGroups)) return false;\n\n return variantConditionCount(a) > variantConditionCount(b);\n}\n\n/**\n * Generic superset check: true if every item in B has a matching key in A.\n */\nfunction isConditionsSuperset<T>(\n a: T[],\n b: T[],\n getKey: (item: T) => string,\n): boolean {\n const aKeys = new Set(a.map(getKey));\n return b.every((c) => aKeys.has(getKey(c)));\n}\n\nfunction isMediaConditionsSuperset(\n a: ParsedMediaCondition[],\n b: ParsedMediaCondition[],\n): boolean {\n return isConditionsSuperset(\n a,\n b,\n (c) => `${c.subtype}|${c.condition}|${c.negated}`,\n );\n}\n\nfunction isContainerConditionsSuperset(\n a: ParsedContainerCondition[],\n b: ParsedContainerCondition[],\n): boolean {\n return isConditionsSuperset(\n a,\n b,\n (c) => `${c.name ?? ''}|${c.condition}|${c.negated}`,\n );\n}\n\nfunction isSupportsConditionsSuperset(\n a: ParsedSupportsCondition[],\n b: ParsedSupportsCondition[],\n): boolean {\n return isConditionsSuperset(\n a,\n b,\n (c) => `${c.subtype}|${c.condition}|${c.negated}`,\n );\n}\n\nfunction isModifierConditionsSuperset(\n a: ParsedModifierCondition[],\n b: ParsedModifierCondition[],\n): boolean {\n return isConditionsSuperset(a, b, getModifierKey);\n}\n\nfunction isPseudoConditionsSuperset(\n a: ParsedPseudoCondition[],\n b: ParsedPseudoCondition[],\n): boolean {\n return isConditionsSuperset(a, b, getPseudoKey);\n}\n\nfunction isSelectorConditionsSuperset(\n a: ParsedSelectorCondition[],\n b: ParsedSelectorCondition[],\n): boolean {\n return isConditionsSuperset(a, b, getSelectorConditionKey);\n}\n\n/**\n * Check if parent groups A is a superset of B.\n * Each group in B must have a matching group in A.\n */\nfunction isParentGroupsSuperset(a: ParentGroup[], b: ParentGroup[]): boolean {\n if (a.length < b.length) return false;\n return isConditionsSuperset(a, b, getParentGroupKey);\n}\n\nfunction getParentGroupKey(g: ParentGroup): string {\n return `${g.negated ? '!' : ''}${g.direct ? '>' : ''}(${getBranchesKey(g.branches)})`;\n}\n\n/**\n * Deduplicate variants\n *\n * Removes:\n * 1. Exact duplicates (same key)\n * 2. Superset variants (more restrictive selectors that are redundant)\n */\nfunction dedupeVariants(variants: SelectorVariant[]): SelectorVariant[] {\n // First pass: exact deduplication\n const seen = new Set<string>();\n const result: SelectorVariant[] = [];\n\n for (const v of variants) {\n const key = getVariantKey(v);\n if (!seen.has(key)) {\n seen.add(key);\n result.push(v);\n }\n }\n\n // Second pass: remove supersets (more restrictive variants)\n // Sort by total condition count (fewer conditions = less restrictive = keep)\n result.sort((a, b) => variantConditionCount(a) - variantConditionCount(b));\n\n // Remove variants that are supersets of earlier (less restrictive) variants\n const filtered: SelectorVariant[] = [];\n for (const candidate of result) {\n let isRedundant = false;\n for (const kept of filtered) {\n if (isVariantSuperset(candidate, kept)) {\n isRedundant = true;\n break;\n }\n }\n if (!isRedundant) {\n filtered.push(candidate);\n }\n }\n\n return filtered;\n}\n\n/**\n * Combine AND conditions into CSS\n *\n * AND of conditions means cartesian product of variants:\n * (A1 | A2) & (B1 | B2) = A1&B1 | A1&B2 | A2&B1 | A2&B2\n *\n * Variants that result in contradictions (e.g., conflicting media rules)\n * are filtered out.\n */\nfunction andToCSS(children: ConditionNode[]): CSSComponents {\n // Start with a single empty variant\n let currentVariants: SelectorVariant[] = [emptyVariant()];\n\n for (const child of children) {\n const childCSS = conditionToCSSInner(child);\n\n if (childCSS.isImpossible || childCSS.variants.length === 0) {\n return { variants: [], isImpossible: true };\n }\n\n // Cartesian product: each current variant × each child variant\n const newVariants: SelectorVariant[] = [];\n for (const current of currentVariants) {\n for (const childVariant of childCSS.variants) {\n const merged = mergeVariants(current, childVariant);\n // Skip impossible variants (contradictions detected during merge)\n if (merged !== null) {\n newVariants.push(merged);\n }\n }\n }\n\n if (newVariants.length === 0) {\n return { variants: [], isImpossible: true };\n }\n\n // Deduplicate after each step to prevent exponential blowup\n currentVariants = dedupeVariants(newVariants);\n }\n\n return {\n variants: currentVariants,\n isImpossible: false,\n };\n}\n\n/**\n * Combine OR conditions into CSS\n *\n * OR in CSS means multiple selector variants (DNF).\n * Each variant becomes a separate selector in the comma-separated list,\n * or multiple CSS rules if they have different at-rules.\n *\n * Note: OR exclusivity is handled at the pipeline level (expandOrConditions),\n * so here we just collect all variants. Any remaining ORs in the condition\n * tree (e.g., from De Morgan expansion) are handled as simple alternatives.\n */\nfunction orToCSS(children: ConditionNode[]): CSSComponents {\n const allVariants: SelectorVariant[] = [];\n\n for (const child of children) {\n const childCSS = conditionToCSSInner(child);\n if (childCSS.isImpossible) continue;\n\n allVariants.push(...childCSS.variants);\n }\n\n if (allVariants.length === 0) {\n return { variants: [], isImpossible: true };\n }\n\n // Deduplicate variants\n return {\n variants: dedupeVariants(allVariants),\n isImpossible: false,\n };\n}\n\n// ============================================================================\n// Utility Functions\n// ============================================================================\n\n/**\n * Build at-rules array from a variant\n */\nexport function buildAtRulesFromVariant(variant: SelectorVariant): string[] {\n const atRules: string[] = [];\n\n // Add media rules - combine all conditions with \"and\"\n if (variant.mediaConditions.length > 0) {\n const conditionParts = variant.mediaConditions.map((c) => {\n if (c.subtype === 'type') {\n // Media type: print, screen, etc.\n return c.negated ? `not ${c.condition}` : c.condition;\n } else {\n // Feature or dimension: use not (condition) syntax for negation\n // MQ Level 4 requires parentheses around the condition for negation\n return c.negated ? `(not ${c.condition})` : c.condition;\n }\n });\n atRules.push(`@media ${conditionParts.join(' and ')}`);\n }\n\n // Add container rules - group by container name and combine with \"and\"\n if (variant.containerConditions.length > 0) {\n // Group conditions by container name (undefined = unnamed/nearest)\n const byName = new Map<string | undefined, ParsedContainerCondition[]>();\n for (const cond of variant.containerConditions) {\n const group = byName.get(cond.name) || [];\n group.push(cond);\n byName.set(cond.name, group);\n }\n\n // Build one @container rule per container name\n for (const [name, conditions] of byName) {\n // CSS Container Query syntax requires parentheses around negated conditions:\n // @container (not style(--x)) and style(--y) - NOT @container not style(--x) and style(--y)\n const conditionParts = conditions.map((c) =>\n c.negated ? `(not ${c.condition})` : c.condition,\n );\n const namePrefix = name ? `${name} ` : '';\n atRules.push(`@container ${namePrefix}${conditionParts.join(' and ')}`);\n }\n }\n\n // Add supports rules - combine all conditions with \"and\"\n if (variant.supportsConditions.length > 0) {\n const conditionParts = variant.supportsConditions.map((c) => {\n // Build the condition based on subtype\n // feature: (display: grid) or (not (display: grid))\n // selector: selector(:has(*)) or (not selector(:has(*)))\n if (c.subtype === 'selector') {\n const selectorCond = `selector(${c.condition})`;\n return c.negated ? `(not ${selectorCond})` : selectorCond;\n } else {\n const featureCond = `(${c.condition})`;\n return c.negated ? `(not ${featureCond})` : featureCond;\n }\n });\n atRules.push(`@supports ${conditionParts.join(' and ')}`);\n }\n\n // Add starting-style\n if (variant.startingStyle) {\n atRules.push('@starting-style');\n }\n\n return atRules;\n}\n"],"mappings":";;;;;;;;;;AA6LA,MAAM,iBAAiB,IAAI,IAA2B,IAAK;;;;AAS3D,SAAgB,eAAe,MAAoC;CAEjE,MAAM,MAAM,qBAAqB,KAAK;CACtC,MAAM,SAAS,eAAe,IAAI,IAAI;AACtC,KAAI,OACF,QAAO;CAGT,MAAM,SAAS,oBAAoB,KAAK;AAGxC,gBAAe,IAAI,KAAK,OAAO;AAE/B,QAAO;;AAcT,SAAS,eAAgC;AACvC,QAAO;EACL,oBAAoB,EAAE;EACtB,kBAAkB,EAAE;EACpB,eAAe,EAAE;EACjB,iBAAiB,EAAE;EACnB,qBAAqB,EAAE;EACvB,oBAAoB,EAAE;EACtB,gBAAgB,EAAE;EAClB,cAAc,EAAE;EAChB,eAAe;EAChB;;AAGH,SAAS,oBAAoB,MAAoC;AAE/D,KAAI,KAAK,SAAS,OAChB,QAAO;EACL,UAAU,CAAC,cAAc,CAAC;EAC1B,cAAc;EACf;AAIH,KAAI,KAAK,SAAS,QAChB,QAAO;EACL,UAAU,EAAE;EACZ,cAAc;EACf;AAIH,KAAI,KAAK,SAAS,QAChB,QAAO,WAAW,KAAK;AAIzB,KAAI,KAAK,SAAS,WAChB,KAAI,KAAK,aAAa,MACpB,QAAO,SAAS,KAAK,SAAS;KAE9B,QAAO,QAAQ,KAAK,SAAS;AAKjC,QAAO;EACL,UAAU,CAAC,cAAc,CAAC;EAC1B,cAAc;EACf;;;;;AAMH,SAAS,WAAW,OAAsC;AACxD,SAAQ,MAAM,MAAd;EACE,KAAK,QAOH,QAAO;GAAE,UANY,c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Q,oBAAoB,SAAS,GAAG;EAE1C,MAAM,yBAAS,IAAI,KAAqD;AACxE,OAAK,MAAM,QAAQ,QAAQ,qBAAqB;GAC9C,MAAM,QAAQ,OAAO,IAAI,KAAK,KAAK,IAAI,EAAE;AACzC,SAAM,KAAK,KAAK;AAChB,UAAO,IAAI,KAAK,MAAM,MAAM;;AAI9B,OAAK,MAAM,CAAC,MAAM,eAAe,QAAQ;GAGvC,MAAM,iBAAiB,WAAW,KAAK,MACrC,EAAE,UAAU,QAAQ,EAAE,UAAU,KAAK,EAAE,UACxC;GACD,MAAM,aAAa,OAAO,GAAG,KAAK,KAAK;AACvC,WAAQ,KAAK,cAAc,aAAa,eAAe,KAAK,QAAQ,GAAG;;;AAK3E,KAAI,QAAQ,mBAAmB,SAAS,GAAG;EACzC,MAAM,iBAAiB,QAAQ,mBAAmB,KAAK,MAAM;AAI3D,OAAI,EAAE,YAAY,YAAY;IAC5B,MAAM,eAAe,YAAY,EAAE,UAAU;AAC7C,WAAO,EAAE,UAAU,QAAQ,aAAa,KAAK;UACxC;IACL,MAAM,cAAc,IAAI,EAAE,UAAU;AACpC,WAAO,EAAE,UAAU,QAAQ,YAAY,KAAK;;IAE9C;AACF,UAAQ,KAAK,aAAa,eAAe,KAAK,QAAQ,GAAG;;AAI3D,KAAI,QAAQ,cACV,SAAQ,KAAK,kBAAkB;AAGjC,QAAO"}
|
|
@@ -2,6 +2,7 @@ import { Lru } from "../parser/lru.js";
|
|
|
2
2
|
import { expandDimensionShorthands, expandTastyUnits, findTopLevelComma, resolvePredefinedState } from "../states/index.js";
|
|
3
3
|
import { camelToKebab } from "../utils/case-converter.js";
|
|
4
4
|
import { and, createContainerDimensionCondition, createContainerRawCondition, createContainerStyleCondition, createMediaDimensionCondition, createMediaFeatureCondition, createMediaTypeCondition, createModifierCondition, createOwnCondition, createParentCondition, createPseudoCondition, createRootCondition, createStartingCondition, createSupportsCondition, not, or, trueCondition } from "./conditions.js";
|
|
5
|
+
import { transformSelectorContent } from "../utils/selector-transform.js";
|
|
5
6
|
import { emitWarning } from "./warnings.js";
|
|
6
7
|
|
|
7
8
|
//#region src/pipeline/parseStateKey.ts
|
|
@@ -23,11 +24,12 @@ const parseCache = new Lru(5e3);
|
|
|
23
24
|
* Matches: operators, parentheses, @-prefixed states, value mods, boolean mods,
|
|
24
25
|
* pseudo-classes, class selectors, and attribute selectors.
|
|
25
26
|
*
|
|
26
|
-
* Note: For @supports
|
|
27
|
-
*
|
|
28
|
-
* We use a pattern that allows
|
|
27
|
+
* Note: For @supports, @(...) container queries, and :is/:has/:not/:where
|
|
28
|
+
* we need to handle nested parentheses.
|
|
29
|
+
* We use a pattern that allows up to 2 levels of nesting:
|
|
30
|
+
* [^()]*(?:\([^()]*(?:\([^)]*\))?[^)]*\))*[^)]*
|
|
29
31
|
*/
|
|
30
|
-
const STATE_TOKEN_PATTERN = /([&|!^])|([()])|(@media:[a-z]+)|(@media\([^)]+\))|(@supports\([^()]*(?:\([^)]*\))?[^)]*\))|(@root\([^)]+\))|(@parent\([^)]+\))|(@own\([^)]+\))|(@\([^()]*(?:\([^)]*\))?[^)]*\))|(@starting)|(@[A-Za-z][A-Za-z0-9-]*)|([a-z][a-z0-9-]*(?:\^=|\$=|\*=|=)(?:"[^"]*"|'[^']*'|[^\s&|!^()]+))|([a-z][a-z0-9-]+)|(:[-a-z][a-z0-9-]*(?:\([^)]+\))?)|(\.[a-z][a-z0-9-]+)|(\[[^\]]+\])/gi;
|
|
32
|
+
const STATE_TOKEN_PATTERN = /([&|!^])|([()])|(@media:[a-z]+)|(@media\([^)]+\))|(@supports\([^()]*(?:\([^)]*\))?[^)]*\))|(@root\([^)]+\))|(@parent\([^)]+\))|(@own\([^)]+\))|(@\([^()]*(?:\([^)]*\))?[^)]*\))|(@starting)|(@[A-Za-z][A-Za-z0-9-]*)|([a-z][a-z0-9-]*(?:\^=|\$=|\*=|=)(?:"[^"]*"|'[^']*'|[^\s&|!^()]+))|([a-z][a-z0-9-]+)|(:(?:is|has|not|where)\([^()]*(?:\([^()]*(?:\([^)]*\))?[^)]*\))*[^)]*\))|(:[-a-z][a-z0-9-]*(?:\([^)]+\))?)|(\.[a-z][a-z0-9-]+)|(\[[^\]]+\])/gi;
|
|
31
33
|
/**
|
|
32
34
|
* Tokenize a state notation string
|
|
33
35
|
*/
|
|
@@ -197,7 +199,18 @@ var Parser = class {
|
|
|
197
199
|
if (value.startsWith("@own(")) return this.parseOwnState(value);
|
|
198
200
|
if (value.startsWith("@(")) return this.parseContainerQuery(value);
|
|
199
201
|
if (value.startsWith("@") && /^@[A-Za-z][A-Za-z0-9-]*$/.test(value)) return this.parsePredefinedState(value);
|
|
200
|
-
if (value.startsWith(":"))
|
|
202
|
+
if (value.startsWith(":")) {
|
|
203
|
+
const enhancedMatch = /^:(is|has|not|where)\(/.exec(value);
|
|
204
|
+
if (enhancedMatch) {
|
|
205
|
+
const fn = enhancedMatch[1];
|
|
206
|
+
const prefix = enhancedMatch[0];
|
|
207
|
+
let content = transformSelectorContent(value.slice(prefix.length, -1));
|
|
208
|
+
content = content.replace(/([>+~])\s*$/, "$1 *");
|
|
209
|
+
if (fn === "not") return createPseudoCondition(`:is(${content})`, true, value);
|
|
210
|
+
return createPseudoCondition(`:${fn}(${content})`, false, value);
|
|
211
|
+
}
|
|
212
|
+
return createPseudoCondition(value, false, value);
|
|
213
|
+
}
|
|
201
214
|
if (value.startsWith(".")) return createPseudoCondition(value, false, value);
|
|
202
215
|
if (value.startsWith("[")) return createPseudoCondition(value, false, value);
|
|
203
216
|
if (value.includes("=")) return this.parseValueModifier(value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseStateKey.js","names":[],"sources":["../../src/pipeline/parseStateKey.ts"],"sourcesContent":["/**\n * State Key Parser\n *\n * Parses state notation strings (like 'hovered & !disabled', '@media(w < 768px)')\n * into ConditionNode trees for processing in the pipeline.\n */\n\nimport { Lru } from '../parser/lru';\nimport type { StateParserContext } from '../states';\nimport {\n expandDimensionShorthands,\n expandTastyUnits,\n findTopLevelComma,\n resolvePredefinedState,\n} from '../states';\nimport { camelToKebab } from '../utils/case-converter';\n\nimport type { ConditionNode, NumericBound } from './conditions';\nimport { emitWarning } from './warnings';\nimport {\n and,\n createContainerDimensionCondition,\n createContainerRawCondition,\n createContainerStyleCondition,\n createMediaDimensionCondition,\n createMediaFeatureCondition,\n createMediaTypeCondition,\n createModifierCondition,\n createOwnCondition,\n createParentCondition,\n createPseudoCondition,\n createRootCondition,\n createStartingCondition,\n createSupportsCondition,\n not,\n or,\n trueCondition,\n} from './conditions';\n\n// ============================================================================\n// Constants\n// ============================================================================\n\n/**\n * Maximum XOR operands before emitting a performance warning.\n * A ^ B ^ C ^ D = 8 OR branches (2^(n-1)), so chains above 4\n * risk exponential blowup in downstream processing.\n */\nconst MAX_XOR_CHAIN_LENGTH = 4;\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface ParseStateKeyOptions {\n context?: StateParserContext;\n isSubElement?: boolean;\n}\n\n// ============================================================================\n// Caching\n// ============================================================================\n\n// Cache for parsed state keys (key -> ConditionNode)\nconst parseCache = new Lru<string, ConditionNode>(5000);\n\n// ============================================================================\n// Tokenizer Patterns\n// ============================================================================\n\n/**\n * Pattern for tokenizing state notation.\n * Matches: operators, parentheses, @-prefixed states, value mods, boolean mods,\n * pseudo-classes, class selectors, and attribute selectors.\n *\n * Note: For @supports and @(...) container queries we need to handle nested parentheses\n * like @supports($, :has(*)) or @(scroll-state(stuck: top)).\n * We use a pattern that allows one level of nesting: [^()]*(?:\\([^)]*\\))?[^)]*\n */\nconst STATE_TOKEN_PATTERN =\n /([&|!^])|([()])|(@media:[a-z]+)|(@media\\([^)]+\\))|(@supports\\([^()]*(?:\\([^)]*\\))?[^)]*\\))|(@root\\([^)]+\\))|(@parent\\([^)]+\\))|(@own\\([^)]+\\))|(@\\([^()]*(?:\\([^)]*\\))?[^)]*\\))|(@starting)|(@[A-Za-z][A-Za-z0-9-]*)|([a-z][a-z0-9-]*(?:\\^=|\\$=|\\*=|=)(?:\"[^\"]*\"|'[^']*'|[^\\s&|!^()]+))|([a-z][a-z0-9-]+)|(:[-a-z][a-z0-9-]*(?:\\([^)]+\\))?)|(\\.[a-z][a-z0-9-]+)|(\\[[^\\]]+\\])/gi;\n\n// ============================================================================\n// Token Types\n// ============================================================================\n\ntype TokenType = 'AND' | 'OR' | 'NOT' | 'XOR' | 'LPAREN' | 'RPAREN' | 'STATE';\n\ninterface Token {\n type: TokenType;\n value: string;\n raw: string;\n}\n\n// ============================================================================\n// Tokenizer\n// ============================================================================\n\n/**\n * Tokenize a state notation string\n */\nfunction tokenize(stateKey: string): Token[] {\n const tokens: Token[] = [];\n let match: RegExpExecArray | null;\n\n // Replace commas with | outside of parentheses (for compatibility)\n const normalized = replaceCommasOutsideParens(stateKey);\n\n STATE_TOKEN_PATTERN.lastIndex = 0;\n while ((match = STATE_TOKEN_PATTERN.exec(normalized)) !== null) {\n const fullMatch = match[0];\n\n if (match[1]) {\n // Operator: &, |, !, ^\n switch (fullMatch) {\n case '&':\n tokens.push({ type: 'AND', value: '&', raw: fullMatch });\n break;\n case '|':\n tokens.push({ type: 'OR', value: '|', raw: fullMatch });\n break;\n case '!':\n tokens.push({ type: 'NOT', value: '!', raw: fullMatch });\n break;\n case '^':\n tokens.push({ type: 'XOR', value: '^', raw: fullMatch });\n break;\n }\n } else if (match[2]) {\n // Parenthesis\n if (fullMatch === '(') {\n tokens.push({ type: 'LPAREN', value: '(', raw: fullMatch });\n } else {\n tokens.push({ type: 'RPAREN', value: ')', raw: fullMatch });\n }\n } else {\n // State token (all other capture groups)\n tokens.push({ type: 'STATE', value: fullMatch, raw: fullMatch });\n }\n }\n\n return tokens;\n}\n\n/**\n * Replace commas with | only outside of parentheses\n */\nfunction replaceCommasOutsideParens(str: string): string {\n let result = '';\n let depth = 0;\n\n for (const char of str) {\n if (char === '(') {\n depth++;\n result += char;\n } else if (char === ')') {\n depth--;\n result += char;\n } else if (char === ',' && depth === 0) {\n result += '|';\n } else {\n result += char;\n }\n }\n\n return result;\n}\n\n// ============================================================================\n// Recursive Descent Parser\n// ============================================================================\n\n/**\n * Parser state\n */\nclass Parser {\n private tokens: Token[];\n private pos = 0;\n private options: ParseStateKeyOptions;\n\n constructor(tokens: Token[], options: ParseStateKeyOptions) {\n this.tokens = tokens;\n this.options = options;\n }\n\n parse(): ConditionNode {\n if (this.tokens.length === 0) {\n return trueCondition();\n }\n const result = this.parseExpression();\n return result;\n }\n\n private current(): Token | undefined {\n return this.tokens[this.pos];\n }\n\n private advance(): Token | undefined {\n return this.tokens[this.pos++];\n }\n\n private match(type: TokenType): boolean {\n if (this.current()?.type === type) {\n this.advance();\n return true;\n }\n return false;\n }\n\n /**\n * Parse expression with operator precedence:\n * ! (NOT) > ^ (XOR) > | (OR) > & (AND)\n */\n private parseExpression(): ConditionNode {\n return this.parseAnd();\n }\n\n private parseAnd(): ConditionNode {\n let left = this.parseOr();\n\n while (this.current()?.type === 'AND') {\n this.advance();\n const right = this.parseOr();\n left = and(left, right);\n }\n\n return left;\n }\n\n private parseOr(): ConditionNode {\n let left = this.parseXor();\n\n while (this.current()?.type === 'OR') {\n this.advance();\n const right = this.parseXor();\n left = or(left, right);\n }\n\n return left;\n }\n\n private parseXor(): ConditionNode {\n let left = this.parseUnary();\n let operandCount = 1;\n\n while (this.current()?.type === 'XOR') {\n this.advance();\n const right = this.parseUnary();\n operandCount++;\n\n if (operandCount > MAX_XOR_CHAIN_LENGTH) {\n emitWarning(\n 'XOR_CHAIN_TOO_LONG',\n `XOR chain with ${operandCount} operands produces ${Math.pow(2, operandCount - 1)} OR branches. ` +\n `Consider breaking into smaller expressions to avoid exponential growth.`,\n );\n }\n\n // XOR: (A & !B) | (!A & B)\n left = or(and(left, not(right)), and(not(left), right));\n }\n\n return left;\n }\n\n private parseUnary(): ConditionNode {\n if (this.match('NOT')) {\n const operand = this.parseUnary();\n return not(operand);\n }\n return this.parsePrimary();\n }\n\n private parsePrimary(): ConditionNode {\n // Handle parentheses\n if (this.match('LPAREN')) {\n const expr = this.parseExpression();\n this.match('RPAREN'); // Consume closing paren (lenient if missing)\n return expr;\n }\n\n // Handle state tokens\n const token = this.current();\n if (token?.type === 'STATE') {\n this.advance();\n return this.parseStateToken(token.value);\n }\n\n // Fallback for empty/invalid - return TRUE\n return trueCondition();\n }\n\n /**\n * Parse a state token into a ConditionNode\n */\n private parseStateToken(value: string): ConditionNode {\n // @starting\n if (value === '@starting') {\n return createStartingCondition(false, value);\n }\n\n // @media:type (e.g., @media:print)\n if (value.startsWith('@media:')) {\n const mediaType = value.slice(7) as 'print' | 'screen' | 'all' | 'speech';\n return createMediaTypeCondition(mediaType, false, value);\n }\n\n // @media(...) - media query\n if (value.startsWith('@media(')) {\n return this.parseMediaQuery(value);\n }\n\n // @supports(...) - feature/selector support query\n if (value.startsWith('@supports(')) {\n return this.parseSupportsQuery(value);\n }\n\n // @root(...) - root state\n if (value.startsWith('@root(')) {\n return this.parseRootState(value);\n }\n\n // @parent(...) - parent element state\n if (value.startsWith('@parent(')) {\n return this.parseParentState(value);\n }\n\n // @own(...) - own state (sub-element)\n if (value.startsWith('@own(')) {\n return this.parseOwnState(value);\n }\n\n // @(...) - container query\n if (value.startsWith('@(')) {\n return this.parseContainerQuery(value);\n }\n\n // @name - predefined state\n if (value.startsWith('@') && /^@[A-Za-z][A-Za-z0-9-]*$/.test(value)) {\n return this.parsePredefinedState(value);\n }\n\n // Pseudo-class (e.g., :hover, :focus-visible, :nth-child(2n))\n if (value.startsWith(':')) {\n return createPseudoCondition(value, false, value);\n }\n\n // Class selector (e.g., .active)\n if (value.startsWith('.')) {\n return createPseudoCondition(value, false, value);\n }\n\n // Attribute selector (e.g., [disabled], [data-state=\"active\"])\n if (value.startsWith('[')) {\n return createPseudoCondition(value, false, value);\n }\n\n // Value modifier (e.g., theme=danger, size=large)\n if (value.includes('=')) {\n return this.parseValueModifier(value);\n }\n\n // Boolean modifier (e.g., hovered, disabled)\n return this.parseBooleanModifier(value);\n }\n\n /**\n * Parse @media(...) query\n */\n private parseMediaQuery(raw: string): ConditionNode {\n const content = raw.slice(7, -1); // Remove '@media(' and ')'\n if (!content.trim()) {\n return trueCondition();\n }\n\n // Expand shorthands and units\n let condition = expandDimensionShorthands(content);\n condition = expandTastyUnits(condition);\n\n // Check for feature queries (contains ':' but not dimension comparison)\n if (\n condition.includes(':') &&\n !condition.includes('<') &&\n !condition.includes('>') &&\n !condition.includes('=')\n ) {\n // Feature query: @media(prefers-contrast: high)\n const colonIdx = condition.indexOf(':');\n const feature = condition.slice(0, colonIdx).trim();\n const featureValue = condition.slice(colonIdx + 1).trim();\n return createMediaFeatureCondition(feature, featureValue, false, raw);\n }\n\n // Boolean feature query: @media(prefers-reduced-motion)\n if (\n !condition.includes('<') &&\n !condition.includes('>') &&\n !condition.includes('=')\n ) {\n return createMediaFeatureCondition(\n condition.trim(),\n undefined,\n false,\n raw,\n );\n }\n\n // Dimension query - parse bounds\n const { dimension, lowerBound, upperBound } =\n this.parseDimensionCondition(condition);\n\n if (!dimension) {\n // Fallback for unparseable - treat as pseudo\n return createPseudoCondition(raw, false, raw);\n }\n\n return createMediaDimensionCondition(\n dimension as 'width' | 'height',\n lowerBound,\n upperBound,\n false,\n raw,\n );\n }\n\n /**\n * Parse dimension condition string (e.g., \"width < 768px\", \"600px <= width < 1200px\")\n */\n private parseDimensionCondition(condition: string): {\n dimension?: string;\n lowerBound?: NumericBound;\n upperBound?: NumericBound;\n } {\n // Range syntax: \"600px <= width < 1200px\"\n const rangeMatch = condition.match(\n /^(.+?)\\s*(<=|<)\\s*(width|height|inline-size|block-size)\\s*(<=|<)\\s*(.+)$/,\n );\n if (rangeMatch) {\n const [, lowerValue, lowerOp, dimension, upperOp, upperValue] =\n rangeMatch;\n return {\n dimension,\n lowerBound: {\n value: lowerValue.trim(),\n valueNumeric: parseNumericValue(lowerValue.trim()),\n inclusive: lowerOp === '<=',\n },\n upperBound: {\n value: upperValue.trim(),\n valueNumeric: parseNumericValue(upperValue.trim()),\n inclusive: upperOp === '<=',\n },\n };\n }\n\n // Simple comparison: \"width < 768px\"\n const simpleMatch = condition.match(\n /^(width|height|inline-size|block-size)\\s*(<=|>=|<|>|=)\\s*(.+)$/,\n );\n if (simpleMatch) {\n const [, dimension, operator, value] = simpleMatch;\n const numeric = parseNumericValue(value.trim());\n\n if (operator === '<' || operator === '<=') {\n return {\n dimension,\n upperBound: {\n value: value.trim(),\n valueNumeric: numeric,\n inclusive: operator === '<=',\n },\n };\n } else if (operator === '>' || operator === '>=') {\n return {\n dimension,\n lowerBound: {\n value: value.trim(),\n valueNumeric: numeric,\n inclusive: operator === '>=',\n },\n };\n } else if (operator === '=') {\n // Exact match: both bounds are the same and inclusive\n return {\n dimension,\n lowerBound: {\n value: value.trim(),\n valueNumeric: numeric,\n inclusive: true,\n },\n upperBound: {\n value: value.trim(),\n valueNumeric: numeric,\n inclusive: true,\n },\n };\n }\n }\n\n // Reversed: \"768px > width\"\n const reversedMatch = condition.match(\n /^(.+?)\\s*(<=|>=|<|>|=)\\s*(width|height|inline-size|block-size)$/,\n );\n if (reversedMatch) {\n const [, value, operator, dimension] = reversedMatch;\n const numeric = parseNumericValue(value.trim());\n\n // Reverse the operator\n if (operator === '<' || operator === '<=') {\n return {\n dimension,\n lowerBound: {\n value: value.trim(),\n valueNumeric: numeric,\n inclusive: operator === '<=',\n },\n };\n } else if (operator === '>' || operator === '>=') {\n return {\n dimension,\n upperBound: {\n value: value.trim(),\n valueNumeric: numeric,\n inclusive: operator === '>=',\n },\n };\n }\n }\n\n return {};\n }\n\n /**\n * Parse @root(...) state\n */\n private parseInnerCondition(\n raw: string,\n prefixLen: number,\n wrap: (inner: ConditionNode) => ConditionNode,\n ): ConditionNode {\n const content = raw.slice(prefixLen, -1);\n if (!content.trim()) return trueCondition();\n return wrap(parseStateKey(content, this.options));\n }\n\n private parseRootState(raw: string): ConditionNode {\n return this.parseInnerCondition(raw, 6, (inner) =>\n createRootCondition(inner, false, raw),\n );\n }\n\n /**\n * Parse @parent(...) state\n *\n * Syntax:\n * @parent(hovered) → :is([data-hovered] *)\n * @parent(theme=dark) → :is([data-theme=\"dark\"] *)\n * @parent(hovered, >) → :is([data-hovered] > *) (direct parent)\n * @parent(.my-class) → :is(.my-class *)\n */\n private parseParentState(raw: string): ConditionNode {\n const content = raw.slice(8, -1);\n if (!content.trim()) {\n return trueCondition();\n }\n\n let condition = content.trim();\n let direct = false;\n\n const lastCommaIdx = condition.lastIndexOf(',');\n if (lastCommaIdx !== -1) {\n const afterComma = condition.slice(lastCommaIdx + 1).trim();\n if (afterComma === '>') {\n direct = true;\n condition = condition.slice(0, lastCommaIdx).trim();\n }\n }\n\n const innerCondition = parseStateKey(condition, this.options);\n return createParentCondition(innerCondition, direct, false, raw);\n }\n\n /**\n * Parse @supports(...) query\n *\n * Syntax:\n * @supports(display: grid) → @supports (display: grid)\n * @supports($, :has(*)) → @supports selector(:has(*))\n */\n private parseSupportsQuery(raw: string): ConditionNode {\n const content = raw.slice(10, -1); // Remove '@supports(' and ')'\n if (!content.trim()) {\n return trueCondition();\n }\n\n // Check for selector syntax: @supports($, :has(*))\n if (content.startsWith('$,')) {\n const selector = content.slice(2).trim(); // Remove '$,' prefix\n return createSupportsCondition('selector', selector, false, raw);\n }\n\n // Feature syntax: @supports(display: grid)\n return createSupportsCondition('feature', content, false, raw);\n }\n\n private parseOwnState(raw: string): ConditionNode {\n return this.parseInnerCondition(raw, 5, (inner) =>\n createOwnCondition(inner, false, raw),\n );\n }\n\n /**\n * Parse @(...) container query\n */\n private parseContainerQuery(raw: string): ConditionNode {\n const content = raw.slice(2, -1); // Remove '@(' and ')'\n if (!content.trim()) {\n return trueCondition();\n }\n\n // Check for named container: @(layout, w < 600px)\n // Use parentheses-aware comma search so inner commas (e.g., scroll-state(a, b)) are skipped\n const commaIdx = findTopLevelComma(content);\n let containerName: string | undefined;\n let condition: string;\n\n if (commaIdx !== -1) {\n containerName = content.slice(0, commaIdx).trim();\n condition = content.slice(commaIdx + 1).trim();\n } else {\n condition = content.trim();\n }\n\n // Check for style query shorthand: @($variant=primary)\n if (condition.startsWith('$')) {\n const styleQuery = condition.slice(1); // Remove '$'\n const eqIdx = styleQuery.indexOf('=');\n\n if (eqIdx === -1) {\n // Existence check: @($variant)\n return createContainerStyleCondition(\n styleQuery,\n undefined,\n containerName,\n false,\n raw,\n );\n }\n\n const property = styleQuery.slice(0, eqIdx).trim();\n let propertyValue = styleQuery.slice(eqIdx + 1).trim();\n\n // Remove quotes if present\n if (\n (propertyValue.startsWith('\"') && propertyValue.endsWith('\"')) ||\n (propertyValue.startsWith(\"'\") && propertyValue.endsWith(\"'\"))\n ) {\n propertyValue = propertyValue.slice(1, -1);\n }\n\n return createContainerStyleCondition(\n property,\n propertyValue,\n containerName,\n false,\n raw,\n );\n }\n\n // Check for function-like syntax: scroll-state(...), style(...), etc.\n // Passes the condition through to CSS verbatim.\n if (/^[a-zA-Z][\\w-]*\\s*\\(/.test(condition)) {\n return createContainerRawCondition(condition, containerName, false, raw);\n }\n\n // Dimension query\n let expandedCondition = expandDimensionShorthands(condition);\n expandedCondition = expandTastyUnits(expandedCondition);\n\n const { dimension, lowerBound, upperBound } =\n this.parseDimensionCondition(expandedCondition);\n\n if (!dimension) {\n // Fallback\n return createPseudoCondition(raw, false, raw);\n }\n\n return createContainerDimensionCondition(\n dimension as 'width' | 'height',\n lowerBound,\n upperBound,\n containerName,\n false,\n raw,\n );\n }\n\n /**\n * Parse predefined state (@mobile, @dark, etc.)\n */\n private parsePredefinedState(raw: string): ConditionNode {\n const ctx = this.options.context;\n if (!ctx) {\n // No context - can't resolve predefined states\n return createPseudoCondition(raw, false, raw);\n }\n\n const resolved = resolvePredefinedState(raw, ctx);\n if (!resolved) {\n // Undefined predefined state - treat as modifier\n return createModifierCondition(\n `data-${camelToKebab(raw.slice(1))}`,\n undefined,\n '=',\n false,\n raw,\n );\n }\n\n // Parse the resolved value recursively\n return parseStateKey(resolved, this.options);\n }\n\n /**\n * Parse value modifier (e.g., theme=danger, size^=sm)\n */\n private parseValueModifier(raw: string): ConditionNode {\n // Match operators: =, ^=, $=, *=\n const opMatch = raw.match(/^([a-z][a-z0-9-]*)(\\^=|\\$=|\\*=|=)(.+)$/i);\n if (!opMatch) {\n return createModifierCondition(\n `data-${camelToKebab(raw)}`,\n undefined,\n '=',\n false,\n raw,\n );\n }\n\n const [, key, operator, value] = opMatch;\n let cleanValue = value;\n\n // Remove quotes if present\n if (\n (cleanValue.startsWith('\"') && cleanValue.endsWith('\"')) ||\n (cleanValue.startsWith(\"'\") && cleanValue.endsWith(\"'\"))\n ) {\n cleanValue = cleanValue.slice(1, -1);\n }\n\n return createModifierCondition(\n `data-${camelToKebab(key)}`,\n cleanValue,\n operator as '=' | '^=' | '$=' | '*=',\n false,\n raw,\n );\n }\n\n /**\n * Parse boolean modifier (e.g., hovered, disabled)\n */\n private parseBooleanModifier(raw: string): ConditionNode {\n return createModifierCondition(\n `data-${camelToKebab(raw)}`,\n undefined,\n '=',\n false,\n raw,\n );\n }\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Parse a numeric value from a CSS value string\n */\nfunction parseNumericValue(value: string): number | null {\n const match = value.match(/^(\\d+(?:\\.\\d+)?)(px|em|rem|vh|vw|%)?$/);\n if (match) {\n return parseFloat(match[1]);\n }\n return null;\n}\n\n// ============================================================================\n// Main Export\n// ============================================================================\n\n/**\n * Parse a state key string into a ConditionNode\n */\nexport function parseStateKey(\n stateKey: string,\n options: ParseStateKeyOptions = {},\n): ConditionNode {\n // Handle empty/default state\n if (!stateKey || !stateKey.trim()) {\n return trueCondition();\n }\n\n const trimmed = stateKey.trim();\n\n // Build cache key including local predefined states (they affect parsing)\n // Global predefined states are set once at initialization and don't change\n const ctx = options.context;\n const localStatesKey =\n ctx && Object.keys(ctx.localPredefinedStates).length > 0\n ? JSON.stringify(ctx.localPredefinedStates)\n : '';\n const cacheKey = JSON.stringify([\n trimmed,\n options.isSubElement,\n localStatesKey,\n ]);\n\n // Check cache\n const cached = parseCache.get(cacheKey);\n if (cached) {\n return cached;\n }\n\n // Tokenize and parse\n const tokens = tokenize(trimmed);\n const parser = new Parser(tokens, options);\n const result = parser.parse();\n\n // Cache result\n parseCache.set(cacheKey, result);\n\n return result;\n}\n\n/**\n * Clear the parse cache (for testing)\n */\nexport function clearParseCache(): void {\n parseCache.clear();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgDA,MAAM,uBAAuB;AAgB7B,MAAM,aAAa,IAAI,IAA2B,IAAK;;;;;;;;;;AAevD,MAAM,sBACJ;;;;AAqBF,SAAS,SAAS,UAA2B;CAC3C,MAAM,SAAkB,EAAE;CAC1B,IAAI;CAGJ,MAAM,aAAa,2BAA2B,SAAS;AAEvD,qBAAoB,YAAY;AAChC,SAAQ,QAAQ,oBAAoB,KAAK,WAAW,MAAM,MAAM;EAC9D,MAAM,YAAY,MAAM;AAExB,MAAI,MAAM,GAER,SAAQ,WAAR;GACE,KAAK;AACH,WAAO,KAAK;KAAE,MAAM;KAAO,OAAO;KAAK,KAAK;KAAW,CAAC;AACxD;GACF,KAAK;AACH,WAAO,KAAK;KAAE,MAAM;KAAM,OAAO;KAAK,KAAK;KAAW,CAAC;AACvD;GACF,KAAK;AACH,WAAO,KAAK;KAAE,MAAM;KAAO,OAAO;KAAK,KAAK;KAAW,CAAC;AACxD;GACF,KAAK;AACH,WAAO,KAAK;KAAE,MAAM;KAAO,OAAO;KAAK,KAAK;KAAW,CAAC;AACxD;;WAEK,MAAM,GAEf,KAAI,cAAc,IAChB,QAAO,KAAK;GAAE,MAAM;GAAU,OAAO;GAAK,KAAK;GAAW,CAAC;MAE3D,QAAO,KAAK;GAAE,MAAM;GAAU,OAAO;GAAK,KAAK;GAAW,CAAC;MAI7D,QAAO,KAAK;GAAE,MAAM;GAAS,OAAO;GAAW,KAAK;GAAW,CAAC;;AAIpE,QAAO;;;;;AAMT,SAAS,2BAA2B,KAAqB;CACvD,IAAI,SA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U,IAAI,MAAM,0CAA0C;AACpE,MAAI,CAAC,QACH,QAAO,wBACL,QAAQ,aAAa,IAAI,IACzB,QACA,KACA,OACA,IACD;EAGH,MAAM,GAAG,KAAK,UAAU,SAAS;EACjC,IAAI,aAAa;AAGjB,MACG,WAAW,WAAW,KAAI,IAAI,WAAW,SAAS,KAAI,IACtD,WAAW,WAAW,IAAI,IAAI,WAAW,SAAS,IAAI,CAEvD,cAAa,WAAW,MAAM,GAAG,GAAG;AAGtC,SAAO,wBACL,QAAQ,aAAa,IAAI,IACzB,YACA,UACA,OACA,IACD;;;;;CAMH,AAAQ,qBAAqB,KAA4B;AACvD,SAAO,wBACL,QAAQ,aAAa,IAAI,IACzB,QACA,KACA,OACA,IACD;;;;;;AAWL,SAAS,kBAAkB,OAA8B;CACvD,MAAM,QAAQ,MAAM,MAAM,wCAAwC;AAClE,KAAI,MACF,QAAO,WAAW,MAAM,GAAG;AAE7B,QAAO;;;;;AAUT,SAAgB,cACd,UACA,UAAgC,EAAE,EACnB;AAEf,KAAI,CAAC,YAAY,CAAC,SAAS,MAAM,CAC/B,QAAO,eAAe;CAGxB,MAAM,UAAU,SAAS,MAAM;CAI/B,MAAM,MAAM,QAAQ;CACpB,MAAM,iBACJ,OAAO,OAAO,KAAK,IAAI,sBAAsB,CAAC,SAAS,IACnD,KAAK,UAAU,IAAI,sBAAsB,GACzC;CACN,MAAM,WAAW,KAAK,UAAU;EAC9B;EACA,QAAQ;EACR;EACD,CAAC;CAGF,MAAM,SAAS,WAAW,IAAI,SAAS;AACvC,KAAI,OACF,QAAO;CAMT,MAAM,SADS,IAAI,OADJ,SAAS,QAAQ,EACE,QAAQ,CACpB,OAAO;AAG7B,YAAW,IAAI,UAAU,OAAO;AAEhC,QAAO"}
|
|
1
|
+
{"version":3,"file":"parseStateKey.js","names":[],"sources":["../../src/pipeline/parseStateKey.ts"],"sourcesContent":["/**\n * State Key Parser\n *\n * Parses state notation strings (like 'hovered & !disabled', '@media(w < 768px)')\n * into ConditionNode trees for processing in the pipeline.\n */\n\nimport { Lru } from '../parser/lru';\nimport type { StateParserContext } from '../states';\nimport {\n expandDimensionShorthands,\n expandTastyUnits,\n findTopLevelComma,\n resolvePredefinedState,\n} from '../states';\nimport { camelToKebab } from '../utils/case-converter';\nimport { transformSelectorContent } from '../utils/selector-transform';\n\nimport type { ConditionNode, NumericBound } from './conditions';\nimport { emitWarning } from './warnings';\nimport {\n and,\n createContainerDimensionCondition,\n createContainerRawCondition,\n createContainerStyleCondition,\n createMediaDimensionCondition,\n createMediaFeatureCondition,\n createMediaTypeCondition,\n createModifierCondition,\n createOwnCondition,\n createParentCondition,\n createPseudoCondition,\n createRootCondition,\n createStartingCondition,\n createSupportsCondition,\n not,\n or,\n trueCondition,\n} from './conditions';\n\n// ============================================================================\n// Constants\n// ============================================================================\n\n/**\n * Maximum XOR operands before emitting a performance warning.\n * A ^ B ^ C ^ D = 8 OR branches (2^(n-1)), so chains above 4\n * risk exponential blowup in downstream processing.\n */\nconst MAX_XOR_CHAIN_LENGTH = 4;\n\n// ============================================================================\n// Types\n// ============================================================================\n\nexport interface ParseStateKeyOptions {\n context?: StateParserContext;\n isSubElement?: boolean;\n}\n\n// ============================================================================\n// Caching\n// ============================================================================\n\n// Cache for parsed state keys (key -> ConditionNode)\nconst parseCache = new Lru<string, ConditionNode>(5000);\n\n// ============================================================================\n// Tokenizer Patterns\n// ============================================================================\n\n/**\n * Pattern for tokenizing state notation.\n * Matches: operators, parentheses, @-prefixed states, value mods, boolean mods,\n * pseudo-classes, class selectors, and attribute selectors.\n *\n * Note: For @supports, @(...) container queries, and :is/:has/:not/:where\n * we need to handle nested parentheses.\n * We use a pattern that allows up to 2 levels of nesting:\n * [^()]*(?:\\([^()]*(?:\\([^)]*\\))?[^)]*\\))*[^)]*\n */\nconst STATE_TOKEN_PATTERN =\n /([&|!^])|([()])|(@media:[a-z]+)|(@media\\([^)]+\\))|(@supports\\([^()]*(?:\\([^)]*\\))?[^)]*\\))|(@root\\([^)]+\\))|(@parent\\([^)]+\\))|(@own\\([^)]+\\))|(@\\([^()]*(?:\\([^)]*\\))?[^)]*\\))|(@starting)|(@[A-Za-z][A-Za-z0-9-]*)|([a-z][a-z0-9-]*(?:\\^=|\\$=|\\*=|=)(?:\"[^\"]*\"|'[^']*'|[^\\s&|!^()]+))|([a-z][a-z0-9-]+)|(:(?:is|has|not|where)\\([^()]*(?:\\([^()]*(?:\\([^)]*\\))?[^)]*\\))*[^)]*\\))|(:[-a-z][a-z0-9-]*(?:\\([^)]+\\))?)|(\\.[a-z][a-z0-9-]+)|(\\[[^\\]]+\\])/gi;\n\n// ============================================================================\n// Token Types\n// ============================================================================\n\ntype TokenType = 'AND' | 'OR' | 'NOT' | 'XOR' | 'LPAREN' | 'RPAREN' | 'STATE';\n\ninterface Token {\n type: TokenType;\n value: string;\n raw: string;\n}\n\n// ============================================================================\n// Tokenizer\n// ============================================================================\n\n/**\n * Tokenize a state notation string\n */\nfunction tokenize(stateKey: string): Token[] {\n const tokens: Token[] = [];\n let match: RegExpExecArray | null;\n\n // Replace commas with | outside of parentheses (for compatibility)\n const normalized = replaceCommasOutsideParens(stateKey);\n\n STATE_TOKEN_PATTERN.lastIndex = 0;\n while ((match = STATE_TOKEN_PATTERN.exec(normalized)) !== null) {\n const fullMatch = match[0];\n\n if (match[1]) {\n // Operator: &, |, !, ^\n switch (fullMatch) {\n case '&':\n tokens.push({ type: 'AND', value: '&', raw: fullMatch });\n break;\n case '|':\n tokens.push({ type: 'OR', value: '|', raw: fullMatch });\n break;\n case '!':\n tokens.push({ type: 'NOT', value: '!', raw: fullMatch });\n break;\n case '^':\n tokens.push({ type: 'XOR', value: '^', raw: fullMatch });\n break;\n }\n } else if (match[2]) {\n // Parenthesis\n if (fullMatch === '(') {\n tokens.push({ type: 'LPAREN', value: '(', raw: fullMatch });\n } else {\n tokens.push({ type: 'RPAREN', value: ')', raw: fullMatch });\n }\n } else {\n // State token (all other capture groups)\n tokens.push({ type: 'STATE', value: fullMatch, raw: fullMatch });\n }\n }\n\n return tokens;\n}\n\n/**\n * Replace commas with | only outside of parentheses\n */\nfunction replaceCommasOutsideParens(str: string): string {\n let result = '';\n let depth = 0;\n\n for (const char of str) {\n if (char === '(') {\n depth++;\n result += char;\n } else if (char === ')') {\n depth--;\n result += char;\n } else if (char === ',' && depth === 0) {\n result += '|';\n } else {\n result += char;\n }\n }\n\n return result;\n}\n\n// ============================================================================\n// Recursive Descent Parser\n// ============================================================================\n\n/**\n * Parser state\n */\nclass Parser {\n private tokens: Token[];\n private pos = 0;\n private options: ParseStateKeyOptions;\n\n constructor(tokens: Token[], options: ParseStateKeyOptions) {\n this.tokens = tokens;\n this.options = options;\n }\n\n parse(): ConditionNode {\n if (this.tokens.length === 0) {\n return trueCondition();\n }\n const result = this.parseExpression();\n return result;\n }\n\n private current(): Token | undefined {\n return this.tokens[this.pos];\n }\n\n private advance(): Token | undefined {\n return this.tokens[this.pos++];\n }\n\n private match(type: TokenType): boolean {\n if (this.current()?.type === type) {\n this.advance();\n return true;\n }\n return false;\n }\n\n /**\n * Parse expression with operator precedence:\n * ! (NOT) > ^ (XOR) > | (OR) > & (AND)\n */\n private parseExpression(): ConditionNode {\n return this.parseAnd();\n }\n\n private parseAnd(): ConditionNode {\n let left = this.parseOr();\n\n while (this.current()?.type === 'AND') {\n this.advance();\n const right = this.parseOr();\n left = and(left, right);\n }\n\n return left;\n }\n\n private parseOr(): ConditionNode {\n let left = this.parseXor();\n\n while (this.current()?.type === 'OR') {\n this.advance();\n const right = this.parseXor();\n left = or(left, right);\n }\n\n return left;\n }\n\n private parseXor(): ConditionNode {\n let left = this.parseUnary();\n let operandCount = 1;\n\n while (this.current()?.type === 'XOR') {\n this.advance();\n const right = this.parseUnary();\n operandCount++;\n\n if (operandCount > MAX_XOR_CHAIN_LENGTH) {\n emitWarning(\n 'XOR_CHAIN_TOO_LONG',\n `XOR chain with ${operandCount} operands produces ${Math.pow(2, operandCount - 1)} OR branches. ` +\n `Consider breaking into smaller expressions to avoid exponential growth.`,\n );\n }\n\n // XOR: (A & !B) | (!A & B)\n left = or(and(left, not(right)), and(not(left), right));\n }\n\n return left;\n }\n\n private parseUnary(): ConditionNode {\n if (this.match('NOT')) {\n const operand = this.parseUnary();\n return not(operand);\n }\n return this.parsePrimary();\n }\n\n private parsePrimary(): ConditionNode {\n // Handle parentheses\n if (this.match('LPAREN')) {\n const expr = this.parseExpression();\n this.match('RPAREN'); // Consume closing paren (lenient if missing)\n return expr;\n }\n\n // Handle state tokens\n const token = this.current();\n if (token?.type === 'STATE') {\n this.advance();\n return this.parseStateToken(token.value);\n }\n\n // Fallback for empty/invalid - return TRUE\n return trueCondition();\n }\n\n /**\n * Parse a state token into a ConditionNode\n */\n private parseStateToken(value: string): ConditionNode {\n // @starting\n if (value === '@starting') {\n return createStartingCondition(false, value);\n }\n\n // @media:type (e.g., @media:print)\n if (value.startsWith('@media:')) {\n const mediaType = value.slice(7) as 'print' | 'screen' | 'all' | 'speech';\n return createMediaTypeCondition(mediaType, false, value);\n }\n\n // @media(...) - media query\n if (value.startsWith('@media(')) {\n return this.parseMediaQuery(value);\n }\n\n // @supports(...) - feature/selector support query\n if (value.startsWith('@supports(')) {\n return this.parseSupportsQuery(value);\n }\n\n // @root(...) - root state\n if (value.startsWith('@root(')) {\n return this.parseRootState(value);\n }\n\n // @parent(...) - parent element state\n if (value.startsWith('@parent(')) {\n return this.parseParentState(value);\n }\n\n // @own(...) - own state (sub-element)\n if (value.startsWith('@own(')) {\n return this.parseOwnState(value);\n }\n\n // @(...) - container query\n if (value.startsWith('@(')) {\n return this.parseContainerQuery(value);\n }\n\n // @name - predefined state\n if (value.startsWith('@') && /^@[A-Za-z][A-Za-z0-9-]*$/.test(value)) {\n return this.parsePredefinedState(value);\n }\n\n // Enhanced pseudo-classes: :is(), :has(), :not(), :where()\n // Transform capitalized words to [data-element=\"...\"] selectors,\n // auto-complete trailing combinators with *, and\n // normalize :not(X) → negated :is(X) for deduplication.\n if (value.startsWith(':')) {\n const enhancedMatch = /^:(is|has|not|where)\\(/.exec(value);\n if (enhancedMatch) {\n const fn = enhancedMatch[1];\n const prefix = enhancedMatch[0];\n let content = transformSelectorContent(value.slice(prefix.length, -1));\n\n // Auto-complete trailing combinator: :has(Icon >) → :has(... > *)\n content = content.replace(/([>+~])\\s*$/, '$1 *');\n\n if (fn === 'not') {\n return createPseudoCondition(`:is(${content})`, true, value);\n }\n\n return createPseudoCondition(`:${fn}(${content})`, false, value);\n }\n\n return createPseudoCondition(value, false, value);\n }\n\n // Class selector (e.g., .active)\n if (value.startsWith('.')) {\n return createPseudoCondition(value, false, value);\n }\n\n // Attribute selector (e.g., [disabled], [data-state=\"active\"])\n if (value.startsWith('[')) {\n return createPseudoCondition(value, false, value);\n }\n\n // Value modifier (e.g., theme=danger, size=large)\n if (value.includes('=')) {\n return this.parseValueModifier(value);\n }\n\n // Boolean modifier (e.g., hovered, disabled)\n return this.parseBooleanModifier(value);\n }\n\n /**\n * Parse @media(...) query\n */\n private parseMediaQuery(raw: string): ConditionNode {\n const content = raw.slice(7, -1); // Remove '@media(' and ')'\n if (!content.trim()) {\n return trueCondition();\n }\n\n // Expand shorthands and units\n let condition = expandDimensionShorthands(content);\n condition = expandTastyUnits(condition);\n\n // Check for feature queries (contains ':' but not dimension comparison)\n if (\n condition.includes(':') &&\n !condition.includes('<') &&\n !condition.includes('>') &&\n !condition.includes('=')\n ) {\n // Feature query: @media(prefers-contrast: high)\n const colonIdx = condition.indexOf(':');\n const feature = condition.slice(0, colonIdx).trim();\n const featureValue = condition.slice(colonIdx + 1).trim();\n return createMediaFeatureCondition(feature, featureValue, false, raw);\n }\n\n // Boolean feature query: @media(prefers-reduced-motion)\n if (\n !condition.includes('<') &&\n !condition.includes('>') &&\n !condition.includes('=')\n ) {\n return createMediaFeatureCondition(\n condition.trim(),\n undefined,\n false,\n raw,\n );\n }\n\n // Dimension query - parse bounds\n const { dimension, lowerBound, upperBound } =\n this.parseDimensionCondition(condition);\n\n if (!dimension) {\n // Fallback for unparseable - treat as pseudo\n return createPseudoCondition(raw, false, raw);\n }\n\n return createMediaDimensionCondition(\n dimension as 'width' | 'height',\n lowerBound,\n upperBound,\n false,\n raw,\n );\n }\n\n /**\n * Parse dimension condition string (e.g., \"width < 768px\", \"600px <= width < 1200px\")\n */\n private parseDimensionCondition(condition: string): {\n dimension?: string;\n lowerBound?: NumericBound;\n upperBound?: NumericBound;\n } {\n // Range syntax: \"600px <= width < 1200px\"\n const rangeMatch = condition.match(\n /^(.+?)\\s*(<=|<)\\s*(width|height|inline-size|block-size)\\s*(<=|<)\\s*(.+)$/,\n );\n if (rangeMatch) {\n const [, lowerValue, lowerOp, dimension, upperOp, upperValue] =\n rangeMatch;\n return {\n dimension,\n lowerBound: {\n value: lowerValue.trim(),\n valueNumeric: parseNumericValue(lowerValue.trim()),\n inclusive: lowerOp === '<=',\n },\n upperBound: {\n value: upperValue.trim(),\n valueNumeric: parseNumericValue(upperValue.trim()),\n inclusive: upperOp === '<=',\n },\n };\n }\n\n // Simple comparison: \"width < 768px\"\n const simpleMatch = condition.match(\n /^(width|height|inline-size|block-size)\\s*(<=|>=|<|>|=)\\s*(.+)$/,\n );\n if (simpleMatch) {\n const [, dimension, operator, value] = simpleMatch;\n const numeric = parseNumericValue(value.trim());\n\n if (operator === '<' || operator === '<=') {\n return {\n dimension,\n upperBound: {\n value: value.trim(),\n valueNumeric: numeric,\n inclusive: operator === '<=',\n },\n };\n } else if (operator === '>' || operator === '>=') {\n return {\n dimension,\n lowerBound: {\n value: value.trim(),\n valueNumeric: numeric,\n inclusive: operator === '>=',\n },\n };\n } else if (operator === '=') {\n // Exact match: both bounds are the same and inclusive\n return {\n dimension,\n lowerBound: {\n value: value.trim(),\n valueNumeric: numeric,\n inclusive: true,\n },\n upperBound: {\n value: value.trim(),\n valueNumeric: numeric,\n inclusive: true,\n },\n };\n }\n }\n\n // Reversed: \"768px > width\"\n const reversedMatch = condition.match(\n /^(.+?)\\s*(<=|>=|<|>|=)\\s*(width|height|inline-size|block-size)$/,\n );\n if (reversedMatch) {\n const [, value, operator, dimension] = reversedMatch;\n const numeric = parseNumericValue(value.trim());\n\n // Reverse the operator\n if (operator === '<' || operator === '<=') {\n return {\n dimension,\n lowerBound: {\n value: value.trim(),\n valueNumeric: numeric,\n inclusive: operator === '<=',\n },\n };\n } else if (operator === '>' || operator === '>=') {\n return {\n dimension,\n upperBound: {\n value: value.trim(),\n valueNumeric: numeric,\n inclusive: operator === '>=',\n },\n };\n }\n }\n\n return {};\n }\n\n /**\n * Parse @root(...) state\n */\n private parseInnerCondition(\n raw: string,\n prefixLen: number,\n wrap: (inner: ConditionNode) => ConditionNode,\n ): ConditionNode {\n const content = raw.slice(prefixLen, -1);\n if (!content.trim()) return trueCondition();\n return wrap(parseStateKey(content, this.options));\n }\n\n private parseRootState(raw: string): ConditionNode {\n return this.parseInnerCondition(raw, 6, (inner) =>\n createRootCondition(inner, false, raw),\n );\n }\n\n /**\n * Parse @parent(...) state\n *\n * Syntax:\n * @parent(hovered) → :is([data-hovered] *)\n * @parent(theme=dark) → :is([data-theme=\"dark\"] *)\n * @parent(hovered, >) → :is([data-hovered] > *) (direct parent)\n * @parent(.my-class) → :is(.my-class *)\n */\n private parseParentState(raw: string): ConditionNode {\n const content = raw.slice(8, -1);\n if (!content.trim()) {\n return trueCondition();\n }\n\n let condition = content.trim();\n let direct = false;\n\n const lastCommaIdx = condition.lastIndexOf(',');\n if (lastCommaIdx !== -1) {\n const afterComma = condition.slice(lastCommaIdx + 1).trim();\n if (afterComma === '>') {\n direct = true;\n condition = condition.slice(0, lastCommaIdx).trim();\n }\n }\n\n const innerCondition = parseStateKey(condition, this.options);\n return createParentCondition(innerCondition, direct, false, raw);\n }\n\n /**\n * Parse @supports(...) query\n *\n * Syntax:\n * @supports(display: grid) → @supports (display: grid)\n * @supports($, :has(*)) → @supports selector(:has(*))\n */\n private parseSupportsQuery(raw: string): ConditionNode {\n const content = raw.slice(10, -1); // Remove '@supports(' and ')'\n if (!content.trim()) {\n return trueCondition();\n }\n\n // Check for selector syntax: @supports($, :has(*))\n if (content.startsWith('$,')) {\n const selector = content.slice(2).trim(); // Remove '$,' prefix\n return createSupportsCondition('selector', selector, false, raw);\n }\n\n // Feature syntax: @supports(display: grid)\n return createSupportsCondition('feature', content, false, raw);\n }\n\n private parseOwnState(raw: string): ConditionNode {\n return this.parseInnerCondition(raw, 5, (inner) =>\n createOwnCondition(inner, false, raw),\n );\n }\n\n /**\n * Parse @(...) container query\n */\n private parseContainerQuery(raw: string): ConditionNode {\n const content = raw.slice(2, -1); // Remove '@(' and ')'\n if (!content.trim()) {\n return trueCondition();\n }\n\n // Check for named container: @(layout, w < 600px)\n // Use parentheses-aware comma search so inner commas (e.g., scroll-state(a, b)) are skipped\n const commaIdx = findTopLevelComma(content);\n let containerName: string | undefined;\n let condition: string;\n\n if (commaIdx !== -1) {\n containerName = content.slice(0, commaIdx).trim();\n condition = content.slice(commaIdx + 1).trim();\n } else {\n condition = content.trim();\n }\n\n // Check for style query shorthand: @($variant=primary)\n if (condition.startsWith('$')) {\n const styleQuery = condition.slice(1); // Remove '$'\n const eqIdx = styleQuery.indexOf('=');\n\n if (eqIdx === -1) {\n // Existence check: @($variant)\n return createContainerStyleCondition(\n styleQuery,\n undefined,\n containerName,\n false,\n raw,\n );\n }\n\n const property = styleQuery.slice(0, eqIdx).trim();\n let propertyValue = styleQuery.slice(eqIdx + 1).trim();\n\n // Remove quotes if present\n if (\n (propertyValue.startsWith('\"') && propertyValue.endsWith('\"')) ||\n (propertyValue.startsWith(\"'\") && propertyValue.endsWith(\"'\"))\n ) {\n propertyValue = propertyValue.slice(1, -1);\n }\n\n return createContainerStyleCondition(\n property,\n propertyValue,\n containerName,\n false,\n raw,\n );\n }\n\n // Check for function-like syntax: scroll-state(...), style(...), etc.\n // Passes the condition through to CSS verbatim.\n if (/^[a-zA-Z][\\w-]*\\s*\\(/.test(condition)) {\n return createContainerRawCondition(condition, containerName, false, raw);\n }\n\n // Dimension query\n let expandedCondition = expandDimensionShorthands(condition);\n expandedCondition = expandTastyUnits(expandedCondition);\n\n const { dimension, lowerBound, upperBound } =\n this.parseDimensionCondition(expandedCondition);\n\n if (!dimension) {\n // Fallback\n return createPseudoCondition(raw, false, raw);\n }\n\n return createContainerDimensionCondition(\n dimension as 'width' | 'height',\n lowerBound,\n upperBound,\n containerName,\n false,\n raw,\n );\n }\n\n /**\n * Parse predefined state (@mobile, @dark, etc.)\n */\n private parsePredefinedState(raw: string): ConditionNode {\n const ctx = this.options.context;\n if (!ctx) {\n // No context - can't resolve predefined states\n return createPseudoCondition(raw, false, raw);\n }\n\n const resolved = resolvePredefinedState(raw, ctx);\n if (!resolved) {\n // Undefined predefined state - treat as modifier\n return createModifierCondition(\n `data-${camelToKebab(raw.slice(1))}`,\n undefined,\n '=',\n false,\n raw,\n );\n }\n\n // Parse the resolved value recursively\n return parseStateKey(resolved, this.options);\n }\n\n /**\n * Parse value modifier (e.g., theme=danger, size^=sm)\n */\n private parseValueModifier(raw: string): ConditionNode {\n // Match operators: =, ^=, $=, *=\n const opMatch = raw.match(/^([a-z][a-z0-9-]*)(\\^=|\\$=|\\*=|=)(.+)$/i);\n if (!opMatch) {\n return createModifierCondition(\n `data-${camelToKebab(raw)}`,\n undefined,\n '=',\n false,\n raw,\n );\n }\n\n const [, key, operator, value] = opMatch;\n let cleanValue = value;\n\n // Remove quotes if present\n if (\n (cleanValue.startsWith('\"') && cleanValue.endsWith('\"')) ||\n (cleanValue.startsWith(\"'\") && cleanValue.endsWith(\"'\"))\n ) {\n cleanValue = cleanValue.slice(1, -1);\n }\n\n return createModifierCondition(\n `data-${camelToKebab(key)}`,\n cleanValue,\n operator as '=' | '^=' | '$=' | '*=',\n false,\n raw,\n );\n }\n\n /**\n * Parse boolean modifier (e.g., hovered, disabled)\n */\n private parseBooleanModifier(raw: string): ConditionNode {\n return createModifierCondition(\n `data-${camelToKebab(raw)}`,\n undefined,\n '=',\n false,\n raw,\n );\n }\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Parse a numeric value from a CSS value string\n */\nfunction parseNumericValue(value: string): number | null {\n const match = value.match(/^(\\d+(?:\\.\\d+)?)(px|em|rem|vh|vw|%)?$/);\n if (match) {\n return parseFloat(match[1]);\n }\n return null;\n}\n\n// ============================================================================\n// Main Export\n// ============================================================================\n\n/**\n * Parse a state key string into a ConditionNode\n */\nexport function parseStateKey(\n stateKey: string,\n options: ParseStateKeyOptions = {},\n): ConditionNode {\n // Handle empty/default state\n if (!stateKey || !stateKey.trim()) {\n return trueCondition();\n }\n\n const trimmed = stateKey.trim();\n\n // Build cache key including local predefined states (they affect parsing)\n // Global predefined states are set once at initialization and don't change\n const ctx = options.context;\n const localStatesKey =\n ctx && Object.keys(ctx.localPredefinedStates).length > 0\n ? JSON.stringify(ctx.localPredefinedStates)\n : '';\n const cacheKey = JSON.stringify([\n trimmed,\n options.isSubElement,\n localStatesKey,\n ]);\n\n // Check cache\n const cached = parseCache.get(cacheKey);\n if (cached) {\n return cached;\n }\n\n // Tokenize and parse\n const tokens = tokenize(trimmed);\n const parser = new Parser(tokens, options);\n const result = parser.parse();\n\n // Cache result\n parseCache.set(cacheKey, result);\n\n return result;\n}\n\n/**\n * Clear the parse cache (for testing)\n */\nexport function clearParseCache(): void {\n parseCache.clear();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAiDA,MAAM,uBAAuB;AAgB7B,MAAM,aAAa,IAAI,IAA2B,IAAK;;;;;;;;;;;AAgBvD,MAAM,sBACJ;;;;AAqBF,SAAS,SAAS,UAA2B;CAC3C,MAAM,SAAkB,EAAE;CAC1B,IAAI;CAGJ,MAAM,aAAa,2BAA2B,SAAS;AAEvD,qBAAoB,YAAY;AAChC,SAAQ,QAAQ,oBAAoB,KAAK,WAAW,MAAM,MAAM;EAC9D,MAAM,YAAY,MAAM;AAExB,MAAI,MAAM,GAER,SAAQ,WAAR;GACE,KAAK;AACH,WAAO,KAAK;KAAE,M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,GAAG;AAGtC,SAAO,wBACL,QAAQ,aAAa,IAAI,IACzB,YACA,UACA,OACA,IACD;;;;;CAMH,AAAQ,qBAAqB,KAA4B;AACvD,SAAO,wBACL,QAAQ,aAAa,IAAI,IACzB,QACA,KACA,OACA,IACD;;;;;;AAWL,SAAS,kBAAkB,OAA8B;CACvD,MAAM,QAAQ,MAAM,MAAM,wCAAwC;AAClE,KAAI,MACF,QAAO,WAAW,MAAM,GAAG;AAE7B,QAAO;;;;;AAUT,SAAgB,cACd,UACA,UAAgC,EAAE,EACnB;AAEf,KAAI,CAAC,YAAY,CAAC,SAAS,MAAM,CAC/B,QAAO,eAAe;CAGxB,MAAM,UAAU,SAAS,MAAM;CAI/B,MAAM,MAAM,QAAQ;CACpB,MAAM,iBACJ,OAAO,OAAO,KAAK,IAAI,sBAAsB,CAAC,SAAS,IACnD,KAAK,UAAU,IAAI,sBAAsB,GACzC;CACN,MAAM,WAAW,KAAK,UAAU;EAC9B;EACA,QAAQ;EACR;EACD,CAAC;CAGF,MAAM,SAAS,WAAW,IAAI,SAAS;AACvC,KAAI,OACF,QAAO;CAMT,MAAM,SADS,IAAI,OADJ,SAAS,QAAQ,EACE,QAAQ,CACpB,OAAO;AAG7B,YAAW,IAAI,UAAU,OAAO;AAEhC,QAAO"}
|
|
@@ -16,7 +16,6 @@ import { presetStyle } from "./preset.js";
|
|
|
16
16
|
import { radiusStyle } from "./radius.js";
|
|
17
17
|
import { scrollbarStyle } from "./scrollbar.js";
|
|
18
18
|
import { shadowStyle } from "./shadow.js";
|
|
19
|
-
import { styledScrollbarStyle } from "./styledScrollbar.js";
|
|
20
19
|
import { transitionStyle } from "./transition.js";
|
|
21
20
|
import { widthStyle } from "./width.js";
|
|
22
21
|
|
|
@@ -64,7 +63,6 @@ declare const styleHandlers: {
|
|
|
64
63
|
readonly radius: typeof radiusStyle;
|
|
65
64
|
readonly scrollbar: typeof scrollbarStyle;
|
|
66
65
|
readonly shadow: typeof shadowStyle;
|
|
67
|
-
readonly styledScrollbar: typeof styledScrollbarStyle;
|
|
68
66
|
readonly transition: typeof transitionStyle;
|
|
69
67
|
readonly width: typeof widthStyle;
|
|
70
68
|
};
|
|
@@ -18,7 +18,6 @@ import { presetStyle } from "./preset.js";
|
|
|
18
18
|
import { radiusStyle } from "./radius.js";
|
|
19
19
|
import { scrollbarStyle } from "./scrollbar.js";
|
|
20
20
|
import { shadowStyle } from "./shadow.js";
|
|
21
|
-
import { styledScrollbarStyle } from "./styledScrollbar.js";
|
|
22
21
|
import { transitionStyle } from "./transition.js";
|
|
23
22
|
import { widthStyle } from "./width.js";
|
|
24
23
|
|
|
@@ -96,7 +95,6 @@ function predefine() {
|
|
|
96
95
|
justifyStyle,
|
|
97
96
|
presetStyle,
|
|
98
97
|
outlineStyle,
|
|
99
|
-
styledScrollbarStyle,
|
|
100
98
|
scrollbarStyle,
|
|
101
99
|
fadeStyle,
|
|
102
100
|
insetStyle
|
|
@@ -231,7 +229,6 @@ const styleHandlers = {
|
|
|
231
229
|
radius: wrapHandler(radiusStyle),
|
|
232
230
|
scrollbar: wrapHandler(scrollbarStyle),
|
|
233
231
|
shadow: wrapHandler(shadowStyle),
|
|
234
|
-
styledScrollbar: wrapHandler(styledScrollbarStyle),
|
|
235
232
|
transition: wrapHandler(transitionStyle),
|
|
236
233
|
width: wrapHandler(widthStyle)
|
|
237
234
|
};
|