@homebound/truss 2.1.0-next.3 → 2.1.0-next.5
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/build/plugin/index.js +105 -13
- package/build/plugin/index.js.map +1 -1
- package/package.json +1 -1
package/build/plugin/index.js
CHANGED
|
@@ -161,8 +161,9 @@ function collectStaticRules(rules, seg, mapping) {
|
|
|
161
161
|
}
|
|
162
162
|
function collectVariableRules(rules, seg, mapping) {
|
|
163
163
|
const prefix = conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints);
|
|
164
|
-
const
|
|
164
|
+
const segmentBaseKey = seg.key.split("__")[0];
|
|
165
165
|
for (const prop of seg.variableProps) {
|
|
166
|
+
const baseKey = seg.key.split("__")[0];
|
|
166
167
|
const className = prefix ? `${prefix}${baseKey}_var` : `${baseKey}_var`;
|
|
167
168
|
const varName = toCssVariableName(className, baseKey, prop);
|
|
168
169
|
const declaration = { cssProperty: camelToKebab(prop), cssValue: `var(${varName})`, cssVarName: varName };
|
|
@@ -195,7 +196,7 @@ function collectVariableRules(rules, seg, mapping) {
|
|
|
195
196
|
}
|
|
196
197
|
if (seg.variableExtraDefs) {
|
|
197
198
|
for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {
|
|
198
|
-
const extraBase = `${
|
|
199
|
+
const extraBase = `${segmentBaseKey}_${cssProp}`;
|
|
199
200
|
const extraName = prefix ? `${prefix}${extraBase}` : extraBase;
|
|
200
201
|
if (!rules.has(extraName)) {
|
|
201
202
|
rules.set(extraName, {
|
|
@@ -238,9 +239,10 @@ function collectWhenStaticRules(rules, seg, mapping) {
|
|
|
238
239
|
function collectWhenVariableRules(rules, seg, mapping) {
|
|
239
240
|
const wp = seg.whenPseudo;
|
|
240
241
|
const prefix = whenPrefix(wp);
|
|
241
|
-
const
|
|
242
|
+
const segmentBaseKey = seg.key.split("__")[0];
|
|
242
243
|
const mClass = markerClassName(wp.markerNode);
|
|
243
244
|
for (const prop of seg.variableProps) {
|
|
245
|
+
const baseKey = seg.key.split("__")[0];
|
|
244
246
|
const className = `${prefix}${baseKey}_var`;
|
|
245
247
|
const varName = toCssVariableName(className, baseKey, prop);
|
|
246
248
|
const declaration = { cssProperty: camelToKebab(prop), cssValue: `var(${varName})`, cssVarName: varName };
|
|
@@ -275,7 +277,7 @@ function collectWhenVariableRules(rules, seg, mapping) {
|
|
|
275
277
|
}
|
|
276
278
|
if (seg.variableExtraDefs) {
|
|
277
279
|
for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {
|
|
278
|
-
const extraName = `${prefix}${
|
|
280
|
+
const extraName = `${prefix}${segmentBaseKey}_${cssProp}`;
|
|
279
281
|
if (!rules.has(extraName)) {
|
|
280
282
|
rules.set(extraName, {
|
|
281
283
|
className: extraName,
|
|
@@ -465,8 +467,9 @@ function buildStyleHashProperties(segments, mapping, maybeIncHelperName) {
|
|
|
465
467
|
if (seg.error || seg.styleArrayArg || seg.typographyLookup) continue;
|
|
466
468
|
if (seg.variableProps) {
|
|
467
469
|
const prefix = seg.whenPseudo ? whenPrefix(seg.whenPseudo) : conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints);
|
|
468
|
-
const
|
|
470
|
+
const segmentBaseKey = seg.key.split("__")[0];
|
|
469
471
|
for (const prop of seg.variableProps) {
|
|
472
|
+
const baseKey = seg.key.split("__")[0];
|
|
470
473
|
const className = prefix ? `${prefix}${baseKey}_var` : `${baseKey}_var`;
|
|
471
474
|
const varName = toCssVariableName(className, baseKey, prop);
|
|
472
475
|
if (!propGroups.has(prop)) propGroups.set(prop, []);
|
|
@@ -481,7 +484,7 @@ function buildStyleHashProperties(segments, mapping, maybeIncHelperName) {
|
|
|
481
484
|
}
|
|
482
485
|
if (seg.variableExtraDefs) {
|
|
483
486
|
for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {
|
|
484
|
-
const extraBase = `${
|
|
487
|
+
const extraBase = `${segmentBaseKey}_${cssProp}`;
|
|
485
488
|
const extraName = prefix ? `${prefix}${extraBase}` : extraBase;
|
|
486
489
|
if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);
|
|
487
490
|
propGroups.get(cssProp).push({ className: extraName, isVariable: false });
|
|
@@ -1139,17 +1142,17 @@ function resolveAddCall(node, mapping, mediaQuery, pseudoClass, pseudoElement, w
|
|
|
1139
1142
|
const wpSuffix = whenPseudoKeyName(whenPseudo);
|
|
1140
1143
|
if (literalValue !== null) {
|
|
1141
1144
|
const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
|
|
1142
|
-
const key =
|
|
1145
|
+
const key = `${propName}__${keySuffix}__${wpSuffix}`;
|
|
1143
1146
|
return { key, defs: { [propName]: literalValue }, whenPseudo, argResolved: literalValue };
|
|
1144
1147
|
} else {
|
|
1145
|
-
const key =
|
|
1148
|
+
const key = `${propName}__${wpSuffix}`;
|
|
1146
1149
|
return { key, defs: {}, whenPseudo, variableProps: [propName], incremented: false, argNode: valueArg };
|
|
1147
1150
|
}
|
|
1148
1151
|
}
|
|
1149
1152
|
const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);
|
|
1150
1153
|
if (literalValue !== null) {
|
|
1151
1154
|
const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, "_").replace(/_+/g, "_").replace(/^_|_$/g, "");
|
|
1152
|
-
const key = suffix ?
|
|
1155
|
+
const key = suffix ? `${propName}__${keySuffix}__${suffix}` : `${propName}__${keySuffix}`;
|
|
1153
1156
|
const defs = { [propName]: literalValue };
|
|
1154
1157
|
const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);
|
|
1155
1158
|
return {
|
|
@@ -1161,7 +1164,7 @@ function resolveAddCall(node, mapping, mediaQuery, pseudoClass, pseudoElement, w
|
|
|
1161
1164
|
argResolved: literalValue
|
|
1162
1165
|
};
|
|
1163
1166
|
} else {
|
|
1164
|
-
const key = suffix ?
|
|
1167
|
+
const key = suffix ? `${propName}__${suffix}` : propName;
|
|
1165
1168
|
return {
|
|
1166
1169
|
key,
|
|
1167
1170
|
defs: {},
|
|
@@ -1709,6 +1712,7 @@ function getCssAttributePath(path) {
|
|
|
1709
1712
|
}
|
|
1710
1713
|
function buildStyleHashFromChain(chain, options) {
|
|
1711
1714
|
const members = [];
|
|
1715
|
+
const previousProperties = /* @__PURE__ */ new Map();
|
|
1712
1716
|
if (chain.markers.length > 0) {
|
|
1713
1717
|
const markerClasses = chain.markers.map(function(marker) {
|
|
1714
1718
|
return markerClassName(marker.markerNode);
|
|
@@ -1717,10 +1721,22 @@ function buildStyleHashFromChain(chain, options) {
|
|
|
1717
1721
|
}
|
|
1718
1722
|
for (const part of chain.parts) {
|
|
1719
1723
|
if (part.type === "unconditional") {
|
|
1720
|
-
|
|
1724
|
+
const partMembers = buildStyleHashMembers(part.segments, options);
|
|
1725
|
+
members.push(...partMembers);
|
|
1726
|
+
for (const member of partMembers) {
|
|
1727
|
+
if (t3.isObjectProperty(member)) {
|
|
1728
|
+
previousProperties.set(propertyName(member.key), member);
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1721
1731
|
} else {
|
|
1722
|
-
const thenMembers =
|
|
1723
|
-
|
|
1732
|
+
const thenMembers = mergeConditionalBranchMembers(
|
|
1733
|
+
buildStyleHashMembers(part.thenSegments, options),
|
|
1734
|
+
previousProperties
|
|
1735
|
+
);
|
|
1736
|
+
const elseMembers = mergeConditionalBranchMembers(
|
|
1737
|
+
buildStyleHashMembers(part.elseSegments, options),
|
|
1738
|
+
previousProperties
|
|
1739
|
+
);
|
|
1724
1740
|
members.push(
|
|
1725
1741
|
t3.spreadElement(
|
|
1726
1742
|
t3.conditionalExpression(part.conditionNode, t3.objectExpression(thenMembers), t3.objectExpression(elseMembers))
|
|
@@ -1764,6 +1780,82 @@ function buildStyleHashMembers(segments, options) {
|
|
|
1764
1780
|
flushNormal();
|
|
1765
1781
|
return members;
|
|
1766
1782
|
}
|
|
1783
|
+
function mergeConditionalBranchMembers(members, previousProperties) {
|
|
1784
|
+
return members.map(function(member) {
|
|
1785
|
+
if (!t3.isObjectProperty(member)) {
|
|
1786
|
+
return member;
|
|
1787
|
+
}
|
|
1788
|
+
const prior = previousProperties.get(propertyName(member.key));
|
|
1789
|
+
if (!prior) {
|
|
1790
|
+
return member;
|
|
1791
|
+
}
|
|
1792
|
+
return t3.objectProperty(
|
|
1793
|
+
clonePropertyKey(member.key),
|
|
1794
|
+
mergePropertyValues(prior.value, member.value)
|
|
1795
|
+
);
|
|
1796
|
+
});
|
|
1797
|
+
}
|
|
1798
|
+
function mergePropertyValues(previousValue, currentValue) {
|
|
1799
|
+
if (t3.isStringLiteral(previousValue) && t3.isStringLiteral(currentValue)) {
|
|
1800
|
+
return t3.stringLiteral(`${previousValue.value} ${currentValue.value}`);
|
|
1801
|
+
}
|
|
1802
|
+
if (t3.isStringLiteral(previousValue) && t3.isArrayExpression(currentValue)) {
|
|
1803
|
+
return mergeTupleValue(currentValue, previousValue.value, true);
|
|
1804
|
+
}
|
|
1805
|
+
if (t3.isArrayExpression(previousValue) && t3.isStringLiteral(currentValue)) {
|
|
1806
|
+
return mergeTupleValue(previousValue, currentValue.value, false);
|
|
1807
|
+
}
|
|
1808
|
+
if (t3.isArrayExpression(previousValue) && t3.isArrayExpression(currentValue)) {
|
|
1809
|
+
const previousClassNames = tupleClassNames(previousValue);
|
|
1810
|
+
return mergeTupleValue(currentValue, previousClassNames, true, arrayElementExpression(previousValue.elements[1]));
|
|
1811
|
+
}
|
|
1812
|
+
return t3.cloneNode(currentValue, true);
|
|
1813
|
+
}
|
|
1814
|
+
function mergeTupleValue(tuple, classNames, prependClassNames, previousVars) {
|
|
1815
|
+
const currentClassNames = tupleClassNames(tuple);
|
|
1816
|
+
const mergedClassNames = prependClassNames ? `${classNames} ${currentClassNames}` : `${currentClassNames} ${classNames}`;
|
|
1817
|
+
const varsExpr = tuple.elements[1];
|
|
1818
|
+
const mergedVars = previousVars && arrayElementExpression(varsExpr) ? mergeVarsObject(previousVars, arrayElementExpression(varsExpr)) : arrayElementExpression(varsExpr) ?? previousVars ?? null;
|
|
1819
|
+
return t3.arrayExpression([
|
|
1820
|
+
t3.stringLiteral(mergedClassNames),
|
|
1821
|
+
mergedVars ? t3.cloneNode(mergedVars, true) : t3.objectExpression([])
|
|
1822
|
+
]);
|
|
1823
|
+
}
|
|
1824
|
+
function tupleClassNames(tuple) {
|
|
1825
|
+
const classNames = tuple.elements[0];
|
|
1826
|
+
return t3.isStringLiteral(classNames) ? classNames.value : "";
|
|
1827
|
+
}
|
|
1828
|
+
function arrayElementExpression(element) {
|
|
1829
|
+
return element && !t3.isSpreadElement(element) ? element : null;
|
|
1830
|
+
}
|
|
1831
|
+
function mergeVarsObject(previousVars, currentVars) {
|
|
1832
|
+
if (t3.isObjectExpression(previousVars) && t3.isObjectExpression(currentVars)) {
|
|
1833
|
+
return t3.objectExpression([
|
|
1834
|
+
...previousVars.properties.map(function(property) {
|
|
1835
|
+
return t3.cloneNode(property, true);
|
|
1836
|
+
}),
|
|
1837
|
+
...currentVars.properties.map(function(property) {
|
|
1838
|
+
return t3.cloneNode(property, true);
|
|
1839
|
+
})
|
|
1840
|
+
]);
|
|
1841
|
+
}
|
|
1842
|
+
return t3.cloneNode(currentVars, true);
|
|
1843
|
+
}
|
|
1844
|
+
function propertyName(key) {
|
|
1845
|
+
if (t3.isIdentifier(key)) {
|
|
1846
|
+
return key.name;
|
|
1847
|
+
}
|
|
1848
|
+
if (t3.isStringLiteral(key)) {
|
|
1849
|
+
return key.value;
|
|
1850
|
+
}
|
|
1851
|
+
return generate(key).code;
|
|
1852
|
+
}
|
|
1853
|
+
function clonePropertyKey(key) {
|
|
1854
|
+
if (t3.isPrivateName(key)) {
|
|
1855
|
+
return t3.identifier(key.id.name);
|
|
1856
|
+
}
|
|
1857
|
+
return t3.cloneNode(key, true);
|
|
1858
|
+
}
|
|
1767
1859
|
function injectDebugInfo(expr, line, options) {
|
|
1768
1860
|
if (!options.debug) return;
|
|
1769
1861
|
const firstProp = expr.properties.find(function(p) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin/index.ts","../../src/plugin/emit-truss.ts","../../src/plugin/transform.ts","../../src/plugin/resolve-chain.ts","../../src/plugin/ast-utils.ts","../../src/plugin/rewrite-sites.ts","../../src/plugin/transform-css.ts","../../src/plugin/css-ts-utils.ts","../../src/plugin/rewrite-css-ts-imports.ts"],"sourcesContent":["import { readFileSync, writeFileSync, existsSync } from \"fs\";\nimport { resolve, dirname, isAbsolute, join } from \"path\";\nimport type { TrussMapping } from \"./types\";\nimport type { AtomicRule } from \"./emit-truss\";\nimport { generateCssText } from \"./emit-truss\";\nimport { transformTruss } from \"./transform\";\nimport { transformCssTs } from \"./transform-css\";\nimport { rewriteCssTsImports } from \"./rewrite-css-ts-imports\";\n\nexport interface TrussPluginOptions {\n /** Path to the Css.json mapping file used for transforming files (relative to project root or absolute). */\n mapping: string;\n /** Packages in `node_modules` that should also be transformed, all other `node_modules` files are skipped. */\n externalPackages?: string[];\n}\n\n// Intentionally loose Vite types so we don't depend on the `vite` package at compile time.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface TrussVitePlugin {\n name: string;\n enforce?: \"pre\" | \"post\";\n configResolved?: (config: any) => void;\n buildStart?: () => void;\n resolveId?: (source: string, importer: string | undefined) => string | null;\n load?: (id: string) => string | null;\n transform?: (code: string, id: string) => { code: string; map: any } | null;\n configureServer?: (server: any) => void;\n transformIndexHtml?: (html: string) => string;\n handleHotUpdate?: (ctx: any) => void;\n generateBundle?: (options: any, bundle: any) => void;\n writeBundle?: (options: any, bundle: any) => void;\n}\n\n/** Prefix for virtual CSS module IDs generated from .css.ts files. */\nconst VIRTUAL_CSS_PREFIX = \"\\0truss-css:\";\nconst CSS_TS_QUERY = \"?truss-css\";\n\n/** Virtual module IDs for dev HMR. */\nconst VIRTUAL_CSS_ENDPOINT = \"/virtual:truss.css\";\nconst VIRTUAL_RUNTIME_ID = \"virtual:truss:runtime\";\nconst RESOLVED_VIRTUAL_RUNTIME_ID = \"\\0\" + VIRTUAL_RUNTIME_ID;\n\n/**\n * Vite plugin that transforms `Css.*.$` expressions from truss's CssBuilder DSL\n * into Truss-native style hash objects and `trussProps()`/`mergeProps()` runtime calls.\n *\n * Also supports `.css.ts` files: a `.css.ts` file with\n * `export const css = { \".selector\": Css.blue.$ }` can keep other runtime exports,\n * while imports are supplemented with a virtual CSS side-effect module.\n *\n * In dev mode, serves CSS via a virtual endpoint that the injected runtime keeps in sync.\n * In production, emits a single `truss.css` asset with all atomic rules.\n */\nexport function trussPlugin(opts: TrussPluginOptions): TrussVitePlugin {\n let mapping: TrussMapping | null = null;\n let projectRoot: string;\n let debug = false;\n let isTest = false;\n let isBuild = false;\n const externalPackages = opts.externalPackages ?? [];\n\n // Global CSS rule registry shared across all transform calls within a build\n const cssRegistry = new Map<string, AtomicRule>();\n let cssVersion = 0;\n let lastSentVersion = 0;\n\n function mappingPath(): string {\n return resolve(projectRoot || process.cwd(), opts.mapping);\n }\n\n // Some tooling can call `transform` before `buildStart`; this keeps behavior\n // resilient without requiring hook ordering assumptions.\n function ensureMapping(): TrussMapping {\n if (!mapping) {\n mapping = loadMapping(mappingPath());\n }\n return mapping;\n }\n\n /** Generate the full CSS string from the global registry, ordered by precedence tiers. */\n function collectCss(): string {\n return generateCssText(cssRegistry);\n }\n\n return {\n name: \"truss\",\n enforce: \"pre\",\n\n configResolved(config: any) {\n projectRoot = config.root;\n debug = config.command === \"serve\" || config.mode === \"development\" || config.mode === \"test\";\n isTest = config.mode === \"test\";\n isBuild = config.command === \"build\";\n },\n\n buildStart() {\n ensureMapping();\n // Reset registry at start of each build\n cssRegistry.clear();\n cssVersion = 0;\n lastSentVersion = 0;\n },\n\n // -- Dev mode HMR --\n\n configureServer(server: any) {\n // Skip dev-server setup in test mode — Vitest doesn't start a real HTTP\n // server, so the interval would keep the process alive.\n if (isTest) return;\n\n // Serve the current collected CSS at the virtual endpoint\n server.middlewares.use(function (req: any, res: any, next: any) {\n if (req.url !== VIRTUAL_CSS_ENDPOINT) return next();\n const css = collectCss();\n res.setHeader(\"Content-Type\", \"text/css\");\n res.setHeader(\"Cache-Control\", \"no-store\");\n res.end(css);\n });\n\n // Poll for CSS version changes and push HMR updates\n const interval = setInterval(function () {\n if (cssVersion !== lastSentVersion && server.ws) {\n lastSentVersion = cssVersion;\n server.ws.send({ type: \"custom\", event: \"truss:css-update\" });\n }\n }, 150);\n\n // Clean up interval when server closes\n server.httpServer?.on(\"close\", function () {\n clearInterval(interval);\n });\n },\n\n transformIndexHtml(html: string) {\n if (isBuild) return html;\n // Inject the virtual runtime script for dev mode; it owns style updates.\n const tags = [`<script type=\"module\" src=\"/${VIRTUAL_RUNTIME_ID}\"></script>`].join(\"\\n \");\n return html.replace(\"</head>\", ` ${tags}\\n </head>`);\n },\n\n handleHotUpdate(ctx: any) {\n // Send CSS update event on any file change for safety\n if (ctx.server?.ws) {\n ctx.server.ws.send({ type: \"custom\", event: \"truss:css-update\" });\n }\n },\n\n // -- Virtual module resolution --\n\n resolveId(source: string, importer: string | undefined) {\n // Handle the dev HMR runtime virtual module\n if (source === VIRTUAL_RUNTIME_ID || source === \"/\" + VIRTUAL_RUNTIME_ID) {\n return RESOLVED_VIRTUAL_RUNTIME_ID;\n }\n\n // Handle .css.ts virtual modules\n if (!source.endsWith(CSS_TS_QUERY)) return null;\n\n const absolutePath = resolveImportPath(source.slice(0, -CSS_TS_QUERY.length), importer, projectRoot);\n\n // Only handle it if the .css.ts file actually exists\n if (!existsSync(absolutePath)) return null;\n\n // Return a virtual CSS module ID that maps back to the source .css.ts file.\n // Strip the trailing `.ts` so the ID ends in `.css` — this tells Vite to\n // route the loaded content through its CSS pipeline.\n return VIRTUAL_CSS_PREFIX + absolutePath.slice(0, -3);\n },\n\n load(id: string) {\n // Serve the dev HMR runtime script\n if (id === RESOLVED_VIRTUAL_RUNTIME_ID) {\n return `\n// Truss dev HMR runtime — keeps styles up to date without page reload\n(function() {\n let style = document.getElementById(\"__truss_virtual__\");\n if (!style) {\n style = document.createElement(\"style\");\n style.id = \"__truss_virtual__\";\n document.head.appendChild(style);\n }\n\n function fetchCss() {\n fetch(\"${VIRTUAL_CSS_ENDPOINT}\")\n .then(function(r) { return r.text(); })\n .then(function(css) { style.textContent = css; })\n .catch(function() {});\n }\n\n fetchCss();\n\n if (import.meta.hot) {\n import.meta.hot.on(\"truss:css-update\", fetchCss);\n import.meta.hot.on(\"vite:afterUpdate\", function() {\n setTimeout(fetchCss, 50);\n });\n }\n})();\n`;\n }\n\n // Handle .css.ts virtual modules\n if (!id.startsWith(VIRTUAL_CSS_PREFIX)) return null;\n\n // Re-add `.ts` to recover the original source file path\n const sourcePath = id.slice(VIRTUAL_CSS_PREFIX.length) + \".ts\";\n const sourceCode = readFileSync(sourcePath, \"utf8\");\n return transformCssTs(sourceCode, sourcePath, ensureMapping());\n },\n\n transform(code: string, id: string) {\n // Only process JS/TS/JSX/TSX files\n if (!/\\.[cm]?[jt]sx?(\\?|$)/.test(id)) return null;\n\n const rewrittenImports = rewriteCssTsImports(code, id);\n const rewrittenCode = rewrittenImports.code;\n const hasCssDsl = rewrittenCode.includes(\"Css\");\n if (!hasCssDsl && !rewrittenImports.changed) return null;\n\n const fileId = stripQueryAndHash(id);\n if (isNodeModulesFile(fileId) && !isWhitelistedExternalPackageFile(fileId, externalPackages)) {\n return null;\n }\n\n if (fileId.endsWith(\".css.ts\")) {\n // Keep `.css.ts` modules as normal TS so named exports like class-name\n // constants still work at runtime; only return code when we injected the\n // companion `?truss-css` side-effect import.\n return rewrittenImports.changed ? { code: rewrittenCode, map: null } : null;\n }\n\n if (!hasCssDsl) {\n // Some non-`.css.ts` modules only need the import rewrite and do not have\n // any `Css.*.$` expressions for the main Truss transform to process.\n return { code: rewrittenCode, map: null };\n }\n\n // For regular JS/TS modules that still use the DSL, run the full Truss\n // transform after the import rewrite so both behaviors compose.\n const result = transformTruss(rewrittenCode, fileId, ensureMapping(), {\n debug,\n // In test mode (jsdom), inject CSS directly so document.styleSheets has rules\n injectCss: isTest,\n });\n if (!result) {\n if (!rewrittenImports.changed) return null;\n return { code: rewrittenCode, map: null };\n }\n\n // Merge new rules into the global registry\n if (result.rules) {\n let hasNewRules = false;\n for (const [className, rule] of result.rules) {\n if (!cssRegistry.has(className)) {\n cssRegistry.set(className, rule);\n hasNewRules = true;\n }\n }\n if (hasNewRules) {\n cssVersion++;\n }\n }\n\n return { code: result.code, map: result.map };\n },\n\n // -- Production CSS emission --\n\n generateBundle(_options: any, bundle: any) {\n if (!isBuild) return;\n const css = collectCss();\n if (!css) return;\n\n // Try to append to an existing CSS asset in the bundle\n for (const key of Object.keys(bundle)) {\n const asset = bundle[key];\n if (asset.type === \"asset\" && key.endsWith(\".css\")) {\n asset.source = asset.source + \"\\n\" + css;\n return;\n }\n }\n\n // No existing CSS asset found — emit a standalone truss.css\n (this as any).emitFile({\n type: \"asset\",\n fileName: \"truss.css\",\n source: css,\n });\n },\n\n writeBundle(options: any, bundle: any) {\n if (!isBuild) return;\n const css = collectCss();\n if (!css) return;\n\n // Fallback: if generateBundle didn't find a target, write to disk\n const outDir = options.dir || join(projectRoot, \"dist\");\n const trussPath = join(outDir, \"truss.css\");\n if (!existsSync(trussPath)) {\n // Check if it was appended to an existing CSS asset\n const alreadyEmitted = Object.keys(bundle).some(function (key) {\n const asset = bundle[key];\n return (\n asset.type === \"asset\" &&\n key.endsWith(\".css\") &&\n typeof asset.source === \"string\" &&\n asset.source.includes(css)\n );\n });\n if (!alreadyEmitted) {\n writeFileSync(trussPath, css, \"utf8\");\n }\n }\n },\n };\n}\n\nfunction resolveImportPath(source: string, importer: string | undefined, projectRoot: string | undefined): string {\n if (isAbsolute(source)) {\n return source;\n }\n\n if (importer) {\n return resolve(dirname(importer), source);\n }\n\n return resolve(projectRoot || process.cwd(), source);\n}\n\n/** Strip Vite query/hash suffixes from an id. */\nfunction stripQueryAndHash(id: string): string {\n const queryIndex = id.indexOf(\"?\");\n const hashIndex = id.indexOf(\"#\");\n\n let end = id.length;\n if (queryIndex >= 0) end = Math.min(end, queryIndex);\n if (hashIndex >= 0) end = Math.min(end, hashIndex);\n\n const cleanId = id.slice(0, end);\n // Vite can prefix absolute paths with `/@fs/`.\n if (cleanId.startsWith(\"/@fs/\")) {\n return cleanId.slice(4);\n }\n return cleanId;\n}\n\nfunction isNodeModulesFile(filePath: string): boolean {\n return normalizePath(filePath).includes(\"/node_modules/\");\n}\n\nfunction isWhitelistedExternalPackageFile(filePath: string, externalPackages: string[]): boolean {\n const normalizedPath = normalizePath(filePath);\n return externalPackages.some(function (pkg) {\n return normalizedPath.includes(`/node_modules/${pkg}/`);\n });\n}\n\nfunction normalizePath(path: string): string {\n return path.replace(/\\\\/g, \"/\");\n}\n\n/** Load a truss mapping file synchronously (for tests). */\nexport function loadMapping(path: string): TrussMapping {\n const raw = readFileSync(path, \"utf8\");\n return JSON.parse(raw);\n}\n\nexport type { TrussMapping, TrussMappingEntry } from \"./types\";\n","import * as t from \"@babel/types\";\nimport type { ResolvedChain } from \"./resolve-chain\";\nimport type { ResolvedSegment, TrussMapping } from \"./types\";\n\n// -- Atomic CSS rule model --\n\n/** A single atomic CSS rule: one class, one selector, one or more declarations. */\nexport interface AtomicRule {\n className: string;\n cssProperty: string;\n cssValue: string;\n declarations?: Array<{\n cssProperty: string;\n cssValue: string;\n cssVarName?: string;\n }>;\n pseudoClass?: string;\n mediaQuery?: string;\n pseudoElement?: string;\n /** If true, this is a `var(--name)` rule that needs an `@property` declaration. */\n cssVarName?: string;\n /** For when() rules: the relationship selector context. */\n whenSelector?: {\n relationship: string;\n markerClass: string;\n pseudo: string;\n };\n}\n\n/** Pseudo-class short suffixes for class naming. */\nconst PSEUDO_SUFFIX: Record<string, string> = {\n \":hover\": \"_h\",\n \":focus\": \"_f\",\n \":focus-visible\": \"_fv\",\n \":active\": \"_a\",\n \":disabled\": \"_d\",\n};\n\n/** Pseudo-class precedence order (weakest to strongest). */\nconst PSEUDO_ORDER: string[] = [\":hover\", \":focus\", \":focus-visible\", \":active\", \":disabled\"];\n\n/** Short abbreviations for relationship types in when() class names. */\nconst RELATIONSHIP_SHORT: Record<string, string> = {\n ancestor: \"anc\",\n descendant: \"desc\",\n siblingAfter: \"sibA\",\n siblingBefore: \"sibB\",\n anySibling: \"anyS\",\n};\n\n/** Default marker class name (used when no explicit marker is provided). */\nexport const DEFAULT_MARKER_CLASS = \"__truss_m\";\n\n/** Derive a marker class name from a marker AST node (or use the default). */\nexport function markerClassName(markerNode?: { type: string; name?: string }): string {\n if (!markerNode) return DEFAULT_MARKER_CLASS;\n if (markerNode.type === \"Identifier\" && markerNode.name) {\n return `__truss_m_${markerNode.name}`;\n }\n return `${DEFAULT_MARKER_CLASS}_marker`;\n}\n\n/**\n * Build a when() class name prefix from whenPseudo info.\n *\n * I.e. `when(\"ancestor\", \":hover\")` → `\"wh_anc_h_\"`,\n * `when(\"ancestor\", row, \":hover\")` → `\"wh_anc_h_row_\"`.\n */\nfunction whenPrefix(whenPseudo: { pseudo: string; markerNode?: any; relationship?: string }): string {\n const rel = RELATIONSHIP_SHORT[whenPseudo.relationship ?? \"ancestor\"] ?? \"anc\";\n const pseudoTag = PSEUDO_SUFFIX[whenPseudo.pseudo]?.replace(/^_/, \"\") ?? whenPseudo.pseudo.replace(/^:/, \"\");\n const markerPart = whenPseudo.markerNode?.type === \"Identifier\" ? `${whenPseudo.markerNode.name}_` : \"\";\n return `wh_${rel}_${pseudoTag}_${markerPart}`;\n}\n\n/**\n * Build a condition prefix string for class naming.\n *\n * Conditions are prefixed so class names read naturally in the DOM:\n * I.e. `h_bgBlack` reads as \"on hover, bgBlack\".\n */\nfunction conditionPrefix(\n pseudoClass: string | null | undefined,\n mediaQuery: string | null | undefined,\n pseudoElement: string | null | undefined,\n breakpoints?: Record<string, string>,\n): string {\n const parts: string[] = [];\n if (pseudoElement) {\n // I.e. \"::placeholder\" → \"placeholder_\"\n parts.push(`${pseudoElement.replace(/^::/, \"\")}_`);\n }\n if (mediaQuery && breakpoints) {\n // Find breakpoint name, i.e. \"ifSm\" → \"sm_\"\n const bpKey = Object.entries(breakpoints).find(([, v]) => v === mediaQuery)?.[0];\n if (bpKey) {\n const shortName = bpKey.replace(/^if/, \"\").toLowerCase();\n parts.push(`${shortName}_`);\n } else {\n parts.push(\"mq_\");\n }\n } else if (mediaQuery) {\n parts.push(\"mq_\");\n }\n if (pseudoClass) {\n const tag = PSEUDO_SUFFIX[pseudoClass];\n // PSEUDO_SUFFIX values still have a leading underscore; strip it and add trailing\n if (tag) parts.push(`${tag.replace(/^_/, \"\")}_`);\n else parts.push(`${pseudoClass.replace(/^:/, \"\")}_`);\n }\n return parts.join(\"\");\n}\n\n/** Convert camelCase CSS property to kebab-case. */\nfunction camelToKebab(s: string): string {\n return s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).replace(/^(webkit|moz|ms)-/, \"-$1-\");\n}\n\n/** Clean a CSS value for use in a class name. */\nfunction cleanValueForClassName(value: string): string {\n // I.e. -8px → neg8px, 16px → 16px, \"0 0 0 1px blue\" → 0_0_0_1px_blue\n let cleaned = value;\n if (cleaned.startsWith(\"-\")) {\n cleaned = \"neg\" + cleaned.slice(1);\n }\n return cleaned\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n}\n\n/**\n * Build a reverse lookup from `\"cssProperty\\0cssValue\"` → canonical abbreviation name.\n *\n * For each single-property static abbreviation in the mapping, records the\n * canonical name so multi-property abbreviations can reuse it.\n * I.e. `{ paddingTop: \"8px\" }` → `\"pt1\"`, `{ borderStyle: \"solid\" }` → `\"bss\"`.\n */\nfunction buildLonghandLookup(mapping: TrussMapping): Map<string, string> {\n const lookup = new Map<string, string>();\n for (const [abbrev, entry] of Object.entries(mapping.abbreviations)) {\n if (entry.kind !== \"static\") continue;\n const props = Object.keys(entry.defs);\n if (props.length !== 1) continue;\n const prop = props[0];\n const value = String(entry.defs[prop]);\n const key = `${prop}\\0${value}`;\n // First match wins — if multiple abbreviations produce the same declaration,\n // the one that appears first in the mapping is canonical.\n if (!lookup.has(key)) {\n lookup.set(key, abbrev);\n }\n }\n return lookup;\n}\n\n/** Cached longhand lookup per mapping (keyed by identity). */\nlet cachedMapping: TrussMapping | null = null;\nlet cachedLookup: Map<string, string> | null = null;\n\n/** Get or build the longhand lookup for a mapping. */\nfunction getLonghandLookup(mapping: TrussMapping): Map<string, string> {\n if (cachedMapping !== mapping) {\n cachedMapping = mapping;\n cachedLookup = buildLonghandLookup(mapping);\n }\n return cachedLookup!;\n}\n\n/**\n * Compute the base class name for a static segment.\n *\n * For multi-property abbreviations, looks up the canonical single-property\n * abbreviation name so classes are maximally reused.\n * I.e. `p1` → `pt1`, `pr1`, `pb1`, `pl1` (not `p1_paddingTop`, etc.)\n * I.e. `ba` → `bss`, `bw1` (not `ba_borderStyle`, etc.)\n *\n * For literal-folded variables (argResolved set), includes the value:\n * I.e. `mt(2)` → `mt_16px`, `bc(\"red\")` → `bc_red`.\n */\nfunction computeStaticBaseName(\n seg: ResolvedSegment,\n cssProp: string,\n cssValue: string,\n isMultiProp: boolean,\n mapping: TrussMapping,\n): string {\n const abbrev = seg.key.split(\"__\")[0];\n\n if (seg.argResolved !== undefined) {\n const valuePart = cleanValueForClassName(seg.argResolved);\n if (isMultiProp) {\n // Try to find a canonical single-property abbreviation for this longhand\n const lookup = getLonghandLookup(mapping);\n const canonical = lookup.get(`${cssProp}\\0${cssValue}`);\n if (canonical) return canonical;\n return `${abbrev}_${valuePart}_${cssProp}`;\n }\n return `${abbrev}_${valuePart}`;\n }\n\n if (isMultiProp) {\n // Try to find a canonical single-property abbreviation for this longhand\n const lookup = getLonghandLookup(mapping);\n const canonical = lookup.get(`${cssProp}\\0${cssValue}`);\n if (canonical) return canonical;\n return `${abbrev}_${cssProp}`;\n }\n\n return abbrev;\n}\n\n// -- Collecting atomic rules from resolved chains --\n\nexport interface CollectedRules {\n rules: Map<string, AtomicRule>;\n needsMaybeInc: boolean;\n}\n\n/**\n * Collect all atomic CSS rules from resolved chains.\n *\n * This processes segments BEFORE mergeOverlappingConditions — each segment\n * maps directly to one or more atomic rules based on its condition context.\n */\nexport function collectAtomicRules(chains: ResolvedChain[], mapping: TrussMapping): CollectedRules {\n const rules = new Map<string, AtomicRule>();\n let needsMaybeInc = false;\n\n for (const chain of chains) {\n for (const part of chain.parts) {\n const segs = part.type === \"unconditional\" ? part.segments : [...part.thenSegments, ...part.elseSegments];\n for (const seg of segs) {\n if (seg.error || seg.styleArrayArg || seg.typographyLookup) continue;\n if (seg.whenPseudo) {\n if (seg.variableProps) {\n if (seg.incremented) needsMaybeInc = true;\n collectWhenVariableRules(rules, seg, mapping);\n } else {\n collectWhenStaticRules(rules, seg, mapping);\n }\n continue;\n }\n if (seg.variableProps) {\n if (seg.incremented) needsMaybeInc = true;\n collectVariableRules(rules, seg, mapping);\n } else {\n collectStaticRules(rules, seg, mapping);\n }\n }\n }\n }\n\n return { rules, needsMaybeInc };\n}\n\n/** Collect atomic rules for a static segment (may have multiple CSS properties). */\nfunction collectStaticRules(rules: Map<string, AtomicRule>, seg: ResolvedSegment, mapping: TrussMapping): void {\n // The segment's defs may be wrapped with StyleX-style condition nesting from\n // wrapDefsWithConditions. We use the segment's raw condition fields instead.\n const rawDefs = unwrapDefs(seg.defs, seg.pseudoElement);\n const prefix = conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints);\n const isMultiProp = Object.keys(rawDefs).length > 1;\n\n for (const [cssProp, value] of Object.entries(rawDefs)) {\n const cssValue = extractLeafValue(value);\n if (cssValue === null) continue;\n\n const baseName = computeStaticBaseName(seg, cssProp, String(cssValue), isMultiProp, mapping);\n const className = prefix ? `${prefix}${baseName}` : baseName;\n\n if (!rules.has(className)) {\n rules.set(className, {\n className,\n cssProperty: camelToKebab(cssProp),\n cssValue: String(cssValue),\n pseudoClass: seg.pseudoClass ?? undefined,\n mediaQuery: seg.mediaQuery ?? undefined,\n pseudoElement: seg.pseudoElement ?? undefined,\n });\n }\n }\n}\n\n/** Collect atomic rules for a variable segment. */\nfunction collectVariableRules(rules: Map<string, AtomicRule>, seg: ResolvedSegment, mapping: TrussMapping): void {\n const prefix = conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints);\n const baseKey = seg.key.split(\"__\")[0];\n\n for (const prop of seg.variableProps!) {\n const className = prefix ? `${prefix}${baseKey}_var` : `${baseKey}_var`;\n const varName = toCssVariableName(className, baseKey, prop);\n const declaration = { cssProperty: camelToKebab(prop), cssValue: `var(${varName})`, cssVarName: varName };\n\n const existingRule = rules.get(className);\n if (!existingRule) {\n rules.set(className, {\n className,\n cssProperty: declaration.cssProperty,\n cssValue: declaration.cssValue,\n declarations: [declaration],\n pseudoClass: seg.pseudoClass ?? undefined,\n mediaQuery: seg.mediaQuery ?? undefined,\n pseudoElement: seg.pseudoElement ?? undefined,\n cssVarName: varName,\n });\n continue;\n }\n\n existingRule.declarations ??= [\n {\n cssProperty: existingRule.cssProperty,\n cssValue: existingRule.cssValue,\n cssVarName: existingRule.cssVarName,\n },\n ];\n if (\n !existingRule.declarations.some(function (entry) {\n return entry.cssProperty === declaration.cssProperty;\n })\n ) {\n existingRule.declarations.push(declaration);\n }\n }\n\n // Extra static defs alongside variable props\n if (seg.variableExtraDefs) {\n for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {\n const extraBase = `${baseKey}_${cssProp}`;\n const extraName = prefix ? `${prefix}${extraBase}` : extraBase;\n if (!rules.has(extraName)) {\n rules.set(extraName, {\n className: extraName,\n cssProperty: camelToKebab(cssProp),\n cssValue: String(value),\n pseudoClass: seg.pseudoClass ?? undefined,\n mediaQuery: seg.mediaQuery ?? undefined,\n pseudoElement: seg.pseudoElement ?? undefined,\n });\n }\n }\n }\n}\n\n/** Collect atomic rules for a static when() segment. */\nfunction collectWhenStaticRules(rules: Map<string, AtomicRule>, seg: ResolvedSegment, mapping: TrussMapping): void {\n const wp = seg.whenPseudo!;\n const prefix = whenPrefix(wp);\n const rawDefs = seg.defs;\n const isMultiProp = Object.keys(rawDefs).length > 1;\n const mClass = markerClassName(wp.markerNode);\n\n for (const [cssProp, value] of Object.entries(rawDefs)) {\n const cssValue = typeof value === \"string\" || typeof value === \"number\" ? value : extractLeafValue(value);\n if (cssValue === null) continue;\n\n const baseName = computeStaticBaseName(seg, cssProp, String(cssValue), isMultiProp, mapping);\n const className = `${prefix}${baseName}`;\n\n if (!rules.has(className)) {\n rules.set(className, {\n className,\n cssProperty: camelToKebab(cssProp),\n cssValue: String(cssValue),\n whenSelector: {\n relationship: wp.relationship ?? \"ancestor\",\n markerClass: mClass,\n pseudo: wp.pseudo,\n },\n });\n }\n }\n}\n\n/** Collect atomic rules for a variable when() segment. */\nfunction collectWhenVariableRules(rules: Map<string, AtomicRule>, seg: ResolvedSegment, mapping: TrussMapping): void {\n const wp = seg.whenPseudo!;\n const prefix = whenPrefix(wp);\n const baseKey = seg.key.split(\"__\")[0];\n const mClass = markerClassName(wp.markerNode);\n\n for (const prop of seg.variableProps!) {\n const className = `${prefix}${baseKey}_var`;\n const varName = toCssVariableName(className, baseKey, prop);\n const declaration = { cssProperty: camelToKebab(prop), cssValue: `var(${varName})`, cssVarName: varName };\n\n const existingRule = rules.get(className);\n if (!existingRule) {\n rules.set(className, {\n className,\n cssProperty: declaration.cssProperty,\n cssValue: declaration.cssValue,\n declarations: [declaration],\n cssVarName: varName,\n whenSelector: {\n relationship: wp.relationship ?? \"ancestor\",\n markerClass: mClass,\n pseudo: wp.pseudo,\n },\n });\n continue;\n }\n\n existingRule.declarations ??= [\n {\n cssProperty: existingRule.cssProperty,\n cssValue: existingRule.cssValue,\n cssVarName: existingRule.cssVarName,\n },\n ];\n if (\n !existingRule.declarations.some(function (entry) {\n return entry.cssProperty === declaration.cssProperty;\n })\n ) {\n existingRule.declarations.push(declaration);\n }\n }\n\n if (seg.variableExtraDefs) {\n for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {\n const extraName = `${prefix}${baseKey}_${cssProp}`;\n if (!rules.has(extraName)) {\n rules.set(extraName, {\n className: extraName,\n cssProperty: camelToKebab(cssProp),\n cssValue: String(value),\n whenSelector: {\n relationship: wp.relationship ?? \"ancestor\",\n markerClass: mClass,\n pseudo: wp.pseudo,\n },\n });\n }\n }\n }\n}\n\n/** Unwrap StyleX-style condition nesting and pseudo-element wrapping to get raw defs. */\nfunction unwrapDefs(defs: Record<string, unknown>, pseudoElement?: string | null): Record<string, unknown> {\n let result = defs;\n // Unwrap pseudo-element wrapper: { \"::placeholder\": { color: ... } } → { color: ... }\n if (pseudoElement && result[pseudoElement] && typeof result[pseudoElement] === \"object\") {\n result = result[pseudoElement] as Record<string, unknown>;\n }\n // Unwrap condition nesting: { color: { default: null, \":hover\": \"blue\" } } → { color: \"blue\" }\n // For segments with conditions, we want just the leaf value\n const unwrapped: Record<string, unknown> = {};\n for (const [prop, val] of Object.entries(result)) {\n unwrapped[prop] = extractLeafValue(val) ?? val;\n }\n return unwrapped;\n}\n\n/**\n * Extract the actual CSS value from a potentially nested condition object.\n * I.e. `{ default: null, \":hover\": \"blue\" }` → `\"blue\"`,\n * or `{ default: null, \":hover\": { default: null, \"@media...\": \"blue\" } }` → `\"blue\"`.\n */\nfunction extractLeafValue(value: unknown): string | number | null {\n if (typeof value === \"string\" || typeof value === \"number\") return value;\n if (value === null) return null;\n if (typeof value === \"object\") {\n const obj = value as Record<string, unknown>;\n // Find the non-default, non-null leaf\n for (const [k, v] of Object.entries(obj)) {\n if (k === \"default\") continue;\n if (typeof v === \"string\" || typeof v === \"number\") return v;\n if (typeof v === \"object\" && v !== null) return extractLeafValue(v);\n }\n // If only default, return it\n if (\"default\" in obj && obj.default !== null) {\n return extractLeafValue(obj.default);\n }\n }\n return null;\n}\n\n// -- CSS text generation --\n\n/** Generate the full CSS text from collected rules, ordered by specificity tiers. */\nexport function generateCssText(rules: Map<string, AtomicRule>): string {\n const allRules = Array.from(rules.values());\n\n // Sort into tiers\n const base: AtomicRule[] = [];\n const pseudo: Map<string, AtomicRule[]> = new Map();\n const pseudoElement: AtomicRule[] = [];\n const whenRules: AtomicRule[] = [];\n const media: AtomicRule[] = [];\n const mediaPseudo: AtomicRule[] = [];\n const mediaPseudoElement: AtomicRule[] = [];\n\n for (const rule of allRules) {\n if (rule.whenSelector) {\n whenRules.push(rule);\n } else if (rule.mediaQuery && rule.pseudoClass) {\n mediaPseudo.push(rule);\n } else if (rule.mediaQuery && rule.pseudoElement) {\n mediaPseudoElement.push(rule);\n } else if (rule.mediaQuery) {\n media.push(rule);\n } else if (rule.pseudoClass && rule.pseudoElement) {\n // pseudo-class + pseudo-element, emit in pseudo tier\n const tier = pseudo.get(rule.pseudoClass) ?? [];\n tier.push(rule);\n pseudo.set(rule.pseudoClass, tier);\n } else if (rule.pseudoElement) {\n pseudoElement.push(rule);\n } else if (rule.pseudoClass) {\n const tier = pseudo.get(rule.pseudoClass) ?? [];\n tier.push(rule);\n pseudo.set(rule.pseudoClass, tier);\n } else {\n base.push(rule);\n }\n }\n\n const lines: string[] = [];\n\n // Tier 1: base atoms\n for (const rule of base) {\n lines.push(formatBaseRule(rule));\n }\n\n // Tier 2: pseudo-class atoms, ordered by precedence\n for (const pc of PSEUDO_ORDER) {\n const tier = pseudo.get(pc);\n if (!tier) continue;\n for (const rule of tier) {\n lines.push(formatPseudoRule(rule));\n }\n }\n // Any pseudo-classes not in the table (shouldn't happen, but be safe)\n for (const [pc, tier] of Array.from(pseudo.entries())) {\n if (PSEUDO_ORDER.includes(pc)) continue;\n for (const rule of tier) {\n lines.push(formatPseudoRule(rule));\n }\n }\n\n // Tier 3: pseudo-element atoms\n for (const rule of pseudoElement) {\n lines.push(formatPseudoElementRule(rule));\n }\n\n // Tier 4: when() relationship selector atoms\n for (const rule of whenRules) {\n lines.push(formatWhenRule(rule));\n }\n\n // Tier 5: media atoms (doubled selector)\n for (const rule of media) {\n lines.push(formatMediaRule(rule));\n }\n\n // Tier 5: media+pseudo atoms (doubled selector + pseudo)\n for (const rule of mediaPseudo) {\n lines.push(formatMediaPseudoRule(rule));\n }\n\n // Tier 6: media+pseudo-element atoms\n for (const rule of mediaPseudoElement) {\n lines.push(formatMediaPseudoElementRule(rule));\n }\n\n // @property declarations for variable rules\n for (const rule of allRules) {\n for (const declaration of getRuleDeclarations(rule)) {\n if (declaration.cssVarName) {\n lines.push(`@property ${declaration.cssVarName} {\\n syntax: \"*\";\\n inherits: false;\\n}`);\n }\n }\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction formatBaseRule(rule: AtomicRule): string {\n return formatRuleBlock(`.${rule.className}`, rule);\n}\n\nfunction formatPseudoRule(rule: AtomicRule): string {\n const pe = rule.pseudoElement ? rule.pseudoElement : \"\";\n return formatRuleBlock(`.${rule.className}${rule.pseudoClass}${pe}`, rule);\n}\n\nfunction formatPseudoElementRule(rule: AtomicRule): string {\n return formatRuleBlock(`.${rule.className}${rule.pseudoElement}`, rule);\n}\n\nfunction formatWhenRule(rule: AtomicRule): string {\n const whenSelector = rule.whenSelector;\n if (!whenSelector) {\n return formatBaseRule(rule);\n }\n\n const markerSelector = `.${whenSelector.markerClass}${whenSelector.pseudo}`;\n const targetSelector = `.${rule.className}`;\n\n if (whenSelector.relationship === \"ancestor\") {\n return formatRuleBlock(`${markerSelector} ${targetSelector}`, rule);\n }\n if (whenSelector.relationship === \"descendant\") {\n return formatRuleBlock(`${targetSelector}:has(${markerSelector})`, rule);\n }\n if (whenSelector.relationship === \"siblingAfter\") {\n return formatRuleBlock(`${targetSelector}:has(~ ${markerSelector})`, rule);\n }\n if (whenSelector.relationship === \"siblingBefore\") {\n return formatRuleBlock(`${markerSelector} ~ ${targetSelector}`, rule);\n }\n if (whenSelector.relationship === \"anySibling\") {\n return formatRuleBlock(`${targetSelector}:has(~ ${markerSelector}), ${markerSelector} ~ ${targetSelector}`, rule);\n }\n\n return formatRuleBlock(`${markerSelector} ${targetSelector}`, rule);\n}\n\nfunction formatMediaRule(rule: AtomicRule): string {\n return formatNestedRuleBlock(rule.mediaQuery!, `.${rule.className}.${rule.className}`, rule);\n}\n\nfunction formatMediaPseudoRule(rule: AtomicRule): string {\n return formatNestedRuleBlock(rule.mediaQuery!, `.${rule.className}.${rule.className}${rule.pseudoClass}`, rule);\n}\n\nfunction formatMediaPseudoElementRule(rule: AtomicRule): string {\n const pe = rule.pseudoElement ?? \"\";\n return formatNestedRuleBlock(rule.mediaQuery!, `.${rule.className}.${rule.className}${pe}`, rule);\n}\n\nfunction getRuleDeclarations(rule: AtomicRule): Array<{ cssProperty: string; cssValue: string; cssVarName?: string }> {\n return rule.declarations ?? [{ cssProperty: rule.cssProperty, cssValue: rule.cssValue, cssVarName: rule.cssVarName }];\n}\n\nfunction formatRuleBlock(selector: string, rule: AtomicRule): string {\n const body = getRuleDeclarations(rule)\n .map(function (declaration) {\n return ` ${declaration.cssProperty}: ${declaration.cssValue};`;\n })\n .join(\"\\n\");\n return `${selector} {\\n${body}\\n}`;\n}\n\nfunction formatNestedRuleBlock(wrapper: string, selector: string, rule: AtomicRule): string {\n const body = getRuleDeclarations(rule)\n .map(function (declaration) {\n return ` ${declaration.cssProperty}: ${declaration.cssValue};`;\n })\n .join(\"\\n\");\n return `${wrapper} {\\n ${selector} {\\n${body}\\n }\\n}`;\n}\n\n// -- AST generation for style hash objects --\n\n/**\n * Build the style hash AST for a list of segments (from one Css.*.$ expression).\n *\n * Groups segments by CSS property and builds space-separated class bundles.\n * Returns an array of ObjectProperty nodes for `{ display: \"df\", color: \"black blue_h\" }`.\n */\nexport function buildStyleHashProperties(\n segments: ResolvedSegment[],\n mapping: TrussMapping,\n maybeIncHelperName?: string | null,\n): t.ObjectProperty[] {\n // Group: cssProperty -> list of { className, isVariable, varName, argNode, incremented, appendPx }\n const propGroups = new Map<\n string,\n Array<{\n className: string;\n isVariable: boolean;\n varName?: string;\n argNode?: unknown;\n incremented?: boolean;\n appendPx?: boolean;\n }>\n >();\n\n for (const seg of segments) {\n if (seg.error || seg.styleArrayArg || seg.typographyLookup) continue;\n\n if (seg.variableProps) {\n const prefix = seg.whenPseudo\n ? whenPrefix(seg.whenPseudo)\n : conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints);\n const baseKey = seg.key.split(\"__\")[0];\n\n for (const prop of seg.variableProps) {\n const className = prefix ? `${prefix}${baseKey}_var` : `${baseKey}_var`;\n const varName = toCssVariableName(className, baseKey, prop);\n\n if (!propGroups.has(prop)) propGroups.set(prop, []);\n propGroups.get(prop)!.push({\n className,\n isVariable: true,\n varName,\n argNode: seg.argNode,\n incremented: seg.incremented,\n appendPx: seg.appendPx,\n });\n }\n\n // Extra static defs\n if (seg.variableExtraDefs) {\n for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {\n const extraBase = `${baseKey}_${cssProp}`;\n const extraName = prefix ? `${prefix}${extraBase}` : extraBase;\n if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);\n propGroups.get(cssProp)!.push({ className: extraName, isVariable: false });\n }\n }\n } else {\n const rawDefs = seg.whenPseudo ? seg.defs : unwrapDefs(seg.defs, seg.pseudoElement);\n const prefix = seg.whenPseudo\n ? whenPrefix(seg.whenPseudo)\n : conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints);\n const isMultiProp = Object.keys(rawDefs).length > 1;\n\n for (const cssProp of Object.keys(rawDefs)) {\n const val = extractLeafValue(rawDefs[cssProp]);\n if (val === null) continue;\n\n const baseName = computeStaticBaseName(seg, cssProp, String(val), isMultiProp, mapping);\n const className = prefix ? `${prefix}${baseName}` : baseName;\n\n if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);\n propGroups.get(cssProp)!.push({ className, isVariable: false });\n }\n }\n }\n\n // Build AST properties\n const properties: t.ObjectProperty[] = [];\n\n for (const [cssProp, entries] of Array.from(propGroups.entries())) {\n const classNames = entries.map((e) => e.className).join(\" \");\n const variableEntries = entries.filter((e) => e.isVariable);\n\n if (variableEntries.length > 0) {\n // Tuple: [classNames, { vars }]\n const varsProps: t.ObjectProperty[] = [];\n for (const dyn of variableEntries) {\n let valueExpr: t.Expression = dyn.argNode as t.Expression;\n if (dyn.incremented) {\n // Wrap with __maybeInc (or whatever name was reserved to avoid collisions)\n valueExpr = t.callExpression(t.identifier(maybeIncHelperName ?? \"__maybeInc\"), [valueExpr]);\n } else if (dyn.appendPx) {\n // Wrap with `${v}px`\n valueExpr = t.templateLiteral(\n [t.templateElement({ raw: \"\", cooked: \"\" }, false), t.templateElement({ raw: \"px\", cooked: \"px\" }, true)],\n [valueExpr],\n );\n }\n varsProps.push(t.objectProperty(t.stringLiteral(dyn.varName!), valueExpr));\n }\n\n const tuple = t.arrayExpression([t.stringLiteral(classNames), t.objectExpression(varsProps)]);\n\n properties.push(t.objectProperty(toPropertyKey(cssProp), tuple));\n } else {\n // Static: plain string\n properties.push(t.objectProperty(toPropertyKey(cssProp), t.stringLiteral(classNames)));\n }\n }\n\n return properties;\n}\n\n/** Build a CSS variable name from the real CSS property and class condition prefix. */\nfunction toCssVariableName(className: string, baseKey: string, cssProp: string): string {\n const baseClassName = `${baseKey}_var`;\n const conditionPrefix = className.endsWith(baseClassName) ? className.slice(0, -baseClassName.length) : \"\";\n return `--${conditionPrefix}${cssProp}`;\n}\n\n// -- Helper declarations --\n\n/** Build the per-file increment helper: `const __maybeInc = (inc) => typeof inc === \"string\" ? inc : \\`${inc * N}px\\`` */\nexport function buildMaybeIncDeclaration(helperName: string, increment: number): t.VariableDeclaration {\n const incParam = t.identifier(\"inc\");\n const body = t.blockStatement([\n t.returnStatement(\n t.conditionalExpression(\n t.binaryExpression(\"===\", t.unaryExpression(\"typeof\", incParam), t.stringLiteral(\"string\")),\n incParam,\n t.templateLiteral(\n [t.templateElement({ raw: \"\", cooked: \"\" }, false), t.templateElement({ raw: \"px\", cooked: \"px\" }, true)],\n [t.binaryExpression(\"*\", incParam, t.numericLiteral(increment))],\n ),\n ),\n ),\n ]);\n\n return t.variableDeclaration(\"const\", [\n t.variableDeclarator(t.identifier(helperName), t.arrowFunctionExpression([incParam], body)),\n ]);\n}\n\n/** Use identifier keys when legal, otherwise string literal keys. */\nfunction toPropertyKey(key: string): t.Identifier | t.StringLiteral {\n return isValidIdentifier(key) ? t.identifier(key) : t.stringLiteral(key);\n}\n\nfunction isValidIdentifier(s: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(s);\n}\n\n/** Build a runtime lookup table declaration: `const __typography = { f24: { fontSize: \"f24\" }, ... }`. */\nexport function buildRuntimeLookupDeclaration(\n lookupName: string,\n segmentsByName: Record<string, ResolvedSegment[]>,\n mapping: TrussMapping,\n): t.VariableDeclaration {\n const properties: t.ObjectProperty[] = [];\n for (const [name, segs] of Object.entries(segmentsByName)) {\n const hashProps = buildStyleHashProperties(segs, mapping);\n properties.push(t.objectProperty(t.identifier(name), t.objectExpression(hashProps)));\n }\n return t.variableDeclaration(\"const\", [\n t.variableDeclarator(t.identifier(lookupName), t.objectExpression(properties)),\n ]);\n}\n","import { parse } from \"@babel/parser\";\nimport _traverse from \"@babel/traverse\";\nimport type { NodePath } from \"@babel/traverse\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport { basename } from \"path\";\nimport type { TrussMapping, ResolvedSegment } from \"./types\";\nimport { resolveFullChain, type ResolvedChain } from \"./resolve-chain\";\nimport {\n collectTopLevelBindings,\n reservePreferredName,\n findCssImportBinding,\n removeCssImport,\n hasCssMethodCall,\n findNamedImportBinding,\n upsertNamedImports,\n extractChain,\n} from \"./ast-utils\";\nimport {\n collectAtomicRules,\n generateCssText,\n buildMaybeIncDeclaration,\n buildRuntimeLookupDeclaration,\n} from \"./emit-truss\";\nimport { rewriteExpressionSites, type ExpressionSite } from \"./rewrite-sites\";\n\n// Babel packages are CJS today; normalize default interop across loaders.\nconst traverse = ((_traverse as unknown as { default?: typeof _traverse }).default ?? _traverse) as typeof _traverse;\nconst generate = ((_generate as unknown as { default?: typeof _generate }).default ?? _generate) as typeof _generate;\n\nexport interface TransformResult {\n code: string;\n map?: unknown;\n /** The generated CSS text for this file's Truss usages. */\n css: string;\n /** The atomic CSS rules collected during this transform, keyed by class name. */\n rules: Map<string, import(\"./emit-truss\").AtomicRule>;\n}\n\nexport interface TransformTrussOptions {\n debug?: boolean;\n /** When true, inject `__injectTrussCSS(cssText)` call for jsdom/test environments. */\n injectCss?: boolean;\n}\n\n/**\n * The core transform function. Given a source file's code and the truss mapping,\n * finds all `Css.*.$` expressions and rewrites them into Truss-native style hash\n * objects and `trussProps()`/`mergeProps()` runtime calls.\n *\n * Returns null if the file doesn't use Css.\n */\nexport function transformTruss(\n code: string,\n filename: string,\n mapping: TrussMapping,\n options: TransformTrussOptions = {},\n): TransformResult | null {\n // Fast bail: skip files that don't reference Css\n if (!code.includes(\"Css\")) return null;\n\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n // Step 1: Find the Css import binding name\n const cssBindingName = findCssImportBinding(ast);\n if (!cssBindingName) return null;\n\n // Step 2: Collect all Css expression sites\n const sites: ExpressionSite[] = [];\n const errorMessages: Array<{ message: string; line: number | null }> = [];\n\n traverse(ast, {\n MemberExpression(path: NodePath<t.MemberExpression>) {\n if (!t.isIdentifier(path.node.property, { name: \"$\" })) return;\n if (path.node.computed) return;\n\n const chain = extractChain(path.node.object, cssBindingName);\n if (!chain) return;\n\n const parentPath = path.parentPath;\n if (parentPath && parentPath.isMemberExpression() && t.isIdentifier(parentPath.node.property, { name: \"$\" })) {\n return;\n }\n\n // Use skipMerge: true so each segment retains its individual condition fields\n const resolvedChain = resolveFullChain(chain, mapping, { skipMerge: true });\n sites.push({ path, resolvedChain });\n\n const line = path.node.loc?.start.line ?? null;\n for (const err of resolvedChain.errors) {\n errorMessages.push({ message: err, line });\n }\n },\n });\n\n // Also check for Css.props(...) calls which need rewriting even without Css.$ sites\n const hasCssPropsCall = hasCssMethodCall(ast, cssBindingName, \"props\");\n if (sites.length === 0 && !hasCssPropsCall) return null;\n\n // Step 3: Collect atomic rules for CSS generation\n const chains = sites.map((s) => s.resolvedChain);\n const { rules, needsMaybeInc } = collectAtomicRules(chains, mapping);\n const cssText = generateCssText(rules);\n\n // Step 4: Reserve local names for injected helpers\n const usedTopLevelNames = collectTopLevelBindings(ast);\n const maybeIncHelperName = needsMaybeInc ? reservePreferredName(usedTopLevelNames, \"__maybeInc\") : null;\n const existingMergePropsHelperName = findNamedImportBinding(ast, \"@homebound/truss/runtime\", \"mergeProps\");\n const mergePropsHelperName = existingMergePropsHelperName ?? reservePreferredName(usedTopLevelNames, \"mergeProps\");\n const needsMergePropsHelper = { current: false };\n const existingTrussPropsHelperName = findNamedImportBinding(ast, \"@homebound/truss/runtime\", \"trussProps\");\n const trussPropsHelperName = existingTrussPropsHelperName ?? reservePreferredName(usedTopLevelNames, \"trussProps\");\n const needsTrussPropsHelper = { current: false };\n const existingTrussDebugInfoName = findNamedImportBinding(ast, \"@homebound/truss/runtime\", \"TrussDebugInfo\");\n const trussDebugInfoName = existingTrussDebugInfoName ?? reservePreferredName(usedTopLevelNames, \"TrussDebugInfo\");\n const needsTrussDebugInfo = { current: false };\n\n // Collect typography runtime lookups\n const runtimeLookupNames = new Map<string, string>();\n const runtimeLookups = collectRuntimeLookups(chains);\n for (const [lookupKey] of runtimeLookups) {\n runtimeLookupNames.set(lookupKey, reservePreferredName(usedTopLevelNames, `__${lookupKey}`));\n }\n\n // Step 5: Rewrite Css sites in-place\n rewriteExpressionSites({\n ast,\n sites,\n cssBindingName,\n filename: basename(filename),\n debug: options.debug ?? false,\n mapping,\n maybeIncHelperName,\n mergePropsHelperName,\n needsMergePropsHelper,\n trussPropsHelperName,\n needsTrussPropsHelper,\n trussDebugInfoName,\n needsTrussDebugInfo,\n skippedCssPropMessages: errorMessages,\n runtimeLookupNames,\n });\n\n // Step 6: Remove Css import now that all usages were rewritten\n removeCssImport(ast, cssBindingName);\n\n // Step 7: Inject runtime imports\n const runtimeImports: Array<{ importedName: string; localName: string }> = [];\n if (needsTrussPropsHelper.current) {\n runtimeImports.push({ importedName: \"trussProps\", localName: trussPropsHelperName });\n }\n if (needsMergePropsHelper.current) {\n runtimeImports.push({ importedName: \"mergeProps\", localName: mergePropsHelperName });\n }\n if (needsTrussDebugInfo.current) {\n runtimeImports.push({ importedName: \"TrussDebugInfo\", localName: trussDebugInfoName });\n }\n if (options.injectCss) {\n runtimeImports.push({ importedName: \"__injectTrussCSS\", localName: \"__injectTrussCSS\" });\n }\n if (runtimeImports.length > 0) {\n upsertNamedImports(ast, \"@homebound/truss/runtime\", runtimeImports);\n }\n\n // Step 8: Insert helper declarations after imports\n const declarationsToInsert: t.Statement[] = [];\n if (maybeIncHelperName) {\n declarationsToInsert.push(buildMaybeIncDeclaration(maybeIncHelperName, mapping.increment));\n }\n\n // Insert runtime lookup tables for typography\n for (const [lookupKey, lookup] of runtimeLookups) {\n const lookupName = runtimeLookupNames.get(lookupKey);\n if (!lookupName) continue;\n declarationsToInsert.push(buildRuntimeLookupDeclaration(lookupName, lookup.segmentsByName, mapping));\n }\n\n // Inject __injectTrussCSS call if requested\n if (options.injectCss && cssText.length > 0) {\n declarationsToInsert.push(\n t.expressionStatement(t.callExpression(t.identifier(\"__injectTrussCSS\"), [t.stringLiteral(cssText)])),\n );\n }\n\n // Emit console.error calls for any unsupported patterns\n for (const { message, line } of errorMessages) {\n const location = line !== null ? `${filename}:${line}` : filename;\n const logMessage = `${message} (${location})`;\n declarationsToInsert.push(\n t.expressionStatement(\n t.callExpression(t.memberExpression(t.identifier(\"console\"), t.identifier(\"error\")), [\n t.stringLiteral(logMessage),\n ]),\n ),\n );\n }\n\n if (declarationsToInsert.length > 0) {\n const insertIndex = ast.program.body.findIndex(function (node) {\n return !t.isImportDeclaration(node);\n });\n ast.program.body.splice(insertIndex === -1 ? ast.program.body.length : insertIndex, 0, ...declarationsToInsert);\n }\n\n const output = generate(ast, {\n sourceFileName: filename,\n retainLines: false,\n });\n\n return { code: output.code, map: output.map, css: cssText, rules };\n}\n\n/** Collect typography runtime lookups from all resolved chains. */\nfunction collectRuntimeLookups(\n chains: ResolvedChain[],\n): Map<string, { segmentsByName: Record<string, ResolvedSegment[]> }> {\n const lookups = new Map<string, { segmentsByName: Record<string, ResolvedSegment[]> }>();\n for (const chain of chains) {\n for (const part of chain.parts) {\n const segs = part.type === \"unconditional\" ? part.segments : [...part.thenSegments, ...part.elseSegments];\n for (const seg of segs) {\n if (seg.typographyLookup && !lookups.has(seg.typographyLookup.lookupKey)) {\n lookups.set(seg.typographyLookup.lookupKey, {\n segmentsByName: seg.typographyLookup.segmentsByName,\n });\n }\n }\n }\n }\n return lookups;\n}\n","import type * as t from \"@babel/types\";\nimport type { TrussMapping, TrussMappingEntry, ResolvedSegment, MarkerSegment } from \"./types\";\n\n/**\n * A resolved chain that may contain conditional (if/else) sections.\n *\n * I.e. `ChainNode` from ast-utils.ts is just the raw AST chain from `Css` to `.$`, which may contain if/else\n * nodes; this `ResolvedChain` is the post-processed result where each if/else has been split into separate segments.\n *\n * The `parts` array contains unconditional segments and conditional groups.\n * The `markers` array contains marker directives (Css.marker.$, Css.markerOf(\"x\").$).\n */\nexport interface ResolvedChain {\n parts: ResolvedChainPart[];\n /** Marker directives to attach to the element (not CSS styles). */\n markers: MarkerSegment[];\n /** Error messages from unsupported patterns found in this chain. */\n errors: string[];\n}\n\nexport type ResolvedChainPart =\n | { type: \"unconditional\"; segments: ResolvedSegment[] }\n | { type: \"conditional\"; conditionNode: any; thenSegments: ResolvedSegment[]; elseSegments: ResolvedSegment[] };\n\n/**\n * High-level chain resolver that handles if/else by splitting into parts.\n *\n * ## Chain semantics\n *\n * A `Css.*.$` chain is read left-to-right. Each segment is either a style\n * abbreviation (getter or call) or a modifier that changes the context for\n * subsequent styles. The modifiers and their precedence:\n *\n * - **`if(bool)`** / **`else`** — Boolean conditional. Splits the chain into\n * then/else branches at the AST level. Subsequent styles go into the active\n * branch. A new `if` starts a new conditional.\n *\n * - **`if(mediaQuery)`** — String overload. Sets the media query context\n * (same as `ifSm`, `ifMd` etc.) for subsequent styles. Does NOT create\n * a boolean branch.\n *\n * - **`ifSm`**, **`ifMd`**, **`ifLg`**, etc. — Breakpoint getters. Set the\n * media query context. Stacks with pseudo-classes: `ifSm.onHover.blue.$`\n * produces `{ color: { default: null, \":hover\": { default: null, \"@media...\": value } } }`.\n *\n * - **`onHover`**, **`onFocus`**, etc. — Pseudo-class getters. Set the\n * pseudo-class context. Stacks with media queries (see above). A new\n * pseudo-class replaces the previous one.\n *\n * - **`element(\"::placeholder\")`** — Pseudo-element. Sets the pseudo-element\n * context. Wraps subsequent defs in a top-level namespace key:\n * `{ \"::placeholder\": { color: value } }`. Stacks with pseudo-classes\n * and media queries inside the pseudo-element.\n *\n * - **`when(\"ancestor\", \":hover\")`** — StyleX `when` API. Resets both media\n * query and pseudo-class contexts. Uses `stylex.when.<relationship>()`\n * computed keys.\n *\n * - **`ifContainer({ gt, lt })`** — Container query. Sets the media query\n * context to an `@container` query string.\n *\n * Contexts accumulate left-to-right until explicitly replaced. A media query\n * set by `ifSm` persists through `onHover` (they stack). A new `if(bool)`\n * resets all contexts for its branches.\n */\nexport function resolveFullChain(\n chain: ChainNode[],\n mapping: TrussMapping,\n options?: { skipMerge?: boolean },\n): ResolvedChain {\n const parts: ResolvedChainPart[] = [];\n const markers: MarkerSegment[] = [];\n\n // Pre-scan for marker nodes and strip them from the chain\n const filteredChain: ChainNode[] = [];\n /** Errors found during marker scanning — attached to the chain result */\n const scanErrors: string[] = [];\n for (let j = 0; j < chain.length; j++) {\n const node = chain[j];\n if (node.type === \"getter\" && node.name === \"marker\") {\n markers.push({ type: \"marker\" });\n } else if (node.type === \"call\" && node.name === \"markerOf\") {\n if (node.args.length !== 1) {\n scanErrors.push(\"[truss] Unsupported pattern: markerOf() requires exactly one argument (a marker variable)\");\n } else {\n markers.push({ type: \"marker\", markerNode: node.args[0] });\n }\n } else {\n filteredChain.push(node);\n }\n }\n\n // Split chain at if/else boundaries\n let i = 0;\n let currentNodes: ChainNode[] = [];\n\n while (i < filteredChain.length) {\n const node = filteredChain[i];\n const mediaStart = getMediaConditionalStartNode(node, mapping);\n if (mediaStart) {\n const elseIndex = findElseIndex(filteredChain, i + 1);\n if (elseIndex !== -1) {\n if (currentNodes.length > 0) {\n const unconditionalSegs = resolveChain(currentNodes, mapping);\n parts.push({\n type: \"unconditional\",\n segments: options?.skipMerge ? unconditionalSegs : mergeOverlappingConditions(unconditionalSegs),\n });\n currentNodes = [];\n }\n\n const thenNodes = mediaStart.thenNodes\n ? [...mediaStart.thenNodes, ...filteredChain.slice(i + 1, elseIndex)]\n : filteredChain.slice(i, elseIndex);\n const elseNodes = [makeMediaQueryNode(mediaStart.inverseMediaQuery), ...filteredChain.slice(elseIndex + 1)];\n const thenSegs = resolveChain(thenNodes, mapping);\n const elseSegs = resolveChain(elseNodes, mapping);\n const combinedSegs = [...thenSegs, ...elseSegs];\n parts.push({\n type: \"unconditional\",\n segments: options?.skipMerge ? combinedSegs : mergeOverlappingConditions(combinedSegs),\n });\n i = filteredChain.length;\n break;\n }\n }\n\n if (node.type === \"if\") {\n // if(stringLiteral) → media query pseudo, not a boolean conditional\n if (node.conditionNode.type === \"StringLiteral\") {\n const mediaQuery: string = (node.conditionNode as any).value;\n // Inject a synthetic \"media query pseudo\" into the current unconditional nodes.\n // This works by creating a synthetic call node that resolveChain's pseudo handling\n // can recognize — but it's simpler to just inject it as a special marker.\n currentNodes.push({ type: \"__mediaQuery\" as any, mediaQuery } as any);\n i++;\n continue;\n }\n\n // Flush any accumulated unconditional nodes\n if (currentNodes.length > 0) {\n const unconditionalSegs = resolveChain(currentNodes, mapping);\n parts.push({\n type: \"unconditional\",\n segments: options?.skipMerge ? unconditionalSegs : mergeOverlappingConditions(unconditionalSegs),\n });\n currentNodes = [];\n }\n // Collect \"then\" nodes until \"else\" or end\n const thenNodes: ChainNode[] = [];\n const elseNodes: ChainNode[] = [];\n i++;\n let inElse = false;\n while (i < filteredChain.length) {\n if (filteredChain[i].type === \"else\") {\n inElse = true;\n i++;\n continue;\n }\n if (filteredChain[i].type === \"if\") {\n // Nested if — break out and let the outer loop handle it\n break;\n }\n if (inElse) {\n elseNodes.push(filteredChain[i]);\n } else {\n thenNodes.push(filteredChain[i]);\n }\n i++;\n }\n const thenSegs = resolveChain(thenNodes, mapping);\n const elseSegs = resolveChain(elseNodes, mapping);\n parts.push({\n type: \"conditional\",\n conditionNode: node.conditionNode,\n thenSegments: options?.skipMerge ? thenSegs : mergeOverlappingConditions(thenSegs),\n elseSegments: options?.skipMerge ? elseSegs : mergeOverlappingConditions(elseSegs),\n });\n } else {\n currentNodes.push(node);\n i++;\n }\n }\n\n // Flush remaining unconditional nodes\n if (currentNodes.length > 0) {\n const remainingSegs = resolveChain(currentNodes, mapping);\n parts.push({\n type: \"unconditional\",\n segments: options?.skipMerge ? remainingSegs : mergeOverlappingConditions(remainingSegs),\n });\n }\n\n // Collect error messages from all resolved segments\n const segmentErrors: string[] = [];\n for (const part of parts) {\n const segs = part.type === \"unconditional\" ? part.segments : [...part.thenSegments, ...part.elseSegments];\n for (const seg of segs) {\n if (seg.error) {\n segmentErrors.push(seg.error);\n }\n }\n }\n\n return { parts, markers, errors: [...scanErrors, ...segmentErrors] };\n}\n\nfunction getMediaConditionalStartNode(\n node: ChainNode,\n mapping: TrussMapping,\n): { inverseMediaQuery: string; thenNodes?: ChainNode[] } | null {\n if (node.type === \"if\" && node.conditionNode.type === \"StringLiteral\") {\n return {\n inverseMediaQuery: invertMediaQuery(node.conditionNode.value),\n thenNodes: [makeMediaQueryNode(node.conditionNode.value)],\n };\n }\n\n if (node.type === \"getter\" && mapping.breakpoints && node.name in mapping.breakpoints) {\n return { inverseMediaQuery: invertMediaQuery(mapping.breakpoints[node.name]) };\n }\n\n return null;\n}\n\nfunction findElseIndex(chain: ChainNode[], start: number): number {\n for (let i = start; i < chain.length; i++) {\n if (chain[i].type === \"if\") {\n return -1;\n }\n if (chain[i].type === \"else\") {\n return i;\n }\n }\n return -1;\n}\n\nfunction makeMediaQueryNode(mediaQuery: string): ChainNode {\n return { type: \"__mediaQuery\" as any, mediaQuery } as any;\n}\n\nfunction invertMediaQuery(query: string): string {\n const screenPrefix = \"@media screen and \";\n if (query.startsWith(screenPrefix)) {\n const conditions = query.slice(screenPrefix.length).trim();\n const rangeMatch = conditions.match(/^\\(min-width: (\\d+)px\\) and \\(max-width: (\\d+)px\\)$/);\n if (rangeMatch) {\n const min = Number(rangeMatch[1]);\n const max = Number(rangeMatch[2]);\n return `@media screen and (max-width: ${min - 1}px), screen and (min-width: ${max + 1}px)`;\n }\n const minMatch = conditions.match(/^\\(min-width: (\\d+)px\\)$/);\n if (minMatch) {\n return `@media screen and (max-width: ${Number(minMatch[1]) - 1}px)`;\n }\n const maxMatch = conditions.match(/^\\(max-width: (\\d+)px\\)$/);\n if (maxMatch) {\n return `@media screen and (min-width: ${Number(maxMatch[1]) + 1}px)`;\n }\n }\n return query.replace(\"@media\", \"@media not\");\n}\n\n/**\n * Walks a Css member-expression chain (the AST between `Css` and `.$`) and\n * resolves each segment into CSS property definitions using the truss mapping.\n *\n * Returns an array of ResolvedSegment, or throws if a pattern is unsupported.\n * Does NOT handle if/else — use resolveFullChain for that.\n */\nexport function resolveChain(chain: ChainNode[], mapping: TrussMapping): ResolvedSegment[] {\n const segments: ResolvedSegment[] = [];\n // Track media query and pseudo-class separately so they can stack.\n // e.g. Css.ifSm.onHover.blue.$ → both mediaQuery and pseudoClass are set\n let currentMediaQuery: string | null = null;\n let currentPseudoClass: string | null = null;\n let currentPseudoElement: string | null = null;\n let currentWhenPseudo: { pseudo: string; markerNode?: any; relationship?: string } | null = null;\n\n for (const node of chain) {\n try {\n // Synthetic media query node injected by resolveFullChain for if(\"@media...\")\n if ((node as any).type === \"__mediaQuery\") {\n currentMediaQuery = (node as any).mediaQuery;\n currentWhenPseudo = null;\n continue;\n }\n\n if (node.type === \"getter\") {\n const abbr = node.name;\n\n // Pseudo-class getters: onHover, onFocus, etc.\n if (isPseudoMethod(abbr)) {\n currentPseudoClass = pseudoSelector(abbr);\n currentWhenPseudo = null;\n continue;\n }\n\n // Breakpoint getters: ifSm, ifMd, ifLg, etc.\n if (mapping.breakpoints && abbr in mapping.breakpoints) {\n currentMediaQuery = mapping.breakpoints[abbr];\n currentWhenPseudo = null;\n continue;\n }\n\n const entry = mapping.abbreviations[abbr];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown abbreviation \"${abbr}\"`);\n }\n\n const resolved = resolveEntry(\n abbr,\n entry,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n currentWhenPseudo,\n );\n segments.push(...resolved);\n } else if (node.type === \"call\") {\n const abbr = node.name;\n\n // Container query call: ifContainer({ gt, lt, name? })\n if (abbr === \"ifContainer\") {\n currentMediaQuery = containerSelectorFromCall(node);\n currentWhenPseudo = null;\n continue;\n }\n\n // add(prop, value) — arbitrary CSS property\n if (abbr === \"add\") {\n const seg = resolveAddCall(\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n currentWhenPseudo,\n );\n segments.push(seg);\n continue;\n }\n\n if (abbr === \"typography\") {\n const resolved = resolveTypographyCall(\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n );\n segments.push(...resolved);\n continue;\n }\n\n // Pseudo-element: element(\"::placeholder\") etc.\n if (abbr === \"element\") {\n if (node.args.length !== 1 || node.args[0].type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(\n `element() requires exactly one string literal argument (e.g. \"::placeholder\")`,\n );\n }\n currentPseudoElement = (node.args[0] as any).value;\n continue;\n }\n\n // Generic when(relationship, pseudo) or when(relationship, marker, pseudo)\n if (abbr === \"when\") {\n const resolved = resolveWhenCall(node);\n currentPseudoClass = null;\n currentMediaQuery = null;\n currentWhenPseudo = resolved;\n continue;\n }\n\n // Simple pseudo-class calls (backward compat — pseudos are now getters)\n if (isPseudoMethod(abbr)) {\n currentPseudoClass = pseudoSelector(abbr);\n currentWhenPseudo = null;\n if (node.args.length > 0) {\n throw new UnsupportedPatternError(\n `${abbr}() does not take arguments -- use when(\"ancestor\", \":hover\") for relationship pseudos`,\n );\n }\n continue;\n }\n\n const entry = mapping.abbreviations[abbr];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown abbreviation \"${abbr}\"`);\n }\n\n if (entry.kind === \"variable\") {\n const seg = resolveVariableCall(\n abbr,\n entry,\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n currentWhenPseudo,\n );\n segments.push(seg);\n } else if (entry.kind === \"delegate\") {\n const seg = resolveDelegateCall(\n abbr,\n entry,\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n currentWhenPseudo,\n );\n segments.push(seg);\n } else {\n throw new UnsupportedPatternError(`Abbreviation \"${abbr}\" is ${entry.kind}, cannot be called as a function`);\n }\n }\n } catch (err) {\n if (err instanceof UnsupportedPatternError) {\n segments.push({ key: \"__error\", defs: {}, error: err.message });\n } else {\n throw err;\n }\n }\n }\n\n return segments;\n}\n\n/** Build the stylex.create key suffix from mediaQuery, pseudoClass, and/or pseudoElement. */\nexport function conditionKeySuffix(\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n breakpoints?: Record<string, string>,\n): string {\n const parts: string[] = [];\n if (pseudoElement) parts.push(pseudoName(pseudoElement));\n if (mediaQuery) parts.push(pseudoName(mediaQuery, breakpoints));\n if (pseudoClass) parts.push(pseudoName(pseudoClass));\n return parts.join(\"_\");\n}\n\n/** Resolve `typography(key)` into either direct segments or a runtime lookup-backed segment. */\nfunction resolveTypographyCall(\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment[] {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`typography() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n if (argAst.type === \"StringLiteral\") {\n return resolveTypographyEntry(argAst.value, mapping, mediaQuery, pseudoClass, pseudoElement);\n }\n\n const typography = mapping.typography ?? [];\n if (typography.length === 0) {\n throw new UnsupportedPatternError(`typography() is unavailable because no typography abbreviations were generated`);\n }\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n const lookupKey = suffix ? `typography__${suffix}` : \"typography\";\n const segmentsByName: Record<string, ResolvedSegment[]> = {};\n\n for (const name of typography) {\n segmentsByName[name] = resolveTypographyEntry(name, mapping, mediaQuery, pseudoClass, pseudoElement);\n }\n\n return [\n {\n key: lookupKey,\n defs: {},\n typographyLookup: {\n lookupKey,\n argNode: argAst,\n segmentsByName,\n },\n },\n ];\n}\n\n/** Resolve a single typography abbreviation name within the current condition context. */\nfunction resolveTypographyEntry(\n name: string,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment[] {\n if (!(mapping.typography ?? []).includes(name)) {\n throw new UnsupportedPatternError(`Unknown typography abbreviation \"${name}\"`);\n }\n\n const entry = mapping.abbreviations[name];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown typography abbreviation \"${name}\"`);\n }\n\n const resolved = resolveEntry(name, entry, mapping, mediaQuery, pseudoClass, pseudoElement, null);\n for (const segment of resolved) {\n if (segment.variableProps || segment.whenPseudo) {\n throw new UnsupportedPatternError(`Typography abbreviation \"${name}\" cannot require runtime arguments`);\n }\n }\n return resolved;\n}\n\n/**\n * Wrap raw CSS defs with condition nesting for StyleX.\n *\n * - mediaQuery only: `{ prop: { default: null, \"@media...\": value } }`\n * - pseudoClass only: `{ prop: { default: null, \":hover\": value } }`\n * - both (stacked): `{ prop: { default: null, \":hover\": { default: null, \"@media...\": value } } }`\n */\nfunction wrapDefsWithConditions(\n defs: Record<string, unknown>,\n mediaQuery: string | null,\n pseudoClass: string | null,\n): Record<string, unknown> {\n if (!mediaQuery && !pseudoClass) return defs;\n const result: Record<string, unknown> = {};\n for (const [prop, value] of Object.entries(defs)) {\n if (pseudoClass && mediaQuery) {\n result[prop] = { default: null, [pseudoClass]: { default: null, [mediaQuery]: value } };\n } else if (pseudoClass) {\n result[prop] = { default: null, [pseudoClass]: value };\n } else {\n result[prop] = { default: null, [mediaQuery!]: value };\n }\n }\n return result;\n}\n\n/** Resolve a static or alias entry (from a getter access). */\nfunction resolveEntry(\n abbr: string,\n entry: TrussMappingEntry,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string } | null,\n): ResolvedSegment[] {\n switch (entry.kind) {\n case \"static\": {\n if (whenPseudo) {\n const suffix = whenPseudoKeyName(whenPseudo);\n const key = `${abbr}__${suffix}`;\n return [{ key, defs: entry.defs, whenPseudo }];\n }\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n const key = suffix ? `${abbr}__${suffix}` : abbr;\n const defs = pseudoElement\n ? { [pseudoElement]: wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass) }\n : wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass);\n return [{ key, defs, mediaQuery, pseudoClass, pseudoElement }];\n }\n case \"alias\": {\n const result: ResolvedSegment[] = [];\n for (const chainAbbr of entry.chain) {\n const subEntry = mapping.abbreviations[chainAbbr];\n if (!subEntry) {\n throw new UnsupportedPatternError(`Alias \"${abbr}\" references unknown abbreviation \"${chainAbbr}\"`);\n }\n result.push(...resolveEntry(chainAbbr, subEntry, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo));\n }\n return result;\n }\n case \"variable\":\n case \"delegate\":\n throw new UnsupportedPatternError(`Abbreviation \"${abbr}\" requires arguments — use ${abbr}() not .${abbr}`);\n default:\n throw new UnsupportedPatternError(`Unhandled entry kind for \"${abbr}\"`);\n }\n}\n\n/** Resolve a variable (parameterized) call like mt(2) or mt(x). */\nfunction resolveVariableCall(\n abbr: string,\n entry: { kind: \"variable\"; props: string[]; incremented: boolean; extraDefs?: Record<string, unknown> },\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string } | null,\n): ResolvedSegment {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n const literalValue = tryEvaluateLiteral(argAst, entry.incremented, mapping.increment);\n\n // When inside a when() context, use whenPseudo key naming instead of condition suffix\n if (whenPseudo) {\n const wpSuffix = whenPseudoKeyName(whenPseudo);\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = `${abbr}__${keySuffix}__${wpSuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of entry.props) {\n defs[prop] = literalValue;\n }\n if (entry.extraDefs) Object.assign(defs, entry.extraDefs);\n return { key, defs, whenPseudo, argResolved: literalValue };\n } else {\n const key = `${abbr}__${wpSuffix}`;\n return {\n key,\n defs: {},\n whenPseudo,\n variableProps: entry.props,\n incremented: entry.incremented,\n variableExtraDefs: entry.extraDefs,\n argNode: argAst,\n };\n }\n }\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = suffix ? `${abbr}__${keySuffix}__${suffix}` : `${abbr}__${keySuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of entry.props) {\n defs[prop] = literalValue;\n }\n if (entry.extraDefs) {\n Object.assign(defs, entry.extraDefs);\n }\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `${abbr}__${suffix}` : abbr;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n variableProps: entry.props,\n incremented: entry.incremented,\n variableExtraDefs: entry.extraDefs,\n argNode: argAst,\n };\n }\n}\n\n/** Resolve a delegate call like mtPx(12). */\nfunction resolveDelegateCall(\n abbr: string,\n entry: { kind: \"delegate\"; target: string },\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string } | null,\n): ResolvedSegment {\n const targetEntry = mapping.abbreviations[entry.target];\n if (!targetEntry || targetEntry.kind !== \"variable\") {\n throw new UnsupportedPatternError(`Delegate \"${abbr}\" targets \"${entry.target}\" which is not a variable entry`);\n }\n\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n const literalValue = tryEvaluatePxLiteral(argAst);\n\n // When inside a when() context, use whenPseudo key naming instead of condition suffix\n if (whenPseudo) {\n const wpSuffix = whenPseudoKeyName(whenPseudo);\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = `${entry.target}__${keySuffix}__${wpSuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of targetEntry.props) {\n defs[prop] = literalValue;\n }\n if (targetEntry.extraDefs) Object.assign(defs, targetEntry.extraDefs);\n return { key, defs, whenPseudo, argResolved: literalValue };\n } else {\n const key = `${entry.target}__${wpSuffix}`;\n return {\n key,\n defs: {},\n whenPseudo,\n variableProps: targetEntry.props,\n incremented: false,\n appendPx: true,\n variableExtraDefs: targetEntry.extraDefs,\n argNode: argAst,\n };\n }\n }\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = suffix ? `${entry.target}__${keySuffix}__${suffix}` : `${entry.target}__${keySuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of targetEntry.props) {\n defs[prop] = literalValue;\n }\n if (targetEntry.extraDefs) {\n Object.assign(defs, targetEntry.extraDefs);\n }\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `${entry.target}__${suffix}` : entry.target;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n pseudoElement,\n variableProps: targetEntry.props,\n incremented: false,\n appendPx: true,\n variableExtraDefs: targetEntry.extraDefs,\n argNode: argAst,\n };\n }\n}\n\n/**\n * Resolve an `add(...)` call.\n *\n * Supported overloads:\n * - `add(cssProp)` to inline an existing CssProp array into the chain output\n * - `add(\"propName\", value)` for an arbitrary CSS property/value pair\n */\nfunction resolveAddCall(\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string } | null,\n): ResolvedSegment {\n if (node.args.length === 1) {\n const styleArg = node.args[0];\n if (styleArg.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(`add() does not support spread arguments`);\n }\n if (styleArg.type === \"ObjectExpression\") {\n throw new UnsupportedPatternError(\n `add(cssProp) does not accept object literals -- pass an existing CssProp expression instead`,\n );\n }\n return {\n key: \"__composed_css_prop\",\n defs: {},\n styleArrayArg: styleArg,\n };\n }\n\n if (node.args.length !== 2) {\n throw new UnsupportedPatternError(\n `add() requires exactly 2 arguments (property name and value), got ${node.args.length}. ` +\n `Supported overloads are add(cssProp) and add(\"propName\", value)`,\n );\n }\n\n const propArg = node.args[0];\n if (propArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`add() first argument must be a string literal property name`);\n }\n const propName: string = (propArg as any).value;\n\n const valueArg = node.args[1];\n // Try to evaluate the value as a literal\n const literalValue = tryEvaluateAddLiteral(valueArg);\n\n // When inside a when() context, use whenPseudo key naming\n if (whenPseudo) {\n const wpSuffix = whenPseudoKeyName(whenPseudo);\n if (literalValue !== null) {\n const keySuffix = literalValue\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n const key = `add_${propName}__${keySuffix}__${wpSuffix}`;\n return { key, defs: { [propName]: literalValue }, whenPseudo, argResolved: literalValue };\n } else {\n const key = `add_${propName}__${wpSuffix}`;\n return { key, defs: {}, whenPseudo, variableProps: [propName], incremented: false, argNode: valueArg };\n }\n }\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n const key = suffix ? `add_${propName}__${keySuffix}__${suffix}` : `add_${propName}__${keySuffix}`;\n const defs: Record<string, unknown> = { [propName]: literalValue };\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `add_${propName}__${suffix}` : `add_${propName}`;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n pseudoElement,\n variableProps: [propName],\n incremented: false,\n argNode: valueArg,\n };\n }\n}\n\n/** Try to evaluate a literal for add() — strings, numbers, and template literals with no expressions. */\nfunction tryEvaluateAddLiteral(node: t.Expression | t.SpreadElement): string | null {\n if (node.type === \"StringLiteral\") {\n return (node as any).value;\n }\n if (node.type === \"NumericLiteral\") {\n return String((node as any).value);\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n return String(-(node.argument as any).value);\n }\n return null;\n}\n\nconst WHEN_RELATIONSHIPS = new Set([\"ancestor\", \"descendant\", \"anySibling\", \"siblingBefore\", \"siblingAfter\"]);\n\n/**\n * Resolve a `when(relationship, pseudo)` or `when(relationship, marker, pseudo)` call.\n *\n * - 2 args: `when(\"ancestor\", \":hover\")` — both must be string literals\n * - 3 args: `when(\"ancestor\", marker, \":hover\")` — 1st and 3rd must be string literals, 2nd is a marker variable\n */\nfunction resolveWhenCall(node: CallChainNode): { pseudo: string; markerNode?: any; relationship: string } {\n if (node.args.length < 2 || node.args.length > 3) {\n throw new UnsupportedPatternError(\n `when() expects 2 or 3 arguments (relationship, [marker], pseudo), got ${node.args.length}`,\n );\n }\n\n const relationshipArg = node.args[0];\n if (relationshipArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() first argument must be a string literal relationship`);\n }\n const relationship: string = (relationshipArg as any).value;\n if (!WHEN_RELATIONSHIPS.has(relationship)) {\n throw new UnsupportedPatternError(\n `when() relationship must be one of: ${[...WHEN_RELATIONSHIPS].join(\", \")} -- got \"${relationship}\"`,\n );\n }\n\n if (node.args.length === 2) {\n // when(\"ancestor\", \":hover\")\n const pseudoArg = node.args[1];\n if (pseudoArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() pseudo selector must be a string literal`);\n }\n return { pseudo: (pseudoArg as any).value, relationship };\n } else {\n // when(\"ancestor\", marker, \":hover\")\n const markerNode = node.args[1];\n const pseudoArg = node.args[2];\n if (pseudoArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() pseudo selector (3rd argument) must be a string literal`);\n }\n return { pseudo: (pseudoArg as any).value, markerNode, relationship };\n }\n}\n\n// ── Helpers ───────────────────────────────────────────────────────────\n\nconst PSEUDO_METHODS: Record<string, string> = {\n onHover: \":hover\",\n onFocus: \":focus\",\n onFocusVisible: \":focus-visible\",\n onActive: \":active\",\n onDisabled: \":disabled\",\n};\n\nfunction isPseudoMethod(name: string): boolean {\n return name in PSEUDO_METHODS;\n}\n\nfunction pseudoSelector(name: string): string {\n return PSEUDO_METHODS[name];\n}\n\n/**\n * Generate the stylex.create key suffix for when/ancestor pseudo segments.\n * e.g. { pseudo: \":hover\" } → \"ancestorHover\"\n * e.g. { pseudo: \":hover\", relationship: \"descendant\" } → \"descendantHover\"\n * e.g. { pseudo: \":hover\", markerNode: Identifier(\"row\") } → \"ancestorHover_row\"\n */\nfunction whenPseudoKeyName(ap: { pseudo: string; markerNode?: any; relationship?: string }): string {\n const rel = ap.relationship ?? \"ancestor\";\n const pn = pseudoName(ap.pseudo);\n const base = `${rel}${pn.charAt(0).toUpperCase()}${pn.slice(1)}`;\n if (!ap.markerNode) return base;\n // Use the identifier name for readable keys; fall back to a generic suffix for complex expressions\n const suffix = ap.markerNode.type === \"Identifier\" ? ap.markerNode.name : \"marker\";\n return `${base}_${suffix}`;\n}\n\n/**\n * Post-process resolved segments to merge entries that target the same CSS\n * properties into a single `stylex.create` entry with stacked conditions.\n *\n * For example, `Css.black.ifSm.white.onHover.blue.$` produces three segments:\n * 1. `black` → `{ color: \"#353535\" }` (base)\n * 2. `white__sm` → `{ color: { default: null, \"@media...\": \"#fcfcfa\" } }` (media-only)\n * 3. `blue__sm_hover` → `{ color: { default: null, \":hover\": { default: null, \"@media...\": \"#526675\" } } }` (media+pseudo)\n *\n * All three set `color`, so they merge into one entry:\n * `{ color: { default: \"#353535\", \"@media...\": \"#fcfcfa\", \":hover\": { default: null, \"@media...\": \"#526675\" } } }`\n */\nexport function mergeOverlappingConditions(segments: ResolvedSegment[]): ResolvedSegment[] {\n // Index: for each CSS property, which segments set it?\n // Only static segments (no variableProps, no styleArrayArg, no whenPseudo, no error) participate in merging.\n const propToIndices = new Map<string, number[]>();\n for (let i = 0; i < segments.length; i++) {\n const seg = segments[i];\n if (seg.variableProps || seg.styleArrayArg || seg.whenPseudo || seg.error) continue;\n for (const prop of Object.keys(seg.defs)) {\n if (!propToIndices.has(prop)) propToIndices.set(prop, []);\n propToIndices.get(prop)!.push(i);\n }\n }\n\n // Find properties where a base (no-condition) segment overlaps with conditional segments.\n // Two base segments setting the same property is NOT a merge — the later one just overrides.\n const mergeableProps = new Set<string>();\n for (const [prop, indices] of propToIndices) {\n if (indices.length < 2) continue;\n const hasBase = indices.some((i) => !segments[i].mediaQuery && !segments[i].pseudoClass);\n const hasConditional = indices.some((i) => !!(segments[i].mediaQuery || segments[i].pseudoClass));\n if (hasBase && hasConditional) {\n mergeableProps.add(prop);\n }\n }\n\n if (mergeableProps.size === 0) return segments;\n\n // For each mergeable property, deep-merge all contributing segments into one defs object.\n // Track which segment indices have properties consumed by the merge.\n const consumedProps = new Map<number, Set<string>>(); // segIndex → consumed prop names\n const mergedPropDefs = new Map<string, { defs: Record<string, unknown>; key: string }>();\n\n for (const prop of mergeableProps) {\n const indices = propToIndices.get(prop)!;\n let merged: Record<string, unknown> = {};\n const keyParts: string[] = [];\n\n for (const idx of indices) {\n const seg = segments[idx];\n const value = seg.defs[prop];\n keyParts.push(seg.key);\n\n if (typeof value === \"string\" || typeof value === \"number\") {\n // Base value → default\n merged.default = value;\n } else if (typeof value === \"object\" && value !== null) {\n // Conditional value — merge all keys (may include default: null which base will override)\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n if (k === \"default\" && v === null && merged.default !== undefined) {\n // Don't let a conditional's `default: null` clobber the base value\n continue;\n }\n merged[k] = v;\n }\n }\n\n // Mark this property as consumed from this segment\n if (!consumedProps.has(idx)) consumedProps.set(idx, new Set());\n consumedProps.get(idx)!.add(prop);\n }\n\n // If the merged object has only a `default` key, it's just a raw value (no conditions)\n const finalValue = Object.keys(merged).length === 1 && \"default\" in merged ? merged.default : merged;\n const mergedKey = [...new Set(keyParts)].join(\"_\");\n mergedPropDefs.set(prop, { defs: { [prop]: finalValue }, key: mergedKey });\n }\n\n // Group mergeable props that share the exact same set of contributing segments\n // so they become one stylex.create entry.\n const groupByIndices = new Map<string, { props: string[]; key: string }>();\n for (const prop of mergeableProps) {\n const indices = propToIndices.get(prop)!;\n const groupKey = indices.join(\",\");\n if (!groupByIndices.has(groupKey)) {\n groupByIndices.set(groupKey, { props: [], key: mergedPropDefs.get(prop)!.key });\n }\n groupByIndices.get(groupKey)!.props.push(prop);\n }\n\n // Build merged segments\n const mergedSegments: ResolvedSegment[] = [];\n for (const [, group] of groupByIndices) {\n const defs: Record<string, unknown> = {};\n for (const prop of group.props) {\n Object.assign(defs, mergedPropDefs.get(prop)!.defs);\n }\n mergedSegments.push({ key: group.key, defs });\n }\n\n // Rebuild result: emit non-consumed segments (or segments with remaining non-consumed props),\n // then emit merged segments at the position of the first consumed segment.\n const result: ResolvedSegment[] = [];\n const mergedEmitted = new Set<string>();\n\n for (let i = 0; i < segments.length; i++) {\n const seg = segments[i];\n const consumed = consumedProps.get(i);\n\n if (!consumed) {\n // Not involved in any merge\n result.push(seg);\n continue;\n }\n\n // Emit any non-consumed properties from this segment\n const remainingDefs: Record<string, unknown> = {};\n for (const [prop, value] of Object.entries(seg.defs)) {\n if (!consumed.has(prop)) {\n remainingDefs[prop] = value;\n }\n }\n if (Object.keys(remainingDefs).length > 0) {\n result.push({ ...seg, defs: remainingDefs });\n }\n\n // Emit the merged segment(s) at the position of the first segment that contributed\n const indices = [...propToIndices.entries()]\n .filter(([prop]) => consumed.has(prop) && mergeableProps.has(prop))\n .map(([, idxs]) => idxs.join(\",\"));\n\n for (const groupKey of new Set(indices)) {\n if (!mergedEmitted.has(groupKey)) {\n const group = groupByIndices.get(groupKey);\n if (group) {\n const defs: Record<string, unknown> = {};\n for (const prop of group.props) {\n Object.assign(defs, mergedPropDefs.get(prop)!.defs);\n }\n result.push({ key: group.key, defs });\n mergedEmitted.add(groupKey);\n }\n }\n }\n }\n\n return result;\n}\n\n/**\n * Convert a pseudo/media selector into a short key suffix.\n * \":hover\" → \"hover\", \":focus-visible\" → \"focus_visible\"\n * \"@media screen and (max-width:599px)\" → \"sm\" (using breakpoints reverse map)\n * \"@container (min-width: 601px)\" → \"container_min_width_601px\"\n */\nexport function pseudoName(pseudo: string, breakpoints?: Record<string, string>): string {\n if (pseudo.startsWith(\"@media\") && breakpoints) {\n // Reverse lookup: find the breakpoint getter name (e.g. \"ifSm\") and strip \"if\" prefix\n for (const [getterName, mediaQuery] of Object.entries(breakpoints)) {\n if (mediaQuery === pseudo) {\n // \"ifSm\" → \"sm\", \"ifSmOrMd\" → \"smOrMd\", \"ifMdAndUp\" → \"mdAndUp\"\n return getterName.replace(/^if/, \"\").replace(/^./, (c) => c.toLowerCase());\n }\n }\n // Fallback: create a compact name from the media query\n return pseudo\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n }\n\n if (pseudo.startsWith(\"@container\")) {\n return pseudo\n .replace(/^@container\\s*/, \"container \")\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n }\n\n return pseudo.replace(/^:+/, \"\").replace(/-/g, \"_\");\n}\n\n/**\n * Try to evaluate a literal AST node to a string value.\n * For incremented entries, also evaluates `maybeInc(literal)`.\n */\nfunction tryEvaluateLiteral(\n node: t.Expression | t.SpreadElement,\n incremented: boolean,\n increment: number,\n): string | null {\n if (node.type === \"NumericLiteral\") {\n if (incremented) {\n return `${node.value * increment}px`;\n }\n return String(node.value);\n }\n if (node.type === \"StringLiteral\") {\n return node.value;\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n const val = -node.argument.value;\n if (incremented) {\n return `${val * increment}px`;\n }\n return String(val);\n }\n return null;\n}\n\n/** Try to evaluate a Px delegate argument (always a number → `${n}px`). */\nfunction tryEvaluatePxLiteral(node: t.Expression | t.SpreadElement): string | null {\n if (node.type === \"NumericLiteral\") {\n return `${node.value}px`;\n }\n return null;\n}\n\n/** Resolve ifContainer({ gt, lt, name? }) to a StyleX pseudo key. */\nfunction containerSelectorFromCall(node: CallChainNode): string {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`ifContainer() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const arg = node.args[0];\n if (!arg || arg.type !== \"ObjectExpression\") {\n throw new UnsupportedPatternError(\"ifContainer() expects an object literal argument\");\n }\n\n let lt: number | undefined;\n let gt: number | undefined;\n let name: string | undefined;\n\n for (const prop of arg.properties) {\n if (prop.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(\"ifContainer() does not support spread properties\");\n }\n if (prop.type !== \"ObjectProperty\" || prop.computed) {\n throw new UnsupportedPatternError(\"ifContainer() expects plain object properties\");\n }\n\n const key = objectPropertyName(prop.key);\n if (!key) {\n throw new UnsupportedPatternError(\"ifContainer() only supports identifier/string keys\");\n }\n\n const valueNode = prop.value as t.Expression | t.SpreadElement;\n\n if (key === \"lt\") {\n lt = numericLiteralValue(valueNode, \"ifContainer().lt must be a numeric literal\");\n continue;\n }\n if (key === \"gt\") {\n gt = numericLiteralValue(valueNode, \"ifContainer().gt must be a numeric literal\");\n continue;\n }\n if (key === \"name\") {\n name = stringLiteralValue(valueNode, \"ifContainer().name must be a string literal\");\n continue;\n }\n\n throw new UnsupportedPatternError(`ifContainer() does not support property \"${key}\"`);\n }\n\n if (lt === undefined && gt === undefined) {\n throw new UnsupportedPatternError('ifContainer() requires at least one of \"lt\" or \"gt\"');\n }\n\n const parts: string[] = [];\n if (gt !== undefined) {\n parts.push(`(min-width: ${gt + 1}px)`);\n }\n if (lt !== undefined) {\n parts.push(`(max-width: ${lt}px)`);\n }\n\n const query = parts.join(\" and \");\n const namePrefix = name ? `${name} ` : \"\";\n return `@container ${namePrefix}${query}`;\n}\n\nfunction objectPropertyName(node: t.Expression | t.Identifier | t.PrivateName): string | null {\n if (node.type === \"Identifier\") return node.name;\n if (node.type === \"StringLiteral\") return node.value;\n return null;\n}\n\nfunction numericLiteralValue(node: t.Expression | t.SpreadElement, errorMessage: string): number {\n if (node.type === \"NumericLiteral\") {\n return node.value;\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n return -node.argument.value;\n }\n throw new UnsupportedPatternError(errorMessage);\n}\n\nfunction stringLiteralValue(node: t.Expression | t.SpreadElement, errorMessage: string): string {\n if (node.type === \"StringLiteral\") {\n return node.value;\n }\n if (node.type === \"TemplateLiteral\" && node.expressions.length === 0 && node.quasis.length === 1) {\n return node.quasis[0].value.cooked ?? \"\";\n }\n throw new UnsupportedPatternError(errorMessage);\n}\n\n// ── Chain node types (parsed from AST) ────────────────────────────────\n\nexport interface GetterChainNode {\n type: \"getter\";\n name: string;\n}\n\nexport interface CallChainNode {\n type: \"call\";\n name: string;\n args: (t.Expression | t.SpreadElement)[];\n}\n\nexport interface IfChainNode {\n type: \"if\";\n conditionNode: t.Expression | t.SpreadElement;\n}\n\nexport interface ElseChainNode {\n type: \"else\";\n}\n\nexport type ChainNode = GetterChainNode | CallChainNode | IfChainNode | ElseChainNode;\n\nexport class UnsupportedPatternError extends Error {\n constructor(message: string) {\n super(`[truss] Unsupported pattern: ${message}`);\n this.name = \"UnsupportedPatternError\";\n }\n}\n","import * as t from \"@babel/types\";\nimport type { ChainNode } from \"./resolve-chain\";\n\n/**\n * Collect module-scope bindings so generated declarations can avoid collisions.\n *\n * We only care about top-level names because the transform injects declarations\n * at the module root, not inside nested blocks.\n */\nexport function collectTopLevelBindings(ast: t.File): Set<string> {\n const used = new Set<string>();\n\n for (const node of ast.program.body) {\n if (t.isImportDeclaration(node)) {\n for (const spec of node.specifiers) {\n used.add(spec.local.name);\n }\n continue;\n }\n\n if (t.isVariableDeclaration(node)) {\n for (const decl of node.declarations) {\n collectPatternBindings(decl.id, used);\n }\n continue;\n }\n\n if (t.isFunctionDeclaration(node) && node.id) {\n used.add(node.id.name);\n continue;\n }\n\n if (t.isClassDeclaration(node) && node.id) {\n used.add(node.id.name);\n continue;\n }\n\n if (t.isExportNamedDeclaration(node) && node.declaration) {\n const decl = node.declaration;\n if (t.isVariableDeclaration(decl)) {\n for (const varDecl of decl.declarations) {\n collectPatternBindings(varDecl.id, used);\n }\n } else if ((t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) && decl.id) {\n used.add(decl.id.name);\n }\n continue;\n }\n\n if (t.isExportDefaultDeclaration(node)) {\n const decl = node.declaration;\n if ((t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) && decl.id) {\n used.add(decl.id.name);\n }\n }\n }\n\n return used;\n}\n\n/**\n * Recursively collect names introduced by binding patterns.\n *\n * This handles destructuring (`const { a } = ...`, `const [x] = ...`) so we do\n * not accidentally generate a helper that shadows an existing binding.\n */\nfunction collectPatternBindings(pattern: t.LVal | t.VoidPattern, used: Set<string>): void {\n if (t.isVoidPattern(pattern)) {\n return;\n }\n\n if (t.isIdentifier(pattern)) {\n used.add(pattern.name);\n return;\n }\n\n if (t.isAssignmentPattern(pattern)) {\n collectPatternBindings(pattern.left, used);\n return;\n }\n\n if (t.isRestElement(pattern)) {\n collectPatternBindings(pattern.argument as t.LVal, used);\n return;\n }\n\n if (t.isObjectPattern(pattern)) {\n for (const prop of pattern.properties) {\n if (t.isObjectProperty(prop)) {\n collectPatternBindings(prop.value as t.LVal, used);\n } else if (t.isRestElement(prop)) {\n collectPatternBindings(prop.argument as t.LVal, used);\n }\n }\n return;\n }\n\n if (t.isArrayPattern(pattern)) {\n for (const el of pattern.elements) {\n if (!el) continue;\n if (t.isIdentifier(el) || t.isAssignmentPattern(el) || t.isObjectPattern(el) || t.isArrayPattern(el)) {\n collectPatternBindings(el, used);\n } else if (t.isRestElement(el)) {\n collectPatternBindings(el.argument as t.LVal, used);\n }\n }\n }\n}\n\n/**\n * Reserve a stable, collision-free identifier.\n *\n * Preference order:\n * 1) preferred\n * 2) secondary (if provided)\n * 3) numbered suffixes based on secondary/preferred\n */\nexport function reservePreferredName(used: Set<string>, preferred: string, secondary?: string): string {\n if (!used.has(preferred)) {\n used.add(preferred);\n return preferred;\n }\n\n if (secondary && !used.has(secondary)) {\n used.add(secondary);\n return secondary;\n }\n\n const base = secondary ?? preferred;\n let i = 1;\n // Numbered fallback keeps generated names deterministic across runs.\n let candidate = `${base}_${i}`;\n while (used.has(candidate)) {\n i++;\n candidate = `${base}_${i}`;\n }\n used.add(candidate);\n return candidate;\n}\n\n/**\n * Find the local binding name for `Css` from import declarations.\n */\nexport function findCssImportBinding(ast: t.File): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n for (const spec of node.specifiers) {\n if (t.isImportSpecifier(spec) && t.isIdentifier(spec.imported, { name: \"Css\" })) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\n/** Check if the AST contains a `binding.method(...)` call expression. */\nexport function hasCssMethodCall(ast: t.File, binding: string, method: string): boolean {\n let found = false;\n t.traverseFast(ast, (node) => {\n if (found) return;\n if (\n t.isCallExpression(node) &&\n t.isMemberExpression(node.callee) &&\n !node.callee.computed &&\n t.isIdentifier(node.callee.object, { name: binding }) &&\n t.isIdentifier(node.callee.property, { name: method })\n ) {\n found = true;\n }\n });\n return found;\n}\n\n/**\n * Remove the Css import specifier. If it was the only specifier, remove the whole import.\n */\nexport function removeCssImport(ast: t.File, cssBinding: string): void {\n for (let i = 0; i < ast.program.body.length; i++) {\n const node = ast.program.body[i];\n if (!t.isImportDeclaration(node)) continue;\n\n const cssSpecIndex = node.specifiers.findIndex((s) => t.isImportSpecifier(s) && s.local.name === cssBinding);\n if (cssSpecIndex === -1) continue;\n\n if (node.specifiers.length === 1) {\n ast.program.body.splice(i, 1);\n } else {\n node.specifiers.splice(cssSpecIndex, 1);\n }\n return;\n }\n}\n\n/**\n * Find an existing namespace import for `@stylexjs/stylex`, if present.\n *\n * Reusing an existing namespace avoids duplicate imports and ensures generated\n * calls use the same local alias as handwritten code (e.g. `sx`).\n */\nexport function findStylexNamespaceImport(ast: t.File): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n if (node.source.value !== \"@stylexjs/stylex\") continue;\n\n for (const spec of node.specifiers) {\n if (t.isImportNamespaceSpecifier(spec)) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\n/** Return the index of the last import declaration in the module. */\nexport function findLastImportIndex(ast: t.File): number {\n let lastImportIndex = -1;\n for (let i = 0; i < ast.program.body.length; i++) {\n if (t.isImportDeclaration(ast.program.body[i])) {\n lastImportIndex = i;\n }\n }\n return lastImportIndex;\n}\n\n/**\n * Insert `import * as <localName> from \"@stylexjs/stylex\"` after existing imports.\n */\nexport function insertStylexNamespaceImport(ast: t.File, localName: string): void {\n const stylexImport = t.importDeclaration(\n [t.importNamespaceSpecifier(t.identifier(localName))],\n t.stringLiteral(\"@stylexjs/stylex\"),\n );\n const idx = findLastImportIndex(ast);\n ast.program.body.splice(idx + 1, 0, stylexImport);\n}\n\nexport function findNamedImportBinding(ast: t.File, source: string, importedName: string): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node) || node.source.value !== source) continue;\n for (const spec of node.specifiers) {\n if (t.isImportSpecifier(spec) && t.isIdentifier(spec.imported, { name: importedName })) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\nexport function upsertNamedImports(\n ast: t.File,\n source: string,\n imports: Array<{ importedName: string; localName: string }>,\n): void {\n if (imports.length === 0) return;\n\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node) || node.source.value !== source) continue;\n\n for (const entry of imports) {\n const exists = node.specifiers.some(function (spec) {\n return t.isImportSpecifier(spec) && t.isIdentifier(spec.imported, { name: entry.importedName });\n });\n if (exists) continue;\n\n node.specifiers.push(t.importSpecifier(t.identifier(entry.localName), t.identifier(entry.importedName)));\n }\n return;\n }\n\n const importDecl = t.importDeclaration(\n imports.map(function (entry) {\n return t.importSpecifier(t.identifier(entry.localName), t.identifier(entry.importedName));\n }),\n t.stringLiteral(source),\n );\n const idx = findLastImportIndex(ast);\n ast.program.body.splice(idx + 1, 0, importDecl);\n}\n\n/**\n * Extract a `Css` method/property chain from an expression.\n *\n * Example: `Css.if(cond).df.else.db.$` ->\n * `[{type:\"if\"}, {type:\"getter\", name:\"df\"}, {type:\"else\"}, {type:\"getter\", name:\"db\"}]`\n *\n * Returns `null` when the expression is not rooted at the Css import binding,\n * which lets the caller ignore unrelated member expressions cheaply.\n */\nexport function extractChain(node: t.Expression, cssBinding: string): ChainNode[] | null {\n const chain: ChainNode[] = [];\n let current: t.Expression = node;\n\n while (true) {\n if (t.isIdentifier(current, { name: cssBinding })) {\n chain.reverse();\n return chain;\n }\n\n if (t.isMemberExpression(current) && !current.computed && t.isIdentifier(current.property)) {\n const name = current.property.name;\n if (name === \"else\") {\n chain.push({ type: \"else\" });\n } else {\n chain.push({ type: \"getter\", name });\n }\n current = current.object as t.Expression;\n continue;\n }\n\n if (\n t.isCallExpression(current) &&\n t.isMemberExpression(current.callee) &&\n !current.callee.computed &&\n t.isIdentifier(current.callee.property)\n ) {\n const name = current.callee.property.name;\n\n if (name === \"if\") {\n chain.push({\n type: \"if\",\n conditionNode: current.arguments[0] as t.Expression,\n });\n current = current.callee.object as t.Expression;\n continue;\n }\n\n chain.push({\n type: \"call\",\n name,\n args: current.arguments as (t.Expression | t.SpreadElement)[],\n });\n current = current.callee.object as t.Expression;\n continue;\n }\n\n return null;\n }\n}\n","import _traverse from \"@babel/traverse\";\nimport type { NodePath } from \"@babel/traverse\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport type { TrussMapping } from \"./types\";\nimport type { ResolvedChain } from \"./resolve-chain\";\nimport { buildStyleHashProperties, markerClassName } from \"./emit-truss\";\nimport type { ResolvedSegment } from \"./types\";\n\n// Babel packages are CJS today; normalize default interop across loaders.\nconst generate = ((_generate as unknown as { default?: typeof _generate }).default ?? _generate) as typeof _generate;\nconst traverse = ((_traverse as unknown as { default?: typeof _traverse }).default ?? _traverse) as typeof _traverse;\n\nexport interface ExpressionSite {\n path: NodePath<t.MemberExpression>;\n resolvedChain: ResolvedChain;\n}\n\nexport interface RewriteSitesOptions {\n ast: t.File;\n sites: ExpressionSite[];\n cssBindingName: string;\n filename: string;\n debug: boolean;\n mapping: TrussMapping;\n maybeIncHelperName: string | null;\n mergePropsHelperName: string;\n needsMergePropsHelper: { current: boolean };\n trussPropsHelperName: string;\n needsTrussPropsHelper: { current: boolean };\n trussDebugInfoName: string;\n needsTrussDebugInfo: { current: boolean };\n skippedCssPropMessages: Array<{ message: string; line: number | null }>;\n runtimeLookupNames: Map<string, string>;\n}\n\n/**\n * Rewrite collected `Css...$` expression sites into Truss-native style hash objects.\n *\n * In the new model, each site becomes an ObjectExpression keyed by CSS property.\n * JSX `css=` attributes become `trussProps(hash)` or `mergeProps(className, style, hash)` spreads.\n * Non-JSX positions become plain object expressions.\n */\nexport function rewriteExpressionSites(options: RewriteSitesOptions): void {\n for (const site of options.sites) {\n const styleHash = buildStyleHashFromChain(site.resolvedChain, options);\n const cssAttrPath = getCssAttributePath(site.path);\n const line = site.path.node.loc?.start.line ?? null;\n\n if (cssAttrPath) {\n // JSX css= attribute → spread trussProps or mergeProps\n cssAttrPath.replaceWith(t.jsxSpreadAttribute(buildCssSpreadExpression(cssAttrPath, styleHash, line, options)));\n } else {\n // Non-JSX position → plain object expression with optional debug info\n if (options.debug && line !== null) {\n injectDebugInfo(styleHash, line, options);\n }\n site.path.replaceWith(styleHash);\n }\n }\n\n rewriteCssPropsCalls(options);\n\n // Second pass: lower any remaining `css={...}` expression to `trussProps(...)`.\n rewriteCssAttributeExpressions(options);\n}\n\n/**\n * Return the enclosing `css={...}` JSX attribute path for a transformed site,\n * or null when the site is in a non-`css` expression context.\n */\nfunction getCssAttributePath(path: NodePath<t.MemberExpression>): NodePath<t.JSXAttribute> | null {\n const parentPath = path.parentPath;\n if (!parentPath || !parentPath.isJSXExpressionContainer()) return null;\n\n const attrPath = parentPath.parentPath;\n if (!attrPath || !attrPath.isJSXAttribute()) return null;\n if (!t.isJSXIdentifier(attrPath.node.name, { name: \"css\" })) return null;\n\n return attrPath;\n}\n\n// ---------------------------------------------------------------------------\n// Building style hash objects from resolved chains\n// ---------------------------------------------------------------------------\n\n/** Build an ObjectExpression from a ResolvedChain, handling conditionals. */\nfunction buildStyleHashFromChain(chain: ResolvedChain, options: RewriteSitesOptions): t.ObjectExpression {\n const members: (t.ObjectProperty | t.SpreadElement)[] = [];\n\n if (chain.markers.length > 0) {\n const markerClasses = chain.markers.map(function (marker) {\n return markerClassName(marker.markerNode);\n });\n members.push(t.objectProperty(t.identifier(\"__marker\"), t.stringLiteral(markerClasses.join(\" \"))));\n }\n\n for (const part of chain.parts) {\n if (part.type === \"unconditional\") {\n members.push(...buildStyleHashMembers(part.segments, options));\n } else {\n // Conditional: ...(cond ? { then } : { else })\n const thenMembers = buildStyleHashMembers(part.thenSegments, options);\n const elseMembers = buildStyleHashMembers(part.elseSegments, options);\n members.push(\n t.spreadElement(\n t.conditionalExpression(part.conditionNode, t.objectExpression(thenMembers), t.objectExpression(elseMembers)),\n ),\n );\n }\n }\n\n return t.objectExpression(members);\n}\n\n/**\n * Build ObjectExpression members from a list of segments.\n *\n * Normal segments are batched and processed by buildStyleHashProperties.\n * Special segments (styleArrayArg, typographyLookup) produce SpreadElements.\n */\nfunction buildStyleHashMembers(\n segments: ResolvedSegment[],\n options: RewriteSitesOptions,\n): (t.ObjectProperty | t.SpreadElement)[] {\n const members: (t.ObjectProperty | t.SpreadElement)[] = [];\n const normalSegs: ResolvedSegment[] = [];\n\n function flushNormal(): void {\n if (normalSegs.length > 0) {\n members.push(...buildStyleHashProperties(normalSegs, options.mapping, options.maybeIncHelperName));\n normalSegs.length = 0;\n }\n }\n\n for (const seg of segments) {\n if (seg.error) continue;\n\n if (seg.styleArrayArg) {\n flushNormal();\n // In the new model, add(cssProp) takes a style hash object — just spread it\n members.push(t.spreadElement(seg.styleArrayArg as t.Expression));\n continue;\n }\n\n if (seg.typographyLookup) {\n flushNormal();\n const lookupName = options.runtimeLookupNames.get(seg.typographyLookup.lookupKey);\n if (lookupName) {\n // I.e. `{ ...(__typography[key] ?? {}) }`\n const lookupAccess = t.memberExpression(\n t.identifier(lookupName),\n seg.typographyLookup.argNode as t.Expression,\n true,\n );\n members.push(t.spreadElement(t.logicalExpression(\"??\", lookupAccess, t.objectExpression([]))));\n }\n continue;\n }\n\n normalSegs.push(seg);\n }\n\n flushNormal();\n return members;\n}\n\n// ---------------------------------------------------------------------------\n// Debug info injection\n// ---------------------------------------------------------------------------\n\n/**\n * Inject debug info into the first property of a style hash ObjectExpression.\n *\n * For static values, promotes `\"df\"` to `[\"df\", new TrussDebugInfo(\"...\")]`.\n * For variable tuples, appends the debug info as a third element.\n */\nfunction injectDebugInfo(\n expr: t.ObjectExpression,\n line: number,\n options: Pick<RewriteSitesOptions, \"debug\" | \"trussDebugInfoName\" | \"needsTrussDebugInfo\" | \"filename\">,\n): void {\n if (!options.debug) return;\n\n // Find the first real style property (skip SpreadElements and __marker metadata)\n const firstProp = expr.properties.find(function (p) {\n return (\n t.isObjectProperty(p) &&\n !(\n (t.isIdentifier(p.key) && p.key.name === \"__marker\") ||\n (t.isStringLiteral(p.key) && p.key.value === \"__marker\")\n )\n );\n }) as t.ObjectProperty | undefined;\n if (!firstProp) return;\n\n options.needsTrussDebugInfo.current = true;\n const debugExpr = t.newExpression(t.identifier(options.trussDebugInfoName), [\n t.stringLiteral(`${options.filename}:${line}`),\n ]);\n\n if (t.isStringLiteral(firstProp.value)) {\n // Static: \"df\" → [\"df\", new TrussDebugInfo(\"...\")]\n firstProp.value = t.arrayExpression([firstProp.value, debugExpr]);\n } else if (t.isArrayExpression(firstProp.value)) {\n // Variable tuple: [\"mt_var\", { vars }] → [\"mt_var\", { vars }, new TrussDebugInfo(\"...\")]\n firstProp.value.elements.push(debugExpr);\n }\n}\n\n/** Build the `new TrussDebugInfo(\"File.tsx:line\")` expression for a site. */\nfunction buildDebugExpr(\n line: number | null,\n options: Pick<RewriteSitesOptions, \"debug\" | \"trussDebugInfoName\" | \"needsTrussDebugInfo\" | \"filename\">,\n): t.NewExpression | null {\n if (!options.debug || line === null) return null;\n\n options.needsTrussDebugInfo.current = true;\n return t.newExpression(t.identifier(options.trussDebugInfoName), [t.stringLiteral(`${options.filename}:${line}`)]);\n}\n\n// ---------------------------------------------------------------------------\n// JSX css= attribute handling\n// ---------------------------------------------------------------------------\n\n/** Build the spread expression for a JSX `css=` attribute. */\nfunction buildCssSpreadExpression(\n path: NodePath<t.JSXAttribute>,\n styleHash: t.Expression,\n line: number | null,\n options: RewriteSitesOptions,\n): t.Expression {\n const existingClassNameExpr = removeExistingAttribute(path, \"className\");\n const existingStyleExpr = removeExistingAttribute(path, \"style\");\n\n if (!existingClassNameExpr && !existingStyleExpr) {\n return buildPropsCall(styleHash, line, options);\n }\n\n // mergeProps(className, style, hash)\n options.needsMergePropsHelper.current = true;\n\n if (options.debug && line !== null) {\n injectDebugInfo(styleHash as t.ObjectExpression, line, options);\n }\n\n return t.callExpression(t.identifier(options.mergePropsHelperName), [\n existingClassNameExpr ?? t.identifier(\"undefined\"),\n existingStyleExpr ?? t.identifier(\"undefined\"),\n styleHash,\n ]);\n}\n\n/** Emit `trussProps(hash)` call. In debug mode, injects debug info into the hash first. */\nfunction buildPropsCall(styleHash: t.Expression, line: number | null, options: RewriteSitesOptions): t.CallExpression {\n options.needsTrussPropsHelper.current = true;\n\n if (options.debug && line !== null && t.isObjectExpression(styleHash)) {\n injectDebugInfo(styleHash, line, options);\n }\n\n return t.callExpression(t.identifier(options.trussPropsHelperName), [styleHash]);\n}\n\n/** Remove a sibling JSX attribute and return its expression. */\nfunction removeExistingAttribute(path: NodePath<t.JSXAttribute>, attrName: string): t.Expression | null {\n const openingElement = path.parentPath;\n if (!openingElement || !openingElement.isJSXOpeningElement()) return null;\n\n const attrs = openingElement.node.attributes;\n for (let i = 0; i < attrs.length; i++) {\n const attr = attrs[i];\n if (!t.isJSXAttribute(attr) || !t.isJSXIdentifier(attr.name, { name: attrName })) continue;\n\n let expr: t.Expression | null = null;\n if (t.isStringLiteral(attr.value)) {\n expr = attr.value;\n } else if (t.isJSXExpressionContainer(attr.value) && t.isExpression(attr.value.expression)) {\n expr = attr.value.expression;\n }\n\n attrs.splice(i, 1);\n return expr;\n }\n\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// Css.props(...) rewriting\n// ---------------------------------------------------------------------------\n\n/**\n * Rewrite `Css.props(expr)` into `trussProps(expr)`.\n *\n * In the new model, the argument is already a style hash, so we just delegate to trussProps.\n */\nfunction rewriteCssPropsCalls(options: RewriteSitesOptions): void {\n traverse(options.ast, {\n CallExpression(path: NodePath<t.CallExpression>) {\n if (!isCssPropsCall(path.node, options.cssBindingName)) return;\n\n const arg = path.node.arguments[0];\n if (!arg || t.isSpreadElement(arg) || !t.isExpression(arg) || path.node.arguments.length !== 1) return;\n\n const line = path.node.loc?.start.line ?? null;\n\n options.needsTrussPropsHelper.current = true;\n\n // Check for a sibling `className` property in the parent object literal\n const classNameExpr = extractSiblingClassName(path);\n if (classNameExpr) {\n options.needsMergePropsHelper.current = true;\n path.replaceWith(\n t.callExpression(t.identifier(options.mergePropsHelperName), [classNameExpr, t.identifier(\"undefined\"), arg]),\n );\n } else {\n path.replaceWith(t.callExpression(t.identifier(options.trussPropsHelperName), [arg]));\n }\n },\n });\n}\n\n// ---------------------------------------------------------------------------\n// Second pass: remaining css={...} attributes\n// ---------------------------------------------------------------------------\n\n/**\n * Rewrite any remaining `css={expr}` JSX attributes into `{...trussProps(expr)}`.\n *\n * This handles cases where the css prop value is not a direct `Css.*.$` chain,\n * e.g. `css={someVariable}`, `css={{ ...a, ...b }}`, `css={cond ? a : b}`.\n *\n * In the new model, all of these just need to be wrapped in trussProps().\n */\nfunction rewriteCssAttributeExpressions(options: RewriteSitesOptions): void {\n traverse(options.ast, {\n JSXAttribute(path: NodePath<t.JSXAttribute>) {\n if (!t.isJSXIdentifier(path.node.name, { name: \"css\" })) return;\n const value = path.node.value;\n if (!t.isJSXExpressionContainer(value)) return;\n if (!t.isExpression(value.expression)) return;\n\n const expr = value.expression;\n const line = path.node.loc?.start.line ?? null;\n\n const existingClassNameExpr = removeExistingAttribute(path, \"className\");\n const existingStyleExpr = removeExistingAttribute(path, \"style\");\n\n if (existingClassNameExpr || existingStyleExpr) {\n options.needsMergePropsHelper.current = true;\n path.replaceWith(\n t.jsxSpreadAttribute(\n t.callExpression(t.identifier(options.mergePropsHelperName), [\n existingClassNameExpr ?? t.identifier(\"undefined\"),\n existingStyleExpr ?? t.identifier(\"undefined\"),\n expr,\n ]),\n ),\n );\n } else {\n options.needsTrussPropsHelper.current = true;\n path.replaceWith(t.jsxSpreadAttribute(t.callExpression(t.identifier(options.trussPropsHelperName), [expr])));\n }\n },\n });\n}\n\n// ---------------------------------------------------------------------------\n// Utility helpers\n// ---------------------------------------------------------------------------\n\n/** Match `Css.props(...)` calls. */\nfunction isCssPropsCall(expr: t.CallExpression, cssBindingName: string): boolean {\n return (\n t.isMemberExpression(expr.callee) &&\n !expr.callee.computed &&\n t.isIdentifier(expr.callee.object, { name: cssBindingName }) &&\n t.isIdentifier(expr.callee.property, { name: \"props\" })\n );\n}\n\n/**\n * If `...Css.props(...)` is spread inside an object literal that has a sibling\n * `className` property, extract and remove that property so the rewrite can\n * merge it via `mergeProps`.\n */\nfunction extractSiblingClassName(callPath: NodePath<t.CallExpression>): t.Expression | null {\n // Walk up: CallExpression → SpreadElement → ObjectExpression\n const spreadPath = callPath.parentPath;\n if (!spreadPath || !spreadPath.isSpreadElement()) return null;\n const objectPath = spreadPath.parentPath;\n if (!objectPath || !objectPath.isObjectExpression()) return null;\n\n const properties = objectPath.node.properties;\n for (let i = 0; i < properties.length; i++) {\n const prop = properties[i];\n if (!t.isObjectProperty(prop)) continue;\n if (!isMatchingPropertyName(prop.key, \"className\")) continue;\n if (!t.isExpression(prop.value)) continue;\n\n const classNameExpr = prop.value;\n properties.splice(i, 1);\n return classNameExpr;\n }\n\n return null;\n}\n\n/** Match static object property names. */\nfunction isMatchingPropertyName(key: t.Expression | t.Identifier | t.PrivateName, name: string): boolean {\n return (t.isIdentifier(key) && key.name === name) || (t.isStringLiteral(key) && key.value === name);\n}\n\n/** Generate a compact code snippet for diagnostics. */\nfunction formatNodeSnippet(node: t.Node): string {\n return generate(node, { compact: true, comments: true }).code;\n}\n","import { parse } from \"@babel/parser\";\nimport * as t from \"@babel/types\";\nimport type { TrussMapping } from \"./types\";\nimport { resolveFullChain } from \"./resolve-chain\";\nimport { extractChain, findCssImportBinding } from \"./ast-utils\";\nimport { collectStaticStringBindings, resolveStaticString } from \"./css-ts-utils\";\n\n/**\n * Transform a `.css.ts` file into a plain CSS string.\n *\n * The file is expected to have the shape:\n * ```ts\n * import { Css } from \"./Css\";\n * export const css = {\n * \".some-selector\": Css.df.blue.$,\n * \".other > .selector\": Css.mt(2).black.$,\n * };\n * ```\n *\n * Each key is a CSS selector (string literal), each value is a `Css.*.$` chain.\n * The chains are resolved via the truss mapping into concrete CSS declarations.\n *\n * Returns the generated CSS string.\n */\nexport function transformCssTs(code: string, filename: string, mapping: TrussMapping): string {\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n const cssBindingName = findCssImportBinding(ast);\n if (!cssBindingName) {\n return `/* [truss] ${filename}: no Css import found */\\n`;\n }\n\n // Find the `export const css = { ... }` expression\n const cssExport = findNamedCssExportObject(ast);\n if (!cssExport) {\n return `/* [truss] ${filename}: expected \\`export const css = { ... }\\` with an object literal */\\n`;\n }\n\n const rules: string[] = [];\n const stringBindings = collectStaticStringBindings(ast);\n\n for (const prop of cssExport.properties) {\n if (t.isSpreadElement(prop)) {\n rules.push(`/* [truss] unsupported: spread elements in css.ts export */`);\n continue;\n }\n\n if (!t.isObjectProperty(prop)) {\n rules.push(`/* [truss] unsupported: non-property in css.ts export */`);\n continue;\n }\n\n // Key must be a string literal (the CSS selector)\n const selector = objectPropertyStringKey(prop, stringBindings);\n if (selector === null) {\n rules.push(`/* [truss] unsupported: non-string-literal key in css.ts export */`);\n continue;\n }\n\n // Value must be a Css.*.$ expression\n const valueNode = prop.value;\n if (!t.isExpression(valueNode)) {\n rules.push(`/* [truss] unsupported: \"${selector}\" value is not an expression */`);\n continue;\n }\n\n const cssResult = resolveCssExpression(valueNode, cssBindingName, mapping, filename);\n if (\"error\" in cssResult) {\n rules.push(`/* [truss] unsupported: \"${selector}\" — ${cssResult.error} */`);\n continue;\n }\n\n rules.push(formatCssRule(selector, cssResult.declarations));\n }\n\n return rules.join(\"\\n\\n\") + \"\\n\";\n}\n\n/** Find the object expression in `export const css = { ... }`. */\nfunction findNamedCssExportObject(ast: t.File): t.ObjectExpression | null {\n for (const node of ast.program.body) {\n if (!t.isExportNamedDeclaration(node) || !node.declaration) continue;\n if (!t.isVariableDeclaration(node.declaration)) continue;\n\n for (const declarator of node.declaration.declarations) {\n if (!t.isIdentifier(declarator.id, { name: \"css\" })) continue;\n const value = unwrapObjectExpression(declarator.init);\n if (value) return value;\n }\n }\n return null;\n}\n\nfunction unwrapObjectExpression(node: t.Expression | null | undefined): t.ObjectExpression | null {\n if (!node) return null;\n if (t.isObjectExpression(node)) return node;\n if (t.isTSAsExpression(node) || t.isTSSatisfiesExpression(node)) return unwrapObjectExpression(node.expression);\n return null;\n}\n\n/** Extract a static string key from an ObjectProperty. */\nfunction objectPropertyStringKey(prop: t.ObjectProperty, stringBindings: Map<string, string>): string | null {\n if (t.isStringLiteral(prop.key)) return prop.key.value;\n // Allow unquoted identifiers as keys too (e.g. `body: Css.df.$`)\n if (t.isIdentifier(prop.key) && !prop.computed) return prop.key.name;\n if (prop.computed) return resolveStaticString(prop.key, stringBindings);\n return null;\n}\n\ninterface CssResolution {\n declarations: Array<{ property: string; value: string }>;\n error?: undefined;\n}\ninterface CssError {\n declarations?: undefined;\n error: string;\n}\n\n/**\n * Resolve a `Css.*.$` expression node to CSS declarations.\n *\n * Validates that the chain only uses static/literal patterns (no variable args,\n * no if/else conditionals, no pseudo/media modifiers).\n */\nfunction resolveCssExpression(\n node: t.Expression,\n cssBindingName: string,\n mapping: TrussMapping,\n filename: string,\n): CssResolution | CssError {\n // The expression must end with `.$`\n if (!t.isMemberExpression(node) || node.computed || !t.isIdentifier(node.property, { name: \"$\" })) {\n return { error: \"value must be a Css.*.$ expression\" };\n }\n\n const chain = extractChain(node.object, cssBindingName);\n if (!chain) {\n return { error: \"could not extract Css chain from expression\" };\n }\n\n // Validate: no if/else nodes\n for (const n of chain) {\n if (n.type === \"if\") return { error: \"if() conditionals are not supported in .css.ts files\" };\n if (n.type === \"else\") return { error: \"else is not supported in .css.ts files\" };\n }\n\n const resolved = resolveFullChain(chain, mapping);\n\n // Check for errors from resolution\n if (resolved.errors.length > 0) {\n return { error: resolved.errors[0] };\n }\n\n // Validate: no conditionals came back\n for (const part of resolved.parts) {\n if (part.type === \"conditional\") {\n return { error: \"conditional chains are not supported in .css.ts files\" };\n }\n }\n\n // Collect all declarations from all unconditional parts\n const declarations: Array<{ property: string; value: string }> = [];\n\n for (const part of resolved.parts) {\n if (part.type !== \"unconditional\") continue;\n for (const seg of part.segments) {\n if (seg.error) {\n return { error: seg.error };\n }\n\n // Reject segments that require runtime (variable with variable args)\n if (seg.variableProps && !seg.argResolved) {\n return { error: `variable value with variable argument is not supported in .css.ts files` };\n }\n if (seg.typographyLookup) {\n return { error: `typography() with a runtime key is not supported in .css.ts files` };\n }\n if (seg.styleArrayArg) {\n return { error: `add(cssProp) is not supported in .css.ts files` };\n }\n\n // Reject segments with media query / pseudo-class / pseudo-element / when modifiers\n if (seg.mediaQuery) {\n return { error: `media query modifiers (ifSm, ifMd, etc.) are not supported in .css.ts files` };\n }\n if (seg.pseudoClass) {\n return { error: `pseudo-class modifiers (onHover, onFocus, etc.) are not supported in .css.ts files` };\n }\n if (seg.pseudoElement) {\n return { error: `pseudo-element modifiers are not supported in .css.ts files` };\n }\n if (seg.whenPseudo) {\n return { error: `when() modifiers are not supported in .css.ts files` };\n }\n\n // Extract CSS property/value pairs from defs\n for (const [prop, value] of Object.entries(seg.defs)) {\n if (typeof value === \"string\" || typeof value === \"number\") {\n declarations.push({ property: camelToKebab(prop), value: String(value) });\n } else {\n // Nested condition objects (shouldn't happen after our validation, but defensive)\n return { error: `unexpected nested value for property \"${prop}\"` };\n }\n }\n }\n }\n\n return { declarations };\n}\n\n/** Convert a camelCase CSS property name to kebab-case. */\nexport function camelToKebab(s: string): string {\n // Handle vendor prefixes like WebkitTransform → -webkit-transform\n return s.replace(/^(Webkit|Moz|Ms|O)/, (m) => `-${m.toLowerCase()}`).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);\n}\n\n/** Format a CSS rule block. */\nfunction formatCssRule(selector: string, declarations: Array<{ property: string; value: string }>): string {\n if (declarations.length === 0) {\n return `${selector} {}`;\n }\n const body = declarations.map((d) => ` ${d.property}: ${d.value};`).join(\"\\n\");\n return `${selector} {\\n${body}\\n}`;\n}\n","import * as t from \"@babel/types\";\n\n/** Resolve module-scope string constants so .css.ts selectors can reuse them. */\nexport function collectStaticStringBindings(ast: t.File): Map<string, string> {\n const bindings = new Map<string, string>();\n let changed = true;\n\n while (changed) {\n changed = false;\n\n for (const node of ast.program.body) {\n const declaration = getTopLevelVariableDeclaration(node);\n if (!declaration) continue;\n\n for (const declarator of declaration.declarations) {\n if (!t.isIdentifier(declarator.id) || !declarator.init) continue;\n if (bindings.has(declarator.id.name)) continue;\n\n const value = resolveStaticString(declarator.init, bindings);\n if (value === null) continue;\n\n bindings.set(declarator.id.name, value);\n changed = true;\n }\n }\n }\n\n return bindings;\n}\n\n/** Resolve a static string expression from a literal, template, or identifier. */\nexport function resolveStaticString(node: t.Node | null | undefined, bindings: Map<string, string>): string | null {\n if (!node) return null;\n\n if (t.isStringLiteral(node)) return node.value;\n\n if (t.isTemplateLiteral(node)) {\n let value = \"\";\n for (let i = 0; i < node.quasis.length; i++) {\n value += node.quasis[i].value.cooked ?? \"\";\n if (i >= node.expressions.length) continue;\n\n const expressionValue = resolveStaticString(node.expressions[i], bindings);\n if (expressionValue === null) return null;\n value += expressionValue;\n }\n return value;\n }\n\n if (t.isIdentifier(node)) {\n return bindings.get(node.name) ?? null;\n }\n\n if (t.isTSAsExpression(node) || t.isTSSatisfiesExpression(node) || t.isTSNonNullExpression(node)) {\n return resolveStaticString(node.expression, bindings);\n }\n\n if (t.isParenthesizedExpression(node)) {\n return resolveStaticString(node.expression, bindings);\n }\n\n if (t.isBinaryExpression(node, { operator: \"+\" })) {\n const left = resolveStaticString(node.left, bindings);\n const right = resolveStaticString(node.right, bindings);\n if (left === null || right === null) return null;\n return left + right;\n }\n\n return null;\n}\n\nfunction getTopLevelVariableDeclaration(node: t.Statement): t.VariableDeclaration | null {\n if (t.isVariableDeclaration(node)) {\n return node;\n }\n\n if (t.isExportNamedDeclaration(node) && node.declaration && t.isVariableDeclaration(node.declaration)) {\n return node.declaration;\n }\n\n return null;\n}\n","import { parse } from \"@babel/parser\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport { findLastImportIndex } from \"./ast-utils\";\n\n// Babel generator is published as CJS, so normalize default interop before using it.\nconst generate = ((_generate as unknown as { default?: typeof _generate }).default ?? _generate) as typeof _generate;\n\nexport interface RewriteCssTsImportsResult {\n code: string;\n changed: boolean;\n}\n\n/**\n * Rewrite `.css.ts` imports so runtime imports stay pointed at the real module,\n * while a separate `?truss-css` side-effect import is added for generated CSS.\n *\n * I.e. `import { foo } from \"./App.css.ts\"` becomes:\n * - `import { foo } from \"./App.css.ts\"`\n * - `import \"./App.css.ts?truss-css\"`\n *\n * Pure side-effect imports are rewritten directly to the virtual CSS import.\n */\nexport function rewriteCssTsImports(code: string, filename: string): RewriteCssTsImportsResult {\n if (!code.includes(\".css.ts\")) {\n return { code, changed: false };\n }\n\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n const existingCssSideEffects = new Set<string>();\n const neededCssSideEffects = new Set<string>();\n let changed = false;\n\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n if (typeof node.source.value !== \"string\") continue;\n if (!node.source.value.endsWith(\".css.ts\")) continue;\n\n if (node.specifiers.length === 0) {\n node.source = t.stringLiteral(toVirtualCssSpecifier(node.source.value));\n existingCssSideEffects.add(node.source.value);\n changed = true;\n continue;\n }\n\n neededCssSideEffects.add(toVirtualCssSpecifier(node.source.value));\n }\n\n const sideEffectImports: t.ImportDeclaration[] = [];\n for (const source of neededCssSideEffects) {\n if (existingCssSideEffects.has(source)) continue;\n sideEffectImports.push(t.importDeclaration([], t.stringLiteral(source)));\n changed = true;\n }\n\n if (!changed) {\n return { code, changed: false };\n }\n\n if (sideEffectImports.length > 0) {\n const insertIndex = findLastImportIndex(ast) + 1;\n ast.program.body.splice(insertIndex, 0, ...sideEffectImports);\n }\n\n const output = generate(ast, {\n sourceFileName: filename,\n retainLines: false,\n });\n return { code: output.code, changed: true };\n}\n\nfunction toVirtualCssSpecifier(source: string): string {\n return `${source}?truss-css`;\n}\n"],"mappings":";AAAA,SAAS,cAAc,eAAe,kBAAkB;AACxD,SAAS,SAAS,SAAS,YAAY,YAAY;;;ACDnD,YAAY,OAAO;AA8BnB,IAAM,gBAAwC;AAAA,EAC5C,UAAU;AAAA,EACV,UAAU;AAAA,EACV,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,aAAa;AACf;AAGA,IAAM,eAAyB,CAAC,UAAU,UAAU,kBAAkB,WAAW,WAAW;AAG5F,IAAM,qBAA6C;AAAA,EACjD,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,eAAe;AAAA,EACf,YAAY;AACd;AAGO,IAAM,uBAAuB;AAG7B,SAAS,gBAAgB,YAAsD;AACpF,MAAI,CAAC,WAAY,QAAO;AACxB,MAAI,WAAW,SAAS,gBAAgB,WAAW,MAAM;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AAiB,KAAK,SAAU,KAAK;AAC1C,WAAO,eAAe,SAAS,iBAAiB,GAAG,GAAG;AAAA,EACxD,CAAC;AACH;AAEA,SAAS,cAAc,MAAsB;AAC3C,SAAO,KAAK,QAAQ,OAAO,GAAG;AAChC;AAGO,SAAS,YAAY,MAA4B;AACtD,QAAM,MAAM,aAAa,MAAM,MAAM;AACrC,SAAO,KAAK,MAAM,GAAG;AACvB;","names":["conditionPrefix","_traverse","_generate","t","suffix","key","t","t","traverse","_traverse","generate","_generate","parse","t","t","parse","camelToKebab","parse","_generate","t","generate","_generate","parse"]}
|
|
1
|
+
{"version":3,"sources":["../../src/plugin/index.ts","../../src/plugin/emit-truss.ts","../../src/plugin/transform.ts","../../src/plugin/resolve-chain.ts","../../src/plugin/ast-utils.ts","../../src/plugin/rewrite-sites.ts","../../src/plugin/transform-css.ts","../../src/plugin/css-ts-utils.ts","../../src/plugin/rewrite-css-ts-imports.ts"],"sourcesContent":["import { readFileSync, writeFileSync, existsSync } from \"fs\";\nimport { resolve, dirname, isAbsolute, join } from \"path\";\nimport type { TrussMapping } from \"./types\";\nimport type { AtomicRule } from \"./emit-truss\";\nimport { generateCssText } from \"./emit-truss\";\nimport { transformTruss } from \"./transform\";\nimport { transformCssTs } from \"./transform-css\";\nimport { rewriteCssTsImports } from \"./rewrite-css-ts-imports\";\n\nexport interface TrussPluginOptions {\n /** Path to the Css.json mapping file used for transforming files (relative to project root or absolute). */\n mapping: string;\n /** Packages in `node_modules` that should also be transformed, all other `node_modules` files are skipped. */\n externalPackages?: string[];\n}\n\n// Intentionally loose Vite types so we don't depend on the `vite` package at compile time.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface TrussVitePlugin {\n name: string;\n enforce?: \"pre\" | \"post\";\n configResolved?: (config: any) => void;\n buildStart?: () => void;\n resolveId?: (source: string, importer: string | undefined) => string | null;\n load?: (id: string) => string | null;\n transform?: (code: string, id: string) => { code: string; map: any } | null;\n configureServer?: (server: any) => void;\n transformIndexHtml?: (html: string) => string;\n handleHotUpdate?: (ctx: any) => void;\n generateBundle?: (options: any, bundle: any) => void;\n writeBundle?: (options: any, bundle: any) => void;\n}\n\n/** Prefix for virtual CSS module IDs generated from .css.ts files. */\nconst VIRTUAL_CSS_PREFIX = \"\\0truss-css:\";\nconst CSS_TS_QUERY = \"?truss-css\";\n\n/** Virtual module IDs for dev HMR. */\nconst VIRTUAL_CSS_ENDPOINT = \"/virtual:truss.css\";\nconst VIRTUAL_RUNTIME_ID = \"virtual:truss:runtime\";\nconst RESOLVED_VIRTUAL_RUNTIME_ID = \"\\0\" + VIRTUAL_RUNTIME_ID;\n\n/**\n * Vite plugin that transforms `Css.*.$` expressions from truss's CssBuilder DSL\n * into Truss-native style hash objects and `trussProps()`/`mergeProps()` runtime calls.\n *\n * Also supports `.css.ts` files: a `.css.ts` file with\n * `export const css = { \".selector\": Css.blue.$ }` can keep other runtime exports,\n * while imports are supplemented with a virtual CSS side-effect module.\n *\n * In dev mode, serves CSS via a virtual endpoint that the injected runtime keeps in sync.\n * In production, emits a single `truss.css` asset with all atomic rules.\n */\nexport function trussPlugin(opts: TrussPluginOptions): TrussVitePlugin {\n let mapping: TrussMapping | null = null;\n let projectRoot: string;\n let debug = false;\n let isTest = false;\n let isBuild = false;\n const externalPackages = opts.externalPackages ?? [];\n\n // Global CSS rule registry shared across all transform calls within a build\n const cssRegistry = new Map<string, AtomicRule>();\n let cssVersion = 0;\n let lastSentVersion = 0;\n\n function mappingPath(): string {\n return resolve(projectRoot || process.cwd(), opts.mapping);\n }\n\n // Some tooling can call `transform` before `buildStart`; this keeps behavior\n // resilient without requiring hook ordering assumptions.\n function ensureMapping(): TrussMapping {\n if (!mapping) {\n mapping = loadMapping(mappingPath());\n }\n return mapping;\n }\n\n /** Generate the full CSS string from the global registry, ordered by precedence tiers. */\n function collectCss(): string {\n return generateCssText(cssRegistry);\n }\n\n return {\n name: \"truss\",\n enforce: \"pre\",\n\n configResolved(config: any) {\n projectRoot = config.root;\n debug = config.command === \"serve\" || config.mode === \"development\" || config.mode === \"test\";\n isTest = config.mode === \"test\";\n isBuild = config.command === \"build\";\n },\n\n buildStart() {\n ensureMapping();\n // Reset registry at start of each build\n cssRegistry.clear();\n cssVersion = 0;\n lastSentVersion = 0;\n },\n\n // -- Dev mode HMR --\n\n configureServer(server: any) {\n // Skip dev-server setup in test mode — Vitest doesn't start a real HTTP\n // server, so the interval would keep the process alive.\n if (isTest) return;\n\n // Serve the current collected CSS at the virtual endpoint\n server.middlewares.use(function (req: any, res: any, next: any) {\n if (req.url !== VIRTUAL_CSS_ENDPOINT) return next();\n const css = collectCss();\n res.setHeader(\"Content-Type\", \"text/css\");\n res.setHeader(\"Cache-Control\", \"no-store\");\n res.end(css);\n });\n\n // Poll for CSS version changes and push HMR updates\n const interval = setInterval(function () {\n if (cssVersion !== lastSentVersion && server.ws) {\n lastSentVersion = cssVersion;\n server.ws.send({ type: \"custom\", event: \"truss:css-update\" });\n }\n }, 150);\n\n // Clean up interval when server closes\n server.httpServer?.on(\"close\", function () {\n clearInterval(interval);\n });\n },\n\n transformIndexHtml(html: string) {\n if (isBuild) return html;\n // Inject the virtual runtime script for dev mode; it owns style updates.\n const tags = [`<script type=\"module\" src=\"/${VIRTUAL_RUNTIME_ID}\"></script>`].join(\"\\n \");\n return html.replace(\"</head>\", ` ${tags}\\n </head>`);\n },\n\n handleHotUpdate(ctx: any) {\n // Send CSS update event on any file change for safety\n if (ctx.server?.ws) {\n ctx.server.ws.send({ type: \"custom\", event: \"truss:css-update\" });\n }\n },\n\n // -- Virtual module resolution --\n\n resolveId(source: string, importer: string | undefined) {\n // Handle the dev HMR runtime virtual module\n if (source === VIRTUAL_RUNTIME_ID || source === \"/\" + VIRTUAL_RUNTIME_ID) {\n return RESOLVED_VIRTUAL_RUNTIME_ID;\n }\n\n // Handle .css.ts virtual modules\n if (!source.endsWith(CSS_TS_QUERY)) return null;\n\n const absolutePath = resolveImportPath(source.slice(0, -CSS_TS_QUERY.length), importer, projectRoot);\n\n // Only handle it if the .css.ts file actually exists\n if (!existsSync(absolutePath)) return null;\n\n // Return a virtual CSS module ID that maps back to the source .css.ts file.\n // Strip the trailing `.ts` so the ID ends in `.css` — this tells Vite to\n // route the loaded content through its CSS pipeline.\n return VIRTUAL_CSS_PREFIX + absolutePath.slice(0, -3);\n },\n\n load(id: string) {\n // Serve the dev HMR runtime script\n if (id === RESOLVED_VIRTUAL_RUNTIME_ID) {\n return `\n// Truss dev HMR runtime — keeps styles up to date without page reload\n(function() {\n let style = document.getElementById(\"__truss_virtual__\");\n if (!style) {\n style = document.createElement(\"style\");\n style.id = \"__truss_virtual__\";\n document.head.appendChild(style);\n }\n\n function fetchCss() {\n fetch(\"${VIRTUAL_CSS_ENDPOINT}\")\n .then(function(r) { return r.text(); })\n .then(function(css) { style.textContent = css; })\n .catch(function() {});\n }\n\n fetchCss();\n\n if (import.meta.hot) {\n import.meta.hot.on(\"truss:css-update\", fetchCss);\n import.meta.hot.on(\"vite:afterUpdate\", function() {\n setTimeout(fetchCss, 50);\n });\n }\n})();\n`;\n }\n\n // Handle .css.ts virtual modules\n if (!id.startsWith(VIRTUAL_CSS_PREFIX)) return null;\n\n // Re-add `.ts` to recover the original source file path\n const sourcePath = id.slice(VIRTUAL_CSS_PREFIX.length) + \".ts\";\n const sourceCode = readFileSync(sourcePath, \"utf8\");\n return transformCssTs(sourceCode, sourcePath, ensureMapping());\n },\n\n transform(code: string, id: string) {\n // Only process JS/TS/JSX/TSX files\n if (!/\\.[cm]?[jt]sx?(\\?|$)/.test(id)) return null;\n\n const rewrittenImports = rewriteCssTsImports(code, id);\n const rewrittenCode = rewrittenImports.code;\n const hasCssDsl = rewrittenCode.includes(\"Css\");\n if (!hasCssDsl && !rewrittenImports.changed) return null;\n\n const fileId = stripQueryAndHash(id);\n if (isNodeModulesFile(fileId) && !isWhitelistedExternalPackageFile(fileId, externalPackages)) {\n return null;\n }\n\n if (fileId.endsWith(\".css.ts\")) {\n // Keep `.css.ts` modules as normal TS so named exports like class-name\n // constants still work at runtime; only return code when we injected the\n // companion `?truss-css` side-effect import.\n return rewrittenImports.changed ? { code: rewrittenCode, map: null } : null;\n }\n\n if (!hasCssDsl) {\n // Some non-`.css.ts` modules only need the import rewrite and do not have\n // any `Css.*.$` expressions for the main Truss transform to process.\n return { code: rewrittenCode, map: null };\n }\n\n // For regular JS/TS modules that still use the DSL, run the full Truss\n // transform after the import rewrite so both behaviors compose.\n const result = transformTruss(rewrittenCode, fileId, ensureMapping(), {\n debug,\n // In test mode (jsdom), inject CSS directly so document.styleSheets has rules\n injectCss: isTest,\n });\n if (!result) {\n if (!rewrittenImports.changed) return null;\n return { code: rewrittenCode, map: null };\n }\n\n // Merge new rules into the global registry\n if (result.rules) {\n let hasNewRules = false;\n for (const [className, rule] of result.rules) {\n if (!cssRegistry.has(className)) {\n cssRegistry.set(className, rule);\n hasNewRules = true;\n }\n }\n if (hasNewRules) {\n cssVersion++;\n }\n }\n\n return { code: result.code, map: result.map };\n },\n\n // -- Production CSS emission --\n\n generateBundle(_options: any, bundle: any) {\n if (!isBuild) return;\n const css = collectCss();\n if (!css) return;\n\n // Try to append to an existing CSS asset in the bundle\n for (const key of Object.keys(bundle)) {\n const asset = bundle[key];\n if (asset.type === \"asset\" && key.endsWith(\".css\")) {\n asset.source = asset.source + \"\\n\" + css;\n return;\n }\n }\n\n // No existing CSS asset found — emit a standalone truss.css\n (this as any).emitFile({\n type: \"asset\",\n fileName: \"truss.css\",\n source: css,\n });\n },\n\n writeBundle(options: any, bundle: any) {\n if (!isBuild) return;\n const css = collectCss();\n if (!css) return;\n\n // Fallback: if generateBundle didn't find a target, write to disk\n const outDir = options.dir || join(projectRoot, \"dist\");\n const trussPath = join(outDir, \"truss.css\");\n if (!existsSync(trussPath)) {\n // Check if it was appended to an existing CSS asset\n const alreadyEmitted = Object.keys(bundle).some(function (key) {\n const asset = bundle[key];\n return (\n asset.type === \"asset\" &&\n key.endsWith(\".css\") &&\n typeof asset.source === \"string\" &&\n asset.source.includes(css)\n );\n });\n if (!alreadyEmitted) {\n writeFileSync(trussPath, css, \"utf8\");\n }\n }\n },\n };\n}\n\nfunction resolveImportPath(source: string, importer: string | undefined, projectRoot: string | undefined): string {\n if (isAbsolute(source)) {\n return source;\n }\n\n if (importer) {\n return resolve(dirname(importer), source);\n }\n\n return resolve(projectRoot || process.cwd(), source);\n}\n\n/** Strip Vite query/hash suffixes from an id. */\nfunction stripQueryAndHash(id: string): string {\n const queryIndex = id.indexOf(\"?\");\n const hashIndex = id.indexOf(\"#\");\n\n let end = id.length;\n if (queryIndex >= 0) end = Math.min(end, queryIndex);\n if (hashIndex >= 0) end = Math.min(end, hashIndex);\n\n const cleanId = id.slice(0, end);\n // Vite can prefix absolute paths with `/@fs/`.\n if (cleanId.startsWith(\"/@fs/\")) {\n return cleanId.slice(4);\n }\n return cleanId;\n}\n\nfunction isNodeModulesFile(filePath: string): boolean {\n return normalizePath(filePath).includes(\"/node_modules/\");\n}\n\nfunction isWhitelistedExternalPackageFile(filePath: string, externalPackages: string[]): boolean {\n const normalizedPath = normalizePath(filePath);\n return externalPackages.some(function (pkg) {\n return normalizedPath.includes(`/node_modules/${pkg}/`);\n });\n}\n\nfunction normalizePath(path: string): string {\n return path.replace(/\\\\/g, \"/\");\n}\n\n/** Load a truss mapping file synchronously (for tests). */\nexport function loadMapping(path: string): TrussMapping {\n const raw = readFileSync(path, \"utf8\");\n return JSON.parse(raw);\n}\n\nexport type { TrussMapping, TrussMappingEntry } from \"./types\";\n","import * as t from \"@babel/types\";\nimport type { ResolvedChain } from \"./resolve-chain\";\nimport type { ResolvedSegment, TrussMapping } from \"./types\";\n\n// -- Atomic CSS rule model --\n\n/** A single atomic CSS rule: one class, one selector, one or more declarations. */\nexport interface AtomicRule {\n className: string;\n cssProperty: string;\n cssValue: string;\n declarations?: Array<{\n cssProperty: string;\n cssValue: string;\n cssVarName?: string;\n }>;\n pseudoClass?: string;\n mediaQuery?: string;\n pseudoElement?: string;\n /** If true, this is a `var(--name)` rule that needs an `@property` declaration. */\n cssVarName?: string;\n /** For when() rules: the relationship selector context. */\n whenSelector?: {\n relationship: string;\n markerClass: string;\n pseudo: string;\n };\n}\n\n/** Pseudo-class short suffixes for class naming. */\nconst PSEUDO_SUFFIX: Record<string, string> = {\n \":hover\": \"_h\",\n \":focus\": \"_f\",\n \":focus-visible\": \"_fv\",\n \":active\": \"_a\",\n \":disabled\": \"_d\",\n};\n\n/** Pseudo-class precedence order (weakest to strongest). */\nconst PSEUDO_ORDER: string[] = [\":hover\", \":focus\", \":focus-visible\", \":active\", \":disabled\"];\n\n/** Short abbreviations for relationship types in when() class names. */\nconst RELATIONSHIP_SHORT: Record<string, string> = {\n ancestor: \"anc\",\n descendant: \"desc\",\n siblingAfter: \"sibA\",\n siblingBefore: \"sibB\",\n anySibling: \"anyS\",\n};\n\n/** Default marker class name (used when no explicit marker is provided). */\nexport const DEFAULT_MARKER_CLASS = \"__truss_m\";\n\n/** Derive a marker class name from a marker AST node (or use the default). */\nexport function markerClassName(markerNode?: { type: string; name?: string }): string {\n if (!markerNode) return DEFAULT_MARKER_CLASS;\n if (markerNode.type === \"Identifier\" && markerNode.name) {\n return `__truss_m_${markerNode.name}`;\n }\n return `${DEFAULT_MARKER_CLASS}_marker`;\n}\n\n/**\n * Build a when() class name prefix from whenPseudo info.\n *\n * I.e. `when(\"ancestor\", \":hover\")` → `\"wh_anc_h_\"`,\n * `when(\"ancestor\", row, \":hover\")` → `\"wh_anc_h_row_\"`.\n */\nfunction whenPrefix(whenPseudo: { pseudo: string; markerNode?: any; relationship?: string }): string {\n const rel = RELATIONSHIP_SHORT[whenPseudo.relationship ?? \"ancestor\"] ?? \"anc\";\n const pseudoTag = PSEUDO_SUFFIX[whenPseudo.pseudo]?.replace(/^_/, \"\") ?? whenPseudo.pseudo.replace(/^:/, \"\");\n const markerPart = whenPseudo.markerNode?.type === \"Identifier\" ? `${whenPseudo.markerNode.name}_` : \"\";\n return `wh_${rel}_${pseudoTag}_${markerPart}`;\n}\n\n/**\n * Build a condition prefix string for class naming.\n *\n * Conditions are prefixed so class names read naturally in the DOM:\n * I.e. `h_bgBlack` reads as \"on hover, bgBlack\".\n */\nfunction conditionPrefix(\n pseudoClass: string | null | undefined,\n mediaQuery: string | null | undefined,\n pseudoElement: string | null | undefined,\n breakpoints?: Record<string, string>,\n): string {\n const parts: string[] = [];\n if (pseudoElement) {\n // I.e. \"::placeholder\" → \"placeholder_\"\n parts.push(`${pseudoElement.replace(/^::/, \"\")}_`);\n }\n if (mediaQuery && breakpoints) {\n // Find breakpoint name, i.e. \"ifSm\" → \"sm_\"\n const bpKey = Object.entries(breakpoints).find(([, v]) => v === mediaQuery)?.[0];\n if (bpKey) {\n const shortName = bpKey.replace(/^if/, \"\").toLowerCase();\n parts.push(`${shortName}_`);\n } else {\n parts.push(\"mq_\");\n }\n } else if (mediaQuery) {\n parts.push(\"mq_\");\n }\n if (pseudoClass) {\n const tag = PSEUDO_SUFFIX[pseudoClass];\n // PSEUDO_SUFFIX values still have a leading underscore; strip it and add trailing\n if (tag) parts.push(`${tag.replace(/^_/, \"\")}_`);\n else parts.push(`${pseudoClass.replace(/^:/, \"\")}_`);\n }\n return parts.join(\"\");\n}\n\n/** Convert camelCase CSS property to kebab-case. */\nfunction camelToKebab(s: string): string {\n return s.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`).replace(/^(webkit|moz|ms)-/, \"-$1-\");\n}\n\n/** Clean a CSS value for use in a class name. */\nfunction cleanValueForClassName(value: string): string {\n // I.e. -8px → neg8px, 16px → 16px, \"0 0 0 1px blue\" → 0_0_0_1px_blue\n let cleaned = value;\n if (cleaned.startsWith(\"-\")) {\n cleaned = \"neg\" + cleaned.slice(1);\n }\n return cleaned\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n}\n\n/**\n * Build a reverse lookup from `\"cssProperty\\0cssValue\"` → canonical abbreviation name.\n *\n * For each single-property static abbreviation in the mapping, records the\n * canonical name so multi-property abbreviations can reuse it.\n * I.e. `{ paddingTop: \"8px\" }` → `\"pt1\"`, `{ borderStyle: \"solid\" }` → `\"bss\"`.\n */\nfunction buildLonghandLookup(mapping: TrussMapping): Map<string, string> {\n const lookup = new Map<string, string>();\n for (const [abbrev, entry] of Object.entries(mapping.abbreviations)) {\n if (entry.kind !== \"static\") continue;\n const props = Object.keys(entry.defs);\n if (props.length !== 1) continue;\n const prop = props[0];\n const value = String(entry.defs[prop]);\n const key = `${prop}\\0${value}`;\n // First match wins — if multiple abbreviations produce the same declaration,\n // the one that appears first in the mapping is canonical.\n if (!lookup.has(key)) {\n lookup.set(key, abbrev);\n }\n }\n return lookup;\n}\n\n/** Cached longhand lookup per mapping (keyed by identity). */\nlet cachedMapping: TrussMapping | null = null;\nlet cachedLookup: Map<string, string> | null = null;\n\n/** Get or build the longhand lookup for a mapping. */\nfunction getLonghandLookup(mapping: TrussMapping): Map<string, string> {\n if (cachedMapping !== mapping) {\n cachedMapping = mapping;\n cachedLookup = buildLonghandLookup(mapping);\n }\n return cachedLookup!;\n}\n\n/**\n * Compute the base class name for a static segment.\n *\n * For multi-property abbreviations, looks up the canonical single-property\n * abbreviation name so classes are maximally reused.\n * I.e. `p1` → `pt1`, `pr1`, `pb1`, `pl1` (not `p1_paddingTop`, etc.)\n * I.e. `ba` → `bss`, `bw1` (not `ba_borderStyle`, etc.)\n *\n * For literal-folded variables (argResolved set), includes the value:\n * I.e. `mt(2)` → `mt_16px`, `bc(\"red\")` → `bc_red`.\n */\nfunction computeStaticBaseName(\n seg: ResolvedSegment,\n cssProp: string,\n cssValue: string,\n isMultiProp: boolean,\n mapping: TrussMapping,\n): string {\n const abbrev = seg.key.split(\"__\")[0];\n\n if (seg.argResolved !== undefined) {\n const valuePart = cleanValueForClassName(seg.argResolved);\n if (isMultiProp) {\n // Try to find a canonical single-property abbreviation for this longhand\n const lookup = getLonghandLookup(mapping);\n const canonical = lookup.get(`${cssProp}\\0${cssValue}`);\n if (canonical) return canonical;\n return `${abbrev}_${valuePart}_${cssProp}`;\n }\n return `${abbrev}_${valuePart}`;\n }\n\n if (isMultiProp) {\n // Try to find a canonical single-property abbreviation for this longhand\n const lookup = getLonghandLookup(mapping);\n const canonical = lookup.get(`${cssProp}\\0${cssValue}`);\n if (canonical) return canonical;\n return `${abbrev}_${cssProp}`;\n }\n\n return abbrev;\n}\n\n// -- Collecting atomic rules from resolved chains --\n\nexport interface CollectedRules {\n rules: Map<string, AtomicRule>;\n needsMaybeInc: boolean;\n}\n\n/**\n * Collect all atomic CSS rules from resolved chains.\n *\n * This processes segments BEFORE mergeOverlappingConditions — each segment\n * maps directly to one or more atomic rules based on its condition context.\n */\nexport function collectAtomicRules(chains: ResolvedChain[], mapping: TrussMapping): CollectedRules {\n const rules = new Map<string, AtomicRule>();\n let needsMaybeInc = false;\n\n for (const chain of chains) {\n for (const part of chain.parts) {\n const segs = part.type === \"unconditional\" ? part.segments : [...part.thenSegments, ...part.elseSegments];\n for (const seg of segs) {\n if (seg.error || seg.styleArrayArg || seg.typographyLookup) continue;\n if (seg.whenPseudo) {\n if (seg.variableProps) {\n if (seg.incremented) needsMaybeInc = true;\n collectWhenVariableRules(rules, seg, mapping);\n } else {\n collectWhenStaticRules(rules, seg, mapping);\n }\n continue;\n }\n if (seg.variableProps) {\n if (seg.incremented) needsMaybeInc = true;\n collectVariableRules(rules, seg, mapping);\n } else {\n collectStaticRules(rules, seg, mapping);\n }\n }\n }\n }\n\n return { rules, needsMaybeInc };\n}\n\n/** Collect atomic rules for a static segment (may have multiple CSS properties). */\nfunction collectStaticRules(rules: Map<string, AtomicRule>, seg: ResolvedSegment, mapping: TrussMapping): void {\n // The segment's defs may be wrapped with StyleX-style condition nesting from\n // wrapDefsWithConditions. We use the segment's raw condition fields instead.\n const rawDefs = unwrapDefs(seg.defs, seg.pseudoElement);\n const prefix = conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints);\n const isMultiProp = Object.keys(rawDefs).length > 1;\n\n for (const [cssProp, value] of Object.entries(rawDefs)) {\n const cssValue = extractLeafValue(value);\n if (cssValue === null) continue;\n\n const baseName = computeStaticBaseName(seg, cssProp, String(cssValue), isMultiProp, mapping);\n const className = prefix ? `${prefix}${baseName}` : baseName;\n\n if (!rules.has(className)) {\n rules.set(className, {\n className,\n cssProperty: camelToKebab(cssProp),\n cssValue: String(cssValue),\n pseudoClass: seg.pseudoClass ?? undefined,\n mediaQuery: seg.mediaQuery ?? undefined,\n pseudoElement: seg.pseudoElement ?? undefined,\n });\n }\n }\n}\n\n/** Collect atomic rules for a variable segment. */\nfunction collectVariableRules(rules: Map<string, AtomicRule>, seg: ResolvedSegment, mapping: TrussMapping): void {\n const prefix = conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints);\n const segmentBaseKey = seg.key.split(\"__\")[0];\n\n for (const prop of seg.variableProps!) {\n const baseKey = seg.key.split(\"__\")[0];\n const className = prefix ? `${prefix}${baseKey}_var` : `${baseKey}_var`;\n const varName = toCssVariableName(className, baseKey, prop);\n const declaration = { cssProperty: camelToKebab(prop), cssValue: `var(${varName})`, cssVarName: varName };\n\n const existingRule = rules.get(className);\n if (!existingRule) {\n rules.set(className, {\n className,\n cssProperty: declaration.cssProperty,\n cssValue: declaration.cssValue,\n declarations: [declaration],\n pseudoClass: seg.pseudoClass ?? undefined,\n mediaQuery: seg.mediaQuery ?? undefined,\n pseudoElement: seg.pseudoElement ?? undefined,\n cssVarName: varName,\n });\n continue;\n }\n\n existingRule.declarations ??= [\n {\n cssProperty: existingRule.cssProperty,\n cssValue: existingRule.cssValue,\n cssVarName: existingRule.cssVarName,\n },\n ];\n if (\n !existingRule.declarations.some(function (entry) {\n return entry.cssProperty === declaration.cssProperty;\n })\n ) {\n existingRule.declarations.push(declaration);\n }\n }\n\n // Extra static defs alongside variable props\n if (seg.variableExtraDefs) {\n for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {\n const extraBase = `${segmentBaseKey}_${cssProp}`;\n const extraName = prefix ? `${prefix}${extraBase}` : extraBase;\n if (!rules.has(extraName)) {\n rules.set(extraName, {\n className: extraName,\n cssProperty: camelToKebab(cssProp),\n cssValue: String(value),\n pseudoClass: seg.pseudoClass ?? undefined,\n mediaQuery: seg.mediaQuery ?? undefined,\n pseudoElement: seg.pseudoElement ?? undefined,\n });\n }\n }\n }\n}\n\n/** Collect atomic rules for a static when() segment. */\nfunction collectWhenStaticRules(rules: Map<string, AtomicRule>, seg: ResolvedSegment, mapping: TrussMapping): void {\n const wp = seg.whenPseudo!;\n const prefix = whenPrefix(wp);\n const rawDefs = seg.defs;\n const isMultiProp = Object.keys(rawDefs).length > 1;\n const mClass = markerClassName(wp.markerNode);\n\n for (const [cssProp, value] of Object.entries(rawDefs)) {\n const cssValue = typeof value === \"string\" || typeof value === \"number\" ? value : extractLeafValue(value);\n if (cssValue === null) continue;\n\n const baseName = computeStaticBaseName(seg, cssProp, String(cssValue), isMultiProp, mapping);\n const className = `${prefix}${baseName}`;\n\n if (!rules.has(className)) {\n rules.set(className, {\n className,\n cssProperty: camelToKebab(cssProp),\n cssValue: String(cssValue),\n whenSelector: {\n relationship: wp.relationship ?? \"ancestor\",\n markerClass: mClass,\n pseudo: wp.pseudo,\n },\n });\n }\n }\n}\n\n/** Collect atomic rules for a variable when() segment. */\nfunction collectWhenVariableRules(rules: Map<string, AtomicRule>, seg: ResolvedSegment, mapping: TrussMapping): void {\n const wp = seg.whenPseudo!;\n const prefix = whenPrefix(wp);\n const segmentBaseKey = seg.key.split(\"__\")[0];\n const mClass = markerClassName(wp.markerNode);\n\n for (const prop of seg.variableProps!) {\n const baseKey = seg.key.split(\"__\")[0];\n const className = `${prefix}${baseKey}_var`;\n const varName = toCssVariableName(className, baseKey, prop);\n const declaration = { cssProperty: camelToKebab(prop), cssValue: `var(${varName})`, cssVarName: varName };\n\n const existingRule = rules.get(className);\n if (!existingRule) {\n rules.set(className, {\n className,\n cssProperty: declaration.cssProperty,\n cssValue: declaration.cssValue,\n declarations: [declaration],\n cssVarName: varName,\n whenSelector: {\n relationship: wp.relationship ?? \"ancestor\",\n markerClass: mClass,\n pseudo: wp.pseudo,\n },\n });\n continue;\n }\n\n existingRule.declarations ??= [\n {\n cssProperty: existingRule.cssProperty,\n cssValue: existingRule.cssValue,\n cssVarName: existingRule.cssVarName,\n },\n ];\n if (\n !existingRule.declarations.some(function (entry) {\n return entry.cssProperty === declaration.cssProperty;\n })\n ) {\n existingRule.declarations.push(declaration);\n }\n }\n\n if (seg.variableExtraDefs) {\n for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {\n const extraName = `${prefix}${segmentBaseKey}_${cssProp}`;\n if (!rules.has(extraName)) {\n rules.set(extraName, {\n className: extraName,\n cssProperty: camelToKebab(cssProp),\n cssValue: String(value),\n whenSelector: {\n relationship: wp.relationship ?? \"ancestor\",\n markerClass: mClass,\n pseudo: wp.pseudo,\n },\n });\n }\n }\n }\n}\n\n/** Unwrap StyleX-style condition nesting and pseudo-element wrapping to get raw defs. */\nfunction unwrapDefs(defs: Record<string, unknown>, pseudoElement?: string | null): Record<string, unknown> {\n let result = defs;\n // Unwrap pseudo-element wrapper: { \"::placeholder\": { color: ... } } → { color: ... }\n if (pseudoElement && result[pseudoElement] && typeof result[pseudoElement] === \"object\") {\n result = result[pseudoElement] as Record<string, unknown>;\n }\n // Unwrap condition nesting: { color: { default: null, \":hover\": \"blue\" } } → { color: \"blue\" }\n // For segments with conditions, we want just the leaf value\n const unwrapped: Record<string, unknown> = {};\n for (const [prop, val] of Object.entries(result)) {\n unwrapped[prop] = extractLeafValue(val) ?? val;\n }\n return unwrapped;\n}\n\n/**\n * Extract the actual CSS value from a potentially nested condition object.\n * I.e. `{ default: null, \":hover\": \"blue\" }` → `\"blue\"`,\n * or `{ default: null, \":hover\": { default: null, \"@media...\": \"blue\" } }` → `\"blue\"`.\n */\nfunction extractLeafValue(value: unknown): string | number | null {\n if (typeof value === \"string\" || typeof value === \"number\") return value;\n if (value === null) return null;\n if (typeof value === \"object\") {\n const obj = value as Record<string, unknown>;\n // Find the non-default, non-null leaf\n for (const [k, v] of Object.entries(obj)) {\n if (k === \"default\") continue;\n if (typeof v === \"string\" || typeof v === \"number\") return v;\n if (typeof v === \"object\" && v !== null) return extractLeafValue(v);\n }\n // If only default, return it\n if (\"default\" in obj && obj.default !== null) {\n return extractLeafValue(obj.default);\n }\n }\n return null;\n}\n\n// -- CSS text generation --\n\n/** Generate the full CSS text from collected rules, ordered by specificity tiers. */\nexport function generateCssText(rules: Map<string, AtomicRule>): string {\n const allRules = Array.from(rules.values());\n\n // Sort into tiers\n const base: AtomicRule[] = [];\n const pseudo: Map<string, AtomicRule[]> = new Map();\n const pseudoElement: AtomicRule[] = [];\n const whenRules: AtomicRule[] = [];\n const media: AtomicRule[] = [];\n const mediaPseudo: AtomicRule[] = [];\n const mediaPseudoElement: AtomicRule[] = [];\n\n for (const rule of allRules) {\n if (rule.whenSelector) {\n whenRules.push(rule);\n } else if (rule.mediaQuery && rule.pseudoClass) {\n mediaPseudo.push(rule);\n } else if (rule.mediaQuery && rule.pseudoElement) {\n mediaPseudoElement.push(rule);\n } else if (rule.mediaQuery) {\n media.push(rule);\n } else if (rule.pseudoClass && rule.pseudoElement) {\n // pseudo-class + pseudo-element, emit in pseudo tier\n const tier = pseudo.get(rule.pseudoClass) ?? [];\n tier.push(rule);\n pseudo.set(rule.pseudoClass, tier);\n } else if (rule.pseudoElement) {\n pseudoElement.push(rule);\n } else if (rule.pseudoClass) {\n const tier = pseudo.get(rule.pseudoClass) ?? [];\n tier.push(rule);\n pseudo.set(rule.pseudoClass, tier);\n } else {\n base.push(rule);\n }\n }\n\n const lines: string[] = [];\n\n // Tier 1: base atoms\n for (const rule of base) {\n lines.push(formatBaseRule(rule));\n }\n\n // Tier 2: pseudo-class atoms, ordered by precedence\n for (const pc of PSEUDO_ORDER) {\n const tier = pseudo.get(pc);\n if (!tier) continue;\n for (const rule of tier) {\n lines.push(formatPseudoRule(rule));\n }\n }\n // Any pseudo-classes not in the table (shouldn't happen, but be safe)\n for (const [pc, tier] of Array.from(pseudo.entries())) {\n if (PSEUDO_ORDER.includes(pc)) continue;\n for (const rule of tier) {\n lines.push(formatPseudoRule(rule));\n }\n }\n\n // Tier 3: pseudo-element atoms\n for (const rule of pseudoElement) {\n lines.push(formatPseudoElementRule(rule));\n }\n\n // Tier 4: when() relationship selector atoms\n for (const rule of whenRules) {\n lines.push(formatWhenRule(rule));\n }\n\n // Tier 5: media atoms (doubled selector)\n for (const rule of media) {\n lines.push(formatMediaRule(rule));\n }\n\n // Tier 5: media+pseudo atoms (doubled selector + pseudo)\n for (const rule of mediaPseudo) {\n lines.push(formatMediaPseudoRule(rule));\n }\n\n // Tier 6: media+pseudo-element atoms\n for (const rule of mediaPseudoElement) {\n lines.push(formatMediaPseudoElementRule(rule));\n }\n\n // @property declarations for variable rules\n for (const rule of allRules) {\n for (const declaration of getRuleDeclarations(rule)) {\n if (declaration.cssVarName) {\n lines.push(`@property ${declaration.cssVarName} {\\n syntax: \"*\";\\n inherits: false;\\n}`);\n }\n }\n }\n\n return lines.join(\"\\n\");\n}\n\nfunction formatBaseRule(rule: AtomicRule): string {\n return formatRuleBlock(`.${rule.className}`, rule);\n}\n\nfunction formatPseudoRule(rule: AtomicRule): string {\n const pe = rule.pseudoElement ? rule.pseudoElement : \"\";\n return formatRuleBlock(`.${rule.className}${rule.pseudoClass}${pe}`, rule);\n}\n\nfunction formatPseudoElementRule(rule: AtomicRule): string {\n return formatRuleBlock(`.${rule.className}${rule.pseudoElement}`, rule);\n}\n\nfunction formatWhenRule(rule: AtomicRule): string {\n const whenSelector = rule.whenSelector;\n if (!whenSelector) {\n return formatBaseRule(rule);\n }\n\n const markerSelector = `.${whenSelector.markerClass}${whenSelector.pseudo}`;\n const targetSelector = `.${rule.className}`;\n\n if (whenSelector.relationship === \"ancestor\") {\n return formatRuleBlock(`${markerSelector} ${targetSelector}`, rule);\n }\n if (whenSelector.relationship === \"descendant\") {\n return formatRuleBlock(`${targetSelector}:has(${markerSelector})`, rule);\n }\n if (whenSelector.relationship === \"siblingAfter\") {\n return formatRuleBlock(`${targetSelector}:has(~ ${markerSelector})`, rule);\n }\n if (whenSelector.relationship === \"siblingBefore\") {\n return formatRuleBlock(`${markerSelector} ~ ${targetSelector}`, rule);\n }\n if (whenSelector.relationship === \"anySibling\") {\n return formatRuleBlock(`${targetSelector}:has(~ ${markerSelector}), ${markerSelector} ~ ${targetSelector}`, rule);\n }\n\n return formatRuleBlock(`${markerSelector} ${targetSelector}`, rule);\n}\n\nfunction formatMediaRule(rule: AtomicRule): string {\n return formatNestedRuleBlock(rule.mediaQuery!, `.${rule.className}.${rule.className}`, rule);\n}\n\nfunction formatMediaPseudoRule(rule: AtomicRule): string {\n return formatNestedRuleBlock(rule.mediaQuery!, `.${rule.className}.${rule.className}${rule.pseudoClass}`, rule);\n}\n\nfunction formatMediaPseudoElementRule(rule: AtomicRule): string {\n const pe = rule.pseudoElement ?? \"\";\n return formatNestedRuleBlock(rule.mediaQuery!, `.${rule.className}.${rule.className}${pe}`, rule);\n}\n\nfunction getRuleDeclarations(rule: AtomicRule): Array<{ cssProperty: string; cssValue: string; cssVarName?: string }> {\n return rule.declarations ?? [{ cssProperty: rule.cssProperty, cssValue: rule.cssValue, cssVarName: rule.cssVarName }];\n}\n\nfunction formatRuleBlock(selector: string, rule: AtomicRule): string {\n const body = getRuleDeclarations(rule)\n .map(function (declaration) {\n return ` ${declaration.cssProperty}: ${declaration.cssValue};`;\n })\n .join(\"\\n\");\n return `${selector} {\\n${body}\\n}`;\n}\n\nfunction formatNestedRuleBlock(wrapper: string, selector: string, rule: AtomicRule): string {\n const body = getRuleDeclarations(rule)\n .map(function (declaration) {\n return ` ${declaration.cssProperty}: ${declaration.cssValue};`;\n })\n .join(\"\\n\");\n return `${wrapper} {\\n ${selector} {\\n${body}\\n }\\n}`;\n}\n\n// -- AST generation for style hash objects --\n\n/**\n * Build the style hash AST for a list of segments (from one Css.*.$ expression).\n *\n * Groups segments by CSS property and builds space-separated class bundles.\n * Returns an array of ObjectProperty nodes for `{ display: \"df\", color: \"black blue_h\" }`.\n */\nexport function buildStyleHashProperties(\n segments: ResolvedSegment[],\n mapping: TrussMapping,\n maybeIncHelperName?: string | null,\n): t.ObjectProperty[] {\n // Group: cssProperty -> list of { className, isVariable, varName, argNode, incremented, appendPx }\n const propGroups = new Map<\n string,\n Array<{\n className: string;\n isVariable: boolean;\n varName?: string;\n argNode?: unknown;\n incremented?: boolean;\n appendPx?: boolean;\n }>\n >();\n\n for (const seg of segments) {\n if (seg.error || seg.styleArrayArg || seg.typographyLookup) continue;\n\n if (seg.variableProps) {\n const prefix = seg.whenPseudo\n ? whenPrefix(seg.whenPseudo)\n : conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints);\n const segmentBaseKey = seg.key.split(\"__\")[0];\n\n for (const prop of seg.variableProps) {\n const baseKey = seg.key.split(\"__\")[0];\n const className = prefix ? `${prefix}${baseKey}_var` : `${baseKey}_var`;\n const varName = toCssVariableName(className, baseKey, prop);\n\n if (!propGroups.has(prop)) propGroups.set(prop, []);\n propGroups.get(prop)!.push({\n className,\n isVariable: true,\n varName,\n argNode: seg.argNode,\n incremented: seg.incremented,\n appendPx: seg.appendPx,\n });\n }\n\n // Extra static defs\n if (seg.variableExtraDefs) {\n for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {\n const extraBase = `${segmentBaseKey}_${cssProp}`;\n const extraName = prefix ? `${prefix}${extraBase}` : extraBase;\n if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);\n propGroups.get(cssProp)!.push({ className: extraName, isVariable: false });\n }\n }\n } else {\n const rawDefs = seg.whenPseudo ? seg.defs : unwrapDefs(seg.defs, seg.pseudoElement);\n const prefix = seg.whenPseudo\n ? whenPrefix(seg.whenPseudo)\n : conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints);\n const isMultiProp = Object.keys(rawDefs).length > 1;\n\n for (const cssProp of Object.keys(rawDefs)) {\n const val = extractLeafValue(rawDefs[cssProp]);\n if (val === null) continue;\n\n const baseName = computeStaticBaseName(seg, cssProp, String(val), isMultiProp, mapping);\n const className = prefix ? `${prefix}${baseName}` : baseName;\n\n if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);\n propGroups.get(cssProp)!.push({ className, isVariable: false });\n }\n }\n }\n\n // Build AST properties\n const properties: t.ObjectProperty[] = [];\n\n for (const [cssProp, entries] of Array.from(propGroups.entries())) {\n const classNames = entries.map((e) => e.className).join(\" \");\n const variableEntries = entries.filter((e) => e.isVariable);\n\n if (variableEntries.length > 0) {\n // Tuple: [classNames, { vars }]\n const varsProps: t.ObjectProperty[] = [];\n for (const dyn of variableEntries) {\n let valueExpr: t.Expression = dyn.argNode as t.Expression;\n if (dyn.incremented) {\n // Wrap with __maybeInc (or whatever name was reserved to avoid collisions)\n valueExpr = t.callExpression(t.identifier(maybeIncHelperName ?? \"__maybeInc\"), [valueExpr]);\n } else if (dyn.appendPx) {\n // Wrap with `${v}px`\n valueExpr = t.templateLiteral(\n [t.templateElement({ raw: \"\", cooked: \"\" }, false), t.templateElement({ raw: \"px\", cooked: \"px\" }, true)],\n [valueExpr],\n );\n }\n varsProps.push(t.objectProperty(t.stringLiteral(dyn.varName!), valueExpr));\n }\n\n const tuple = t.arrayExpression([t.stringLiteral(classNames), t.objectExpression(varsProps)]);\n\n properties.push(t.objectProperty(toPropertyKey(cssProp), tuple));\n } else {\n // Static: plain string\n properties.push(t.objectProperty(toPropertyKey(cssProp), t.stringLiteral(classNames)));\n }\n }\n\n return properties;\n}\n\n/** Build a CSS variable name from the real CSS property and class condition prefix. */\nfunction toCssVariableName(className: string, baseKey: string, cssProp: string): string {\n const baseClassName = `${baseKey}_var`;\n const conditionPrefix = className.endsWith(baseClassName) ? className.slice(0, -baseClassName.length) : \"\";\n return `--${conditionPrefix}${cssProp}`;\n}\n\n// -- Helper declarations --\n\n/** Build the per-file increment helper: `const __maybeInc = (inc) => typeof inc === \"string\" ? inc : \\`${inc * N}px\\`` */\nexport function buildMaybeIncDeclaration(helperName: string, increment: number): t.VariableDeclaration {\n const incParam = t.identifier(\"inc\");\n const body = t.blockStatement([\n t.returnStatement(\n t.conditionalExpression(\n t.binaryExpression(\"===\", t.unaryExpression(\"typeof\", incParam), t.stringLiteral(\"string\")),\n incParam,\n t.templateLiteral(\n [t.templateElement({ raw: \"\", cooked: \"\" }, false), t.templateElement({ raw: \"px\", cooked: \"px\" }, true)],\n [t.binaryExpression(\"*\", incParam, t.numericLiteral(increment))],\n ),\n ),\n ),\n ]);\n\n return t.variableDeclaration(\"const\", [\n t.variableDeclarator(t.identifier(helperName), t.arrowFunctionExpression([incParam], body)),\n ]);\n}\n\n/** Use identifier keys when legal, otherwise string literal keys. */\nfunction toPropertyKey(key: string): t.Identifier | t.StringLiteral {\n return isValidIdentifier(key) ? t.identifier(key) : t.stringLiteral(key);\n}\n\nfunction isValidIdentifier(s: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(s);\n}\n\n/** Build a runtime lookup table declaration: `const __typography = { f24: { fontSize: \"f24\" }, ... }`. */\nexport function buildRuntimeLookupDeclaration(\n lookupName: string,\n segmentsByName: Record<string, ResolvedSegment[]>,\n mapping: TrussMapping,\n): t.VariableDeclaration {\n const properties: t.ObjectProperty[] = [];\n for (const [name, segs] of Object.entries(segmentsByName)) {\n const hashProps = buildStyleHashProperties(segs, mapping);\n properties.push(t.objectProperty(t.identifier(name), t.objectExpression(hashProps)));\n }\n return t.variableDeclaration(\"const\", [\n t.variableDeclarator(t.identifier(lookupName), t.objectExpression(properties)),\n ]);\n}\n","import { parse } from \"@babel/parser\";\nimport _traverse from \"@babel/traverse\";\nimport type { NodePath } from \"@babel/traverse\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport { basename } from \"path\";\nimport type { TrussMapping, ResolvedSegment } from \"./types\";\nimport { resolveFullChain, type ResolvedChain } from \"./resolve-chain\";\nimport {\n collectTopLevelBindings,\n reservePreferredName,\n findCssImportBinding,\n removeCssImport,\n hasCssMethodCall,\n findNamedImportBinding,\n upsertNamedImports,\n extractChain,\n} from \"./ast-utils\";\nimport {\n collectAtomicRules,\n generateCssText,\n buildMaybeIncDeclaration,\n buildRuntimeLookupDeclaration,\n} from \"./emit-truss\";\nimport { rewriteExpressionSites, type ExpressionSite } from \"./rewrite-sites\";\n\n// Babel packages are CJS today; normalize default interop across loaders.\nconst traverse = ((_traverse as unknown as { default?: typeof _traverse }).default ?? _traverse) as typeof _traverse;\nconst generate = ((_generate as unknown as { default?: typeof _generate }).default ?? _generate) as typeof _generate;\n\nexport interface TransformResult {\n code: string;\n map?: unknown;\n /** The generated CSS text for this file's Truss usages. */\n css: string;\n /** The atomic CSS rules collected during this transform, keyed by class name. */\n rules: Map<string, import(\"./emit-truss\").AtomicRule>;\n}\n\nexport interface TransformTrussOptions {\n debug?: boolean;\n /** When true, inject `__injectTrussCSS(cssText)` call for jsdom/test environments. */\n injectCss?: boolean;\n}\n\n/**\n * The core transform function. Given a source file's code and the truss mapping,\n * finds all `Css.*.$` expressions and rewrites them into Truss-native style hash\n * objects and `trussProps()`/`mergeProps()` runtime calls.\n *\n * Returns null if the file doesn't use Css.\n */\nexport function transformTruss(\n code: string,\n filename: string,\n mapping: TrussMapping,\n options: TransformTrussOptions = {},\n): TransformResult | null {\n // Fast bail: skip files that don't reference Css\n if (!code.includes(\"Css\")) return null;\n\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n // Step 1: Find the Css import binding name\n const cssBindingName = findCssImportBinding(ast);\n if (!cssBindingName) return null;\n\n // Step 2: Collect all Css expression sites\n const sites: ExpressionSite[] = [];\n const errorMessages: Array<{ message: string; line: number | null }> = [];\n\n traverse(ast, {\n MemberExpression(path: NodePath<t.MemberExpression>) {\n if (!t.isIdentifier(path.node.property, { name: \"$\" })) return;\n if (path.node.computed) return;\n\n const chain = extractChain(path.node.object, cssBindingName);\n if (!chain) return;\n\n const parentPath = path.parentPath;\n if (parentPath && parentPath.isMemberExpression() && t.isIdentifier(parentPath.node.property, { name: \"$\" })) {\n return;\n }\n\n // Use skipMerge: true so each segment retains its individual condition fields\n const resolvedChain = resolveFullChain(chain, mapping, { skipMerge: true });\n sites.push({ path, resolvedChain });\n\n const line = path.node.loc?.start.line ?? null;\n for (const err of resolvedChain.errors) {\n errorMessages.push({ message: err, line });\n }\n },\n });\n\n // Also check for Css.props(...) calls which need rewriting even without Css.$ sites\n const hasCssPropsCall = hasCssMethodCall(ast, cssBindingName, \"props\");\n if (sites.length === 0 && !hasCssPropsCall) return null;\n\n // Step 3: Collect atomic rules for CSS generation\n const chains = sites.map((s) => s.resolvedChain);\n const { rules, needsMaybeInc } = collectAtomicRules(chains, mapping);\n const cssText = generateCssText(rules);\n\n // Step 4: Reserve local names for injected helpers\n const usedTopLevelNames = collectTopLevelBindings(ast);\n const maybeIncHelperName = needsMaybeInc ? reservePreferredName(usedTopLevelNames, \"__maybeInc\") : null;\n const existingMergePropsHelperName = findNamedImportBinding(ast, \"@homebound/truss/runtime\", \"mergeProps\");\n const mergePropsHelperName = existingMergePropsHelperName ?? reservePreferredName(usedTopLevelNames, \"mergeProps\");\n const needsMergePropsHelper = { current: false };\n const existingTrussPropsHelperName = findNamedImportBinding(ast, \"@homebound/truss/runtime\", \"trussProps\");\n const trussPropsHelperName = existingTrussPropsHelperName ?? reservePreferredName(usedTopLevelNames, \"trussProps\");\n const needsTrussPropsHelper = { current: false };\n const existingTrussDebugInfoName = findNamedImportBinding(ast, \"@homebound/truss/runtime\", \"TrussDebugInfo\");\n const trussDebugInfoName = existingTrussDebugInfoName ?? reservePreferredName(usedTopLevelNames, \"TrussDebugInfo\");\n const needsTrussDebugInfo = { current: false };\n\n // Collect typography runtime lookups\n const runtimeLookupNames = new Map<string, string>();\n const runtimeLookups = collectRuntimeLookups(chains);\n for (const [lookupKey] of runtimeLookups) {\n runtimeLookupNames.set(lookupKey, reservePreferredName(usedTopLevelNames, `__${lookupKey}`));\n }\n\n // Step 5: Rewrite Css sites in-place\n rewriteExpressionSites({\n ast,\n sites,\n cssBindingName,\n filename: basename(filename),\n debug: options.debug ?? false,\n mapping,\n maybeIncHelperName,\n mergePropsHelperName,\n needsMergePropsHelper,\n trussPropsHelperName,\n needsTrussPropsHelper,\n trussDebugInfoName,\n needsTrussDebugInfo,\n skippedCssPropMessages: errorMessages,\n runtimeLookupNames,\n });\n\n // Step 6: Remove Css import now that all usages were rewritten\n removeCssImport(ast, cssBindingName);\n\n // Step 7: Inject runtime imports\n const runtimeImports: Array<{ importedName: string; localName: string }> = [];\n if (needsTrussPropsHelper.current) {\n runtimeImports.push({ importedName: \"trussProps\", localName: trussPropsHelperName });\n }\n if (needsMergePropsHelper.current) {\n runtimeImports.push({ importedName: \"mergeProps\", localName: mergePropsHelperName });\n }\n if (needsTrussDebugInfo.current) {\n runtimeImports.push({ importedName: \"TrussDebugInfo\", localName: trussDebugInfoName });\n }\n if (options.injectCss) {\n runtimeImports.push({ importedName: \"__injectTrussCSS\", localName: \"__injectTrussCSS\" });\n }\n if (runtimeImports.length > 0) {\n upsertNamedImports(ast, \"@homebound/truss/runtime\", runtimeImports);\n }\n\n // Step 8: Insert helper declarations after imports\n const declarationsToInsert: t.Statement[] = [];\n if (maybeIncHelperName) {\n declarationsToInsert.push(buildMaybeIncDeclaration(maybeIncHelperName, mapping.increment));\n }\n\n // Insert runtime lookup tables for typography\n for (const [lookupKey, lookup] of runtimeLookups) {\n const lookupName = runtimeLookupNames.get(lookupKey);\n if (!lookupName) continue;\n declarationsToInsert.push(buildRuntimeLookupDeclaration(lookupName, lookup.segmentsByName, mapping));\n }\n\n // Inject __injectTrussCSS call if requested\n if (options.injectCss && cssText.length > 0) {\n declarationsToInsert.push(\n t.expressionStatement(t.callExpression(t.identifier(\"__injectTrussCSS\"), [t.stringLiteral(cssText)])),\n );\n }\n\n // Emit console.error calls for any unsupported patterns\n for (const { message, line } of errorMessages) {\n const location = line !== null ? `${filename}:${line}` : filename;\n const logMessage = `${message} (${location})`;\n declarationsToInsert.push(\n t.expressionStatement(\n t.callExpression(t.memberExpression(t.identifier(\"console\"), t.identifier(\"error\")), [\n t.stringLiteral(logMessage),\n ]),\n ),\n );\n }\n\n if (declarationsToInsert.length > 0) {\n const insertIndex = ast.program.body.findIndex(function (node) {\n return !t.isImportDeclaration(node);\n });\n ast.program.body.splice(insertIndex === -1 ? ast.program.body.length : insertIndex, 0, ...declarationsToInsert);\n }\n\n const output = generate(ast, {\n sourceFileName: filename,\n retainLines: false,\n });\n\n return { code: output.code, map: output.map, css: cssText, rules };\n}\n\n/** Collect typography runtime lookups from all resolved chains. */\nfunction collectRuntimeLookups(\n chains: ResolvedChain[],\n): Map<string, { segmentsByName: Record<string, ResolvedSegment[]> }> {\n const lookups = new Map<string, { segmentsByName: Record<string, ResolvedSegment[]> }>();\n for (const chain of chains) {\n for (const part of chain.parts) {\n const segs = part.type === \"unconditional\" ? part.segments : [...part.thenSegments, ...part.elseSegments];\n for (const seg of segs) {\n if (seg.typographyLookup && !lookups.has(seg.typographyLookup.lookupKey)) {\n lookups.set(seg.typographyLookup.lookupKey, {\n segmentsByName: seg.typographyLookup.segmentsByName,\n });\n }\n }\n }\n }\n return lookups;\n}\n","import type * as t from \"@babel/types\";\nimport type { TrussMapping, TrussMappingEntry, ResolvedSegment, MarkerSegment } from \"./types\";\n\n/**\n * A resolved chain that may contain conditional (if/else) sections.\n *\n * I.e. `ChainNode` from ast-utils.ts is just the raw AST chain from `Css` to `.$`, which may contain if/else\n * nodes; this `ResolvedChain` is the post-processed result where each if/else has been split into separate segments.\n *\n * The `parts` array contains unconditional segments and conditional groups.\n * The `markers` array contains marker directives (Css.marker.$, Css.markerOf(\"x\").$).\n */\nexport interface ResolvedChain {\n parts: ResolvedChainPart[];\n /** Marker directives to attach to the element (not CSS styles). */\n markers: MarkerSegment[];\n /** Error messages from unsupported patterns found in this chain. */\n errors: string[];\n}\n\nexport type ResolvedChainPart =\n | { type: \"unconditional\"; segments: ResolvedSegment[] }\n | { type: \"conditional\"; conditionNode: any; thenSegments: ResolvedSegment[]; elseSegments: ResolvedSegment[] };\n\n/**\n * High-level chain resolver that handles if/else by splitting into parts.\n *\n * ## Chain semantics\n *\n * A `Css.*.$` chain is read left-to-right. Each segment is either a style\n * abbreviation (getter or call) or a modifier that changes the context for\n * subsequent styles. The modifiers and their precedence:\n *\n * - **`if(bool)`** / **`else`** — Boolean conditional. Splits the chain into\n * then/else branches at the AST level. Subsequent styles go into the active\n * branch. A new `if` starts a new conditional.\n *\n * - **`if(mediaQuery)`** — String overload. Sets the media query context\n * (same as `ifSm`, `ifMd` etc.) for subsequent styles. Does NOT create\n * a boolean branch.\n *\n * - **`ifSm`**, **`ifMd`**, **`ifLg`**, etc. — Breakpoint getters. Set the\n * media query context. Stacks with pseudo-classes: `ifSm.onHover.blue.$`\n * produces `{ color: { default: null, \":hover\": { default: null, \"@media...\": value } } }`.\n *\n * - **`onHover`**, **`onFocus`**, etc. — Pseudo-class getters. Set the\n * pseudo-class context. Stacks with media queries (see above). A new\n * pseudo-class replaces the previous one.\n *\n * - **`element(\"::placeholder\")`** — Pseudo-element. Sets the pseudo-element\n * context. Wraps subsequent defs in a top-level namespace key:\n * `{ \"::placeholder\": { color: value } }`. Stacks with pseudo-classes\n * and media queries inside the pseudo-element.\n *\n * - **`when(\"ancestor\", \":hover\")`** — StyleX `when` API. Resets both media\n * query and pseudo-class contexts. Uses `stylex.when.<relationship>()`\n * computed keys.\n *\n * - **`ifContainer({ gt, lt })`** — Container query. Sets the media query\n * context to an `@container` query string.\n *\n * Contexts accumulate left-to-right until explicitly replaced. A media query\n * set by `ifSm` persists through `onHover` (they stack). A new `if(bool)`\n * resets all contexts for its branches.\n */\nexport function resolveFullChain(\n chain: ChainNode[],\n mapping: TrussMapping,\n options?: { skipMerge?: boolean },\n): ResolvedChain {\n const parts: ResolvedChainPart[] = [];\n const markers: MarkerSegment[] = [];\n\n // Pre-scan for marker nodes and strip them from the chain\n const filteredChain: ChainNode[] = [];\n /** Errors found during marker scanning — attached to the chain result */\n const scanErrors: string[] = [];\n for (let j = 0; j < chain.length; j++) {\n const node = chain[j];\n if (node.type === \"getter\" && node.name === \"marker\") {\n markers.push({ type: \"marker\" });\n } else if (node.type === \"call\" && node.name === \"markerOf\") {\n if (node.args.length !== 1) {\n scanErrors.push(\"[truss] Unsupported pattern: markerOf() requires exactly one argument (a marker variable)\");\n } else {\n markers.push({ type: \"marker\", markerNode: node.args[0] });\n }\n } else {\n filteredChain.push(node);\n }\n }\n\n // Split chain at if/else boundaries\n let i = 0;\n let currentNodes: ChainNode[] = [];\n\n while (i < filteredChain.length) {\n const node = filteredChain[i];\n const mediaStart = getMediaConditionalStartNode(node, mapping);\n if (mediaStart) {\n const elseIndex = findElseIndex(filteredChain, i + 1);\n if (elseIndex !== -1) {\n if (currentNodes.length > 0) {\n const unconditionalSegs = resolveChain(currentNodes, mapping);\n parts.push({\n type: \"unconditional\",\n segments: options?.skipMerge ? unconditionalSegs : mergeOverlappingConditions(unconditionalSegs),\n });\n currentNodes = [];\n }\n\n const thenNodes = mediaStart.thenNodes\n ? [...mediaStart.thenNodes, ...filteredChain.slice(i + 1, elseIndex)]\n : filteredChain.slice(i, elseIndex);\n const elseNodes = [makeMediaQueryNode(mediaStart.inverseMediaQuery), ...filteredChain.slice(elseIndex + 1)];\n const thenSegs = resolveChain(thenNodes, mapping);\n const elseSegs = resolveChain(elseNodes, mapping);\n const combinedSegs = [...thenSegs, ...elseSegs];\n parts.push({\n type: \"unconditional\",\n segments: options?.skipMerge ? combinedSegs : mergeOverlappingConditions(combinedSegs),\n });\n i = filteredChain.length;\n break;\n }\n }\n\n if (node.type === \"if\") {\n // if(stringLiteral) → media query pseudo, not a boolean conditional\n if (node.conditionNode.type === \"StringLiteral\") {\n const mediaQuery: string = (node.conditionNode as any).value;\n // Inject a synthetic \"media query pseudo\" into the current unconditional nodes.\n // This works by creating a synthetic call node that resolveChain's pseudo handling\n // can recognize — but it's simpler to just inject it as a special marker.\n currentNodes.push({ type: \"__mediaQuery\" as any, mediaQuery } as any);\n i++;\n continue;\n }\n\n // Flush any accumulated unconditional nodes\n if (currentNodes.length > 0) {\n const unconditionalSegs = resolveChain(currentNodes, mapping);\n parts.push({\n type: \"unconditional\",\n segments: options?.skipMerge ? unconditionalSegs : mergeOverlappingConditions(unconditionalSegs),\n });\n currentNodes = [];\n }\n // Collect \"then\" nodes until \"else\" or end\n const thenNodes: ChainNode[] = [];\n const elseNodes: ChainNode[] = [];\n i++;\n let inElse = false;\n while (i < filteredChain.length) {\n if (filteredChain[i].type === \"else\") {\n inElse = true;\n i++;\n continue;\n }\n if (filteredChain[i].type === \"if\") {\n // Nested if — break out and let the outer loop handle it\n break;\n }\n if (inElse) {\n elseNodes.push(filteredChain[i]);\n } else {\n thenNodes.push(filteredChain[i]);\n }\n i++;\n }\n const thenSegs = resolveChain(thenNodes, mapping);\n const elseSegs = resolveChain(elseNodes, mapping);\n parts.push({\n type: \"conditional\",\n conditionNode: node.conditionNode,\n thenSegments: options?.skipMerge ? thenSegs : mergeOverlappingConditions(thenSegs),\n elseSegments: options?.skipMerge ? elseSegs : mergeOverlappingConditions(elseSegs),\n });\n } else {\n currentNodes.push(node);\n i++;\n }\n }\n\n // Flush remaining unconditional nodes\n if (currentNodes.length > 0) {\n const remainingSegs = resolveChain(currentNodes, mapping);\n parts.push({\n type: \"unconditional\",\n segments: options?.skipMerge ? remainingSegs : mergeOverlappingConditions(remainingSegs),\n });\n }\n\n // Collect error messages from all resolved segments\n const segmentErrors: string[] = [];\n for (const part of parts) {\n const segs = part.type === \"unconditional\" ? part.segments : [...part.thenSegments, ...part.elseSegments];\n for (const seg of segs) {\n if (seg.error) {\n segmentErrors.push(seg.error);\n }\n }\n }\n\n return { parts, markers, errors: [...scanErrors, ...segmentErrors] };\n}\n\nfunction getMediaConditionalStartNode(\n node: ChainNode,\n mapping: TrussMapping,\n): { inverseMediaQuery: string; thenNodes?: ChainNode[] } | null {\n if (node.type === \"if\" && node.conditionNode.type === \"StringLiteral\") {\n return {\n inverseMediaQuery: invertMediaQuery(node.conditionNode.value),\n thenNodes: [makeMediaQueryNode(node.conditionNode.value)],\n };\n }\n\n if (node.type === \"getter\" && mapping.breakpoints && node.name in mapping.breakpoints) {\n return { inverseMediaQuery: invertMediaQuery(mapping.breakpoints[node.name]) };\n }\n\n return null;\n}\n\nfunction findElseIndex(chain: ChainNode[], start: number): number {\n for (let i = start; i < chain.length; i++) {\n if (chain[i].type === \"if\") {\n return -1;\n }\n if (chain[i].type === \"else\") {\n return i;\n }\n }\n return -1;\n}\n\nfunction makeMediaQueryNode(mediaQuery: string): ChainNode {\n return { type: \"__mediaQuery\" as any, mediaQuery } as any;\n}\n\nfunction invertMediaQuery(query: string): string {\n const screenPrefix = \"@media screen and \";\n if (query.startsWith(screenPrefix)) {\n const conditions = query.slice(screenPrefix.length).trim();\n const rangeMatch = conditions.match(/^\\(min-width: (\\d+)px\\) and \\(max-width: (\\d+)px\\)$/);\n if (rangeMatch) {\n const min = Number(rangeMatch[1]);\n const max = Number(rangeMatch[2]);\n return `@media screen and (max-width: ${min - 1}px), screen and (min-width: ${max + 1}px)`;\n }\n const minMatch = conditions.match(/^\\(min-width: (\\d+)px\\)$/);\n if (minMatch) {\n return `@media screen and (max-width: ${Number(minMatch[1]) - 1}px)`;\n }\n const maxMatch = conditions.match(/^\\(max-width: (\\d+)px\\)$/);\n if (maxMatch) {\n return `@media screen and (min-width: ${Number(maxMatch[1]) + 1}px)`;\n }\n }\n return query.replace(\"@media\", \"@media not\");\n}\n\n/**\n * Walks a Css member-expression chain (the AST between `Css` and `.$`) and\n * resolves each segment into CSS property definitions using the truss mapping.\n *\n * Returns an array of ResolvedSegment, or throws if a pattern is unsupported.\n * Does NOT handle if/else — use resolveFullChain for that.\n */\nexport function resolveChain(chain: ChainNode[], mapping: TrussMapping): ResolvedSegment[] {\n const segments: ResolvedSegment[] = [];\n // Track media query and pseudo-class separately so they can stack.\n // e.g. Css.ifSm.onHover.blue.$ → both mediaQuery and pseudoClass are set\n let currentMediaQuery: string | null = null;\n let currentPseudoClass: string | null = null;\n let currentPseudoElement: string | null = null;\n let currentWhenPseudo: { pseudo: string; markerNode?: any; relationship?: string } | null = null;\n\n for (const node of chain) {\n try {\n // Synthetic media query node injected by resolveFullChain for if(\"@media...\")\n if ((node as any).type === \"__mediaQuery\") {\n currentMediaQuery = (node as any).mediaQuery;\n currentWhenPseudo = null;\n continue;\n }\n\n if (node.type === \"getter\") {\n const abbr = node.name;\n\n // Pseudo-class getters: onHover, onFocus, etc.\n if (isPseudoMethod(abbr)) {\n currentPseudoClass = pseudoSelector(abbr);\n currentWhenPseudo = null;\n continue;\n }\n\n // Breakpoint getters: ifSm, ifMd, ifLg, etc.\n if (mapping.breakpoints && abbr in mapping.breakpoints) {\n currentMediaQuery = mapping.breakpoints[abbr];\n currentWhenPseudo = null;\n continue;\n }\n\n const entry = mapping.abbreviations[abbr];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown abbreviation \"${abbr}\"`);\n }\n\n const resolved = resolveEntry(\n abbr,\n entry,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n currentWhenPseudo,\n );\n segments.push(...resolved);\n } else if (node.type === \"call\") {\n const abbr = node.name;\n\n // Container query call: ifContainer({ gt, lt, name? })\n if (abbr === \"ifContainer\") {\n currentMediaQuery = containerSelectorFromCall(node);\n currentWhenPseudo = null;\n continue;\n }\n\n // add(prop, value) — arbitrary CSS property\n if (abbr === \"add\") {\n const seg = resolveAddCall(\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n currentWhenPseudo,\n );\n segments.push(seg);\n continue;\n }\n\n if (abbr === \"typography\") {\n const resolved = resolveTypographyCall(\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n );\n segments.push(...resolved);\n continue;\n }\n\n // Pseudo-element: element(\"::placeholder\") etc.\n if (abbr === \"element\") {\n if (node.args.length !== 1 || node.args[0].type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(\n `element() requires exactly one string literal argument (e.g. \"::placeholder\")`,\n );\n }\n currentPseudoElement = (node.args[0] as any).value;\n continue;\n }\n\n // Generic when(relationship, pseudo) or when(relationship, marker, pseudo)\n if (abbr === \"when\") {\n const resolved = resolveWhenCall(node);\n currentPseudoClass = null;\n currentMediaQuery = null;\n currentWhenPseudo = resolved;\n continue;\n }\n\n // Simple pseudo-class calls (backward compat — pseudos are now getters)\n if (isPseudoMethod(abbr)) {\n currentPseudoClass = pseudoSelector(abbr);\n currentWhenPseudo = null;\n if (node.args.length > 0) {\n throw new UnsupportedPatternError(\n `${abbr}() does not take arguments -- use when(\"ancestor\", \":hover\") for relationship pseudos`,\n );\n }\n continue;\n }\n\n const entry = mapping.abbreviations[abbr];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown abbreviation \"${abbr}\"`);\n }\n\n if (entry.kind === \"variable\") {\n const seg = resolveVariableCall(\n abbr,\n entry,\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n currentWhenPseudo,\n );\n segments.push(seg);\n } else if (entry.kind === \"delegate\") {\n const seg = resolveDelegateCall(\n abbr,\n entry,\n node,\n mapping,\n currentMediaQuery,\n currentPseudoClass,\n currentPseudoElement,\n currentWhenPseudo,\n );\n segments.push(seg);\n } else {\n throw new UnsupportedPatternError(`Abbreviation \"${abbr}\" is ${entry.kind}, cannot be called as a function`);\n }\n }\n } catch (err) {\n if (err instanceof UnsupportedPatternError) {\n segments.push({ key: \"__error\", defs: {}, error: err.message });\n } else {\n throw err;\n }\n }\n }\n\n return segments;\n}\n\n/** Build the stylex.create key suffix from mediaQuery, pseudoClass, and/or pseudoElement. */\nexport function conditionKeySuffix(\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n breakpoints?: Record<string, string>,\n): string {\n const parts: string[] = [];\n if (pseudoElement) parts.push(pseudoName(pseudoElement));\n if (mediaQuery) parts.push(pseudoName(mediaQuery, breakpoints));\n if (pseudoClass) parts.push(pseudoName(pseudoClass));\n return parts.join(\"_\");\n}\n\n/** Resolve `typography(key)` into either direct segments or a runtime lookup-backed segment. */\nfunction resolveTypographyCall(\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment[] {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`typography() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n if (argAst.type === \"StringLiteral\") {\n return resolveTypographyEntry(argAst.value, mapping, mediaQuery, pseudoClass, pseudoElement);\n }\n\n const typography = mapping.typography ?? [];\n if (typography.length === 0) {\n throw new UnsupportedPatternError(`typography() is unavailable because no typography abbreviations were generated`);\n }\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n const lookupKey = suffix ? `typography__${suffix}` : \"typography\";\n const segmentsByName: Record<string, ResolvedSegment[]> = {};\n\n for (const name of typography) {\n segmentsByName[name] = resolveTypographyEntry(name, mapping, mediaQuery, pseudoClass, pseudoElement);\n }\n\n return [\n {\n key: lookupKey,\n defs: {},\n typographyLookup: {\n lookupKey,\n argNode: argAst,\n segmentsByName,\n },\n },\n ];\n}\n\n/** Resolve a single typography abbreviation name within the current condition context. */\nfunction resolveTypographyEntry(\n name: string,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n): ResolvedSegment[] {\n if (!(mapping.typography ?? []).includes(name)) {\n throw new UnsupportedPatternError(`Unknown typography abbreviation \"${name}\"`);\n }\n\n const entry = mapping.abbreviations[name];\n if (!entry) {\n throw new UnsupportedPatternError(`Unknown typography abbreviation \"${name}\"`);\n }\n\n const resolved = resolveEntry(name, entry, mapping, mediaQuery, pseudoClass, pseudoElement, null);\n for (const segment of resolved) {\n if (segment.variableProps || segment.whenPseudo) {\n throw new UnsupportedPatternError(`Typography abbreviation \"${name}\" cannot require runtime arguments`);\n }\n }\n return resolved;\n}\n\n/**\n * Wrap raw CSS defs with condition nesting for StyleX.\n *\n * - mediaQuery only: `{ prop: { default: null, \"@media...\": value } }`\n * - pseudoClass only: `{ prop: { default: null, \":hover\": value } }`\n * - both (stacked): `{ prop: { default: null, \":hover\": { default: null, \"@media...\": value } } }`\n */\nfunction wrapDefsWithConditions(\n defs: Record<string, unknown>,\n mediaQuery: string | null,\n pseudoClass: string | null,\n): Record<string, unknown> {\n if (!mediaQuery && !pseudoClass) return defs;\n const result: Record<string, unknown> = {};\n for (const [prop, value] of Object.entries(defs)) {\n if (pseudoClass && mediaQuery) {\n result[prop] = { default: null, [pseudoClass]: { default: null, [mediaQuery]: value } };\n } else if (pseudoClass) {\n result[prop] = { default: null, [pseudoClass]: value };\n } else {\n result[prop] = { default: null, [mediaQuery!]: value };\n }\n }\n return result;\n}\n\n/** Resolve a static or alias entry (from a getter access). */\nfunction resolveEntry(\n abbr: string,\n entry: TrussMappingEntry,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string } | null,\n): ResolvedSegment[] {\n switch (entry.kind) {\n case \"static\": {\n if (whenPseudo) {\n const suffix = whenPseudoKeyName(whenPseudo);\n const key = `${abbr}__${suffix}`;\n return [{ key, defs: entry.defs, whenPseudo }];\n }\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n const key = suffix ? `${abbr}__${suffix}` : abbr;\n const defs = pseudoElement\n ? { [pseudoElement]: wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass) }\n : wrapDefsWithConditions(entry.defs, mediaQuery, pseudoClass);\n return [{ key, defs, mediaQuery, pseudoClass, pseudoElement }];\n }\n case \"alias\": {\n const result: ResolvedSegment[] = [];\n for (const chainAbbr of entry.chain) {\n const subEntry = mapping.abbreviations[chainAbbr];\n if (!subEntry) {\n throw new UnsupportedPatternError(`Alias \"${abbr}\" references unknown abbreviation \"${chainAbbr}\"`);\n }\n result.push(...resolveEntry(chainAbbr, subEntry, mapping, mediaQuery, pseudoClass, pseudoElement, whenPseudo));\n }\n return result;\n }\n case \"variable\":\n case \"delegate\":\n throw new UnsupportedPatternError(`Abbreviation \"${abbr}\" requires arguments — use ${abbr}() not .${abbr}`);\n default:\n throw new UnsupportedPatternError(`Unhandled entry kind for \"${abbr}\"`);\n }\n}\n\n/** Resolve a variable (parameterized) call like mt(2) or mt(x). */\nfunction resolveVariableCall(\n abbr: string,\n entry: { kind: \"variable\"; props: string[]; incremented: boolean; extraDefs?: Record<string, unknown> },\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string } | null,\n): ResolvedSegment {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n const literalValue = tryEvaluateLiteral(argAst, entry.incremented, mapping.increment);\n\n // When inside a when() context, use whenPseudo key naming instead of condition suffix\n if (whenPseudo) {\n const wpSuffix = whenPseudoKeyName(whenPseudo);\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = `${abbr}__${keySuffix}__${wpSuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of entry.props) {\n defs[prop] = literalValue;\n }\n if (entry.extraDefs) Object.assign(defs, entry.extraDefs);\n return { key, defs, whenPseudo, argResolved: literalValue };\n } else {\n const key = `${abbr}__${wpSuffix}`;\n return {\n key,\n defs: {},\n whenPseudo,\n variableProps: entry.props,\n incremented: entry.incremented,\n variableExtraDefs: entry.extraDefs,\n argNode: argAst,\n };\n }\n }\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = suffix ? `${abbr}__${keySuffix}__${suffix}` : `${abbr}__${keySuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of entry.props) {\n defs[prop] = literalValue;\n }\n if (entry.extraDefs) {\n Object.assign(defs, entry.extraDefs);\n }\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `${abbr}__${suffix}` : abbr;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n variableProps: entry.props,\n incremented: entry.incremented,\n variableExtraDefs: entry.extraDefs,\n argNode: argAst,\n };\n }\n}\n\n/** Resolve a delegate call like mtPx(12). */\nfunction resolveDelegateCall(\n abbr: string,\n entry: { kind: \"delegate\"; target: string },\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string } | null,\n): ResolvedSegment {\n const targetEntry = mapping.abbreviations[entry.target];\n if (!targetEntry || targetEntry.kind !== \"variable\") {\n throw new UnsupportedPatternError(`Delegate \"${abbr}\" targets \"${entry.target}\" which is not a variable entry`);\n }\n\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const argAst = node.args[0];\n const literalValue = tryEvaluatePxLiteral(argAst);\n\n // When inside a when() context, use whenPseudo key naming instead of condition suffix\n if (whenPseudo) {\n const wpSuffix = whenPseudoKeyName(whenPseudo);\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = `${entry.target}__${keySuffix}__${wpSuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of targetEntry.props) {\n defs[prop] = literalValue;\n }\n if (targetEntry.extraDefs) Object.assign(defs, targetEntry.extraDefs);\n return { key, defs, whenPseudo, argResolved: literalValue };\n } else {\n const key = `${entry.target}__${wpSuffix}`;\n return {\n key,\n defs: {},\n whenPseudo,\n variableProps: targetEntry.props,\n incremented: false,\n appendPx: true,\n variableExtraDefs: targetEntry.extraDefs,\n argNode: argAst,\n };\n }\n }\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue.replace(/[^a-zA-Z0-9]/g, \"_\");\n const key = suffix ? `${entry.target}__${keySuffix}__${suffix}` : `${entry.target}__${keySuffix}`;\n const defs: Record<string, unknown> = {};\n for (const prop of targetEntry.props) {\n defs[prop] = literalValue;\n }\n if (targetEntry.extraDefs) {\n Object.assign(defs, targetEntry.extraDefs);\n }\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `${entry.target}__${suffix}` : entry.target;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n pseudoElement,\n variableProps: targetEntry.props,\n incremented: false,\n appendPx: true,\n variableExtraDefs: targetEntry.extraDefs,\n argNode: argAst,\n };\n }\n}\n\n/**\n * Resolve an `add(...)` call.\n *\n * Supported overloads:\n * - `add(cssProp)` to inline an existing CssProp array into the chain output\n * - `add(\"propName\", value)` for an arbitrary CSS property/value pair\n */\nfunction resolveAddCall(\n node: CallChainNode,\n mapping: TrussMapping,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo?: { pseudo: string; markerNode?: any; relationship?: string } | null,\n): ResolvedSegment {\n if (node.args.length === 1) {\n const styleArg = node.args[0];\n if (styleArg.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(`add() does not support spread arguments`);\n }\n if (styleArg.type === \"ObjectExpression\") {\n throw new UnsupportedPatternError(\n `add(cssProp) does not accept object literals -- pass an existing CssProp expression instead`,\n );\n }\n return {\n key: \"__composed_css_prop\",\n defs: {},\n styleArrayArg: styleArg,\n };\n }\n\n if (node.args.length !== 2) {\n throw new UnsupportedPatternError(\n `add() requires exactly 2 arguments (property name and value), got ${node.args.length}. ` +\n `Supported overloads are add(cssProp) and add(\"propName\", value)`,\n );\n }\n\n const propArg = node.args[0];\n if (propArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`add() first argument must be a string literal property name`);\n }\n const propName: string = (propArg as any).value;\n\n const valueArg = node.args[1];\n // Try to evaluate the value as a literal\n const literalValue = tryEvaluateAddLiteral(valueArg);\n\n // When inside a when() context, use whenPseudo key naming\n if (whenPseudo) {\n const wpSuffix = whenPseudoKeyName(whenPseudo);\n if (literalValue !== null) {\n const keySuffix = literalValue\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n const key = `${propName}__${keySuffix}__${wpSuffix}`;\n return { key, defs: { [propName]: literalValue }, whenPseudo, argResolved: literalValue };\n } else {\n const key = `${propName}__${wpSuffix}`;\n return { key, defs: {}, whenPseudo, variableProps: [propName], incremented: false, argNode: valueArg };\n }\n }\n\n const suffix = conditionKeySuffix(mediaQuery, pseudoClass, pseudoElement, mapping.breakpoints);\n\n if (literalValue !== null) {\n const keySuffix = literalValue\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n const key = suffix ? `${propName}__${keySuffix}__${suffix}` : `${propName}__${keySuffix}`;\n const defs: Record<string, unknown> = { [propName]: literalValue };\n const wrappedDefs = wrapDefsWithConditions(defs, mediaQuery, pseudoClass);\n return {\n key,\n defs: pseudoElement ? { [pseudoElement]: wrappedDefs } : wrappedDefs,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n argResolved: literalValue,\n };\n } else {\n const key = suffix ? `${propName}__${suffix}` : propName;\n return {\n key,\n defs: {},\n mediaQuery,\n pseudoClass,\n pseudoElement,\n variableProps: [propName],\n incremented: false,\n argNode: valueArg,\n };\n }\n}\n\n/** Try to evaluate a literal for add() — strings, numbers, and template literals with no expressions. */\nfunction tryEvaluateAddLiteral(node: t.Expression | t.SpreadElement): string | null {\n if (node.type === \"StringLiteral\") {\n return (node as any).value;\n }\n if (node.type === \"NumericLiteral\") {\n return String((node as any).value);\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n return String(-(node.argument as any).value);\n }\n return null;\n}\n\nconst WHEN_RELATIONSHIPS = new Set([\"ancestor\", \"descendant\", \"anySibling\", \"siblingBefore\", \"siblingAfter\"]);\n\n/**\n * Resolve a `when(relationship, pseudo)` or `when(relationship, marker, pseudo)` call.\n *\n * - 2 args: `when(\"ancestor\", \":hover\")` — both must be string literals\n * - 3 args: `when(\"ancestor\", marker, \":hover\")` — 1st and 3rd must be string literals, 2nd is a marker variable\n */\nfunction resolveWhenCall(node: CallChainNode): { pseudo: string; markerNode?: any; relationship: string } {\n if (node.args.length < 2 || node.args.length > 3) {\n throw new UnsupportedPatternError(\n `when() expects 2 or 3 arguments (relationship, [marker], pseudo), got ${node.args.length}`,\n );\n }\n\n const relationshipArg = node.args[0];\n if (relationshipArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() first argument must be a string literal relationship`);\n }\n const relationship: string = (relationshipArg as any).value;\n if (!WHEN_RELATIONSHIPS.has(relationship)) {\n throw new UnsupportedPatternError(\n `when() relationship must be one of: ${[...WHEN_RELATIONSHIPS].join(\", \")} -- got \"${relationship}\"`,\n );\n }\n\n if (node.args.length === 2) {\n // when(\"ancestor\", \":hover\")\n const pseudoArg = node.args[1];\n if (pseudoArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() pseudo selector must be a string literal`);\n }\n return { pseudo: (pseudoArg as any).value, relationship };\n } else {\n // when(\"ancestor\", marker, \":hover\")\n const markerNode = node.args[1];\n const pseudoArg = node.args[2];\n if (pseudoArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() pseudo selector (3rd argument) must be a string literal`);\n }\n return { pseudo: (pseudoArg as any).value, markerNode, relationship };\n }\n}\n\n// ── Helpers ───────────────────────────────────────────────────────────\n\nconst PSEUDO_METHODS: Record<string, string> = {\n onHover: \":hover\",\n onFocus: \":focus\",\n onFocusVisible: \":focus-visible\",\n onActive: \":active\",\n onDisabled: \":disabled\",\n};\n\nfunction isPseudoMethod(name: string): boolean {\n return name in PSEUDO_METHODS;\n}\n\nfunction pseudoSelector(name: string): string {\n return PSEUDO_METHODS[name];\n}\n\n/**\n * Generate the stylex.create key suffix for when/ancestor pseudo segments.\n * e.g. { pseudo: \":hover\" } → \"ancestorHover\"\n * e.g. { pseudo: \":hover\", relationship: \"descendant\" } → \"descendantHover\"\n * e.g. { pseudo: \":hover\", markerNode: Identifier(\"row\") } → \"ancestorHover_row\"\n */\nfunction whenPseudoKeyName(ap: { pseudo: string; markerNode?: any; relationship?: string }): string {\n const rel = ap.relationship ?? \"ancestor\";\n const pn = pseudoName(ap.pseudo);\n const base = `${rel}${pn.charAt(0).toUpperCase()}${pn.slice(1)}`;\n if (!ap.markerNode) return base;\n // Use the identifier name for readable keys; fall back to a generic suffix for complex expressions\n const suffix = ap.markerNode.type === \"Identifier\" ? ap.markerNode.name : \"marker\";\n return `${base}_${suffix}`;\n}\n\n/**\n * Post-process resolved segments to merge entries that target the same CSS\n * properties into a single `stylex.create` entry with stacked conditions.\n *\n * For example, `Css.black.ifSm.white.onHover.blue.$` produces three segments:\n * 1. `black` → `{ color: \"#353535\" }` (base)\n * 2. `white__sm` → `{ color: { default: null, \"@media...\": \"#fcfcfa\" } }` (media-only)\n * 3. `blue__sm_hover` → `{ color: { default: null, \":hover\": { default: null, \"@media...\": \"#526675\" } } }` (media+pseudo)\n *\n * All three set `color`, so they merge into one entry:\n * `{ color: { default: \"#353535\", \"@media...\": \"#fcfcfa\", \":hover\": { default: null, \"@media...\": \"#526675\" } } }`\n */\nexport function mergeOverlappingConditions(segments: ResolvedSegment[]): ResolvedSegment[] {\n // Index: for each CSS property, which segments set it?\n // Only static segments (no variableProps, no styleArrayArg, no whenPseudo, no error) participate in merging.\n const propToIndices = new Map<string, number[]>();\n for (let i = 0; i < segments.length; i++) {\n const seg = segments[i];\n if (seg.variableProps || seg.styleArrayArg || seg.whenPseudo || seg.error) continue;\n for (const prop of Object.keys(seg.defs)) {\n if (!propToIndices.has(prop)) propToIndices.set(prop, []);\n propToIndices.get(prop)!.push(i);\n }\n }\n\n // Find properties where a base (no-condition) segment overlaps with conditional segments.\n // Two base segments setting the same property is NOT a merge — the later one just overrides.\n const mergeableProps = new Set<string>();\n for (const [prop, indices] of propToIndices) {\n if (indices.length < 2) continue;\n const hasBase = indices.some((i) => !segments[i].mediaQuery && !segments[i].pseudoClass);\n const hasConditional = indices.some((i) => !!(segments[i].mediaQuery || segments[i].pseudoClass));\n if (hasBase && hasConditional) {\n mergeableProps.add(prop);\n }\n }\n\n if (mergeableProps.size === 0) return segments;\n\n // For each mergeable property, deep-merge all contributing segments into one defs object.\n // Track which segment indices have properties consumed by the merge.\n const consumedProps = new Map<number, Set<string>>(); // segIndex → consumed prop names\n const mergedPropDefs = new Map<string, { defs: Record<string, unknown>; key: string }>();\n\n for (const prop of mergeableProps) {\n const indices = propToIndices.get(prop)!;\n let merged: Record<string, unknown> = {};\n const keyParts: string[] = [];\n\n for (const idx of indices) {\n const seg = segments[idx];\n const value = seg.defs[prop];\n keyParts.push(seg.key);\n\n if (typeof value === \"string\" || typeof value === \"number\") {\n // Base value → default\n merged.default = value;\n } else if (typeof value === \"object\" && value !== null) {\n // Conditional value — merge all keys (may include default: null which base will override)\n for (const [k, v] of Object.entries(value as Record<string, unknown>)) {\n if (k === \"default\" && v === null && merged.default !== undefined) {\n // Don't let a conditional's `default: null` clobber the base value\n continue;\n }\n merged[k] = v;\n }\n }\n\n // Mark this property as consumed from this segment\n if (!consumedProps.has(idx)) consumedProps.set(idx, new Set());\n consumedProps.get(idx)!.add(prop);\n }\n\n // If the merged object has only a `default` key, it's just a raw value (no conditions)\n const finalValue = Object.keys(merged).length === 1 && \"default\" in merged ? merged.default : merged;\n const mergedKey = [...new Set(keyParts)].join(\"_\");\n mergedPropDefs.set(prop, { defs: { [prop]: finalValue }, key: mergedKey });\n }\n\n // Group mergeable props that share the exact same set of contributing segments\n // so they become one stylex.create entry.\n const groupByIndices = new Map<string, { props: string[]; key: string }>();\n for (const prop of mergeableProps) {\n const indices = propToIndices.get(prop)!;\n const groupKey = indices.join(\",\");\n if (!groupByIndices.has(groupKey)) {\n groupByIndices.set(groupKey, { props: [], key: mergedPropDefs.get(prop)!.key });\n }\n groupByIndices.get(groupKey)!.props.push(prop);\n }\n\n // Build merged segments\n const mergedSegments: ResolvedSegment[] = [];\n for (const [, group] of groupByIndices) {\n const defs: Record<string, unknown> = {};\n for (const prop of group.props) {\n Object.assign(defs, mergedPropDefs.get(prop)!.defs);\n }\n mergedSegments.push({ key: group.key, defs });\n }\n\n // Rebuild result: emit non-consumed segments (or segments with remaining non-consumed props),\n // then emit merged segments at the position of the first consumed segment.\n const result: ResolvedSegment[] = [];\n const mergedEmitted = new Set<string>();\n\n for (let i = 0; i < segments.length; i++) {\n const seg = segments[i];\n const consumed = consumedProps.get(i);\n\n if (!consumed) {\n // Not involved in any merge\n result.push(seg);\n continue;\n }\n\n // Emit any non-consumed properties from this segment\n const remainingDefs: Record<string, unknown> = {};\n for (const [prop, value] of Object.entries(seg.defs)) {\n if (!consumed.has(prop)) {\n remainingDefs[prop] = value;\n }\n }\n if (Object.keys(remainingDefs).length > 0) {\n result.push({ ...seg, defs: remainingDefs });\n }\n\n // Emit the merged segment(s) at the position of the first segment that contributed\n const indices = [...propToIndices.entries()]\n .filter(([prop]) => consumed.has(prop) && mergeableProps.has(prop))\n .map(([, idxs]) => idxs.join(\",\"));\n\n for (const groupKey of new Set(indices)) {\n if (!mergedEmitted.has(groupKey)) {\n const group = groupByIndices.get(groupKey);\n if (group) {\n const defs: Record<string, unknown> = {};\n for (const prop of group.props) {\n Object.assign(defs, mergedPropDefs.get(prop)!.defs);\n }\n result.push({ key: group.key, defs });\n mergedEmitted.add(groupKey);\n }\n }\n }\n }\n\n return result;\n}\n\n/**\n * Convert a pseudo/media selector into a short key suffix.\n * \":hover\" → \"hover\", \":focus-visible\" → \"focus_visible\"\n * \"@media screen and (max-width:599px)\" → \"sm\" (using breakpoints reverse map)\n * \"@container (min-width: 601px)\" → \"container_min_width_601px\"\n */\nexport function pseudoName(pseudo: string, breakpoints?: Record<string, string>): string {\n if (pseudo.startsWith(\"@media\") && breakpoints) {\n // Reverse lookup: find the breakpoint getter name (e.g. \"ifSm\") and strip \"if\" prefix\n for (const [getterName, mediaQuery] of Object.entries(breakpoints)) {\n if (mediaQuery === pseudo) {\n // \"ifSm\" → \"sm\", \"ifSmOrMd\" → \"smOrMd\", \"ifMdAndUp\" → \"mdAndUp\"\n return getterName.replace(/^if/, \"\").replace(/^./, (c) => c.toLowerCase());\n }\n }\n // Fallback: create a compact name from the media query\n return pseudo\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n }\n\n if (pseudo.startsWith(\"@container\")) {\n return pseudo\n .replace(/^@container\\s*/, \"container \")\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n }\n\n return pseudo.replace(/^:+/, \"\").replace(/-/g, \"_\");\n}\n\n/**\n * Try to evaluate a literal AST node to a string value.\n * For incremented entries, also evaluates `maybeInc(literal)`.\n */\nfunction tryEvaluateLiteral(\n node: t.Expression | t.SpreadElement,\n incremented: boolean,\n increment: number,\n): string | null {\n if (node.type === \"NumericLiteral\") {\n if (incremented) {\n return `${node.value * increment}px`;\n }\n return String(node.value);\n }\n if (node.type === \"StringLiteral\") {\n return node.value;\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n const val = -node.argument.value;\n if (incremented) {\n return `${val * increment}px`;\n }\n return String(val);\n }\n return null;\n}\n\n/** Try to evaluate a Px delegate argument (always a number → `${n}px`). */\nfunction tryEvaluatePxLiteral(node: t.Expression | t.SpreadElement): string | null {\n if (node.type === \"NumericLiteral\") {\n return `${node.value}px`;\n }\n return null;\n}\n\n/** Resolve ifContainer({ gt, lt, name? }) to a StyleX pseudo key. */\nfunction containerSelectorFromCall(node: CallChainNode): string {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`ifContainer() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const arg = node.args[0];\n if (!arg || arg.type !== \"ObjectExpression\") {\n throw new UnsupportedPatternError(\"ifContainer() expects an object literal argument\");\n }\n\n let lt: number | undefined;\n let gt: number | undefined;\n let name: string | undefined;\n\n for (const prop of arg.properties) {\n if (prop.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(\"ifContainer() does not support spread properties\");\n }\n if (prop.type !== \"ObjectProperty\" || prop.computed) {\n throw new UnsupportedPatternError(\"ifContainer() expects plain object properties\");\n }\n\n const key = objectPropertyName(prop.key);\n if (!key) {\n throw new UnsupportedPatternError(\"ifContainer() only supports identifier/string keys\");\n }\n\n const valueNode = prop.value as t.Expression | t.SpreadElement;\n\n if (key === \"lt\") {\n lt = numericLiteralValue(valueNode, \"ifContainer().lt must be a numeric literal\");\n continue;\n }\n if (key === \"gt\") {\n gt = numericLiteralValue(valueNode, \"ifContainer().gt must be a numeric literal\");\n continue;\n }\n if (key === \"name\") {\n name = stringLiteralValue(valueNode, \"ifContainer().name must be a string literal\");\n continue;\n }\n\n throw new UnsupportedPatternError(`ifContainer() does not support property \"${key}\"`);\n }\n\n if (lt === undefined && gt === undefined) {\n throw new UnsupportedPatternError('ifContainer() requires at least one of \"lt\" or \"gt\"');\n }\n\n const parts: string[] = [];\n if (gt !== undefined) {\n parts.push(`(min-width: ${gt + 1}px)`);\n }\n if (lt !== undefined) {\n parts.push(`(max-width: ${lt}px)`);\n }\n\n const query = parts.join(\" and \");\n const namePrefix = name ? `${name} ` : \"\";\n return `@container ${namePrefix}${query}`;\n}\n\nfunction objectPropertyName(node: t.Expression | t.Identifier | t.PrivateName): string | null {\n if (node.type === \"Identifier\") return node.name;\n if (node.type === \"StringLiteral\") return node.value;\n return null;\n}\n\nfunction numericLiteralValue(node: t.Expression | t.SpreadElement, errorMessage: string): number {\n if (node.type === \"NumericLiteral\") {\n return node.value;\n }\n if (node.type === \"UnaryExpression\" && node.operator === \"-\" && node.argument.type === \"NumericLiteral\") {\n return -node.argument.value;\n }\n throw new UnsupportedPatternError(errorMessage);\n}\n\nfunction stringLiteralValue(node: t.Expression | t.SpreadElement, errorMessage: string): string {\n if (node.type === \"StringLiteral\") {\n return node.value;\n }\n if (node.type === \"TemplateLiteral\" && node.expressions.length === 0 && node.quasis.length === 1) {\n return node.quasis[0].value.cooked ?? \"\";\n }\n throw new UnsupportedPatternError(errorMessage);\n}\n\n// ── Chain node types (parsed from AST) ────────────────────────────────\n\nexport interface GetterChainNode {\n type: \"getter\";\n name: string;\n}\n\nexport interface CallChainNode {\n type: \"call\";\n name: string;\n args: (t.Expression | t.SpreadElement)[];\n}\n\nexport interface IfChainNode {\n type: \"if\";\n conditionNode: t.Expression | t.SpreadElement;\n}\n\nexport interface ElseChainNode {\n type: \"else\";\n}\n\nexport type ChainNode = GetterChainNode | CallChainNode | IfChainNode | ElseChainNode;\n\nexport class UnsupportedPatternError extends Error {\n constructor(message: string) {\n super(`[truss] Unsupported pattern: ${message}`);\n this.name = \"UnsupportedPatternError\";\n }\n}\n","import * as t from \"@babel/types\";\nimport type { ChainNode } from \"./resolve-chain\";\n\n/**\n * Collect module-scope bindings so generated declarations can avoid collisions.\n *\n * We only care about top-level names because the transform injects declarations\n * at the module root, not inside nested blocks.\n */\nexport function collectTopLevelBindings(ast: t.File): Set<string> {\n const used = new Set<string>();\n\n for (const node of ast.program.body) {\n if (t.isImportDeclaration(node)) {\n for (const spec of node.specifiers) {\n used.add(spec.local.name);\n }\n continue;\n }\n\n if (t.isVariableDeclaration(node)) {\n for (const decl of node.declarations) {\n collectPatternBindings(decl.id, used);\n }\n continue;\n }\n\n if (t.isFunctionDeclaration(node) && node.id) {\n used.add(node.id.name);\n continue;\n }\n\n if (t.isClassDeclaration(node) && node.id) {\n used.add(node.id.name);\n continue;\n }\n\n if (t.isExportNamedDeclaration(node) && node.declaration) {\n const decl = node.declaration;\n if (t.isVariableDeclaration(decl)) {\n for (const varDecl of decl.declarations) {\n collectPatternBindings(varDecl.id, used);\n }\n } else if ((t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) && decl.id) {\n used.add(decl.id.name);\n }\n continue;\n }\n\n if (t.isExportDefaultDeclaration(node)) {\n const decl = node.declaration;\n if ((t.isFunctionDeclaration(decl) || t.isClassDeclaration(decl)) && decl.id) {\n used.add(decl.id.name);\n }\n }\n }\n\n return used;\n}\n\n/**\n * Recursively collect names introduced by binding patterns.\n *\n * This handles destructuring (`const { a } = ...`, `const [x] = ...`) so we do\n * not accidentally generate a helper that shadows an existing binding.\n */\nfunction collectPatternBindings(pattern: t.LVal | t.VoidPattern, used: Set<string>): void {\n if (t.isVoidPattern(pattern)) {\n return;\n }\n\n if (t.isIdentifier(pattern)) {\n used.add(pattern.name);\n return;\n }\n\n if (t.isAssignmentPattern(pattern)) {\n collectPatternBindings(pattern.left, used);\n return;\n }\n\n if (t.isRestElement(pattern)) {\n collectPatternBindings(pattern.argument as t.LVal, used);\n return;\n }\n\n if (t.isObjectPattern(pattern)) {\n for (const prop of pattern.properties) {\n if (t.isObjectProperty(prop)) {\n collectPatternBindings(prop.value as t.LVal, used);\n } else if (t.isRestElement(prop)) {\n collectPatternBindings(prop.argument as t.LVal, used);\n }\n }\n return;\n }\n\n if (t.isArrayPattern(pattern)) {\n for (const el of pattern.elements) {\n if (!el) continue;\n if (t.isIdentifier(el) || t.isAssignmentPattern(el) || t.isObjectPattern(el) || t.isArrayPattern(el)) {\n collectPatternBindings(el, used);\n } else if (t.isRestElement(el)) {\n collectPatternBindings(el.argument as t.LVal, used);\n }\n }\n }\n}\n\n/**\n * Reserve a stable, collision-free identifier.\n *\n * Preference order:\n * 1) preferred\n * 2) secondary (if provided)\n * 3) numbered suffixes based on secondary/preferred\n */\nexport function reservePreferredName(used: Set<string>, preferred: string, secondary?: string): string {\n if (!used.has(preferred)) {\n used.add(preferred);\n return preferred;\n }\n\n if (secondary && !used.has(secondary)) {\n used.add(secondary);\n return secondary;\n }\n\n const base = secondary ?? preferred;\n let i = 1;\n // Numbered fallback keeps generated names deterministic across runs.\n let candidate = `${base}_${i}`;\n while (used.has(candidate)) {\n i++;\n candidate = `${base}_${i}`;\n }\n used.add(candidate);\n return candidate;\n}\n\n/**\n * Find the local binding name for `Css` from import declarations.\n */\nexport function findCssImportBinding(ast: t.File): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n for (const spec of node.specifiers) {\n if (t.isImportSpecifier(spec) && t.isIdentifier(spec.imported, { name: \"Css\" })) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\n/** Check if the AST contains a `binding.method(...)` call expression. */\nexport function hasCssMethodCall(ast: t.File, binding: string, method: string): boolean {\n let found = false;\n t.traverseFast(ast, (node) => {\n if (found) return;\n if (\n t.isCallExpression(node) &&\n t.isMemberExpression(node.callee) &&\n !node.callee.computed &&\n t.isIdentifier(node.callee.object, { name: binding }) &&\n t.isIdentifier(node.callee.property, { name: method })\n ) {\n found = true;\n }\n });\n return found;\n}\n\n/**\n * Remove the Css import specifier. If it was the only specifier, remove the whole import.\n */\nexport function removeCssImport(ast: t.File, cssBinding: string): void {\n for (let i = 0; i < ast.program.body.length; i++) {\n const node = ast.program.body[i];\n if (!t.isImportDeclaration(node)) continue;\n\n const cssSpecIndex = node.specifiers.findIndex((s) => t.isImportSpecifier(s) && s.local.name === cssBinding);\n if (cssSpecIndex === -1) continue;\n\n if (node.specifiers.length === 1) {\n ast.program.body.splice(i, 1);\n } else {\n node.specifiers.splice(cssSpecIndex, 1);\n }\n return;\n }\n}\n\n/**\n * Find an existing namespace import for `@stylexjs/stylex`, if present.\n *\n * Reusing an existing namespace avoids duplicate imports and ensures generated\n * calls use the same local alias as handwritten code (e.g. `sx`).\n */\nexport function findStylexNamespaceImport(ast: t.File): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n if (node.source.value !== \"@stylexjs/stylex\") continue;\n\n for (const spec of node.specifiers) {\n if (t.isImportNamespaceSpecifier(spec)) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\n/** Return the index of the last import declaration in the module. */\nexport function findLastImportIndex(ast: t.File): number {\n let lastImportIndex = -1;\n for (let i = 0; i < ast.program.body.length; i++) {\n if (t.isImportDeclaration(ast.program.body[i])) {\n lastImportIndex = i;\n }\n }\n return lastImportIndex;\n}\n\n/**\n * Insert `import * as <localName> from \"@stylexjs/stylex\"` after existing imports.\n */\nexport function insertStylexNamespaceImport(ast: t.File, localName: string): void {\n const stylexImport = t.importDeclaration(\n [t.importNamespaceSpecifier(t.identifier(localName))],\n t.stringLiteral(\"@stylexjs/stylex\"),\n );\n const idx = findLastImportIndex(ast);\n ast.program.body.splice(idx + 1, 0, stylexImport);\n}\n\nexport function findNamedImportBinding(ast: t.File, source: string, importedName: string): string | null {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node) || node.source.value !== source) continue;\n for (const spec of node.specifiers) {\n if (t.isImportSpecifier(spec) && t.isIdentifier(spec.imported, { name: importedName })) {\n return spec.local.name;\n }\n }\n }\n return null;\n}\n\nexport function upsertNamedImports(\n ast: t.File,\n source: string,\n imports: Array<{ importedName: string; localName: string }>,\n): void {\n if (imports.length === 0) return;\n\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node) || node.source.value !== source) continue;\n\n for (const entry of imports) {\n const exists = node.specifiers.some(function (spec) {\n return t.isImportSpecifier(spec) && t.isIdentifier(spec.imported, { name: entry.importedName });\n });\n if (exists) continue;\n\n node.specifiers.push(t.importSpecifier(t.identifier(entry.localName), t.identifier(entry.importedName)));\n }\n return;\n }\n\n const importDecl = t.importDeclaration(\n imports.map(function (entry) {\n return t.importSpecifier(t.identifier(entry.localName), t.identifier(entry.importedName));\n }),\n t.stringLiteral(source),\n );\n const idx = findLastImportIndex(ast);\n ast.program.body.splice(idx + 1, 0, importDecl);\n}\n\n/**\n * Extract a `Css` method/property chain from an expression.\n *\n * Example: `Css.if(cond).df.else.db.$` ->\n * `[{type:\"if\"}, {type:\"getter\", name:\"df\"}, {type:\"else\"}, {type:\"getter\", name:\"db\"}]`\n *\n * Returns `null` when the expression is not rooted at the Css import binding,\n * which lets the caller ignore unrelated member expressions cheaply.\n */\nexport function extractChain(node: t.Expression, cssBinding: string): ChainNode[] | null {\n const chain: ChainNode[] = [];\n let current: t.Expression = node;\n\n while (true) {\n if (t.isIdentifier(current, { name: cssBinding })) {\n chain.reverse();\n return chain;\n }\n\n if (t.isMemberExpression(current) && !current.computed && t.isIdentifier(current.property)) {\n const name = current.property.name;\n if (name === \"else\") {\n chain.push({ type: \"else\" });\n } else {\n chain.push({ type: \"getter\", name });\n }\n current = current.object as t.Expression;\n continue;\n }\n\n if (\n t.isCallExpression(current) &&\n t.isMemberExpression(current.callee) &&\n !current.callee.computed &&\n t.isIdentifier(current.callee.property)\n ) {\n const name = current.callee.property.name;\n\n if (name === \"if\") {\n chain.push({\n type: \"if\",\n conditionNode: current.arguments[0] as t.Expression,\n });\n current = current.callee.object as t.Expression;\n continue;\n }\n\n chain.push({\n type: \"call\",\n name,\n args: current.arguments as (t.Expression | t.SpreadElement)[],\n });\n current = current.callee.object as t.Expression;\n continue;\n }\n\n return null;\n }\n}\n","import _traverse from \"@babel/traverse\";\nimport type { NodePath } from \"@babel/traverse\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport type { TrussMapping } from \"./types\";\nimport type { ResolvedChain } from \"./resolve-chain\";\nimport { buildStyleHashProperties, markerClassName } from \"./emit-truss\";\nimport type { ResolvedSegment } from \"./types\";\n\n// Babel packages are CJS today; normalize default interop across loaders.\nconst generate = ((_generate as unknown as { default?: typeof _generate }).default ?? _generate) as typeof _generate;\nconst traverse = ((_traverse as unknown as { default?: typeof _traverse }).default ?? _traverse) as typeof _traverse;\n\nexport interface ExpressionSite {\n path: NodePath<t.MemberExpression>;\n resolvedChain: ResolvedChain;\n}\n\nexport interface RewriteSitesOptions {\n ast: t.File;\n sites: ExpressionSite[];\n cssBindingName: string;\n filename: string;\n debug: boolean;\n mapping: TrussMapping;\n maybeIncHelperName: string | null;\n mergePropsHelperName: string;\n needsMergePropsHelper: { current: boolean };\n trussPropsHelperName: string;\n needsTrussPropsHelper: { current: boolean };\n trussDebugInfoName: string;\n needsTrussDebugInfo: { current: boolean };\n skippedCssPropMessages: Array<{ message: string; line: number | null }>;\n runtimeLookupNames: Map<string, string>;\n}\n\n/**\n * Rewrite collected `Css...$` expression sites into Truss-native style hash objects.\n *\n * In the new model, each site becomes an ObjectExpression keyed by CSS property.\n * JSX `css=` attributes become `trussProps(hash)` or `mergeProps(className, style, hash)` spreads.\n * Non-JSX positions become plain object expressions.\n */\nexport function rewriteExpressionSites(options: RewriteSitesOptions): void {\n for (const site of options.sites) {\n const styleHash = buildStyleHashFromChain(site.resolvedChain, options);\n const cssAttrPath = getCssAttributePath(site.path);\n const line = site.path.node.loc?.start.line ?? null;\n\n if (cssAttrPath) {\n // JSX css= attribute → spread trussProps or mergeProps\n cssAttrPath.replaceWith(t.jsxSpreadAttribute(buildCssSpreadExpression(cssAttrPath, styleHash, line, options)));\n } else {\n // Non-JSX position → plain object expression with optional debug info\n if (options.debug && line !== null) {\n injectDebugInfo(styleHash, line, options);\n }\n site.path.replaceWith(styleHash);\n }\n }\n\n rewriteCssPropsCalls(options);\n\n // Second pass: lower any remaining `css={...}` expression to `trussProps(...)`.\n rewriteCssAttributeExpressions(options);\n}\n\n/**\n * Return the enclosing `css={...}` JSX attribute path for a transformed site,\n * or null when the site is in a non-`css` expression context.\n */\nfunction getCssAttributePath(path: NodePath<t.MemberExpression>): NodePath<t.JSXAttribute> | null {\n const parentPath = path.parentPath;\n if (!parentPath || !parentPath.isJSXExpressionContainer()) return null;\n\n const attrPath = parentPath.parentPath;\n if (!attrPath || !attrPath.isJSXAttribute()) return null;\n if (!t.isJSXIdentifier(attrPath.node.name, { name: \"css\" })) return null;\n\n return attrPath;\n}\n\n// ---------------------------------------------------------------------------\n// Building style hash objects from resolved chains\n// ---------------------------------------------------------------------------\n\n/** Build an ObjectExpression from a ResolvedChain, handling conditionals. */\nfunction buildStyleHashFromChain(chain: ResolvedChain, options: RewriteSitesOptions): t.ObjectExpression {\n const members: (t.ObjectProperty | t.SpreadElement)[] = [];\n const previousProperties = new Map<string, t.ObjectProperty>();\n\n if (chain.markers.length > 0) {\n const markerClasses = chain.markers.map(function (marker) {\n return markerClassName(marker.markerNode);\n });\n members.push(t.objectProperty(t.identifier(\"__marker\"), t.stringLiteral(markerClasses.join(\" \"))));\n }\n\n for (const part of chain.parts) {\n if (part.type === \"unconditional\") {\n const partMembers = buildStyleHashMembers(part.segments, options);\n members.push(...partMembers);\n for (const member of partMembers) {\n if (t.isObjectProperty(member)) {\n previousProperties.set(propertyName(member.key), member);\n }\n }\n } else {\n // Conditional: ...(cond ? { then } : { else })\n const thenMembers = mergeConditionalBranchMembers(\n buildStyleHashMembers(part.thenSegments, options),\n previousProperties,\n );\n const elseMembers = mergeConditionalBranchMembers(\n buildStyleHashMembers(part.elseSegments, options),\n previousProperties,\n );\n members.push(\n t.spreadElement(\n t.conditionalExpression(part.conditionNode, t.objectExpression(thenMembers), t.objectExpression(elseMembers)),\n ),\n );\n }\n }\n\n return t.objectExpression(members);\n}\n\n/**\n * Build ObjectExpression members from a list of segments.\n *\n * Normal segments are batched and processed by buildStyleHashProperties.\n * Special segments (styleArrayArg, typographyLookup) produce SpreadElements.\n */\nfunction buildStyleHashMembers(\n segments: ResolvedSegment[],\n options: RewriteSitesOptions,\n): (t.ObjectProperty | t.SpreadElement)[] {\n const members: (t.ObjectProperty | t.SpreadElement)[] = [];\n const normalSegs: ResolvedSegment[] = [];\n\n function flushNormal(): void {\n if (normalSegs.length > 0) {\n members.push(...buildStyleHashProperties(normalSegs, options.mapping, options.maybeIncHelperName));\n normalSegs.length = 0;\n }\n }\n\n for (const seg of segments) {\n if (seg.error) continue;\n\n if (seg.styleArrayArg) {\n flushNormal();\n // In the new model, add(cssProp) takes a style hash object — just spread it\n members.push(t.spreadElement(seg.styleArrayArg as t.Expression));\n continue;\n }\n\n if (seg.typographyLookup) {\n flushNormal();\n const lookupName = options.runtimeLookupNames.get(seg.typographyLookup.lookupKey);\n if (lookupName) {\n // I.e. `{ ...(__typography[key] ?? {}) }`\n const lookupAccess = t.memberExpression(\n t.identifier(lookupName),\n seg.typographyLookup.argNode as t.Expression,\n true,\n );\n members.push(t.spreadElement(t.logicalExpression(\"??\", lookupAccess, t.objectExpression([]))));\n }\n continue;\n }\n\n normalSegs.push(seg);\n }\n\n flushNormal();\n return members;\n}\n\nfunction mergeConditionalBranchMembers(\n members: (t.ObjectProperty | t.SpreadElement)[],\n previousProperties: Map<string, t.ObjectProperty>,\n): (t.ObjectProperty | t.SpreadElement)[] {\n return members.map(function (member) {\n if (!t.isObjectProperty(member)) {\n return member;\n }\n\n const prior = previousProperties.get(propertyName(member.key));\n if (!prior) {\n return member;\n }\n\n return t.objectProperty(\n clonePropertyKey(member.key),\n mergePropertyValues(prior.value as t.Expression, member.value as t.Expression),\n );\n });\n}\n\nfunction mergePropertyValues(previousValue: t.Expression, currentValue: t.Expression): t.Expression {\n if (t.isStringLiteral(previousValue) && t.isStringLiteral(currentValue)) {\n return t.stringLiteral(`${previousValue.value} ${currentValue.value}`);\n }\n\n if (t.isStringLiteral(previousValue) && t.isArrayExpression(currentValue)) {\n return mergeTupleValue(currentValue, previousValue.value, true);\n }\n\n if (t.isArrayExpression(previousValue) && t.isStringLiteral(currentValue)) {\n return mergeTupleValue(previousValue, currentValue.value, false);\n }\n\n if (t.isArrayExpression(previousValue) && t.isArrayExpression(currentValue)) {\n const previousClassNames = tupleClassNames(previousValue);\n return mergeTupleValue(currentValue, previousClassNames, true, arrayElementExpression(previousValue.elements[1]));\n }\n\n return t.cloneNode(currentValue, true);\n}\n\nfunction mergeTupleValue(\n tuple: t.ArrayExpression,\n classNames: string,\n prependClassNames: boolean,\n previousVars?: t.Expression | null,\n): t.ArrayExpression {\n const currentClassNames = tupleClassNames(tuple);\n const mergedClassNames = prependClassNames\n ? `${classNames} ${currentClassNames}`\n : `${currentClassNames} ${classNames}`;\n const varsExpr = tuple.elements[1];\n const mergedVars =\n previousVars && arrayElementExpression(varsExpr)\n ? mergeVarsObject(previousVars, arrayElementExpression(varsExpr)!)\n : (arrayElementExpression(varsExpr) ?? previousVars ?? null);\n\n return t.arrayExpression([\n t.stringLiteral(mergedClassNames),\n mergedVars ? t.cloneNode(mergedVars, true) : t.objectExpression([]),\n ]);\n}\n\nfunction tupleClassNames(tuple: t.ArrayExpression): string {\n const classNames = tuple.elements[0];\n return t.isStringLiteral(classNames) ? classNames.value : \"\";\n}\n\nfunction arrayElementExpression(element: t.Expression | t.SpreadElement | null | undefined): t.Expression | null {\n return element && !t.isSpreadElement(element) ? element : null;\n}\n\nfunction mergeVarsObject(previousVars: t.Expression, currentVars: t.Expression): t.Expression {\n if (t.isObjectExpression(previousVars) && t.isObjectExpression(currentVars)) {\n return t.objectExpression([\n ...previousVars.properties.map(function (property) {\n return t.cloneNode(property, true);\n }),\n ...currentVars.properties.map(function (property) {\n return t.cloneNode(property, true);\n }),\n ]);\n }\n\n return t.cloneNode(currentVars, true);\n}\n\nfunction propertyName(key: t.Expression | t.Identifier | t.PrivateName): string {\n if (t.isIdentifier(key)) {\n return key.name;\n }\n if (t.isStringLiteral(key)) {\n return key.value;\n }\n return generate(key).code;\n}\n\nfunction clonePropertyKey(key: t.Expression | t.Identifier | t.PrivateName): t.Expression | t.Identifier {\n if (t.isPrivateName(key)) {\n return t.identifier(key.id.name);\n }\n return t.cloneNode(key, true);\n}\n\n// ---------------------------------------------------------------------------\n// Debug info injection\n// ---------------------------------------------------------------------------\n\n/**\n * Inject debug info into the first property of a style hash ObjectExpression.\n *\n * For static values, promotes `\"df\"` to `[\"df\", new TrussDebugInfo(\"...\")]`.\n * For variable tuples, appends the debug info as a third element.\n */\nfunction injectDebugInfo(\n expr: t.ObjectExpression,\n line: number,\n options: Pick<RewriteSitesOptions, \"debug\" | \"trussDebugInfoName\" | \"needsTrussDebugInfo\" | \"filename\">,\n): void {\n if (!options.debug) return;\n\n // Find the first real style property (skip SpreadElements and __marker metadata)\n const firstProp = expr.properties.find(function (p) {\n return (\n t.isObjectProperty(p) &&\n !(\n (t.isIdentifier(p.key) && p.key.name === \"__marker\") ||\n (t.isStringLiteral(p.key) && p.key.value === \"__marker\")\n )\n );\n }) as t.ObjectProperty | undefined;\n if (!firstProp) return;\n\n options.needsTrussDebugInfo.current = true;\n const debugExpr = t.newExpression(t.identifier(options.trussDebugInfoName), [\n t.stringLiteral(`${options.filename}:${line}`),\n ]);\n\n if (t.isStringLiteral(firstProp.value)) {\n // Static: \"df\" → [\"df\", new TrussDebugInfo(\"...\")]\n firstProp.value = t.arrayExpression([firstProp.value, debugExpr]);\n } else if (t.isArrayExpression(firstProp.value)) {\n // Variable tuple: [\"mt_var\", { vars }] → [\"mt_var\", { vars }, new TrussDebugInfo(\"...\")]\n firstProp.value.elements.push(debugExpr);\n }\n}\n\n/** Build the `new TrussDebugInfo(\"File.tsx:line\")` expression for a site. */\nfunction buildDebugExpr(\n line: number | null,\n options: Pick<RewriteSitesOptions, \"debug\" | \"trussDebugInfoName\" | \"needsTrussDebugInfo\" | \"filename\">,\n): t.NewExpression | null {\n if (!options.debug || line === null) return null;\n\n options.needsTrussDebugInfo.current = true;\n return t.newExpression(t.identifier(options.trussDebugInfoName), [t.stringLiteral(`${options.filename}:${line}`)]);\n}\n\n// ---------------------------------------------------------------------------\n// JSX css= attribute handling\n// ---------------------------------------------------------------------------\n\n/** Build the spread expression for a JSX `css=` attribute. */\nfunction buildCssSpreadExpression(\n path: NodePath<t.JSXAttribute>,\n styleHash: t.Expression,\n line: number | null,\n options: RewriteSitesOptions,\n): t.Expression {\n const existingClassNameExpr = removeExistingAttribute(path, \"className\");\n const existingStyleExpr = removeExistingAttribute(path, \"style\");\n\n if (!existingClassNameExpr && !existingStyleExpr) {\n return buildPropsCall(styleHash, line, options);\n }\n\n // mergeProps(className, style, hash)\n options.needsMergePropsHelper.current = true;\n\n if (options.debug && line !== null) {\n injectDebugInfo(styleHash as t.ObjectExpression, line, options);\n }\n\n return t.callExpression(t.identifier(options.mergePropsHelperName), [\n existingClassNameExpr ?? t.identifier(\"undefined\"),\n existingStyleExpr ?? t.identifier(\"undefined\"),\n styleHash,\n ]);\n}\n\n/** Emit `trussProps(hash)` call. In debug mode, injects debug info into the hash first. */\nfunction buildPropsCall(styleHash: t.Expression, line: number | null, options: RewriteSitesOptions): t.CallExpression {\n options.needsTrussPropsHelper.current = true;\n\n if (options.debug && line !== null && t.isObjectExpression(styleHash)) {\n injectDebugInfo(styleHash, line, options);\n }\n\n return t.callExpression(t.identifier(options.trussPropsHelperName), [styleHash]);\n}\n\n/** Remove a sibling JSX attribute and return its expression. */\nfunction removeExistingAttribute(path: NodePath<t.JSXAttribute>, attrName: string): t.Expression | null {\n const openingElement = path.parentPath;\n if (!openingElement || !openingElement.isJSXOpeningElement()) return null;\n\n const attrs = openingElement.node.attributes;\n for (let i = 0; i < attrs.length; i++) {\n const attr = attrs[i];\n if (!t.isJSXAttribute(attr) || !t.isJSXIdentifier(attr.name, { name: attrName })) continue;\n\n let expr: t.Expression | null = null;\n if (t.isStringLiteral(attr.value)) {\n expr = attr.value;\n } else if (t.isJSXExpressionContainer(attr.value) && t.isExpression(attr.value.expression)) {\n expr = attr.value.expression;\n }\n\n attrs.splice(i, 1);\n return expr;\n }\n\n return null;\n}\n\n// ---------------------------------------------------------------------------\n// Css.props(...) rewriting\n// ---------------------------------------------------------------------------\n\n/**\n * Rewrite `Css.props(expr)` into `trussProps(expr)`.\n *\n * In the new model, the argument is already a style hash, so we just delegate to trussProps.\n */\nfunction rewriteCssPropsCalls(options: RewriteSitesOptions): void {\n traverse(options.ast, {\n CallExpression(path: NodePath<t.CallExpression>) {\n if (!isCssPropsCall(path.node, options.cssBindingName)) return;\n\n const arg = path.node.arguments[0];\n if (!arg || t.isSpreadElement(arg) || !t.isExpression(arg) || path.node.arguments.length !== 1) return;\n\n const line = path.node.loc?.start.line ?? null;\n\n options.needsTrussPropsHelper.current = true;\n\n // Check for a sibling `className` property in the parent object literal\n const classNameExpr = extractSiblingClassName(path);\n if (classNameExpr) {\n options.needsMergePropsHelper.current = true;\n path.replaceWith(\n t.callExpression(t.identifier(options.mergePropsHelperName), [classNameExpr, t.identifier(\"undefined\"), arg]),\n );\n } else {\n path.replaceWith(t.callExpression(t.identifier(options.trussPropsHelperName), [arg]));\n }\n },\n });\n}\n\n// ---------------------------------------------------------------------------\n// Second pass: remaining css={...} attributes\n// ---------------------------------------------------------------------------\n\n/**\n * Rewrite any remaining `css={expr}` JSX attributes into `{...trussProps(expr)}`.\n *\n * This handles cases where the css prop value is not a direct `Css.*.$` chain,\n * e.g. `css={someVariable}`, `css={{ ...a, ...b }}`, `css={cond ? a : b}`.\n *\n * In the new model, all of these just need to be wrapped in trussProps().\n */\nfunction rewriteCssAttributeExpressions(options: RewriteSitesOptions): void {\n traverse(options.ast, {\n JSXAttribute(path: NodePath<t.JSXAttribute>) {\n if (!t.isJSXIdentifier(path.node.name, { name: \"css\" })) return;\n const value = path.node.value;\n if (!t.isJSXExpressionContainer(value)) return;\n if (!t.isExpression(value.expression)) return;\n\n const expr = value.expression;\n const line = path.node.loc?.start.line ?? null;\n\n const existingClassNameExpr = removeExistingAttribute(path, \"className\");\n const existingStyleExpr = removeExistingAttribute(path, \"style\");\n\n if (existingClassNameExpr || existingStyleExpr) {\n options.needsMergePropsHelper.current = true;\n path.replaceWith(\n t.jsxSpreadAttribute(\n t.callExpression(t.identifier(options.mergePropsHelperName), [\n existingClassNameExpr ?? t.identifier(\"undefined\"),\n existingStyleExpr ?? t.identifier(\"undefined\"),\n expr,\n ]),\n ),\n );\n } else {\n options.needsTrussPropsHelper.current = true;\n path.replaceWith(t.jsxSpreadAttribute(t.callExpression(t.identifier(options.trussPropsHelperName), [expr])));\n }\n },\n });\n}\n\n// ---------------------------------------------------------------------------\n// Utility helpers\n// ---------------------------------------------------------------------------\n\n/** Match `Css.props(...)` calls. */\nfunction isCssPropsCall(expr: t.CallExpression, cssBindingName: string): boolean {\n return (\n t.isMemberExpression(expr.callee) &&\n !expr.callee.computed &&\n t.isIdentifier(expr.callee.object, { name: cssBindingName }) &&\n t.isIdentifier(expr.callee.property, { name: \"props\" })\n );\n}\n\n/**\n * If `...Css.props(...)` is spread inside an object literal that has a sibling\n * `className` property, extract and remove that property so the rewrite can\n * merge it via `mergeProps`.\n */\nfunction extractSiblingClassName(callPath: NodePath<t.CallExpression>): t.Expression | null {\n // Walk up: CallExpression → SpreadElement → ObjectExpression\n const spreadPath = callPath.parentPath;\n if (!spreadPath || !spreadPath.isSpreadElement()) return null;\n const objectPath = spreadPath.parentPath;\n if (!objectPath || !objectPath.isObjectExpression()) return null;\n\n const properties = objectPath.node.properties;\n for (let i = 0; i < properties.length; i++) {\n const prop = properties[i];\n if (!t.isObjectProperty(prop)) continue;\n if (!isMatchingPropertyName(prop.key, \"className\")) continue;\n if (!t.isExpression(prop.value)) continue;\n\n const classNameExpr = prop.value;\n properties.splice(i, 1);\n return classNameExpr;\n }\n\n return null;\n}\n\n/** Match static object property names. */\nfunction isMatchingPropertyName(key: t.Expression | t.Identifier | t.PrivateName, name: string): boolean {\n return (t.isIdentifier(key) && key.name === name) || (t.isStringLiteral(key) && key.value === name);\n}\n\n/** Generate a compact code snippet for diagnostics. */\nfunction formatNodeSnippet(node: t.Node): string {\n return generate(node, { compact: true, comments: true }).code;\n}\n","import { parse } from \"@babel/parser\";\nimport * as t from \"@babel/types\";\nimport type { TrussMapping } from \"./types\";\nimport { resolveFullChain } from \"./resolve-chain\";\nimport { extractChain, findCssImportBinding } from \"./ast-utils\";\nimport { collectStaticStringBindings, resolveStaticString } from \"./css-ts-utils\";\n\n/**\n * Transform a `.css.ts` file into a plain CSS string.\n *\n * The file is expected to have the shape:\n * ```ts\n * import { Css } from \"./Css\";\n * export const css = {\n * \".some-selector\": Css.df.blue.$,\n * \".other > .selector\": Css.mt(2).black.$,\n * };\n * ```\n *\n * Each key is a CSS selector (string literal), each value is a `Css.*.$` chain.\n * The chains are resolved via the truss mapping into concrete CSS declarations.\n *\n * Returns the generated CSS string.\n */\nexport function transformCssTs(code: string, filename: string, mapping: TrussMapping): string {\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n const cssBindingName = findCssImportBinding(ast);\n if (!cssBindingName) {\n return `/* [truss] ${filename}: no Css import found */\\n`;\n }\n\n // Find the `export const css = { ... }` expression\n const cssExport = findNamedCssExportObject(ast);\n if (!cssExport) {\n return `/* [truss] ${filename}: expected \\`export const css = { ... }\\` with an object literal */\\n`;\n }\n\n const rules: string[] = [];\n const stringBindings = collectStaticStringBindings(ast);\n\n for (const prop of cssExport.properties) {\n if (t.isSpreadElement(prop)) {\n rules.push(`/* [truss] unsupported: spread elements in css.ts export */`);\n continue;\n }\n\n if (!t.isObjectProperty(prop)) {\n rules.push(`/* [truss] unsupported: non-property in css.ts export */`);\n continue;\n }\n\n // Key must be a string literal (the CSS selector)\n const selector = objectPropertyStringKey(prop, stringBindings);\n if (selector === null) {\n rules.push(`/* [truss] unsupported: non-string-literal key in css.ts export */`);\n continue;\n }\n\n // Value must be a Css.*.$ expression\n const valueNode = prop.value;\n if (!t.isExpression(valueNode)) {\n rules.push(`/* [truss] unsupported: \"${selector}\" value is not an expression */`);\n continue;\n }\n\n const cssResult = resolveCssExpression(valueNode, cssBindingName, mapping, filename);\n if (\"error\" in cssResult) {\n rules.push(`/* [truss] unsupported: \"${selector}\" — ${cssResult.error} */`);\n continue;\n }\n\n rules.push(formatCssRule(selector, cssResult.declarations));\n }\n\n return rules.join(\"\\n\\n\") + \"\\n\";\n}\n\n/** Find the object expression in `export const css = { ... }`. */\nfunction findNamedCssExportObject(ast: t.File): t.ObjectExpression | null {\n for (const node of ast.program.body) {\n if (!t.isExportNamedDeclaration(node) || !node.declaration) continue;\n if (!t.isVariableDeclaration(node.declaration)) continue;\n\n for (const declarator of node.declaration.declarations) {\n if (!t.isIdentifier(declarator.id, { name: \"css\" })) continue;\n const value = unwrapObjectExpression(declarator.init);\n if (value) return value;\n }\n }\n return null;\n}\n\nfunction unwrapObjectExpression(node: t.Expression | null | undefined): t.ObjectExpression | null {\n if (!node) return null;\n if (t.isObjectExpression(node)) return node;\n if (t.isTSAsExpression(node) || t.isTSSatisfiesExpression(node)) return unwrapObjectExpression(node.expression);\n return null;\n}\n\n/** Extract a static string key from an ObjectProperty. */\nfunction objectPropertyStringKey(prop: t.ObjectProperty, stringBindings: Map<string, string>): string | null {\n if (t.isStringLiteral(prop.key)) return prop.key.value;\n // Allow unquoted identifiers as keys too (e.g. `body: Css.df.$`)\n if (t.isIdentifier(prop.key) && !prop.computed) return prop.key.name;\n if (prop.computed) return resolveStaticString(prop.key, stringBindings);\n return null;\n}\n\ninterface CssResolution {\n declarations: Array<{ property: string; value: string }>;\n error?: undefined;\n}\ninterface CssError {\n declarations?: undefined;\n error: string;\n}\n\n/**\n * Resolve a `Css.*.$` expression node to CSS declarations.\n *\n * Validates that the chain only uses static/literal patterns (no variable args,\n * no if/else conditionals, no pseudo/media modifiers).\n */\nfunction resolveCssExpression(\n node: t.Expression,\n cssBindingName: string,\n mapping: TrussMapping,\n filename: string,\n): CssResolution | CssError {\n // The expression must end with `.$`\n if (!t.isMemberExpression(node) || node.computed || !t.isIdentifier(node.property, { name: \"$\" })) {\n return { error: \"value must be a Css.*.$ expression\" };\n }\n\n const chain = extractChain(node.object, cssBindingName);\n if (!chain) {\n return { error: \"could not extract Css chain from expression\" };\n }\n\n // Validate: no if/else nodes\n for (const n of chain) {\n if (n.type === \"if\") return { error: \"if() conditionals are not supported in .css.ts files\" };\n if (n.type === \"else\") return { error: \"else is not supported in .css.ts files\" };\n }\n\n const resolved = resolveFullChain(chain, mapping);\n\n // Check for errors from resolution\n if (resolved.errors.length > 0) {\n return { error: resolved.errors[0] };\n }\n\n // Validate: no conditionals came back\n for (const part of resolved.parts) {\n if (part.type === \"conditional\") {\n return { error: \"conditional chains are not supported in .css.ts files\" };\n }\n }\n\n // Collect all declarations from all unconditional parts\n const declarations: Array<{ property: string; value: string }> = [];\n\n for (const part of resolved.parts) {\n if (part.type !== \"unconditional\") continue;\n for (const seg of part.segments) {\n if (seg.error) {\n return { error: seg.error };\n }\n\n // Reject segments that require runtime (variable with variable args)\n if (seg.variableProps && !seg.argResolved) {\n return { error: `variable value with variable argument is not supported in .css.ts files` };\n }\n if (seg.typographyLookup) {\n return { error: `typography() with a runtime key is not supported in .css.ts files` };\n }\n if (seg.styleArrayArg) {\n return { error: `add(cssProp) is not supported in .css.ts files` };\n }\n\n // Reject segments with media query / pseudo-class / pseudo-element / when modifiers\n if (seg.mediaQuery) {\n return { error: `media query modifiers (ifSm, ifMd, etc.) are not supported in .css.ts files` };\n }\n if (seg.pseudoClass) {\n return { error: `pseudo-class modifiers (onHover, onFocus, etc.) are not supported in .css.ts files` };\n }\n if (seg.pseudoElement) {\n return { error: `pseudo-element modifiers are not supported in .css.ts files` };\n }\n if (seg.whenPseudo) {\n return { error: `when() modifiers are not supported in .css.ts files` };\n }\n\n // Extract CSS property/value pairs from defs\n for (const [prop, value] of Object.entries(seg.defs)) {\n if (typeof value === \"string\" || typeof value === \"number\") {\n declarations.push({ property: camelToKebab(prop), value: String(value) });\n } else {\n // Nested condition objects (shouldn't happen after our validation, but defensive)\n return { error: `unexpected nested value for property \"${prop}\"` };\n }\n }\n }\n }\n\n return { declarations };\n}\n\n/** Convert a camelCase CSS property name to kebab-case. */\nexport function camelToKebab(s: string): string {\n // Handle vendor prefixes like WebkitTransform → -webkit-transform\n return s.replace(/^(Webkit|Moz|Ms|O)/, (m) => `-${m.toLowerCase()}`).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);\n}\n\n/** Format a CSS rule block. */\nfunction formatCssRule(selector: string, declarations: Array<{ property: string; value: string }>): string {\n if (declarations.length === 0) {\n return `${selector} {}`;\n }\n const body = declarations.map((d) => ` ${d.property}: ${d.value};`).join(\"\\n\");\n return `${selector} {\\n${body}\\n}`;\n}\n","import * as t from \"@babel/types\";\n\n/** Resolve module-scope string constants so .css.ts selectors can reuse them. */\nexport function collectStaticStringBindings(ast: t.File): Map<string, string> {\n const bindings = new Map<string, string>();\n let changed = true;\n\n while (changed) {\n changed = false;\n\n for (const node of ast.program.body) {\n const declaration = getTopLevelVariableDeclaration(node);\n if (!declaration) continue;\n\n for (const declarator of declaration.declarations) {\n if (!t.isIdentifier(declarator.id) || !declarator.init) continue;\n if (bindings.has(declarator.id.name)) continue;\n\n const value = resolveStaticString(declarator.init, bindings);\n if (value === null) continue;\n\n bindings.set(declarator.id.name, value);\n changed = true;\n }\n }\n }\n\n return bindings;\n}\n\n/** Resolve a static string expression from a literal, template, or identifier. */\nexport function resolveStaticString(node: t.Node | null | undefined, bindings: Map<string, string>): string | null {\n if (!node) return null;\n\n if (t.isStringLiteral(node)) return node.value;\n\n if (t.isTemplateLiteral(node)) {\n let value = \"\";\n for (let i = 0; i < node.quasis.length; i++) {\n value += node.quasis[i].value.cooked ?? \"\";\n if (i >= node.expressions.length) continue;\n\n const expressionValue = resolveStaticString(node.expressions[i], bindings);\n if (expressionValue === null) return null;\n value += expressionValue;\n }\n return value;\n }\n\n if (t.isIdentifier(node)) {\n return bindings.get(node.name) ?? null;\n }\n\n if (t.isTSAsExpression(node) || t.isTSSatisfiesExpression(node) || t.isTSNonNullExpression(node)) {\n return resolveStaticString(node.expression, bindings);\n }\n\n if (t.isParenthesizedExpression(node)) {\n return resolveStaticString(node.expression, bindings);\n }\n\n if (t.isBinaryExpression(node, { operator: \"+\" })) {\n const left = resolveStaticString(node.left, bindings);\n const right = resolveStaticString(node.right, bindings);\n if (left === null || right === null) return null;\n return left + right;\n }\n\n return null;\n}\n\nfunction getTopLevelVariableDeclaration(node: t.Statement): t.VariableDeclaration | null {\n if (t.isVariableDeclaration(node)) {\n return node;\n }\n\n if (t.isExportNamedDeclaration(node) && node.declaration && t.isVariableDeclaration(node.declaration)) {\n return node.declaration;\n }\n\n return null;\n}\n","import { parse } from \"@babel/parser\";\nimport _generate from \"@babel/generator\";\nimport * as t from \"@babel/types\";\nimport { findLastImportIndex } from \"./ast-utils\";\n\n// Babel generator is published as CJS, so normalize default interop before using it.\nconst generate = ((_generate as unknown as { default?: typeof _generate }).default ?? _generate) as typeof _generate;\n\nexport interface RewriteCssTsImportsResult {\n code: string;\n changed: boolean;\n}\n\n/**\n * Rewrite `.css.ts` imports so runtime imports stay pointed at the real module,\n * while a separate `?truss-css` side-effect import is added for generated CSS.\n *\n * I.e. `import { foo } from \"./App.css.ts\"` becomes:\n * - `import { foo } from \"./App.css.ts\"`\n * - `import \"./App.css.ts?truss-css\"`\n *\n * Pure side-effect imports are rewritten directly to the virtual CSS import.\n */\nexport function rewriteCssTsImports(code: string, filename: string): RewriteCssTsImportsResult {\n if (!code.includes(\".css.ts\")) {\n return { code, changed: false };\n }\n\n const ast = parse(code, {\n sourceType: \"module\",\n plugins: [\"typescript\", \"jsx\"],\n sourceFilename: filename,\n });\n\n const existingCssSideEffects = new Set<string>();\n const neededCssSideEffects = new Set<string>();\n let changed = false;\n\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n if (typeof node.source.value !== \"string\") continue;\n if (!node.source.value.endsWith(\".css.ts\")) continue;\n\n if (node.specifiers.length === 0) {\n node.source = t.stringLiteral(toVirtualCssSpecifier(node.source.value));\n existingCssSideEffects.add(node.source.value);\n changed = true;\n continue;\n }\n\n neededCssSideEffects.add(toVirtualCssSpecifier(node.source.value));\n }\n\n const sideEffectImports: t.ImportDeclaration[] = [];\n for (const source of neededCssSideEffects) {\n if (existingCssSideEffects.has(source)) continue;\n sideEffectImports.push(t.importDeclaration([], t.stringLiteral(source)));\n changed = true;\n }\n\n if (!changed) {\n return { code, changed: false };\n }\n\n if (sideEffectImports.length > 0) {\n const insertIndex = findLastImportIndex(ast) + 1;\n ast.program.body.splice(insertIndex, 0, ...sideEffectImports);\n }\n\n const output = generate(ast, {\n sourceFileName: filename,\n retainLines: false,\n });\n return { code: output.code, changed: true };\n}\n\nfunction toVirtualCssSpecifier(source: string): string {\n return `${source}?truss-css`;\n}\n"],"mappings":";AAAA,SAAS,cAAc,eAAe,kBAAkB;AACxD,SAAS,SAAS,SAAS,YAAY,YAAY;;;ACDnD,YAAY,OAAO;AA8BnB,IAAM,gBAAwC;AAAA,EAC5C,UAAU;AAAA,EACV,UAAU;AAAA,EACV,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX,aAAa;AACf;AAGA,IAAM,eAAyB,CAAC,UAAU,UAAU,kBAAkB,WAAW,WAAW;AAG5F,IAAM,qBAA6C;AAAA,EACjD,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,eAAe;AAAA,EACf,YAAY;AACd;AAGO,IAAM,uBAAuB;AAG7B,SAAS,gBAAgB,YAAsD;AACpF,MAAI,CAAC,WAAY,QAAO;AACxB,MAAI,WAAW,SAAS,gBAAgB,WAAW,MAAM;AACvD,WAAO,aAAa,WAAW,IAAI;AAAA,EACrC;AACA,SAAO,GAAG,oBAAoB;AAChC;AAQA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A,SAAO;AACT;AAEA,SAAS,kBAAkB,UAA2B;AACpD,SAAO,cAAc,QAAQ,EAAE,SAAS,gBAAgB;AAC1D;AAEA,SAAS,iCAAiC,UAAkB,kBAAqC;AAC/F,QAAM,iBAAiB,cAAc,QAAQ;AAC7C,SAAO,iBAAiB,KAAK,SAAU,KAAK;AAC1C,WAAO,eAAe,SAAS,iBAAiB,GAAG,GAAG;AAAA,EACxD,CAAC;AACH;AAEA,SAAS,cAAc,MAAsB;AAC3C,SAAO,KAAK,QAAQ,OAAO,GAAG;AAChC;AAGO,SAAS,YAAY,MAA4B;AACtD,QAAM,MAAM,aAAa,MAAM,MAAM;AACrC,SAAO,KAAK,MAAM,GAAG;AACvB;","names":["conditionPrefix","_traverse","_generate","t","suffix","key","t","t","traverse","_traverse","generate","_generate","parse","t","t","parse","camelToKebab","parse","_generate","t","generate","_generate","parse"]}
|