@homebound/truss 2.19.1 → 2.19.3
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/index.js +2 -2
- package/build/index.js.map +1 -1
- package/build/plugin/index.js +64 -17
- package/build/plugin/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugin/index.ts","../../src/plugin/emit-truss.ts","../../src/plugin/property-priorities.ts","../../src/plugin/priority.ts","../../src/plugin/css-property-abbreviations.ts","../../src/plugin/transform.ts","../../src/plugin/ast-utils.ts","../../src/plugin/resolve-chain.ts","../../src/plugin/rewrite-sites.ts","../../src/plugin/transform-css.ts","../../src/plugin/css-ts-utils.ts","../../src/plugin/rewrite-css-ts-imports.ts","../../src/plugin/merge-css.ts","../../src/plugin/esbuild-plugin.ts"],"sourcesContent":["import { readFileSync, writeFileSync, existsSync, readdirSync } from \"fs\";\nimport { resolve, dirname, isAbsolute, join } from \"path\";\nimport { createHash } from \"crypto\";\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\";\nimport { readTrussCss, mergeTrussCss, parseTrussCss, type ParsedTrussCss } from \"./merge-css\";\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 /** Paths to pre-compiled truss.css files from libraries to merge into the app's CSS. */\n libraries?: 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/** Placeholder injected into HTML during build; replaced with the hashed CSS filename in generateBundle. */\nconst TRUSS_CSS_PLACEHOLDER = \"__TRUSS_CSS_HASH__\";\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// Test-only bootstrap that injects the same merged collectCss() output used by\n// /virtual:truss.css, but as a virtual module side effect instead of an HTTP\n// fetch. In dev, the browser reaches /virtual:truss.css via transformIndexHtml\n// -> virtual:truss:runtime -> fetch(\"/virtual:truss.css\") -> configureServer.\n// Vitest/jsdom does not boot from index.html or run that browser fetch/HMR path;\n// it imports modules directly into the test environment, so CSS has to enter via\n// a module side effect instead.\nconst VIRTUAL_TEST_CSS_ID = \"virtual:truss:test-css\";\nconst RESOLVED_VIRTUAL_TEST_CSS_ID = \"\\0\" + VIRTUAL_TEST_CSS_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 content-hashed CSS asset (e.g. `assets/truss-abc123.css`) for long-term caching.\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 libraryPaths = opts.libraries ?? [];\n /** The hashed CSS filename emitted during generateBundle, used by writeBundle to patch HTML. */\n let emittedCssFileName: string | null = null;\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 /** Cached parsed library CSS (loaded once per build). */\n let libraryCache: ParsedTrussCss[] | null = null;\n\n /** Load and cache all library truss.css files. */\n function loadLibraries(): ParsedTrussCss[] {\n if (!libraryCache) {\n libraryCache = libraryPaths.map((libPath) => {\n const resolved = resolve(projectRoot || process.cwd(), libPath);\n return readTrussCss(resolved);\n });\n }\n return libraryCache;\n }\n\n /**\n * Generate the full CSS string from the global registry, merged with library CSS.\n *\n * When `libraries` are configured, parses each library's annotated truss.css,\n * combines with the app's own rules, deduplicates by class name, and sorts\n * by priority to produce a unified stylesheet.\n */\n function collectCss(): string {\n const appCss = generateCssText(cssRegistry);\n const libs = loadLibraries();\n if (libs.length === 0) return appCss;\n // Parse the app's own annotated CSS and merge with library sources\n const appParsed = parseTrussCss(appCss);\n return mergeTrussCss([...libs, appParsed]);\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 and library cache at start of each build\n cssRegistry.clear();\n libraryCache = null;\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((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(() => {\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\", () => {\n clearInterval(interval);\n });\n },\n\n transformIndexHtml(html: string) {\n if (isBuild) {\n // Strip any existing truss CSS references so the hook is idempotent when\n // a tool (e.g. Storybook) runs multiple Vite builds with the same plugin.\n // I.e. removes /virtual:truss.css, __TRUSS_CSS_HASH__, and /assets/truss-<hash>.css\n const stripped = html\n .replace(/\\s*<link[^>]*href=[\"'][^\"']*virtual:truss\\.css[\"'][^>]*\\/?>/g, \"\")\n .replace(/\\s*<link[^>]*href=[\"'][^\"']*__TRUSS_CSS_HASH__[\"'][^>]*\\/?>/g, \"\")\n .replace(/\\s*<link[^>]*href=[\"'][^\"']*\\/assets\\/truss-[0-9a-f]+\\.css[\"'][^>]*\\/?>/g, \"\");\n // Inject a stylesheet link with a placeholder; writeBundle replaces it\n // with the content-hashed filename for long-term caching.\n const link = `<link rel=\"stylesheet\" href=\"${TRUSS_CSS_PLACEHOLDER}\">`;\n return stripped.replace(\"</head>\", ` ${link}\\n </head>`);\n }\n // Inject the virtual runtime script for dev mode; it owns style updates.\n const tag = `<script type=\"module\" src=\"/${VIRTUAL_RUNTIME_ID}\"></script>`;\n return html.replace(\"</head>\", ` ${tag}\\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 if (source === VIRTUAL_TEST_CSS_ID || source === \"/\" + VIRTUAL_TEST_CSS_ID) {\n return RESOLVED_VIRTUAL_TEST_CSS_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(() => {\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((r) => r.text())\n .then((css) => { style.textContent = css; })\n .catch(() => {});\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\", () => {\n setTimeout(fetchCss, 50);\n });\n }\n})();\n`;\n }\n if (id === RESOLVED_VIRTUAL_TEST_CSS_ID) {\n // Vitest/jsdom has no dev server stylesheet fetch, so inject the full\n // merged CSS payload once via a virtual side-effect module.\n const css = collectCss();\n return `\nimport { __injectTrussCSS } from \"@homebound/truss/runtime\";\n\n__injectTrussCSS(${JSON.stringify(css)});\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 fileId = stripQueryAndHash(id);\n\n // In tests, we do not boot through index.html and the dev runtime fetch path\n // (`virtual:truss:runtime` -> fetch(\"/virtual:truss.css\")), so we inject the\n // merged application + library CSS through a virtual module side effect instead.\n //\n // We add `import \"virtual:truss:test-css\"` to each eligible transformed module,\n // but ESM module caching should evaluate that virtual module only once per test\n // module graph. Transformed files may still emit per-file `__injectTrussCSS`\n // calls; exact repeated chunks are deduped in the runtime helper.\n const shouldBootstrapTestCss = isTest && libraryPaths.length > 0 && !isNodeModulesFile(fileId);\n const testCssBootstrap = injectTestCssBootstrapImport(rewrittenCode, shouldBootstrapTestCss);\n const transformedCode = testCssBootstrap.code;\n const hasCssDsl = rewrittenCode.includes(\"Css\") || rewrittenCode.includes(\"css=\");\n if (isNodeModulesFile(fileId)) {\n return null;\n }\n if (!hasCssDsl && !rewrittenImports.changed && !testCssBootstrap.changed) return null;\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 || testCssBootstrap.changed ? { code: transformedCode, 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: transformedCode, 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(\n transformedCode,\n fileId,\n ensureMapping(),\n // In test mode (jsdom), inject CSS directly so document.styleSheets has rules\n { debug, injectCss: isTest },\n );\n if (!result) {\n if (!rewrittenImports.changed && !testCssBootstrap.changed) return null;\n return { code: transformedCode, 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 // Compute a content hash so the filename is cache-bustable.\n const hash = createHash(\"sha256\").update(css).digest(\"hex\").slice(0, 8);\n const fileName = `assets/truss-${hash}.css`;\n emittedCssFileName = fileName;\n\n (this as any).emitFile({\n type: \"asset\",\n fileName,\n source: css,\n });\n },\n\n /** Patch HTML files on disk to replace the CSS placeholder with the hashed filename. */\n writeBundle(options: any, _bundle: any) {\n if (!emittedCssFileName) return;\n const outDir = options.dir || join(projectRoot, \"dist\");\n // Find and patch all HTML files in the output directory\n for (const entry of readdirSync(outDir)) {\n if (!entry.endsWith(\".html\")) continue;\n const htmlPath = join(outDir, entry);\n const html = readFileSync(htmlPath, \"utf8\");\n if (html.includes(TRUSS_CSS_PLACEHOLDER)) {\n writeFileSync(htmlPath, html.replace(TRUSS_CSS_PLACEHOLDER, `/${emittedCssFileName}`), \"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 filePath.replace(/\\\\/g, \"/\").includes(\"/node_modules/\");\n}\n\nfunction injectTestCssBootstrapImport(code: string, shouldInject: boolean): { code: string; changed: boolean } {\n // Keep this as a normal ESM import so Vite/Vitest module caching ensures the\n // bootstrap executes once per module graph instead of once per transformed file.\n if (!shouldInject) {\n return { code, changed: false };\n }\n\n return {\n code: `${code}\\nimport \"${VIRTUAL_TEST_CSS_ID}\";`,\n changed: true,\n };\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\";\nexport { trussEsbuildPlugin, type TrussEsbuildPluginOptions } from \"./esbuild-plugin\";\n","import * as t from \"@babel/types\";\nimport type { ResolvedChain } from \"./resolve-chain\";\nimport type { ResolvedSegment, TrussMapping, WhenCondition } from \"./types\";\nimport { computeRulePriority, sortRulesByPriority } from \"./priority\";\nimport { cssPropertyAbbreviations } from \"./css-property-abbreviations\";\n\n// ── Atomic CSS rule model ─────────────────────────────────────────────\n\n/**\n * A single atomic CSS rule: one class, one selector, one or more declarations.\n *\n * I.e. `.black { color: #353535; }` is one AtomicRule with a single declaration,\n * while `sq(x)` produces one AtomicRule with two declarations (`height` + `width`).\n */\nexport interface AtomicRule {\n /** I.e. `\"sm_h_blue\"` — the generated class name including condition prefixes. */\n className: string;\n /**\n * The CSS property/value pairs this rule sets. Always has at least one entry.\n *\n * I.e. `[{ cssProperty: \"color\", cssValue: \"#526675\" }]` for a static rule, or\n * `[{ cssProperty: \"height\", cssValue: \"var(--height)\", cssVarName: \"--height\" },\n * { cssProperty: \"width\", cssValue: \"var(--width)\", cssVarName: \"--width\" }]` for `sq(x)`.\n */\n declarations: Array<{\n cssProperty: string;\n cssValue: string;\n /** I.e. `\"--marginTop\"` — present when this declaration uses a CSS custom property. */\n cssVarName?: string;\n }>;\n pseudoClass?: string;\n mediaQuery?: string;\n pseudoElement?: string;\n /** I.e. `when(row, \"ancestor\", \":hover\")` → `{ relationship: \"ancestor\", markerClass: \"_row_mrk\", pseudo: \":hover\" }`. */\n whenSelector?: {\n relationship: string;\n markerClass: string;\n pseudo: string;\n };\n}\n\n// ── Class-name constants and abbreviation maps ────────────────────────\n\n/** I.e. `:hover` → `_h`, `:focus-visible` → `_fv`. */\nconst PSEUDO_SUFFIX: Record<string, string> = {\n \":hover\": \"_h\",\n \":focus\": \"_f\",\n \":focus-visible\": \"_fv\",\n \":focus-within\": \"_fw\",\n \":active\": \"_a\",\n \":disabled\": \"_d\",\n \":first-of-type\": \"_fot\",\n \":last-of-type\": \"_lot\",\n};\n\n/** I.e. extends PSEUDO_SUFFIX with `:not` → `_n`, `:has` → `_has` for when() class tokens. */\nconst PSEUDO_SELECTOR_SUFFIX: Record<string, string> = {\n ...PSEUDO_SUFFIX,\n \":not\": \"_n\",\n \":is\": \"_is\",\n \":where\": \"_where\",\n \":has\": \"_has\",\n};\n\n/** I.e. `\"ancestor\"` → `\"anc\"`, `\"siblingAfter\"` → `\"sibA\"`. */\nconst RELATIONSHIP_SHORT: Record<string, string> = {\n ancestor: \"anc\",\n descendant: \"desc\",\n siblingAfter: \"sibA\",\n siblingBefore: \"sibB\",\n anySibling: \"anyS\",\n};\n\n// ── Marker class helpers ──────────────────────────────────────────────\n\n/** I.e. the shared default marker class is `_mrk`. */\nexport const DEFAULT_MARKER_CLASS = \"_mrk\";\n\n/** I.e. `markerClassName(row)` → `\"_row_mrk\"`, `markerClassName()` → `\"_mrk\"`. */\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 `_${markerNode.name}_mrk`;\n }\n return \"_marker_mrk\";\n}\n\n// ── Class-name prefix builders ────────────────────────────────────────\n\n/** I.e. `when(marker, \"ancestor\", \":hover\")` → `\"wh_anc_h_\"`, `when(row, …)` → `\"wh_anc_h_row_\"`. */\nfunction whenPrefix(whenPseudo: WhenCondition): string {\n const rel = RELATIONSHIP_SHORT[whenPseudo.relationship ?? \"ancestor\"] ?? \"anc\";\n const pseudoTag = pseudoSelectorTag(whenPseudo.pseudo);\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 * I.e. `conditionPrefix(\":hover\", smMedia, null, breakpoints)` → `\"sm_h_\"`,\n * so the final class reads `sm_h_bgBlack` (\"on sm + 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 // I.e. find breakpoint name: \"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 parts.push(`${pseudoSelectorTag(pseudoClass)}_`);\n }\n return parts.join(\"\");\n}\n\n// ── Pseudo-selector tokenizers ────────────────────────────────────────\n\n/** I.e. `\":hover:not(:disabled)\"` → `\"h_n_d\"` (a safe class-name token). */\nfunction pseudoSelectorTag(pseudo: string): string {\n const replaced = pseudo.trim().replace(/::?[a-zA-Z-]+/g, (match) => {\n return `_${pseudoIdentifierTag(match)}_`;\n });\n const cleaned = replaced\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n return cleaned || \"pseudo\";\n}\n\n/** I.e. `\":hover\"` → `\"h\"`, `\":focus-visible\"` → `\"fv\"`, `\":first-of-type\"` → `\"fot\"`. */\nfunction pseudoIdentifierTag(pseudo: string): string {\n const normalized = normalizePseudoIdentifier(pseudo);\n const known = PSEUDO_SELECTOR_SUFFIX[normalized];\n if (known) {\n return known.replace(/^_/, \"\");\n }\n return normalized.replace(/^::?/, \"\").replace(/-/g, \"_\");\n}\n\n/** I.e. `\":focusVisible\"` → `\":focus-visible\"` (camelCase → kebab-case after the colon prefix). */\nfunction normalizePseudoIdentifier(pseudo: string): string {\n const prefixMatch = pseudo.match(/^::?/);\n const prefix = prefixMatch?.[0] ?? \"\";\n const name = pseudo.slice(prefix.length).replace(/[A-Z]/g, (match) => {\n return `-${match.toLowerCase()}`;\n });\n return `${prefix}${name}`;\n}\n\n// ── CSS property / value helpers ──────────────────────────────────────\n\n/** I.e. `\"backgroundColor\"` → `\"background-color\"`, `\"WebkitTransform\"` → `\"-webkit-transform\"`. */\nexport function camelToKebab(s: string): string {\n return s.replace(/^(Webkit|Moz|Ms|O)/, (m) => `-${m.toLowerCase()}`).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);\n}\n\n/** I.e. `\"-8px\"` → `\"neg8px\"`, `\"0 0 0 1px blue\"` → `\"0_0_0_1px_blue\"`. */\nfunction cleanValueForClassName(value: string): string {\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/** I.e. `\"backgroundColor\"` → `\"bg\"` (from the abbreviation table), or the raw name as fallback. */\nfunction getPropertyAbbreviation(cssProp: string): string {\n return cssPropertyAbbreviations[cssProp] ?? cssProp;\n}\n\n// ── Longhand lookup (canonical abbreviation reuse) ────────────────────\n\n/**\n * Build a reverse lookup from `\"cssProperty\\0cssValue\"` → canonical abbreviation name.\n *\n * I.e. `{ paddingTop: \"8px\" }` → `\"pt1\"`, `{ borderStyle: \"solid\" }` → `\"bss\"`.\n * Used so multi-property abbreviations can reuse existing single-property class names.\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/** I.e. returns the cached `buildLonghandLookup` result, rebuilding only when the mapping changes. */\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// ── Static base class-name computation ────────────────────────────────\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 abbr = seg.abbr;\n\n if (seg.argResolved !== undefined) {\n const valuePart = cleanValueForClassName(seg.argResolved);\n if (isMultiProp) {\n const lookup = getLonghandLookup(mapping);\n const canonical = lookup.get(`${cssProp}\\0${cssValue}`);\n if (canonical) return canonical;\n // I.e. lineClamp(\"3\") display:-webkit-box → `d_negwebkit_box`, not `d_3`\n return `${getPropertyAbbreviation(cssProp)}_${cleanValueForClassName(cssValue)}`;\n }\n return `${abbr}_${valuePart}`;\n }\n\n if (isMultiProp) {\n const lookup = getLonghandLookup(mapping);\n const canonical = lookup.get(`${cssProp}\\0${cssValue}`);\n if (canonical) return canonical;\n return `${getPropertyAbbreviation(cssProp)}_${cleanValueForClassName(cssValue)}`;\n }\n\n return abbr;\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 * I.e. walks every segment in every chain part and registers one AtomicRule\n * per CSS declaration, keyed by the prefixed class name.\n */\nexport function collectAtomicRules(chains: ResolvedChain[], mapping: TrussMapping): CollectedRules {\n const rules = new Map<string, AtomicRule>();\n let needsMaybeInc = false;\n\n function collectSegment(seg: ResolvedSegment): void {\n if (seg.error || seg.styleArrayArg || seg.classNameArg || seg.styleArg) return;\n if (seg.typographyLookup) {\n for (const segments of Object.values(seg.typographyLookup.segmentsByName)) {\n for (const nestedSeg of segments) {\n collectSegment(nestedSeg);\n }\n }\n return;\n }\n if (seg.incremented) needsMaybeInc = true;\n if (seg.variableProps) {\n collectVariableRules(rules, seg, mapping);\n } else {\n collectStaticRules(rules, seg, mapping);\n }\n }\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 collectSegment(seg);\n }\n }\n }\n\n return { rules, needsMaybeInc };\n}\n\n/**\n * Compute the class name prefix and optional whenSelector for a segment.\n *\n * I.e. a segment with `pseudoClass: \":hover\"` and `mediaQuery: smMedia` gets\n * prefix `\"sm_h_\"`, while one with `whenPseudo: { relationship: \"ancestor\", pseudo: \":hover\" }`\n * also gets its `whenSelector` populated for CSS rule generation.\n */\nfunction segmentContext(\n seg: ResolvedSegment,\n mapping: TrussMapping,\n): { prefix: string; whenSelector?: AtomicRule[\"whenSelector\"] } {\n const prefix = `${conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints)}${seg.whenPseudo ? whenPrefix(seg.whenPseudo) : \"\"}`;\n if (seg.whenPseudo) {\n const wp = seg.whenPseudo;\n return {\n prefix,\n whenSelector: {\n relationship: wp.relationship ?? \"ancestor\",\n markerClass: markerClassName(wp.markerNode),\n pseudo: wp.pseudo,\n },\n };\n }\n return { prefix };\n}\n\n/** I.e. extracts `pseudoClass`, `mediaQuery`, `pseudoElement` from a segment for AtomicRule fields. */\nfunction baseRuleFields(seg: ResolvedSegment): Pick<AtomicRule, \"pseudoClass\" | \"mediaQuery\" | \"pseudoElement\"> {\n return {\n pseudoClass: seg.pseudoClass ?? undefined,\n mediaQuery: seg.mediaQuery ?? undefined,\n pseudoElement: seg.pseudoElement ?? undefined,\n };\n}\n\n/**\n * Collect atomic rules for a static segment (may have multiple CSS properties).\n *\n * I.e. `Css.ba.$` (borderStyle + borderWidth) registers one AtomicRule per longhand property.\n */\nfunction collectStaticRules(rules: Map<string, AtomicRule>, seg: ResolvedSegment, mapping: TrussMapping): void {\n const { prefix, whenSelector } = segmentContext(seg, mapping);\n const isMultiProp = Object.keys(seg.defs).length > 1;\n\n for (const [cssProp, value] of Object.entries(seg.defs)) {\n const cssValue = String(value);\n const baseName = computeStaticBaseName(seg, cssProp, cssValue, isMultiProp, mapping);\n const className = prefix ? `${prefix}${baseName}` : baseName;\n\n if (!rules.has(className)) {\n rules.set(className, {\n className,\n declarations: [{ cssProperty: camelToKebab(cssProp), cssValue }],\n ...baseRuleFields(seg),\n whenSelector,\n });\n }\n }\n}\n\n/**\n * Collect atomic rules for a variable segment.\n *\n * I.e. `Css.mt(x).$` registers a rule with `var(--marginTop)` and an `@property` declaration,\n * plus any extra static defs like `display: -webkit-box` for `lineClamp(n)`.\n */\nfunction collectVariableRules(rules: Map<string, AtomicRule>, seg: ResolvedSegment, mapping: TrussMapping): void {\n const { prefix, whenSelector } = segmentContext(seg, mapping);\n\n for (const prop of seg.variableProps!) {\n const className = prefix ? `${prefix}${seg.abbr}_var` : `${seg.abbr}_var`;\n const varName = toCssVariableName(className, seg.abbr, 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 declarations: [declaration],\n ...baseRuleFields(seg),\n whenSelector,\n });\n continue;\n }\n\n if (\n !existingRule.declarations.some((entry) => {\n return entry.cssProperty === declaration.cssProperty;\n })\n ) {\n existingRule.declarations.push(declaration);\n }\n }\n\n // I.e. lineClamp(n) also needs `display: -webkit-box` alongside the variable props\n if (seg.variableExtraDefs) {\n for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {\n const cssValue = String(value);\n const lookup = getLonghandLookup(mapping);\n const canonical = lookup.get(`${cssProp}\\0${cssValue}`);\n const extraBase = canonical ?? `${getPropertyAbbreviation(cssProp)}_${cleanValueForClassName(cssValue)}`;\n const extraName = prefix ? `${prefix}${extraBase}` : extraBase;\n if (!rules.has(extraName)) {\n rules.set(extraName, {\n className: extraName,\n declarations: [{ cssProperty: camelToKebab(cssProp), cssValue }],\n ...baseRuleFields(seg),\n whenSelector,\n });\n }\n }\n }\n}\n\n// ── CSS text generation ───────────────────────────────────────────────\n\n/**\n * Generate the full CSS text from collected rules, sorted by StyleX priority.\n *\n * I.e. produces output like:\n * ```\n * /* @truss p:3000 c:black *\\/\n * .black { color: #353535; }\n * /* @truss p:3200 c:sm_blue *\\/\n * @media screen and (max-width: 599px) { .sm_blue.sm_blue { color: #526675; } }\n * ```\n */\nexport function generateCssText(rules: Map<string, AtomicRule>): string {\n const allRules = Array.from(rules.values());\n\n sortRulesByPriority(allRules);\n\n const priorities = allRules.map(computeRulePriority);\n const lines: string[] = [];\n\n for (let i = 0; i < allRules.length; i++) {\n const rule = allRules[i];\n const priority = priorities[i];\n lines.push(`/* @truss p:${priority} c:${rule.className} */`);\n lines.push(formatRule(rule));\n }\n\n // I.e. `@property --marginTop { syntax: \"*\"; inherits: false; }` for variable rules\n for (const rule of allRules) {\n for (const declaration of getRuleDeclarations(rule)) {\n if (declaration.cssVarName) {\n lines.push(`/* @truss @property */`);\n lines.push(`@property ${declaration.cssVarName} { syntax: \"*\"; inherits: false; }`);\n }\n }\n }\n\n return lines.join(\"\\n\");\n}\n\n// ── CSS rule formatting ───────────────────────────────────────────────\n\n/**\n * Format a single rule into its CSS text, dispatching by rule kind.\n *\n * I.e. a base rule → `.black { color: #353535; }`,\n * a media rule → `@media (...) { .sm_blue.sm_blue { color: #526675; } }`,\n * a when rule → `._mrk:hover .wh_anc_h_blue { color: #526675; }`.\n */\nfunction formatRule(rule: AtomicRule): string {\n const whenSelector = rule.whenSelector;\n if (whenSelector) return formatWhenRule(rule, whenSelector);\n const selector = buildTargetSelector(rule, !!rule.mediaQuery);\n return formatRuleWithOptionalMedia(rule, selector);\n}\n\n/**\n * Format a when()-relationship rule with the correct combinator per relationship kind.\n *\n * I.e. ancestor → `._mrk:hover .target { … }`,\n * descendant → `.target:has(._mrk:hover) { … }`,\n * anySibling → `.target:has(~ ._mrk:hover), ._mrk:hover ~ .target { … }`.\n */\nfunction formatWhenRule(rule: AtomicRule, whenSelector: NonNullable<AtomicRule[\"whenSelector\"]>): string {\n const markerSelector = `.${whenSelector.markerClass}${whenSelector.pseudo}`;\n const duplicateClassName = !!rule.mediaQuery;\n\n if (whenSelector.relationship === \"ancestor\") {\n return formatRuleWithOptionalMedia(rule, `${markerSelector} ${buildTargetSelector(rule, duplicateClassName)}`);\n }\n if (whenSelector.relationship === \"descendant\") {\n return formatRuleWithOptionalMedia(rule, buildTargetSelector(rule, duplicateClassName, `:has(${markerSelector})`));\n }\n if (whenSelector.relationship === \"siblingAfter\") {\n return formatRuleWithOptionalMedia(\n rule,\n buildTargetSelector(rule, duplicateClassName, `:has(~ ${markerSelector})`),\n );\n }\n if (whenSelector.relationship === \"siblingBefore\") {\n return formatRuleWithOptionalMedia(rule, `${markerSelector} ~ ${buildTargetSelector(rule, duplicateClassName)}`);\n }\n if (whenSelector.relationship === \"anySibling\") {\n const afterSelector = buildTargetSelector(rule, duplicateClassName, `:has(~ ${markerSelector})`);\n const beforeSelector = `${markerSelector} ~ ${buildTargetSelector(rule, duplicateClassName)}`;\n return formatRuleWithOptionalMedia(rule, `${afterSelector}, ${beforeSelector}`);\n }\n\n // I.e. unknown relationship falls back to ancestor-style descendant combinator\n return formatRuleWithOptionalMedia(rule, `${markerSelector} ${buildTargetSelector(rule, duplicateClassName)}`);\n}\n\n/**\n * Assemble the target element's CSS selector from all active condition slots.\n *\n * I.e. `buildTargetSelector(rule, true)` → `.sm_h_blue.sm_h_blue:hover`,\n * `buildTargetSelector(rule, false, \":has(._mrk:hover)\")` → `.wh_anc_h_blue:has(._mrk:hover)`.\n */\nfunction buildTargetSelector(rule: AtomicRule, duplicateClassName: boolean, extraPseudoClass?: string): string {\n const classSelector = duplicateClassName ? `.${rule.className}.${rule.className}` : `.${rule.className}`;\n const pseudoClass = rule.pseudoClass ?? \"\";\n const relationshipPseudoClass = extraPseudoClass ?? \"\";\n const pseudoElement = rule.pseudoElement ?? \"\";\n return `${classSelector}${pseudoClass}${relationshipPseudoClass}${pseudoElement}`;\n}\n\n/** I.e. wraps the selector in a media-query block when `rule.mediaQuery` is set. */\nfunction formatRuleWithOptionalMedia(rule: AtomicRule, selector: string): string {\n if (rule.mediaQuery) {\n return formatNestedRuleBlock(rule.mediaQuery, selector, rule);\n }\n return formatRuleBlock(selector, rule);\n}\n\n/** I.e. returns the rule's declarations array (always has at least one entry). */\nfunction getRuleDeclarations(rule: AtomicRule): Array<{ cssProperty: string; cssValue: string; cssVarName?: string }> {\n return rule.declarations;\n}\n\n/** I.e. `.black { color: #353535; }`. */\nfunction formatRuleBlock(selector: string, rule: AtomicRule): string {\n const body = getRuleDeclarations(rule)\n .map((declaration) => {\n return `${declaration.cssProperty}: ${declaration.cssValue};`;\n })\n .join(\" \");\n return `${selector} { ${body} }`;\n}\n\n/** I.e. `@media (...) { .sm_blue.sm_blue { color: #526675; } }`. */\nfunction formatNestedRuleBlock(wrapper: string, selector: string, rule: AtomicRule): string {\n const body = getRuleDeclarations(rule)\n .map((declaration) => {\n return `${declaration.cssProperty}: ${declaration.cssValue};`;\n })\n .join(\" \");\n return `${wrapper} { ${selector} { ${body} } }`;\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 * I.e. `[blue, h_white]` → `{ color: \"blue h_white\" }`.\n *\n * Variable entries produce tuples: `{ marginTop: [\"mt_var\", { \"--marginTop\": __maybeInc(x) }] }`.\n */\nexport function buildStyleHashProperties(\n segments: ResolvedSegment[],\n mapping: TrussMapping,\n maybeIncHelperName?: string | null,\n): t.ObjectProperty[] {\n // I.e. cssProperty → list of { className, isVariable, isConditional, varName, argNode, ... }\n const propGroups = new Map<\n string,\n Array<{\n className: string;\n isVariable: boolean;\n /** Whether this entry has a condition prefix (pseudo/media/when). */\n isConditional: boolean;\n varName?: string;\n argNode?: unknown;\n incremented?: boolean;\n appendPx?: boolean;\n }>\n >();\n\n /**\n * Push an entry, replacing earlier base-level entries when a new base-level entry\n * overrides the same property.\n *\n * I.e. `Css.blue.black.$` → the later `black` replaces `blue` for `color`,\n * but `Css.blue.onHover.black.$` accumulates both because `onHover.black` is conditional.\n */\n function pushEntry(cssProp: string, entry: typeof propGroups extends Map<string, Array<infer E>> ? E : never): void {\n if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);\n const entries = propGroups.get(cssProp)!;\n if (!entry.isConditional) {\n for (let i = entries.length - 1; i >= 0; i--) {\n if (!entries[i].isConditional) {\n entries.splice(i, 1);\n }\n }\n }\n entries.push(entry);\n }\n\n for (const seg of segments) {\n if (seg.error || seg.styleArrayArg || seg.typographyLookup || seg.classNameArg || seg.styleArg) continue;\n\n const { prefix } = segmentContext(seg, mapping);\n const isConditional = prefix !== \"\";\n\n if (seg.variableProps) {\n for (const prop of seg.variableProps) {\n const className = prefix ? `${prefix}${seg.abbr}_var` : `${seg.abbr}_var`;\n const varName = toCssVariableName(className, seg.abbr, prop);\n\n pushEntry(prop, {\n className,\n isVariable: true,\n isConditional,\n varName,\n argNode: seg.argNode,\n incremented: seg.incremented,\n appendPx: seg.appendPx,\n });\n }\n\n // I.e. lineClamp(n) also contributes static extra defs like `display: -webkit-box`\n if (seg.variableExtraDefs) {\n for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {\n const cssValue = String(value);\n const lookup = getLonghandLookup(mapping);\n const canonical = lookup.get(`${cssProp}\\0${cssValue}`);\n const extraBase = canonical ?? `${getPropertyAbbreviation(cssProp)}_${cleanValueForClassName(cssValue)}`;\n const extraName = prefix ? `${prefix}${extraBase}` : extraBase;\n pushEntry(cssProp, { className: extraName, isVariable: false, isConditional });\n }\n }\n } else {\n const isMultiProp = Object.keys(seg.defs).length > 1;\n\n for (const [cssProp, val] of Object.entries(seg.defs)) {\n const baseName = computeStaticBaseName(seg, cssProp, String(val), isMultiProp, mapping);\n const className = prefix ? `${prefix}${baseName}` : baseName;\n\n pushEntry(cssProp, { className, isVariable: false, isConditional });\n }\n }\n }\n\n // Build AST ObjectProperty nodes\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 // I.e. `{ marginTop: [\"mt_var\", { \"--marginTop\": __maybeInc(x) }] }`\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 // I.e. wrap with `__maybeInc(x)` for increment-based values\n valueExpr = t.callExpression(t.identifier(maybeIncHelperName ?? \"__maybeInc\"), [valueExpr]);\n } else if (dyn.appendPx) {\n // I.e. wrap with `` `${v}px` `` for Px delegate values\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 properties.push(t.objectProperty(toPropertyKey(cssProp), tuple));\n } else {\n // I.e. static: `{ color: \"blue h_white\" }`\n properties.push(t.objectProperty(toPropertyKey(cssProp), t.stringLiteral(classNames)));\n }\n }\n\n return properties;\n}\n\n// ── CSS variable naming ───────────────────────────────────────────────\n\n/** I.e. `toCssVariableName(\"sm_mt_var\", \"mt\", \"marginTop\")` → `\"--sm_marginTop\"`. */\nfunction toCssVariableName(className: string, baseKey: string, cssProp: string): string {\n const baseClassName = `${baseKey}_var`;\n const cp = className.endsWith(baseClassName) ? className.slice(0, -baseClassName.length) : \"\";\n return `--${cp}${cssProp}`;\n}\n\n// ── Helper AST declarations ───────────────────────────────────────────\n\n/**\n * Build the per-file increment helper declaration.\n *\n * I.e. `const __maybeInc = (inc) => { return typeof inc === \"string\" ? inc : \\`${inc * 8}px\\`; };`\n */\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/** I.e. `\"color\"` → `t.identifier(\"color\")`, `\"box-shadow\"` → `t.stringLiteral(\"box-shadow\")`. */\nfunction toPropertyKey(key: string): t.Identifier | t.StringLiteral {\n return isValidIdentifier(key) ? t.identifier(key) : t.stringLiteral(key);\n}\n\n/** I.e. `\"color\"` → true, `\"box-shadow\"` → false. */\nfunction isValidIdentifier(s: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(s);\n}\n\n/**\n * Build a runtime lookup table declaration for typography.\n *\n * I.e. `const __typography = { f24: { fontSize: \"f24\", lineHeight: \"lh32\" }, ... };`\n */\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","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Converted from Flow to TypeScript; otherwise kept as-is for easy updates from upstream.\n * Source: https://github.com/facebook/stylex/blob/1ddee1dde1d55134c7d4f6889d8cbf34091e72fd/packages/%40stylexjs/shared/src/utils/property-priorities.js\n */\n\n// Physical properties that have logical equivalents:\nconst longHandPhysical = new Set<string>();\n// Logical properties *and* all other long hand properties:\nconst longHandLogical = new Set<string>();\n// Shorthand properties that override longhand properties:\nconst shorthandsOfLonghands = new Set<string>();\n// Shorthand properties that override other shorthand properties:\nconst shorthandsOfShorthands = new Set<string>();\n\n// Using MDN data as a source of truth to populate the above sets\n// by group in alphabetical order:\n\n// Composition and Blending\nlongHandLogical.add(\"background-blend-mode\");\nlongHandLogical.add(\"isolation\");\nlongHandLogical.add(\"mix-blend-mode\");\n\n// CSS Animations\nshorthandsOfShorthands.add(\"animation\");\nlongHandLogical.add(\"animation-composition\");\nlongHandLogical.add(\"animation-delay\");\nlongHandLogical.add(\"animation-direction\");\nlongHandLogical.add(\"animation-duration\");\nlongHandLogical.add(\"animation-fill-mode\");\nlongHandLogical.add(\"animation-iteration-count\");\nlongHandLogical.add(\"animation-name\");\nlongHandLogical.add(\"animation-play-state\");\nshorthandsOfLonghands.add(\"animation-range\");\nlongHandLogical.add(\"animation-range-end\");\nlongHandLogical.add(\"animation-range-start\");\nlongHandLogical.add(\"animation-timing-function\");\nlongHandLogical.add(\"animation-timeline\");\n\nshorthandsOfLonghands.add(\"scroll-timeline\");\nlongHandLogical.add(\"scroll-timeline-axis\");\nlongHandLogical.add(\"scroll-timeline-name\");\n\nlongHandLogical.add(\"timeline-scope\");\n\nshorthandsOfLonghands.add(\"view-timeline\");\nlongHandLogical.add(\"view-timeline-axis\");\nlongHandLogical.add(\"view-timeline-inset\");\nlongHandLogical.add(\"view-timeline-name\");\n\n// CSS Backgrounds and Borders\nshorthandsOfShorthands.add(\"background\");\nlongHandLogical.add(\"background-attachment\");\nlongHandLogical.add(\"background-clip\");\nlongHandLogical.add(\"background-color\");\nlongHandLogical.add(\"background-image\");\nlongHandLogical.add(\"background-origin\");\nlongHandLogical.add(\"background-repeat\");\nlongHandLogical.add(\"background-size\");\nshorthandsOfLonghands.add(\"background-position\");\nlongHandLogical.add(\"background-position-x\");\nlongHandLogical.add(\"background-position-y\");\n\nshorthandsOfShorthands.add(\"border\"); // OF SHORTHANDS!\nshorthandsOfLonghands.add(\"border-color\");\nshorthandsOfLonghands.add(\"border-style\");\nshorthandsOfLonghands.add(\"border-width\");\nshorthandsOfShorthands.add(\"border-block\"); // Logical Properties\nlongHandLogical.add(\"border-block-color\"); // Logical Properties\nlongHandLogical.add(\"border-block-stylex\"); // Logical Properties\nlongHandLogical.add(\"border-block-width\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-block-start\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-top\");\nlongHandLogical.add(\"border-block-start-color\"); // Logical Properties\nlongHandPhysical.add(\"border-top-color\");\nlongHandLogical.add(\"border-block-start-style\"); // Logical Properties\nlongHandPhysical.add(\"border-top-style\");\nlongHandLogical.add(\"border-block-start-width\"); // Logical Properties\nlongHandPhysical.add(\"border-top-width\");\nshorthandsOfLonghands.add(\"border-block-end\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-bottom\");\nlongHandLogical.add(\"border-block-end-color\"); // Logical Properties\nlongHandPhysical.add(\"border-bottom-color\");\nlongHandLogical.add(\"border-block-end-style\"); // Logical Properties\nlongHandPhysical.add(\"border-bottom-style\");\nlongHandLogical.add(\"border-block-end-width\"); // Logical Properties\nlongHandPhysical.add(\"border-bottom-width\");\nshorthandsOfShorthands.add(\"border-inline\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-inline-color\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-inline-style\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-inline-width\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-inline-start\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-left\");\nlongHandLogical.add(\"border-inline-start-color\"); // Logical Properties\nlongHandPhysical.add(\"border-left-color\");\nlongHandLogical.add(\"border-inline-start-style\"); // Logical Properties\nlongHandPhysical.add(\"border-left-style\");\nlongHandLogical.add(\"border-inline-start-width\"); // Logical Properties\nlongHandPhysical.add(\"border-left-width\");\nshorthandsOfLonghands.add(\"border-inline-end\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-right\");\nlongHandLogical.add(\"border-inline-end-color\"); // Logical Properties\nlongHandPhysical.add(\"border-right-color\");\nlongHandLogical.add(\"border-inline-end-style\"); // Logical Properties\nlongHandPhysical.add(\"border-right-style\");\nlongHandLogical.add(\"border-inline-end-width\"); // Logical Properties\nlongHandPhysical.add(\"border-right-width\");\n\nshorthandsOfLonghands.add(\"border-image\");\nlongHandLogical.add(\"border-image-outset\");\nlongHandLogical.add(\"border-image-repeat\");\nlongHandLogical.add(\"border-image-slice\");\nlongHandLogical.add(\"border-image-source\");\nlongHandLogical.add(\"border-image-width\");\n\nshorthandsOfLonghands.add(\"border-radius\");\nlongHandLogical.add(\"border-start-end-radius\"); // Logical Properties\nlongHandLogical.add(\"border-start-start-radius\"); // Logical Properties\nlongHandLogical.add(\"border-end-end-radius\"); // Logical Properties\nlongHandLogical.add(\"border-end-start-radius\"); // Logical Properties\nlongHandPhysical.add(\"border-top-left-radius\");\nlongHandPhysical.add(\"border-top-right-radius\");\nlongHandPhysical.add(\"border-bottom-left-radius\");\nlongHandPhysical.add(\"border-bottom-right-radius\");\n\nshorthandsOfLonghands.add(\"corner-shape\");\nlongHandLogical.add(\"corner-start-start-shape\"); // Logical Properties\nlongHandLogical.add(\"corner-start-end-shape\"); // Logical Properties\nlongHandLogical.add(\"corner-end-start-shape\"); // Logical Properties\nlongHandLogical.add(\"corner-end-end-shape\"); // Logical Properties\nlongHandPhysical.add(\"corner-top-left-shape\");\nlongHandPhysical.add(\"corner-top-right-shape\");\nlongHandPhysical.add(\"corner-bottom-left-shape\");\nlongHandPhysical.add(\"corner-bottom-right-shape\");\n\nlongHandLogical.add(\"box-shadow\");\n\n// CSS Basic User Interface\nlongHandLogical.add(\"accent-color\");\nlongHandLogical.add(\"appearance\");\nlongHandLogical.add(\"aspect-ratio\");\n\nshorthandsOfLonghands.add(\"caret\");\nlongHandLogical.add(\"caret-color\");\nlongHandLogical.add(\"caret-shape\");\n\nlongHandLogical.add(\"cursor\");\nlongHandLogical.add(\"ime-mode\");\nlongHandLogical.add(\"input-security\");\n\nshorthandsOfLonghands.add(\"outline\");\nlongHandLogical.add(\"outline-color\");\nlongHandLogical.add(\"outline-offset\");\nlongHandLogical.add(\"outline-style\");\nlongHandLogical.add(\"outline-width\");\n\nlongHandLogical.add(\"pointer-events\");\nlongHandLogical.add(\"resize\"); // horizontal, vertical, block, inline, both\nlongHandLogical.add(\"text-overflow\");\nlongHandLogical.add(\"user-select\");\n\n// CSS Box Alignment\nshorthandsOfLonghands.add(\"grid-gap\"); // alias for `gap`\nshorthandsOfLonghands.add(\"gap\");\nlongHandLogical.add(\"grid-row-gap\"); // alias for `row-gap`\nlongHandLogical.add(\"row-gap\");\nlongHandLogical.add(\"grid-column-gap\"); // alias for `column-gap`\nlongHandLogical.add(\"column-gap\");\n\nshorthandsOfLonghands.add(\"place-content\");\nlongHandLogical.add(\"align-content\");\nlongHandLogical.add(\"justify-content\");\n\nshorthandsOfLonghands.add(\"place-items\");\nlongHandLogical.add(\"align-items\");\nlongHandLogical.add(\"justify-items\");\n\nshorthandsOfLonghands.add(\"place-self\");\nlongHandLogical.add(\"align-self\");\nlongHandLogical.add(\"justify-self\");\n\n// CSS Box Model\nlongHandLogical.add(\"box-sizing\");\n\nlongHandLogical.add(\"block-size\"); // Logical Properties\nlongHandPhysical.add(\"height\");\nlongHandLogical.add(\"inline-size\"); // Logical Properties\nlongHandPhysical.add(\"width\");\n\nlongHandLogical.add(\"max-block-size\"); // Logical Properties\nlongHandPhysical.add(\"max-height\");\nlongHandLogical.add(\"max-inline-size\"); // Logical Properties\nlongHandPhysical.add(\"max-width\");\nlongHandLogical.add(\"min-block-size\"); // Logical Properties\nlongHandPhysical.add(\"min-height\");\nlongHandLogical.add(\"min-inline-size\"); // Logical Properties\nlongHandPhysical.add(\"min-width\");\n\nshorthandsOfShorthands.add(\"margin\");\nshorthandsOfLonghands.add(\"margin-block\"); // Logical Properties\nlongHandLogical.add(\"margin-block-start\"); // Logical Properties\nlongHandPhysical.add(\"margin-top\");\nlongHandLogical.add(\"margin-block-end\"); // Logical Properties\nlongHandPhysical.add(\"margin-bottom\");\nshorthandsOfLonghands.add(\"margin-inline\"); // Logical Properties\nlongHandLogical.add(\"margin-inline-start\"); // Logical Properties\nlongHandPhysical.add(\"margin-left\");\nlongHandLogical.add(\"margin-inline-end\"); // Logical Properties\nlongHandPhysical.add(\"margin-right\");\n\nlongHandLogical.add(\"margin-trim\");\n\nshorthandsOfLonghands.add(\"overscroll-behavior\");\nlongHandLogical.add(\"overscroll-behavior-block\");\nlongHandPhysical.add(\"overscroll-behavior-y\");\nlongHandLogical.add(\"overscroll-behavior-inline\");\nlongHandPhysical.add(\"overscroll-behavior-x\");\n\nshorthandsOfShorthands.add(\"padding\");\nshorthandsOfLonghands.add(\"padding-block\"); // Logical Properties\nlongHandLogical.add(\"padding-block-start\"); // Logical Properties\nlongHandPhysical.add(\"padding-top\");\nlongHandLogical.add(\"padding-block-end\"); // Logical Properties\nlongHandPhysical.add(\"padding-bottom\");\nshorthandsOfLonghands.add(\"padding-inline\"); // Logical Properties\nlongHandLogical.add(\"padding-inline-start\"); // Logical Properties\nlongHandPhysical.add(\"padding-left\");\nlongHandLogical.add(\"padding-inline-end\"); // Logical Properties\nlongHandPhysical.add(\"padding-right\");\n\nlongHandLogical.add(\"visibility\");\n\n// CSS Color\nlongHandLogical.add(\"color\");\nlongHandLogical.add(\"color-scheme\");\nlongHandLogical.add(\"forced-color-adjust\");\nlongHandLogical.add(\"opacity\");\nlongHandLogical.add(\"print-color-adjust\");\n\n// CSS Columns\nshorthandsOfLonghands.add(\"columns\");\nlongHandLogical.add(\"column-count\");\nlongHandLogical.add(\"column-width\");\n\nlongHandLogical.add(\"column-fill\");\nlongHandLogical.add(\"column-span\");\n\nshorthandsOfLonghands.add(\"column-rule\");\nlongHandLogical.add(\"column-rule-color\");\nlongHandLogical.add(\"column-rule-style\");\nlongHandLogical.add(\"column-rule-width\");\n\n// CSS Containment\nlongHandLogical.add(\"contain\");\n\nshorthandsOfLonghands.add(\"contain-intrinsic-size\");\nlongHandLogical.add(\"contain-intrinsic-block-size\");\nlongHandLogical.add(\"contain-intrinsic-width\");\nlongHandLogical.add(\"contain-intrinsic-height\");\nlongHandLogical.add(\"contain-intrinsic-inline-size\");\n\nshorthandsOfLonghands.add(\"container\");\nlongHandLogical.add(\"container-name\");\nlongHandLogical.add(\"container-type\");\n\nlongHandLogical.add(\"content-visibility\");\n\n// CSS Counter Styles\nlongHandLogical.add(\"counter-increment\");\nlongHandLogical.add(\"counter-reset\");\nlongHandLogical.add(\"counter-set\");\n\n// CSS Display\nlongHandLogical.add(\"display\");\n\n// CSS Flexible Box Layout\nshorthandsOfLonghands.add(\"flex\");\nlongHandLogical.add(\"flex-basis\");\nlongHandLogical.add(\"flex-grow\");\nlongHandLogical.add(\"flex-shrink\");\n\nshorthandsOfLonghands.add(\"flex-flow\");\nlongHandLogical.add(\"flex-direction\");\nlongHandLogical.add(\"flex-wrap\");\n\nlongHandLogical.add(\"order\");\n\n// CSS Fonts\nshorthandsOfShorthands.add(\"font\");\nlongHandLogical.add(\"font-family\");\nlongHandLogical.add(\"font-size\");\nlongHandLogical.add(\"font-stretch\");\nlongHandLogical.add(\"font-style\");\nlongHandLogical.add(\"font-weight\");\nlongHandLogical.add(\"line-height\");\nshorthandsOfLonghands.add(\"font-variant\");\nlongHandLogical.add(\"font-variant-alternates\");\nlongHandLogical.add(\"font-variant-caps\");\nlongHandLogical.add(\"font-variant-east-asian\");\nlongHandLogical.add(\"font-variant-emoji\");\nlongHandLogical.add(\"font-variant-ligatures\");\nlongHandLogical.add(\"font-variant-numeric\");\nlongHandLogical.add(\"font-variant-position\");\n\nlongHandLogical.add(\"font-feature-settings\");\nlongHandLogical.add(\"font-kerning\");\nlongHandLogical.add(\"font-language-override\");\nlongHandLogical.add(\"font-optical-sizing\");\nlongHandLogical.add(\"font-palette\");\nlongHandLogical.add(\"font-variation-settings\");\nlongHandLogical.add(\"font-size-adjust\");\nlongHandLogical.add(\"font-smooth\"); // Non-standard\nlongHandLogical.add(\"font-synthesis-position\");\nlongHandLogical.add(\"font-synthesis-small-caps\");\nlongHandLogical.add(\"font-synthesis-style\");\nlongHandLogical.add(\"font-synthesis-weight\");\n\nlongHandLogical.add(\"line-height-step\");\n\n// CSS Fragmentation\nlongHandLogical.add(\"box-decoration-break\");\nlongHandLogical.add(\"break-after\");\nlongHandLogical.add(\"break-before\");\nlongHandLogical.add(\"break-inside\");\nlongHandLogical.add(\"orphans\");\nlongHandLogical.add(\"widows\");\n\n// CSS Generated Content\nlongHandLogical.add(\"content\");\nlongHandLogical.add(\"quotes\");\n\n// CSS Grid Layout\nshorthandsOfShorthands.add(\"grid\");\nlongHandLogical.add(\"grid-auto-flow\");\nlongHandLogical.add(\"grid-auto-rows\");\nlongHandLogical.add(\"grid-auto-columns\");\nshorthandsOfShorthands.add(\"grid-template\");\nshorthandsOfLonghands.add(\"grid-template-areas\");\nlongHandLogical.add(\"grid-template-columns\");\nlongHandLogical.add(\"grid-template-rows\");\n\nshorthandsOfShorthands.add(\"grid-area\");\nshorthandsOfLonghands.add(\"grid-row\");\nlongHandLogical.add(\"grid-row-start\");\nlongHandLogical.add(\"grid-row-end\");\nshorthandsOfLonghands.add(\"grid-column\");\nlongHandLogical.add(\"grid-column-start\");\nlongHandLogical.add(\"grid-column-end\");\n\nlongHandLogical.add(\"align-tracks\");\nlongHandLogical.add(\"justify-tracks\");\nlongHandLogical.add(\"masonry-auto-flow\");\n\n// CSS Images\nlongHandLogical.add(\"image-orientation\");\nlongHandLogical.add(\"image-rendering\");\nlongHandLogical.add(\"image-resolution\");\nlongHandLogical.add(\"object-fit\");\nlongHandLogical.add(\"object-position\");\n\n// CSS Inline\nlongHandLogical.add(\"initial-letter\");\nlongHandLogical.add(\"initial-letter-align\");\n\n// CSS Lists and Counters\nshorthandsOfLonghands.add(\"list-style\");\nlongHandLogical.add(\"list-style-image\");\nlongHandLogical.add(\"list-style-position\");\nlongHandLogical.add(\"list-style-type\");\n\n// CSS Masking\nlongHandLogical.add(\"clip\"); // @deprecated\nlongHandLogical.add(\"clip-path\");\n\nshorthandsOfLonghands.add(\"mask\");\nlongHandLogical.add(\"mask-clip\");\nlongHandLogical.add(\"mask-composite\");\nlongHandLogical.add(\"mask-image\");\nlongHandLogical.add(\"mask-mode\");\nlongHandLogical.add(\"mask-origin\");\nlongHandLogical.add(\"mask-position\");\nlongHandLogical.add(\"mask-repeat\");\nlongHandLogical.add(\"mask-size\");\n\nlongHandLogical.add(\"mask-type\");\n\nshorthandsOfLonghands.add(\"mask-border\");\nlongHandLogical.add(\"mask-border-mode\");\nlongHandLogical.add(\"mask-border-outset\");\nlongHandLogical.add(\"mask-border-repeat\");\nlongHandLogical.add(\"mask-border-slice\");\nlongHandLogical.add(\"mask-border-source\");\nlongHandLogical.add(\"mask-border-width\");\n\n// CSS Miscellaneous\nshorthandsOfShorthands.add(\"all\"); // avoid!\nlongHandLogical.add(\"text-rendering\");\n\n// CSS Motion Path\nshorthandsOfLonghands.add(\"offset\");\nlongHandLogical.add(\"offset-anchor\");\nlongHandLogical.add(\"offset-distance\");\nlongHandLogical.add(\"offset-path\");\nlongHandLogical.add(\"offset-position\");\nlongHandLogical.add(\"offset-rotate\");\n\n// CSS Overflow\nlongHandLogical.add(\"-webkit-box-orient\");\nlongHandLogical.add(\"-webkit-line-clamp\");\n\nshorthandsOfLonghands.add(\"overflow\");\nlongHandLogical.add(\"overflow-block\");\nlongHandPhysical.add(\"overflow-y\");\nlongHandLogical.add(\"overflow-inline\");\nlongHandPhysical.add(\"overflow-x\");\n\nlongHandLogical.add(\"overflow-clip-margin\"); // partial support\n\nlongHandLogical.add(\"scroll-gutter\");\nlongHandLogical.add(\"scroll-behavior\");\n\n// CSS Pages\nlongHandLogical.add(\"page\");\nlongHandLogical.add(\"page-break-after\");\nlongHandLogical.add(\"page-break-before\");\nlongHandLogical.add(\"page-break-inside\");\n\n// CSS Positioning\nshorthandsOfShorthands.add(\"inset\"); // Logical Properties\nshorthandsOfLonghands.add(\"inset-block\"); // Logical Properties\nlongHandLogical.add(\"inset-block-start\"); // Logical Properties\nlongHandPhysical.add(\"top\");\nlongHandLogical.add(\"inset-block-end\"); // Logical Properties\nlongHandPhysical.add(\"bottom\");\nshorthandsOfLonghands.add(\"inset-inline\"); // Logical Properties\nlongHandLogical.add(\"inset-inline-start\"); // Logical Properties\nlongHandPhysical.add(\"left\");\nlongHandLogical.add(\"inset-inline-end\"); // Logical Properties\nlongHandPhysical.add(\"right\");\n\nlongHandLogical.add(\"clear\");\nlongHandLogical.add(\"float\");\nlongHandLogical.add(\"position\");\nlongHandLogical.add(\"z-index\");\n\n// CSS Ruby\nlongHandLogical.add(\"ruby-align\");\nlongHandLogical.add(\"ruby-merge\");\nlongHandLogical.add(\"ruby-position\");\n\n// CSS Scroll Anchoring\nlongHandLogical.add(\"overflow-anchor\");\n\n// CSS Scroll Snap\nshorthandsOfShorthands.add(\"scroll-margin\");\nshorthandsOfLonghands.add(\"scroll-margin-block\");\nlongHandLogical.add(\"scroll-margin-block-start\");\nlongHandPhysical.add(\"scroll-margin-top\");\nlongHandLogical.add(\"scroll-margin-block-end\");\nlongHandPhysical.add(\"scroll-margin-bottom\");\nshorthandsOfLonghands.add(\"scroll-margin-inline\");\nlongHandLogical.add(\"scroll-margin-inline-start\");\nlongHandPhysical.add(\"scroll-margin-left\");\nlongHandLogical.add(\"scroll-margin-inline-end\");\nlongHandPhysical.add(\"scroll-margin-right\");\n\nshorthandsOfShorthands.add(\"scroll-padding\");\nshorthandsOfLonghands.add(\"scroll-padding-block\");\nlongHandLogical.add(\"scroll-padding-block-start\");\nlongHandPhysical.add(\"scroll-padding-top\");\nlongHandLogical.add(\"scroll-padding-block-end\");\nlongHandPhysical.add(\"scroll-padding-bottom\");\nshorthandsOfLonghands.add(\"scroll-padding-inline\");\nlongHandLogical.add(\"scroll-padding-inline-start\");\nlongHandPhysical.add(\"scroll-padding-left\");\nlongHandLogical.add(\"scroll-padding-inline-end\");\nlongHandPhysical.add(\"scroll-padding-right\");\n\nlongHandLogical.add(\"scroll-snap-align\");\nlongHandLogical.add(\"scroll-snap-stop\");\nshorthandsOfLonghands.add(\"scroll-snap-type\");\n\n// CSS Scrollbars\nlongHandLogical.add(\"scrollbar-color\");\nlongHandLogical.add(\"scrollbar-width\");\n\n// CSS Shapes\nlongHandLogical.add(\"shape-image-threshold\");\nlongHandLogical.add(\"shape-margin\");\nlongHandLogical.add(\"shape-outside\");\n\n// CSS Speech\nlongHandLogical.add(\"azimuth\");\n\n// CSS Table\nlongHandLogical.add(\"border-collapse\");\nlongHandLogical.add(\"border-spacing\");\nlongHandLogical.add(\"caption-side\");\nlongHandLogical.add(\"empty-cells\");\nlongHandLogical.add(\"table-layout\");\nlongHandLogical.add(\"vertical-align\");\n\n// CSS Text Decoration\nshorthandsOfLonghands.add(\"text-decoration\");\nlongHandLogical.add(\"text-decoration-color\");\nlongHandLogical.add(\"text-decoration-line\");\nlongHandLogical.add(\"text-decoration-skip\");\nlongHandLogical.add(\"text-decoration-skip-ink\");\nlongHandLogical.add(\"text-decoration-style\");\nlongHandLogical.add(\"text-decoration-thickness\");\n\nshorthandsOfLonghands.add(\"text-emphasis\");\nlongHandLogical.add(\"text-emphasis-color\");\nlongHandLogical.add(\"text-emphasis-position\");\nlongHandLogical.add(\"text-emphasis-style\");\nlongHandLogical.add(\"text-shadow\");\nlongHandLogical.add(\"text-underline-offset\");\nlongHandLogical.add(\"text-underline-position\");\n\n// CSS Text\nlongHandLogical.add(\"hanging-punctuation\");\nlongHandLogical.add(\"hyphenate-character\");\nlongHandLogical.add(\"hyphenate-limit-chars\");\nlongHandLogical.add(\"hyphens\");\nlongHandLogical.add(\"letter-spacing\");\nlongHandLogical.add(\"line-break\");\nlongHandLogical.add(\"overflow-wrap\");\nlongHandLogical.add(\"paint-order\");\nlongHandLogical.add(\"tab-size\");\nlongHandLogical.add(\"text-align\");\nlongHandLogical.add(\"text-align-last\");\nlongHandLogical.add(\"text-indent\");\nlongHandLogical.add(\"text-justify\");\nlongHandLogical.add(\"text-size-adjust\");\nlongHandLogical.add(\"text-transform\");\nlongHandLogical.add(\"text-wrap\");\nlongHandLogical.add(\"white-space\");\nlongHandLogical.add(\"white-space-collapse\");\nlongHandLogical.add(\"word-break\");\nlongHandLogical.add(\"word-spacing\");\nlongHandLogical.add(\"word-wrap\");\n\n// CSS Transforms\nlongHandLogical.add(\"backface-visibility\");\nlongHandLogical.add(\"perspective\");\nlongHandLogical.add(\"perspective-origin\");\nlongHandLogical.add(\"rotate\");\nlongHandLogical.add(\"scale\");\nlongHandLogical.add(\"transform\");\nlongHandLogical.add(\"transform-box\");\nlongHandLogical.add(\"transform-origin\");\nlongHandLogical.add(\"transform-style\");\nlongHandLogical.add(\"translate\");\n\n// CSS Transitions\nshorthandsOfLonghands.add(\"transition\");\nlongHandLogical.add(\"transition-delay\");\nlongHandLogical.add(\"transition-duration\");\nlongHandLogical.add(\"transition-property\");\nlongHandLogical.add(\"transition-timing-function\");\n\n// CSS View Transitions\nlongHandLogical.add(\"view-transition-name\");\n\n// CSS Will Change\nlongHandLogical.add(\"will-change\");\n\n// CSS Writing Modes\nlongHandLogical.add(\"direction\");\nlongHandLogical.add(\"text-combine-upright\");\nlongHandLogical.add(\"text-orientation\");\nlongHandLogical.add(\"unicode-bidi\");\nlongHandLogical.add(\"writing-mode\");\n\n// CSS Filter Effects\nlongHandLogical.add(\"backdrop-filter\");\nlongHandLogical.add(\"filter\");\n\n// MathML\nlongHandLogical.add(\"math-depth\");\nlongHandLogical.add(\"math-shift\");\nlongHandLogical.add(\"math-style\");\n\n// CSS Pointer Events\nlongHandLogical.add(\"touch-action\");\n\nexport const PSEUDO_CLASS_PRIORITIES: Readonly<Record<string, number>> = {\n \":is\": 40,\n \":where\": 40,\n \":not\": 40,\n \":has\": 45,\n \":dir\": 50,\n \":lang\": 51,\n \":first-child\": 52,\n \":first-of-type\": 53,\n \":last-child\": 54,\n \":last-of-type\": 55,\n \":only-child\": 56,\n \":only-of-type\": 57,\n \":nth-child\": 60,\n \":nth-last-child\": 61,\n \":nth-of-type\": 62,\n \":nth-last-of-type\": 63,\n \":empty\": 70,\n \":link\": 80,\n \":any-link\": 81,\n \":local-link\": 82,\n \":target-within\": 83,\n \":target\": 84,\n \":visited\": 85,\n \":enabled\": 91,\n \":disabled\": 92,\n \":required\": 93,\n \":optional\": 94,\n \":read-only\": 95,\n \":read-write\": 96,\n \":placeholder-shown\": 97,\n \":in-range\": 98,\n \":out-of-range\": 99,\n \":default\": 100,\n \":checked\": 101,\n \":indeterminate\": 101,\n \":blank\": 102,\n \":valid\": 103,\n \":invalid\": 104,\n \":user-invalid\": 105,\n \":autofill\": 110,\n \":picture-in-picture\": 120,\n \":modal\": 121,\n \":fullscreen\": 122,\n \":paused\": 123,\n \":playing\": 124,\n \":current\": 125,\n \":past\": 126,\n \":future\": 127,\n \":hover\": 130,\n \":focus-within\": 140,\n \":focus\": 150,\n \":focus-visible\": 160,\n \":active\": 170,\n};\n\nexport const AT_RULE_PRIORITIES: Readonly<Record<string, number>> = {\n \"@supports\": 30,\n \"@media\": 200,\n \"@container\": 300,\n};\n\nexport const PSEUDO_ELEMENT_PRIORITY: number = 5000;\n\n/** Get the property tier for a CSS property (kebab-case). */\nexport function getPropertyPriority(property: string): number {\n if (shorthandsOfShorthands.has(property)) return 1000;\n if (shorthandsOfLonghands.has(property)) return 2000;\n if (longHandLogical.has(property)) return 3000;\n if (longHandPhysical.has(property)) return 4000;\n // Unknown properties default to 3000 (longhand) — safest default\n return 3000;\n}\n\n/** Get the priority for a pseudo-class selector. */\nexport function getPseudoClassPriority(pseudo: string): number {\n const leadingPseudo = pseudo.trim().match(/^::?[a-zA-Z-]+/)?.[0] ?? pseudo.split(\"(\")[0];\n const base = leadingPseudo.replace(/[A-Z]/g, (match) => {\n return `-${match.toLowerCase()}`;\n });\n return PSEUDO_CLASS_PRIORITIES[base] ?? 40;\n}\n\n/** Get the priority for an at-rule. */\nexport function getAtRulePriority(atRule: string): number {\n if (atRule.startsWith(\"--\")) return 1;\n if (atRule.startsWith(\"@supports\")) return AT_RULE_PRIORITIES[\"@supports\"];\n if (atRule.startsWith(\"@media\")) return AT_RULE_PRIORITIES[\"@media\"];\n if (atRule.startsWith(\"@container\")) return AT_RULE_PRIORITIES[\"@container\"];\n return 0;\n}\n","/**\n * Computes CSS rule priority using StyleX's priority system.\n *\n * Priority is an additive sum: propertyPriority + pseudoPriority + atRulePriority + pseudoElementPriority.\n * Rules are sorted by this number before emission, guaranteeing longhands beat shorthands,\n * pseudo-classes follow LVFHA order, and at-rules override base styles — all deterministically.\n */\n\nimport {\n getPropertyPriority,\n getPseudoClassPriority,\n getAtRulePriority,\n PSEUDO_ELEMENT_PRIORITY,\n} from \"./property-priorities\";\nimport type { AtomicRule } from \"./emit-truss\";\n\n/** Relationship base priorities for when() selectors, matching StyleX's relational selector system. */\nconst RELATIONSHIP_BASE: Record<string, number> = {\n ancestor: 10,\n descendant: 15,\n anySibling: 20,\n siblingBefore: 30,\n siblingAfter: 40,\n};\n\n/**\n * Compute the numeric priority for a single AtomicRule.\n *\n * I.e. a rule with `declarations: [{ cssProperty: \"border-top-color\", ... }]`, `pseudoClass: \":hover\"`,\n * `mediaQuery: \"@media ...\"` → 4000 (physical longhand) + 130 (:hover) + 200 (@media) = 4330\n */\nexport function computeRulePriority(rule: AtomicRule): number {\n let priority = getPropertyPriority(rule.declarations[0].cssProperty);\n\n if (rule.pseudoElement) {\n priority += PSEUDO_ELEMENT_PRIORITY;\n }\n\n if (rule.pseudoClass) {\n priority += getPseudoClassPriority(rule.pseudoClass);\n }\n\n if (rule.mediaQuery) {\n priority += getAtRulePriority(rule.mediaQuery);\n }\n\n if (rule.whenSelector) {\n const relBase = RELATIONSHIP_BASE[rule.whenSelector.relationship] ?? 10;\n const pseudoFraction = getPseudoClassPriority(rule.whenSelector.pseudo) / 100;\n priority += relBase + pseudoFraction;\n }\n\n // Variable rules get a small bonus (+0.5) so they sort after static rules for the same property\n if (isVariableRule(rule)) {\n priority += 0.5;\n }\n\n return priority;\n}\n\n/** Returns true if this rule uses CSS custom property var() values. */\nfunction isVariableRule(rule: AtomicRule): boolean {\n return rule.declarations.some((d) => d.cssVarName !== undefined);\n}\n\n/**\n * Sort an array of AtomicRules in-place by their computed priority.\n *\n * When two rules have the same priority (e.g. two different longhands both at 3000),\n * we tiebreak by class name so the output is fully deterministic regardless of\n * file processing order (which differs between dev HMR and production builds).\n *\n * Uses a decorate-sort-undecorate pattern so each rule's priority is computed\n * once upfront rather than re-evaluated on every comparator call.\n */\nexport function sortRulesByPriority(rules: AtomicRule[]): void {\n // Pre-compute priorities so the O(n log n) comparisons are just number/string compares\n const decorated = rules.map((rule, i) => {\n return { rule, priority: computeRulePriority(rule), index: i };\n });\n decorated.sort((a, b) => {\n const diff = a.priority - b.priority;\n if (diff !== 0) return diff;\n // Alphabetical tiebreaker ensures identical output in dev and production\n return a.rule.className < b.rule.className ? -1 : a.rule.className > b.rule.className ? 1 : 0;\n });\n for (let i = 0; i < decorated.length; i++) {\n rules[i] = decorated[i].rule;\n }\n}\n","/**\n * Static mapping of CSS property names (camelCase) to unique short abbreviations.\n *\n * Used by the Truss compiler to generate compact, deterministic class names\n * when no user-defined canonical abbreviation exists for a given property+value.\n *\n * Convention: first letter of each camelCase word, with conflict resolution\n * via extra characters where needed. I.e. `borderBottomWidth` → `bbw`,\n * `flexDirection` → `fxd`, `fontSize` → `fz`.\n *\n * User-defined abbreviations (from the longhand lookup) always take priority\n * over these — this mapping is only the fallback.\n */\nexport const cssPropertyAbbreviations: Record<string, string> = {\n // Alignment\n alignContent: \"ac\",\n alignItems: \"ai\",\n alignSelf: \"als\",\n\n // Animation\n animation: \"anim\",\n animationDelay: \"animd\",\n animationDirection: \"animdr\",\n animationDuration: \"animdu\",\n animationFillMode: \"animfm\",\n animationIterationCount: \"animic\",\n animationName: \"animn\",\n animationPlayState: \"animps\",\n animationTimingFunction: \"animtf\",\n\n // Appearance\n appearance: \"app\",\n\n // Aspect ratio\n aspectRatio: \"ar\",\n\n // Backdrop filter\n backdropFilter: \"bdf\",\n\n // Background\n background: \"bg\",\n backgroundAttachment: \"bga\",\n backgroundBlendMode: \"bgbm\",\n backgroundClip: \"bgcl\",\n backgroundColor: \"bgc\",\n backgroundImage: \"bgi\",\n backgroundOrigin: \"bgo\",\n backgroundPosition: \"bgp\",\n backgroundRepeat: \"bgr\",\n backgroundSize: \"bgs\",\n\n // Border – shorthand\n border: \"bd\",\n borderCollapse: \"bdcl\",\n borderColor: \"bdc\",\n borderImage: \"bdi\",\n borderRadius: \"bra\",\n borderSpacing: \"bdsp\",\n borderStyle: \"bs\",\n borderWidth: \"bw\",\n\n // Border – top\n borderTop: \"bdt\",\n borderTopColor: \"btc\",\n borderTopLeftRadius: \"btlr\",\n borderTopRightRadius: \"btrr\",\n borderTopStyle: \"bts\",\n borderTopWidth: \"btw\",\n\n // Border – right\n borderRight: \"bdr\",\n borderRightColor: \"brc\",\n borderRightStyle: \"brs\",\n borderRightWidth: \"brw\",\n\n // Border – bottom\n borderBottom: \"bdb\",\n borderBottomColor: \"bbc\",\n borderBottomLeftRadius: \"bblr\",\n borderBottomRightRadius: \"bbrr\",\n borderBottomStyle: \"bbs\",\n borderBottomWidth: \"bbw\",\n\n // Border – left\n borderLeft: \"bdl\",\n borderLeftColor: \"blc\",\n borderLeftStyle: \"bls\",\n borderLeftWidth: \"blw\",\n\n // Box\n boxDecorationBreak: \"bxdb\",\n boxShadow: \"bxs\",\n boxSizing: \"bxz\",\n\n // Break\n breakAfter: \"bka\",\n breakBefore: \"bkb\",\n breakInside: \"bki\",\n\n // Caret / caption\n captionSide: \"cps\",\n caretColor: \"cac\",\n\n // Clear / clip\n clear: \"clr\",\n clip: \"cli\",\n clipPath: \"clp\",\n\n // Color\n color: \"c\",\n colorScheme: \"cs\",\n\n // Columns\n columnCount: \"cc\",\n columnFill: \"cf\",\n columnGap: \"cg\",\n columnRule: \"cr\",\n columnRuleColor: \"crc\",\n columnRuleStyle: \"crs\",\n columnRuleWidth: \"crw\",\n columnSpan: \"csp\",\n columnWidth: \"cw\",\n columns: \"cols\",\n\n // Contain / container\n contain: \"ctn\",\n containerName: \"ctnm\",\n containerType: \"ctnt\",\n content: \"cnt\",\n contentVisibility: \"cv\",\n\n // Counter\n counterIncrement: \"coi\",\n counterReset: \"cor\",\n\n // Cursor\n cursor: \"cur\",\n\n // Direction\n direction: \"dir\",\n\n // Display\n display: \"d\",\n\n // Empty cells\n emptyCells: \"ec\",\n\n // Fill (SVG)\n fill: \"fi\",\n fillOpacity: \"fio\",\n fillRule: \"fir\",\n\n // Filter\n filter: \"flt\",\n\n // Flex\n flex: \"fx\",\n flexBasis: \"fxb\",\n flexDirection: \"fxd\",\n flexFlow: \"fxf\",\n flexGrow: \"fxg\",\n flexShrink: \"fxs\",\n flexWrap: \"fxw\",\n\n // Float\n float: \"fl\",\n\n // Font\n font: \"fnt\",\n fontDisplay: \"fntd\",\n fontFamily: \"ff\",\n fontFeatureSettings: \"ffs\",\n fontKerning: \"fk\",\n fontSize: \"fz\",\n fontSizeAdjust: \"fza\",\n fontStretch: \"fst\",\n fontStyle: \"fsy\",\n fontSynthesis: \"fsyn\",\n fontVariant: \"fv\",\n fontVariantCaps: \"fvc\",\n fontVariantLigatures: \"fvl\",\n fontVariantNumeric: \"fvn\",\n fontWeight: \"fw\",\n\n // Gap\n gap: \"g\",\n\n // Grid\n grid: \"gd\",\n gridArea: \"ga\",\n gridAutoColumns: \"gac\",\n gridAutoFlow: \"gaf\",\n gridAutoRows: \"gar\",\n gridColumn: \"gc\",\n gridColumnEnd: \"gce\",\n gridColumnGap: \"gcg\",\n gridColumnStart: \"gcs\",\n gridGap: \"gg\",\n gridRow: \"gr\",\n gridRowEnd: \"gre\",\n gridRowGap: \"grg\",\n gridRowStart: \"grs\",\n gridTemplate: \"gt\",\n gridTemplateAreas: \"gta\",\n gridTemplateColumns: \"gtc\",\n gridTemplateRows: \"gtr\",\n\n // Height\n height: \"h\",\n maxHeight: \"mxh\",\n minHeight: \"mnh\",\n\n // Hyphens\n hyphens: \"hyp\",\n\n // Image rendering\n imageRendering: \"ir\",\n\n // Inset\n inset: \"ins\",\n insetBlock: \"insb\",\n insetBlockEnd: \"insbe\",\n insetBlockStart: \"insbs\",\n insetInline: \"insi\",\n insetInlineEnd: \"insie\",\n insetInlineStart: \"insis\",\n\n // Isolation\n isolation: \"iso\",\n\n // Justify\n justifyContent: \"jc\",\n justifyItems: \"ji\",\n justifySelf: \"jfs\",\n\n // Left\n left: \"l\",\n\n // Letter spacing\n letterSpacing: \"ls\",\n\n // Line\n lineBreak: \"lb\",\n lineHeight: \"lh\",\n\n // List\n listStyle: \"lis\",\n listStyleImage: \"lsi\",\n listStylePosition: \"lsp\",\n listStyleType: \"lst\",\n\n // Margin\n margin: \"m\",\n marginBlock: \"mbl\",\n marginBlockEnd: \"mble\",\n marginBlockStart: \"mbls\",\n marginBottom: \"mb\",\n marginInline: \"mil\",\n marginInlineEnd: \"mile\",\n marginInlineStart: \"mils\",\n marginLeft: \"ml\",\n marginRight: \"mr\",\n marginTop: \"mt\",\n\n // Mask\n mask: \"msk\",\n maskImage: \"mski\",\n maskPosition: \"mskp\",\n maskRepeat: \"mskr\",\n maskSize: \"msks\",\n\n // Max / min width\n maxWidth: \"mxw\",\n minWidth: \"mnw\",\n\n // Mix blend mode\n mixBlendMode: \"mbm\",\n\n // Object\n objectFit: \"obf\",\n objectPosition: \"obp\",\n\n // Offset\n offset: \"ofs\",\n offsetPath: \"ofsp\",\n\n // Opacity\n opacity: \"op\",\n\n // Order\n order: \"ord\",\n\n // Orphans / widows\n orphans: \"orp\",\n widows: \"wid\",\n\n // Outline\n outline: \"ol\",\n outlineColor: \"olc\",\n outlineOffset: \"olo\",\n outlineStyle: \"ols\",\n outlineWidth: \"olw\",\n\n // Overflow\n overflow: \"ov\",\n overflowAnchor: \"ova\",\n overflowWrap: \"ovw\",\n overflowX: \"ovx\",\n overflowY: \"ovy\",\n overscrollBehavior: \"osb\",\n overscrollBehaviorX: \"osbx\",\n overscrollBehaviorY: \"osby\",\n\n // Padding\n padding: \"p\",\n paddingBlock: \"pbl\",\n paddingBlockEnd: \"pble\",\n paddingBlockStart: \"pbls\",\n paddingBottom: \"pb\",\n paddingInline: \"pil\",\n paddingInlineEnd: \"pile\",\n paddingInlineStart: \"pils\",\n paddingLeft: \"pl\",\n paddingRight: \"pr\",\n paddingTop: \"pt\",\n\n // Page break\n pageBreakAfter: \"pgba\",\n pageBreakBefore: \"pgbb\",\n pageBreakInside: \"pgbi\",\n\n // Perspective\n perspective: \"per\",\n perspectiveOrigin: \"pero\",\n\n // Place\n placeContent: \"plc\",\n placeItems: \"pli\",\n placeSelf: \"pls\",\n\n // Pointer events\n pointerEvents: \"pe\",\n\n // Position\n position: \"pos\",\n\n // Quotes\n quotes: \"q\",\n\n // Resize\n resize: \"rsz\",\n\n // Right\n right: \"r\",\n\n // Rotate / scale\n rotate: \"rot\",\n scale: \"sc\",\n\n // Row gap\n rowGap: \"rg\",\n\n // Scroll\n scrollBehavior: \"scb\",\n scrollMargin: \"scm\",\n scrollPadding: \"scp\",\n scrollSnapAlign: \"ssa\",\n scrollSnapStop: \"sss\",\n scrollSnapType: \"sst\",\n\n // Shape\n shapeImageThreshold: \"sit\",\n shapeMargin: \"sm\",\n shapeOutside: \"so\",\n\n // Stroke (SVG)\n stroke: \"stk\",\n strokeDasharray: \"sda\",\n strokeDashoffset: \"sdo\",\n strokeLinecap: \"slc\",\n strokeLinejoin: \"slj\",\n strokeOpacity: \"sop\",\n strokeWidth: \"sw\",\n\n // Tab size\n tabSize: \"ts\",\n\n // Table layout\n tableLayout: \"tl\",\n\n // Text\n textAlign: \"ta\",\n textAlignLast: \"tal\",\n textDecoration: \"td\",\n textDecorationColor: \"tdc\",\n textDecorationLine: \"tdl\",\n textDecorationStyle: \"tds\",\n textDecorationThickness: \"tdt\",\n textEmphasis: \"te\",\n textIndent: \"ti\",\n textJustify: \"tj\",\n textOrientation: \"tor\",\n textOverflow: \"to\",\n textRendering: \"tr\",\n textShadow: \"tsh\",\n textTransform: \"tt\",\n textUnderlineOffset: \"tuo\",\n textUnderlinePosition: \"tup\",\n textWrap: \"twp\",\n\n // Top\n top: \"tp\",\n\n // Touch action\n touchAction: \"tca\",\n\n // Transform\n transform: \"tf\",\n transformOrigin: \"tfo\",\n transformStyle: \"tfs\",\n\n // Transition\n transition: \"tsn\",\n transitionDelay: \"tsnd\",\n transitionDuration: \"tsndu\",\n transitionProperty: \"tsnp\",\n transitionTimingFunction: \"tsntf\",\n\n // Translate\n translate: \"tsl\",\n\n // Unicode / user select\n unicodeBidi: \"ub\",\n userSelect: \"us\",\n\n // Vertical align\n verticalAlign: \"va\",\n\n // Visibility\n visibility: \"vis\",\n\n // Webkit\n WebkitAppearance: \"wkapp\",\n WebkitBackdropFilter: \"wkbdf\",\n WebkitBoxOrient: \"wbo\",\n WebkitFontSmoothing: \"wkfs\",\n WebkitLineClamp: \"wlc\",\n WebkitMaskImage: \"wkmi\",\n WebkitOverflowScrolling: \"wkos\",\n WebkitTapHighlightColor: \"wkthc\",\n WebkitTextFillColor: \"wktfc\",\n WebkitTextStrokeColor: \"wktsc\",\n WebkitTextStrokeWidth: \"wktsw\",\n\n // White space\n whiteSpace: \"ws\",\n\n // Width\n width: \"w\",\n\n // Will change\n willChange: \"wc\",\n\n // Word\n wordBreak: \"wdb\",\n wordSpacing: \"wds\",\n wordWrap: \"wdw\",\n writingMode: \"wm\",\n\n // Z-index\n zIndex: \"zi\",\n\n // Bottom (positioned after \"border*\" to avoid scan confusion)\n bottom: \"bot\",\n};\n\n// Validate uniqueness at module load time\nconst seen = new Map<string, string>();\nfor (const [prop, abbr] of Object.entries(cssPropertyAbbreviations)) {\n const existing = seen.get(abbr);\n if (existing) {\n throw new Error(`CSS property abbreviation conflict: \"${abbr}\" is used by both \"${existing}\" and \"${prop}\"`);\n }\n seen.set(abbr, prop);\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 findCssBuilderBinding,\n removeCssImport,\n findNamedImportBinding,\n findImportDeclaration,\n replaceCssImportWithNamedImports,\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 or use JSX css= attributes\n if (!code.includes(\"Css\") && !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 binding name — either from an import or a local `new CssBuilder(...)` declaration.\n // May be null when the file only has JSX css= attributes without importing Css.\n const cssImportBinding = findCssImportBinding(ast);\n const cssBindingName = cssImportBinding ?? findCssBuilderBinding(ast);\n const cssIsImported = cssImportBinding !== null;\n\n // Step 2: Collect all Css.*.$ expression sites AND detect Css.props() / JSX css= in a single pass.\n const sites: ExpressionSite[] = [];\n const errorMessages: Array<{ message: string; line: number | null }> = [];\n let hasCssPropsCall = false;\n let hasBuildtimeJsxCssAttribute = false;\n let hasRuntimeStyleCssUsage = false;\n\n traverse(ast, {\n // -- Css.*.$ chain collection --\n MemberExpression(path: NodePath<t.MemberExpression>) {\n if (!cssBindingName) return;\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 if (isInsideRuntimeStyleCssObject(path)) {\n hasRuntimeStyleCssUsage = true;\n return;\n }\n if (isInsideWhenObjectValue(path, cssBindingName)) {\n return;\n }\n\n const parentPath = path.parentPath;\n if (parentPath && parentPath.isMemberExpression() && t.isIdentifier(parentPath.node.property, { name: \"$\" })) {\n return;\n }\n\n const resolvedChain = resolveFullChain(chain, mapping, cssBindingName);\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 // -- Css.props() detection (so we don't bail early when there are no Css.*.$ sites) --\n CallExpression(path: NodePath<t.CallExpression>) {\n if (!cssBindingName || hasCssPropsCall) return;\n const callee = path.node.callee;\n if (\n t.isMemberExpression(callee) &&\n !callee.computed &&\n t.isIdentifier(callee.object, { name: cssBindingName }) &&\n t.isIdentifier(callee.property, { name: \"props\" })\n ) {\n hasCssPropsCall = true;\n }\n },\n // -- JSX css={...} attribute detection (so we don't bail when there are only css props) --\n JSXAttribute(path: NodePath<t.JSXAttribute>) {\n if (!t.isJSXIdentifier(path.node.name, { name: \"css\" })) return;\n if (isRuntimeStyleCssAttribute(path)) return;\n hasBuildtimeJsxCssAttribute = true;\n },\n });\n\n if (sites.length === 0 && !hasCssPropsCall && !hasBuildtimeJsxCssAttribute) 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: 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 runtimeLookupNames,\n });\n\n // Step 6: Prepare runtime imports before removing the Css import.\n const runtimeImports: Array<{ importedName: string; localName: string }> = [];\n if (needsTrussPropsHelper.current && !existingTrussPropsHelperName) {\n runtimeImports.push({ importedName: \"trussProps\", localName: trussPropsHelperName });\n }\n if (needsMergePropsHelper.current && !existingMergePropsHelperName) {\n runtimeImports.push({ importedName: \"mergeProps\", localName: mergePropsHelperName });\n }\n if (needsTrussDebugInfo.current && !existingTrussDebugInfoName) {\n runtimeImports.push({ importedName: \"TrussDebugInfo\", localName: trussDebugInfoName });\n }\n if (options.injectCss) {\n runtimeImports.push({ importedName: \"__injectTrussCSS\", localName: \"__injectTrussCSS\" });\n }\n\n // Step 7: Remove/replace the Css import and inject runtime imports.\n // When Css comes from a local `new CssBuilder(...)` (tsup bundles), skip import removal.\n let reusedCssImportLine = false;\n if (cssIsImported && !hasRuntimeStyleCssUsage) {\n reusedCssImportLine =\n runtimeImports.length > 0 &&\n findImportDeclaration(ast, \"@homebound/truss/runtime\") === null &&\n replaceCssImportWithNamedImports(ast, cssImportBinding!, \"@homebound/truss/runtime\", runtimeImports);\n\n if (!reusedCssImportLine) {\n removeCssImport(ast, cssImportBinding!);\n }\n }\n\n if (runtimeImports.length > 0 && !reusedCssImportLine) {\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((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 sourceMaps: true,\n retainLines: false,\n });\n\n const outputCode = preserveBlankLineAfterImports(code, output.code);\n\n return { code: outputCode, map: output.map, css: cssText, rules };\n}\n\nfunction isInsideRuntimeStyleCssObject(path: NodePath<t.MemberExpression>): boolean {\n let current: NodePath<t.Node> | null = path.parentPath;\n\n while (current) {\n // JSX path: <RuntimeStyle css={{ \".sel\": Css.blue.$ }} />\n if (current.isJSXExpressionContainer()) {\n const attrPath = current.parentPath;\n if (!attrPath || !attrPath.isJSXAttribute()) return false;\n return t.isObjectExpression(current.node.expression) && isRuntimeStyleCssAttribute(attrPath);\n }\n // Hook path: useRuntimeStyle({ \".sel\": Css.blue.$ })\n if (current.isCallExpression() && isUseRuntimeStyleCall(current.node)) {\n return true;\n }\n current = current.parentPath;\n }\n\n return false;\n}\n\n/** Match `useRuntimeStyle(...)` call expressions. */\nfunction isUseRuntimeStyleCall(node: t.CallExpression): boolean {\n return t.isIdentifier(node.callee, { name: \"useRuntimeStyle\" });\n}\n\nfunction isRuntimeStyleCssAttribute(path: NodePath<t.JSXAttribute>): boolean {\n if (!t.isJSXIdentifier(path.node.name, { name: \"css\" })) return false;\n\n const openingElementPath = path.parentPath;\n if (!openingElementPath || !openingElementPath.isJSXOpeningElement()) return false;\n return t.isJSXIdentifier(openingElementPath.node.name, { name: \"RuntimeStyle\" });\n}\n\nfunction isInsideWhenObjectValue(path: NodePath<t.MemberExpression>, cssBindingName: string): boolean {\n let current: NodePath<t.Node> | null = path.parentPath;\n\n while (current) {\n if (current.isObjectExpression()) {\n const parent = current.parentPath;\n if (\n parent?.isCallExpression() &&\n parent.node.arguments[0] === current.node &&\n t.isMemberExpression(parent.node.callee) &&\n !parent.node.callee.computed &&\n t.isIdentifier(parent.node.callee.property, { name: \"when\" }) &&\n extractChain(parent.node.callee.object as t.Expression, cssBindingName)\n ) {\n return true;\n }\n }\n\n current = current.parentPath;\n }\n\n return false;\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\nfunction preserveBlankLineAfterImports(input: string, output: string): string {\n const inputLines = input.split(\"\\n\");\n const outputLines = output.split(\"\\n\");\n const lastInputImportLine = findLastImportLine(inputLines);\n const lastOutputImportLine = findLastImportLine(outputLines);\n\n if (lastInputImportLine === -1 || lastOutputImportLine === -1) {\n return output;\n }\n\n const inputHasBlankLineAfterImports = inputLines[lastInputImportLine + 1]?.trim() === \"\";\n const outputHasBlankLineAfterImports = outputLines[lastOutputImportLine + 1]?.trim() === \"\";\n if (!inputHasBlankLineAfterImports || outputHasBlankLineAfterImports) {\n return output;\n }\n\n outputLines.splice(lastOutputImportLine + 1, 0, \"\");\n return outputLines.join(\"\\n\");\n}\n\nfunction findLastImportLine(lines: string[]): number {\n let lastImportLine = -1;\n for (let index = 0; index < lines.length; index++) {\n if (lines[index].trimStart().startsWith(\"import \")) {\n lastImportLine = index;\n }\n }\n return lastImportLine;\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/**\n * Find a local binding where `Css` is created via `new CssBuilder(...)`.\n *\n * This handles tsup-bundled libraries where Css is not imported but declared as:\n * var Css = new CssBuilder({ ... });\n */\nexport function findCssBuilderBinding(ast: t.File): string | null {\n for (const node of ast.program.body) {\n if (!t.isVariableDeclaration(node)) continue;\n for (const decl of node.declarations) {\n if (\n t.isIdentifier(decl.id) &&\n decl.init &&\n t.isNewExpression(decl.init) &&\n t.isIdentifier(decl.init.callee, { name: \"CssBuilder\" })\n ) {\n return decl.id.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/** 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\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 findImportDeclaration(ast: t.File, source: string): t.ImportDeclaration | null {\n for (const node of ast.program.body) {\n if (t.isImportDeclaration(node) && node.source.value === source) {\n return node;\n }\n }\n return null;\n}\n\nexport function replaceCssImportWithNamedImports(\n ast: t.File,\n cssBinding: string,\n source: string,\n imports: Array<{ importedName: string; localName: string }>,\n): boolean {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n\n const cssSpecIndex = node.specifiers.findIndex((spec) => {\n return t.isImportSpecifier(spec) && spec.local.name === cssBinding;\n });\n if (cssSpecIndex === -1 || node.specifiers.length !== 1) continue;\n\n node.source = t.stringLiteral(source);\n node.specifiers = imports.map((entry) => {\n return t.importSpecifier(t.identifier(entry.localName), t.identifier(entry.importedName));\n });\n return true;\n }\n\n return false;\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((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((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 type * as t from \"@babel/types\";\nimport type {\n MarkerSegment,\n ResolvedConditionContext,\n ResolvedSegment,\n TrussMapping,\n TrussMappingEntry,\n WhenCondition,\n} from \"./types\";\nimport { extractChain } from \"./ast-utils\";\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\nfunction emptyConditionContext(): ResolvedConditionContext {\n return {\n mediaQuery: null,\n pseudoClass: null,\n pseudoElement: null,\n whenPseudo: null,\n };\n}\n\nfunction cloneConditionContext(context: ResolvedConditionContext): ResolvedConditionContext {\n return {\n mediaQuery: context.mediaQuery,\n pseudoClass: context.pseudoClass,\n pseudoElement: context.pseudoElement,\n whenPseudo: context.whenPseudo ? { ...context.whenPseudo } : null,\n };\n}\n\nfunction resetConditionContext(context: ResolvedConditionContext): void {\n context.mediaQuery = null;\n context.pseudoClass = null;\n context.pseudoElement = null;\n context.whenPseudo = null;\n}\n\nfunction segmentWithConditionContext(\n segment: Omit<ResolvedSegment, \"mediaQuery\" | \"pseudoClass\" | \"pseudoElement\" | \"whenPseudo\">,\n context: ResolvedConditionContext,\n): ResolvedSegment {\n return {\n ...segment,\n mediaQuery: context.mediaQuery,\n pseudoClass: context.pseudoClass,\n pseudoElement: context.pseudoElement,\n whenPseudo: context.whenPseudo,\n };\n}\n\nfunction applyModifierNodeToConditionContext(\n context: ResolvedConditionContext,\n node: ChainNode,\n mapping: TrussMapping,\n): void {\n if ((node as any).type === \"__mediaQuery\") {\n context.mediaQuery = (node as any).mediaQuery;\n return;\n }\n\n if (node.type === \"getter\") {\n if (node.name === \"end\") {\n resetConditionContext(context);\n return;\n }\n if (isPseudoMethod(node.name)) {\n context.pseudoClass = pseudoSelector(node.name);\n return;\n }\n if (mapping.breakpoints && node.name in mapping.breakpoints) {\n context.mediaQuery = mapping.breakpoints[node.name];\n }\n return;\n }\n\n if (node.type !== \"call\") {\n return;\n }\n\n if (node.name === \"ifContainer\") {\n try {\n context.mediaQuery = containerSelectorFromCall(node);\n } catch {\n // Ignore invalid modifiers here; resolveChain() will report the real error.\n }\n return;\n }\n\n if (node.name === \"element\") {\n if (node.args.length === 1 && node.args[0].type === \"StringLiteral\") {\n context.pseudoElement = node.args[0].value;\n }\n return;\n }\n\n if (node.name === \"when\") {\n try {\n const resolved = resolveWhenCall(node);\n if (resolved.kind === \"selector\") {\n context.pseudoClass = resolved.pseudo;\n } else {\n context.whenPseudo = resolved;\n }\n } catch {\n // Ignore invalid modifiers here; resolveChain() will report the real error.\n }\n return;\n }\n\n if (isPseudoMethod(node.name)) {\n context.pseudoClass = pseudoSelector(node.name);\n }\n}\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 * applies both conditions.\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 for subsequent styles.\n *\n * - **`when(\":hover\")`** — Same-element selector pseudo. Behaves like a custom\n * pseudo-class context and stacks with media queries.\n *\n * - **`when({ \":hover\": Css.blue.$ })`** — Object form. Each value is resolved\n * like an inline `Css.*.$` chain using the selector key as its initial\n * pseudo-class context, while inheriting the current media/when context.\n *\n * - **`when(marker, \"ancestor\", \":hover\")`** — Relationship selector. Sets the\n * relationship selector context and stacks with same-element pseudos, pseudo-elements,\n * and media queries.\n *\n * - **`ifContainer({ gt, lt })`** — Container query. Sets the media query\n * context to an `@container` query string.\n *\n * - **`end`** — Resets the active media query, pseudo-class, pseudo-element,\n * and `when(...)` relationship-selector context so subsequent styles start\n * from the base condition state again.\n *\n * Contexts accumulate left-to-right until explicitly replaced within the same\n * axis or cleared with `end`. A media query set by `ifSm` persists through\n * `onHover` and `when(...)`.\n * A boolean `if(bool)` nests the chain but inherits the currently-active\n * modifier axes into both branches.\n */\nexport function resolveFullChain(\n chain: ChainNode[],\n mapping: TrussMapping,\n cssBindingName?: string,\n initialContext: ResolvedConditionContext = emptyConditionContext(),\n): ResolvedChain {\n const parts: ResolvedChainPart[] = [];\n const markers: MarkerSegment[] = [];\n const nestedErrors: string[] = [];\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 let currentContext = cloneConditionContext(initialContext);\n let currentNodesStartContext = cloneConditionContext(initialContext);\n\n function flushCurrentNodes(): void {\n if (currentNodes.length === 0) {\n return;\n }\n\n parts.push({\n type: \"unconditional\",\n segments: resolveChain(currentNodes, mapping, currentNodesStartContext, cssBindingName),\n });\n currentNodes = [];\n currentNodesStartContext = cloneConditionContext(currentContext);\n }\n\n function pushCurrentNode(nodeToPush: ChainNode): void {\n if (currentNodes.length === 0) {\n currentNodesStartContext = cloneConditionContext(currentContext);\n }\n\n currentNodes.push(nodeToPush);\n applyModifierNodeToConditionContext(currentContext, nodeToPush, mapping);\n }\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 flushCurrentNodes();\n const branchContext = cloneConditionContext(currentContext);\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, branchContext, cssBindingName);\n const elseSegs = resolveChain(elseNodes, mapping, branchContext, cssBindingName);\n parts.push({ type: \"unconditional\", segments: [...thenSegs, ...elseSegs] });\n i = filteredChain.length;\n break;\n }\n }\n\n if (isWhenObjectCall(node)) {\n flushCurrentNodes();\n const resolved = resolveWhenObjectSelectors(node, mapping, cssBindingName, currentContext);\n parts.push(...resolved.parts);\n markers.push(...resolved.markers);\n nestedErrors.push(...resolved.errors);\n i++;\n continue;\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 pushCurrentNode({ type: \"__mediaQuery\" as any, mediaQuery } as any);\n i++;\n continue;\n }\n\n // Flush any accumulated unconditional nodes\n flushCurrentNodes();\n const branchContext = cloneConditionContext(currentContext);\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, branchContext, cssBindingName);\n const elseSegs = resolveChain(elseNodes, mapping, branchContext, cssBindingName);\n parts.push({\n type: \"conditional\",\n conditionNode: node.conditionNode,\n thenSegments: thenSegs,\n elseSegments: elseSegs,\n });\n } else {\n pushCurrentNode(node);\n i++;\n }\n }\n\n // Flush remaining unconditional nodes\n flushCurrentNodes();\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: [...new Set([...scanErrors, ...nestedErrors, ...segmentErrors])] };\n}\n\n/** Detect `when({ ... })` so object-form selector groups can be resolved specially. */\nfunction isWhenObjectCall(node: ChainNode): node is CallChainNode {\n return (\n node.type === \"call\" && node.name === \"when\" && node.args.length === 1 && node.args[0].type === \"ObjectExpression\"\n );\n}\n\n/**\n * Resolve `when({ \":hover\": Css.blue.$, ... })` by recursively resolving each\n * nested `Css.*.$` value with the selector key as its initial pseudo-class.\n */\nfunction resolveWhenObjectSelectors(\n node: CallChainNode,\n mapping: TrussMapping,\n cssBindingName: string | undefined,\n initialContext: ResolvedConditionContext,\n): ResolvedChain {\n if (!cssBindingName) {\n return {\n parts: [],\n markers: [],\n errors: [new UnsupportedPatternError(`when({ ... }) requires a resolvable Css binding`).message],\n };\n }\n\n const objectArg = node.args[0];\n if (objectArg.type !== \"ObjectExpression\") {\n throw new UnsupportedPatternError(`when({ ... }) requires an object literal argument`);\n }\n\n const parts: ResolvedChainPart[] = [];\n const markers: MarkerSegment[] = [];\n const errors: string[] = [];\n\n for (const property of objectArg.properties) {\n try {\n if (property.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(`when({ ... }) does not support spread properties`);\n }\n if (property.type !== \"ObjectProperty\") {\n throw new UnsupportedPatternError(`when({ ... }) only supports plain object properties`);\n }\n if (property.computed || property.key.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when({ ... }) selector keys must be string literals`);\n }\n\n const value = unwrapExpression(property.value as t.Expression);\n if (\n value.type !== \"MemberExpression\" ||\n value.computed ||\n value.property.type !== \"Identifier\" ||\n value.property.name !== \"$\"\n ) {\n throw new UnsupportedPatternError(`when({ ... }) values must be Css.*.$ expressions`);\n }\n\n const innerChain = extractChain(value.object as t.Expression, cssBindingName);\n if (!innerChain) {\n throw new UnsupportedPatternError(`when({ ... }) values must be Css.*.$ expressions`);\n }\n\n const selectorContext = cloneConditionContext(initialContext);\n selectorContext.pseudoClass = property.key.value;\n const resolved = resolveFullChain(innerChain, mapping, cssBindingName, selectorContext);\n parts.push(...resolved.parts);\n markers.push(...resolved.markers);\n errors.push(...resolved.errors);\n } catch (err) {\n if (err instanceof UnsupportedPatternError) {\n errors.push(err.message);\n } else {\n throw err;\n }\n }\n }\n\n return { parts, markers, errors: [...new Set(errors)] };\n}\n\n/** Flatten nested `when({ ... })` parts back into plain segments for `resolveChain()`. */\nfunction flattenWhenObjectParts(resolved: ResolvedChain): ResolvedSegment[] {\n const segments: ResolvedSegment[] = [];\n\n // I.e. `resolveChain()` needs a flat segment list, even though `when({ ... })` is resolved via `resolveFullChain()`.\n for (const part of resolved.parts) {\n if (part.type !== \"unconditional\") {\n throw new UnsupportedPatternError(`when({ ... }) values cannot use if()/else in this context`);\n }\n\n segments.push(...part.segments);\n }\n\n for (const err of resolved.errors) {\n segments.push({ abbr: \"__error\", defs: {}, error: err });\n }\n\n return segments;\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 with flat defs (no condition nesting).\n * Does NOT handle if/else — use resolveFullChain for that.\n */\nexport function resolveChain(\n chain: ChainNode[],\n mapping: TrussMapping,\n initialContext: ResolvedConditionContext = emptyConditionContext(),\n cssBindingName?: string,\n): ResolvedSegment[] {\n const segments: ResolvedSegment[] = [];\n const context = cloneConditionContext(initialContext);\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 context.mediaQuery = (node as any).mediaQuery;\n continue;\n }\n\n if (node.type === \"getter\") {\n const abbr = node.name;\n\n if (abbr === \"end\") {\n resetConditionContext(context);\n continue;\n }\n\n // Pseudo-class getters: onHover, onFocus, etc.\n if (isPseudoMethod(abbr)) {\n context.pseudoClass = pseudoSelector(abbr);\n continue;\n }\n\n // Breakpoint getters: ifSm, ifMd, ifLg, etc.\n if (mapping.breakpoints && abbr in mapping.breakpoints) {\n context.mediaQuery = mapping.breakpoints[abbr];\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 context.mediaQuery,\n context.pseudoClass,\n context.pseudoElement,\n context.whenPseudo,\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 context.mediaQuery = containerSelectorFromCall(node);\n continue;\n }\n\n // add(prop, value) / addCss(cssProp)\n if (abbr === \"add\" || abbr === \"addCss\") {\n const seg = resolveAddCall(\n node,\n mapping,\n context.mediaQuery,\n context.pseudoClass,\n context.pseudoElement,\n context.whenPseudo,\n );\n segments.push(seg);\n continue;\n }\n\n // Raw class passthrough, i.e. `Css.className(buttonClass).df.$`\n if (abbr === \"className\") {\n const seg = resolveClassNameCall(\n node,\n context.mediaQuery,\n context.pseudoClass,\n context.pseudoElement,\n context.whenPseudo,\n );\n segments.push(seg);\n continue;\n }\n\n // Raw inline style passthrough, i.e. `Css.mt(x).style(vars).$`\n if (abbr === \"style\") {\n const seg = resolveStyleCall(\n node,\n context.mediaQuery,\n context.pseudoClass,\n context.pseudoElement,\n context.whenPseudo,\n );\n segments.push(seg);\n continue;\n }\n\n if (abbr === \"typography\") {\n const resolved = resolveTypographyCall(\n node,\n mapping,\n context.mediaQuery,\n context.pseudoClass,\n context.pseudoElement,\n context.whenPseudo,\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 context.pseudoElement = (node.args[0] as any).value;\n continue;\n }\n\n // Generic when(selector) or when(marker, relationship, pseudo)\n if (abbr === \"when\") {\n if (isWhenObjectCall(node)) {\n const resolved = resolveWhenObjectSelectors(node, mapping, cssBindingName, context);\n segments.push(...flattenWhenObjectParts(resolved));\n continue;\n }\n\n const resolved = resolveWhenCall(node);\n if (resolved.kind === \"selector\") {\n context.pseudoClass = resolved.pseudo;\n } else {\n context.whenPseudo = resolved;\n }\n continue;\n }\n\n // Simple pseudo-class calls (backward compat — pseudos are now getters)\n if (isPseudoMethod(abbr)) {\n context.pseudoClass = pseudoSelector(abbr);\n if (node.args.length > 0) {\n throw new UnsupportedPatternError(\n `${abbr}() does not take arguments -- use when(marker, \"ancestor\", \":hover\") for relationship selectors`,\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 context.mediaQuery,\n context.pseudoClass,\n context.pseudoElement,\n context.whenPseudo,\n );\n segments.push(seg);\n } else if (entry.kind === \"delegate\") {\n const seg = resolveDelegateCall(\n abbr,\n entry,\n node,\n mapping,\n context.mediaQuery,\n context.pseudoClass,\n context.pseudoElement,\n context.whenPseudo,\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({ abbr: \"__error\", defs: {}, error: err.message });\n } else {\n throw err;\n }\n }\n }\n\n return segments;\n}\n\n/**\n * Build a typography lookup key suffix from condition context.\n *\n * I.e. `typography(key)` → `\"typography\"`, `ifSm.typography(key)` → `\"typography__sm\"`.\n */\nfunction typographyLookupKeySuffix(\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo: WhenCondition | null,\n breakpoints?: Record<string, string>,\n): string {\n const parts: string[] = [];\n if (pseudoElement) parts.push(pseudoElement.replace(/^::/, \"\"));\n if (mediaQuery && breakpoints) {\n const bp = Object.entries(breakpoints).find(([, v]) => v === mediaQuery)?.[0];\n parts.push(bp ? bp.replace(/^if/, \"\").replace(/^./, (c) => c.toLowerCase()) : \"mq\");\n } else if (mediaQuery) {\n parts.push(\"mq\");\n }\n if (pseudoClass) parts.push(pseudoClass.replace(/^:+/, \"\").replace(/-/g, \"_\"));\n if (whenPseudo) parts.push(whenLookupKeyPart(whenPseudo));\n return parts.join(\"_\");\n}\n\nfunction whenLookupKeyPart(whenPseudo: WhenCondition): string {\n const parts = [\"when\", whenPseudo.relationship ?? \"ancestor\", sanitizeLookupToken(whenPseudo.pseudo)];\n\n if (whenPseudo.markerNode?.type === \"Identifier\" && whenPseudo.markerNode.name) {\n parts.push(whenPseudo.markerNode.name);\n }\n\n return parts.join(\"_\");\n}\n\nfunction sanitizeLookupToken(value: string): string {\n return (\n value\n .replace(/[^a-zA-Z0-9]+/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\") || \"value\"\n );\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 whenPseudo: WhenCondition | 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, whenPseudo);\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 = typographyLookupKeySuffix(mediaQuery, pseudoClass, pseudoElement, whenPseudo, 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, whenPseudo);\n }\n\n return [\n {\n abbr: 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 whenPseudo: WhenCondition | 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, whenPseudo);\n for (const segment of resolved) {\n if (segment.variableProps) {\n throw new UnsupportedPatternError(`Typography abbreviation \"${name}\" cannot require runtime arguments`);\n }\n }\n return resolved;\n}\n\n/** Resolve a static or alias entry (from a getter access). Defs are always flat. */\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: WhenCondition | null,\n): ResolvedSegment[] {\n const context: ResolvedConditionContext = {\n mediaQuery,\n pseudoClass,\n pseudoElement,\n whenPseudo,\n };\n\n switch (entry.kind) {\n case \"static\": {\n return [segmentWithConditionContext({ abbr, defs: entry.defs }, context)];\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: WhenCondition | null,\n): ResolvedSegment {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n const literalValue = tryEvaluateLiteral(node.args[0], entry.incremented, mapping.increment);\n return buildParameterizedSegment({\n abbr,\n props: entry.props,\n incremented: entry.incremented,\n extraDefs: entry.extraDefs,\n argAst: node.args[0],\n literalValue,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n whenPseudo,\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: WhenCondition | 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 if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n const literalValue = tryEvaluatePxLiteral(node.args[0]);\n // Use the target abbreviation name for delegate segments (i.e. mtPx → mt)\n return buildParameterizedSegment({\n abbr: entry.target,\n props: targetEntry.props,\n incremented: false,\n appendPx: true,\n extraDefs: targetEntry.extraDefs,\n argAst: node.args[0],\n literalValue,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n whenPseudo,\n });\n}\n\n/** Shared builder for variable and delegate call segments. */\nfunction buildParameterizedSegment(params: {\n abbr: string;\n props: string[];\n incremented: boolean;\n appendPx?: boolean;\n extraDefs?: Record<string, unknown>;\n argAst: t.Expression | t.SpreadElement;\n literalValue: string | null;\n mediaQuery: string | null;\n pseudoClass: string | null;\n pseudoElement: string | null;\n whenPseudo: WhenCondition | null;\n}): ResolvedSegment {\n const { abbr, props, incremented, appendPx, extraDefs, argAst, literalValue, whenPseudo } = params;\n const context: ResolvedConditionContext = {\n mediaQuery: params.mediaQuery,\n pseudoClass: params.pseudoClass,\n pseudoElement: params.pseudoElement,\n whenPseudo,\n };\n\n if (literalValue !== null) {\n const defs: Record<string, unknown> = {};\n for (const prop of props) {\n defs[prop] = literalValue;\n }\n if (extraDefs) Object.assign(defs, extraDefs);\n return segmentWithConditionContext({ abbr, defs, argResolved: literalValue }, context);\n }\n\n const base = segmentWithConditionContext(\n {\n abbr,\n defs: {},\n variableProps: props,\n incremented,\n variableExtraDefs: extraDefs,\n argNode: argAst,\n },\n context,\n );\n if (appendPx) base.appendPx = true;\n return base;\n}\n\nfunction resolveClassNameCall(\n node: CallChainNode,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo: WhenCondition | null,\n): ResolvedSegment {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`className() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const arg = node.args[0];\n if (arg.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(`className() does not support spread arguments`);\n }\n\n if (mediaQuery || pseudoClass || pseudoElement || whenPseudo) {\n // I.e. `ifSm.className(\"x\")` cannot be represented as a runtime-only class append.\n throw new UnsupportedPatternError(\n `className() cannot be used inside media query, pseudo-class, pseudo-element, or when() contexts`,\n );\n }\n\n return {\n // I.e. this is metadata for the rewriter/runtime, not an atomic CSS rule.\n abbr: \"className\",\n defs: {},\n classNameArg: arg,\n };\n}\n\nfunction resolveStyleCall(\n node: CallChainNode,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo: WhenCondition | null,\n): ResolvedSegment {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`style() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const arg = node.args[0];\n if (arg.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(`style() does not support spread arguments`);\n }\n\n if (mediaQuery || pseudoClass || pseudoElement || whenPseudo) {\n throw new UnsupportedPatternError(\n `style() cannot be used inside media query, pseudo-class, pseudo-element, or when() contexts`,\n );\n }\n\n return {\n abbr: \"style\",\n defs: {},\n styleArg: arg,\n };\n}\n\n/**\n * Resolve an `add(...)` or `addCss(...)` call.\n *\n * Supported overloads:\n * - `add(cssProp)` to inline an existing CssProp array into the chain output\n * - `addCss(cssProp)` to inline an existing Truss style hash 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: WhenCondition | null,\n): ResolvedSegment {\n const isAddCss = node.name === \"addCss\";\n\n if (isAddCss) {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(\n `addCss() requires exactly 1 argument (an existing CssProp/style hash expression)`,\n );\n }\n\n const styleArg = node.args[0];\n if (styleArg.type === \"SpreadElement\") {\n // I.e. reject call-arg spread like `addCss(...xss)`; callers should use `addCss(xss)` or `addCss({ ...xss })`.\n throw new UnsupportedPatternError(`addCss() does not support spread arguments`);\n }\n return {\n abbr: \"__composed_css_prop\",\n defs: {},\n styleArrayArg: styleArg,\n isAddCss: true,\n };\n }\n\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 abbr: \"__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), addCss(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 const literalValue = tryEvaluateAddLiteral(valueArg);\n\n const context: ResolvedConditionContext = {\n mediaQuery,\n pseudoClass,\n pseudoElement,\n whenPseudo,\n };\n\n if (literalValue !== null) {\n return segmentWithConditionContext(\n { abbr: propName, defs: { [propName]: literalValue }, argResolved: literalValue },\n context,\n );\n }\n\n return segmentWithConditionContext(\n {\n abbr: propName,\n defs: {},\n variableProps: [propName],\n incremented: false,\n argNode: valueArg,\n },\n context,\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(selector)` or `when(marker, relationship, pseudo)` call.\n *\n * - 1 arg: `when(\":hover\")` — same-element selector, must be a string literal\n * - 3 args: `when(marker, \"ancestor\", \":hover\")` — marker must be a marker variable or\n * the shared `marker` token, relationship/pseudo must be string literals\n */\nfunction resolveWhenCall(\n node: CallChainNode,\n):\n | { kind: \"selector\"; pseudo: string }\n | { kind: \"relationship\"; pseudo: string; markerNode?: any; relationship: string } {\n if (node.args.length !== 1 && node.args.length !== 3) {\n throw new UnsupportedPatternError(\n `when() expects 1 or 3 arguments (selector) or (marker, relationship, pseudo), got ${node.args.length}`,\n );\n }\n\n if (node.args.length === 1) {\n const pseudoArg = node.args[0];\n if (pseudoArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() selector must be a string literal`);\n }\n return { kind: \"selector\", pseudo: (pseudoArg as any).value };\n }\n\n const markerArg = node.args[0];\n const markerNode = resolveWhenMarker(markerArg);\n const relationshipArg = node.args[1];\n if (relationshipArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() relationship argument must be a string literal`);\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 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 { kind: \"relationship\", pseudo: (pseudoArg as any).value, markerNode, relationship };\n}\n\nfunction resolveWhenMarker(node: t.Expression | t.SpreadElement): any | undefined {\n if (isDefaultMarkerNode(node)) {\n return undefined;\n }\n if (node.type === \"Identifier\") {\n return node;\n }\n throw new UnsupportedPatternError(`when() marker must be a marker variable or marker`);\n}\n\nfunction isDefaultMarkerNode(node: t.Expression | t.SpreadElement): boolean {\n if (node.type === \"Identifier\" && (node.name === \"marker\" || node.name === \"defaultMarker\")) {\n return true;\n }\n return isLegacyDefaultMarkerExpression(node);\n}\n\nfunction isLegacyDefaultMarkerExpression(node: t.Expression | t.SpreadElement): boolean {\n return (\n node.type === \"CallExpression\" &&\n node.arguments.length === 0 &&\n node.callee.type === \"MemberExpression\" &&\n !node.callee.computed &&\n node.callee.property.type === \"Identifier\" &&\n node.callee.property.name === \"defaultMarker\"\n );\n}\n\n// ── Helpers ───────────────────────────────────────────────────────────\n\nconst PSEUDO_METHODS: Record<string, string> = {\n onHover: \":hover\",\n onFocus: \":focus\",\n onFocusVisible: \":focus-visible\",\n onFocusWithin: \":focus-within\",\n onActive: \":active\",\n onDisabled: \":disabled\",\n ifFirstOfType: \":first-of-type\",\n ifLastOfType: \":last-of-type\",\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 * 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 container query 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\n/** Unwrap TS/paren wrappers so nested `when({ ... })` values can be validated uniformly. */\nfunction unwrapExpression(node: t.Expression): t.Expression {\n let current = node;\n\n while (true) {\n if (\n current.type === \"ParenthesizedExpression\" ||\n current.type === \"TSAsExpression\" ||\n current.type === \"TSTypeAssertion\" ||\n current.type === \"TSNonNullExpression\" ||\n current.type === \"TSSatisfiesExpression\"\n ) {\n current = current.expression;\n continue;\n }\n\n return current;\n }\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 _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 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 → static className when possible, otherwise spread trussProps/mergeProps\n if (\n !options.debug &&\n isFullyStaticStyleHash(styleHash) &&\n !hasExistingAttribute(cssAttrPath, \"className\") &&\n !hasExistingAttribute(cssAttrPath, \"style\")\n ) {\n const classNames = extractStaticClassNames(styleHash);\n cssAttrPath.replaceWith(t.jsxAttribute(t.jsxIdentifier(\"className\"), t.stringLiteral(classNames)));\n } else {\n cssAttrPath.replaceWith(t.jsxSpreadAttribute(buildCssSpreadExpression(cssAttrPath, styleHash, line, options)));\n }\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 // Single pass: rewrite Css.props(...) calls and remaining css={...} attributes together\n rewriteCssPropsAndCssAttributes(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 const pendingUnconditionalSegments: ResolvedSegment[] = [];\n\n function flushPendingUnconditionalSegments(): void {\n // I.e. `Css.black.when({ \":hover\": Css.blue.$ }).$` becomes one merged `color: \"black h_blue\"` entry.\n if (pendingUnconditionalSegments.length === 0) {\n return;\n }\n\n const partMembers = buildStyleHashMembers(pendingUnconditionalSegments, 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 pendingUnconditionalSegments.length = 0;\n }\n\n if (chain.markers.length > 0) {\n const markerClasses = chain.markers.map((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 pendingUnconditionalSegments.push(...part.segments);\n } else {\n flushPendingUnconditionalSegments();\n // Conditional: ...(cond ? { then } : { else })\n const thenMembers = mergeConditionalBranchMembers(\n buildStyleHashMembers(part.thenSegments, options),\n previousProperties,\n collectConditionalOnlyProps(part.thenSegments),\n );\n const elseMembers = mergeConditionalBranchMembers(\n buildStyleHashMembers(part.elseSegments, options),\n previousProperties,\n collectConditionalOnlyProps(part.elseSegments),\n );\n members.push(\n t.spreadElement(\n t.conditionalExpression(part.conditionNode, t.objectExpression(thenMembers), t.objectExpression(elseMembers)),\n ),\n );\n }\n }\n\n flushPendingUnconditionalSegments();\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, classNameArg, styleArg) produce\n * spread members or reserved metadata properties.\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 const classNameArgs: t.Expression[] = [];\n const styleKeyCounts = new Map<string, number>();\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.classNameArg) {\n // I.e. `Css.className(cls).df.$` becomes `className_cls: cls` in the style hash.\n classNameArgs.push(t.cloneNode(seg.classNameArg, true) as t.Expression);\n continue;\n }\n\n if (seg.styleArg) {\n flushNormal();\n members.push(buildInlineStyleMember(seg.styleArg as t.Expression, styleKeyCounts));\n continue;\n }\n\n if (seg.styleArrayArg) {\n flushNormal();\n if (seg.isAddCss && t.isObjectExpression(seg.styleArrayArg)) {\n members.push(...buildAddCssObjectMembers(seg.styleArrayArg));\n } else {\n members.push(t.spreadElement(seg.styleArrayArg as t.Expression));\n }\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 // In debug mode, add the abbreviation name as a marker className for multi-property\n // segments so engineers can see the origin in the DOM. I.e. `Css.bb.$` adds \"bb\"\n // alongside \"bbs_solid bbw_1px\", and `Css.lineClamp(n).$` adds \"lineClamp\".\n if (options.debug && !seg.classNameArg && !seg.styleArg && !seg.styleArrayArg && !seg.typographyLookup) {\n const isMultiProp = Object.keys(seg.defs).length > 1;\n const hasExtraDefs = seg.variableExtraDefs && Object.keys(seg.variableExtraDefs).length > 0;\n if (isMultiProp || hasExtraDefs) {\n classNameArgs.push(t.stringLiteral(seg.abbr));\n }\n }\n\n normalSegs.push(seg);\n }\n\n flushNormal();\n if (classNameArgs.length > 0) {\n // Prepend so markers/custom classes appear first in the DOM,\n // I.e. `className=\"bb bbs_solid bbw_1px\"` rather than at the end.\n // Uses unique `className_${key}` keys so spreading preserves all entries.\n members.unshift(...buildCustomClassNameMembers(classNameArgs));\n }\n return members;\n}\n\nfunction buildCustomClassNameMembers(classNameArgs: t.Expression[]): t.ObjectProperty[] {\n const counts = new Map<string, number>();\n\n return classNameArgs.map((arg) => {\n const baseKey = `className_${sanitizeMetadataKey(arg)}`;\n const count = (counts.get(baseKey) ?? 0) + 1;\n counts.set(baseKey, count);\n const key = count === 1 ? baseKey : `${baseKey}_${count}`;\n return t.objectProperty(t.identifier(key), t.cloneNode(arg, true));\n });\n}\n\nfunction buildInlineStyleMember(arg: t.Expression, counts: Map<string, number>): t.ObjectProperty {\n const baseKey = `style_${sanitizeMetadataKey(arg)}`;\n const count = (counts.get(baseKey) ?? 0) + 1;\n counts.set(baseKey, count);\n const key = count === 1 ? baseKey : `${baseKey}_${count}`;\n return t.objectProperty(t.identifier(key), t.cloneNode(arg, true));\n}\n\n/** Derive a valid JS identifier suffix from metadata args. I.e. `\"my-btn\"` → `my_btn`, `vars` → `vars`. */\nfunction sanitizeMetadataKey(arg: t.Expression): string {\n const raw = t.isStringLiteral(arg)\n ? arg.value\n : t.isTemplateLiteral(arg) && arg.expressions.length === 0 && arg.quasis.length === 1\n ? (arg.quasis[0].value.cooked ?? \"\")\n : generate(arg).code;\n\n const sanitized = raw\n .replace(/[^a-zA-Z0-9_$]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_+|_+$/g, \"\");\n return sanitized || \"value\";\n}\n\nfunction buildAddCssObjectMembers(styleObject: t.ObjectExpression): (t.ObjectProperty | t.SpreadElement)[] {\n const members: (t.ObjectProperty | t.SpreadElement)[] = [];\n\n for (const property of styleObject.properties) {\n if (t.isSpreadElement(property)) {\n members.push(t.spreadElement(t.cloneNode(property.argument, true) as t.Expression));\n continue;\n }\n\n if (!t.isObjectProperty(property) || property.computed) {\n members.push(t.spreadElement(t.objectExpression([t.cloneNode(property, true)])));\n continue;\n }\n\n const value = property.value;\n if (t.isIdentifier(value) || t.isMemberExpression(value) || t.isOptionalMemberExpression(value)) {\n members.push(\n t.spreadElement(\n t.conditionalExpression(\n t.binaryExpression(\"===\", t.cloneNode(value, true), t.identifier(\"undefined\")),\n t.objectExpression([]),\n t.objectExpression([t.objectProperty(clonePropertyKey(property.key), t.cloneNode(value, true))]),\n ),\n ),\n );\n continue;\n }\n\n members.push(t.spreadElement(t.objectExpression([t.cloneNode(property, true)])));\n }\n\n return members;\n}\n\n/**\n * Collect the set of CSS properties where ALL contributing segments have a condition\n * (pseudo-class, media query, pseudo-element, or when relationship).\n *\n * I.e. `onHover.white` → `color` is conditional-only (needs base merged in),\n * but `bgWhite` → `backgroundColor` is a plain replacement (should NOT merge).\n */\nfunction collectConditionalOnlyProps(segments: ResolvedSegment[]): Set<string> {\n const allProps = new Map<string, boolean>();\n for (const seg of segments) {\n if (seg.error || seg.styleArrayArg || seg.typographyLookup || seg.classNameArg || seg.styleArg) continue;\n const hasCondition = !!(seg.pseudoClass || seg.mediaQuery || seg.pseudoElement || seg.whenPseudo);\n const props = seg.variableProps ?? Object.keys(seg.defs);\n for (const prop of props) {\n const current = allProps.get(prop);\n // If any segment for this property is unconditional, it's not conditional-only\n allProps.set(prop, current === undefined ? hasCondition : current && hasCondition);\n }\n }\n const result = new Set<string>();\n for (const [prop, isConditionalOnly] of allProps) {\n if (isConditionalOnly) result.add(prop);\n }\n return result;\n}\n\n/**\n * Merge prior base properties into conditional branch members, but only for\n * properties that are purely conditional (pseudo/media overlays). Plain\n * base-level replacements should NOT be merged — the spread will correctly\n * override the base when the condition is true.\n */\nfunction mergeConditionalBranchMembers(\n members: (t.ObjectProperty | t.SpreadElement)[],\n previousProperties: Map<string, t.ObjectProperty>,\n conditionalOnlyProps: Set<string>,\n): (t.ObjectProperty | t.SpreadElement)[] {\n return members.map((member) => {\n if (!t.isObjectProperty(member)) {\n return member;\n }\n\n const prop = propertyName(member.key);\n const prior = previousProperties.get(prop);\n if (!prior || !conditionalOnlyProps.has(prop)) {\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((property) => {\n return t.cloneNode(property, true);\n }),\n ...currentVars.properties.map((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((p) => {\n return (\n t.isObjectProperty(p) &&\n !(\n (t.isIdentifier(p.key) && p.key.name.startsWith(\"className_\")) ||\n (t.isStringLiteral(p.key) && p.key.value.startsWith(\"className_\")) ||\n (t.isIdentifier(p.key) && p.key.name.startsWith(\"style_\")) ||\n (t.isStringLiteral(p.key) && p.key.value.startsWith(\"style_\")) ||\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// ---------------------------------------------------------------------------\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// Combined pass: Css.props(...) rewriting + remaining css={...} attributes\n// ---------------------------------------------------------------------------\n\n/**\n * Single traversal that rewrites both `Css.props(expr)` calls and remaining\n * `css={expr}` JSX attributes, avoiding two separate full-AST passes.\n */\nfunction rewriteCssPropsAndCssAttributes(options: RewriteSitesOptions): void {\n traverse(options.ast, {\n // -- Css.props(expr) → trussProps(expr) or mergeProps(...) --\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 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 // -- Remaining css={expr} JSX attributes → {...trussProps(expr)} spreads --\n // I.e. css={someVariable}, css={{ ...a, ...b }}, css={cond ? a : b}\n JSXAttribute(path: NodePath<t.JSXAttribute>) {\n if (!t.isJSXIdentifier(path.node.name, { name: \"css\" })) return;\n if (isRuntimeStyleCssAttribute(path)) 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\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\nfunction isRuntimeStyleCssAttribute(path: NodePath<t.JSXAttribute>): boolean {\n const openingElementPath = path.parentPath;\n if (!openingElementPath || !openingElementPath.isJSXOpeningElement()) return false;\n return t.isJSXIdentifier(openingElementPath.node.name, { name: \"RuntimeStyle\" });\n}\n\n// ---------------------------------------------------------------------------\n// Static style hash detection\n// ---------------------------------------------------------------------------\n\n/** Check whether a style hash has only static string values (no spreads, no tuples). */\nfunction isFullyStaticStyleHash(hash: t.ObjectExpression): boolean {\n for (const prop of hash.properties) {\n if (!t.isObjectProperty(prop)) return false;\n if (!t.isStringLiteral(prop.value)) return false;\n }\n return true;\n}\n\n/** Extract all static class names from a fully-static style hash, joined with spaces. */\nfunction extractStaticClassNames(hash: t.ObjectExpression): string {\n const classNames: string[] = [];\n for (const prop of hash.properties) {\n if (t.isObjectProperty(prop) && t.isStringLiteral(prop.value)) {\n classNames.push(prop.value.value);\n }\n }\n return classNames.join(\" \");\n}\n\n/** Check whether a sibling JSX attribute exists without removing it. */\nfunction hasExistingAttribute(path: NodePath<t.JSXAttribute>, attrName: string): boolean {\n const openingElement = path.parentPath;\n if (!openingElement || !openingElement.isJSXOpeningElement()) return false;\n return openingElement.node.attributes.some((attr) => {\n return t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name, { name: attrName });\n });\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\";\nimport { camelToKebab } from \"./emit-truss\";\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 * body: `\n * margin: 0;\n * font-size: 14px !important;\n * `,\n * };\n * ```\n *\n * Each key is a CSS selector (string literal), each value is either a `Css.*.$`\n * chain or a string literal / template literal containing raw CSS declarations.\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 // Css import is optional — only needed when Css.*.$ chains are used\n const cssBindingName = findCssImportBinding(ast);\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 const valueNode = prop.value;\n\n // String literal or template literal → pass through as raw CSS\n const rawCss = extractStaticStringValue(valueNode, cssBindingName);\n if (rawCss !== null) {\n rules.push(formatRawCssRule(selector, rawCss));\n continue;\n }\n\n // Otherwise value must be a Css.*.$ expression\n if (!t.isExpression(valueNode)) {\n rules.push(`/* [truss] unsupported: \"${selector}\" value is not an expression */`);\n continue;\n }\n\n if (!cssBindingName) {\n rules.push(`/* [truss] unsupported: \"${selector}\" — Css.*.$ chain requires a Css import */`);\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\n/**\n * Extract a static string from a StringLiteral, a no-expression TemplateLiteral,\n * or a `Css.raw` tagged template literal (i.e. `Css.raw\\`...\\``).\n */\nfunction extractStaticStringValue(node: t.Node, cssBindingName: string | null): string | null {\n if (t.isStringLiteral(node)) return node.value;\n if (t.isTemplateLiteral(node) && node.expressions.length === 0 && node.quasis.length === 1) {\n return node.quasis[0].value.cooked ?? node.quasis[0].value.raw;\n }\n // Css.raw`...` tagged template literal\n if (\n t.isTaggedTemplateExpression(node) &&\n t.isMemberExpression(node.tag) &&\n !node.tag.computed &&\n t.isIdentifier(node.tag.property, { name: \"raw\" }) &&\n t.isIdentifier(node.tag.object, { name: cssBindingName ?? \"\" }) &&\n node.quasi.expressions.length === 0 &&\n node.quasi.quasis.length === 1\n ) {\n return node.quasi.quasis[0].value.cooked ?? node.quasi.quasis[0].value.raw;\n }\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, cssBindingName);\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 if (seg.styleArg) {\n return { error: `style() 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/** Format a CSS rule block from a raw CSS string, passed through as-is. */\nfunction formatRawCssRule(selector: string, raw: string): string {\n const trimmed = raw.trim();\n if (!trimmed) return `${selector} {}`;\n // Indent each non-empty line by two spaces\n const body = trimmed\n .split(\"\\n\")\n .map((line) => ` ${line.trim()}`)\n .filter((line) => line.trim().length > 0)\n .join(\"\\n\");\n return `${selector} {\\n${body}\\n}`;\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","import { readFileSync } from \"fs\";\n\n/** A parsed CSS rule extracted from an annotated truss.css file. */\nexport interface ParsedCssRule {\n priority: number;\n className: string;\n cssText: string;\n}\n\n/** A parsed @property declaration extracted from an annotated truss.css file. */\nexport interface ParsedPropertyDeclaration {\n cssText: string;\n /** The variable name, i.e. `--marginTop`. */\n varName: string;\n}\n\n/** A parsed arbitrary CSS block extracted from an annotated truss.css file. */\nexport interface ParsedArbitraryCssBlock {\n cssText: string;\n}\n\n/** The result of parsing an annotated truss.css file. */\nexport interface ParsedTrussCss {\n rules: ParsedCssRule[];\n properties: ParsedPropertyDeclaration[];\n arbitraryCssBlocks?: ParsedArbitraryCssBlock[];\n}\n\n/** Regex matching `/* @truss p:<priority> c:<className> *\\/` annotations. */\nconst RULE_ANNOTATION_RE = /^\\/\\* @truss p:([\\d.]+) c:(\\S+) \\*\\/$/;\n\n/** Regex matching `/* @truss @property *\\/` annotations. */\nconst PROPERTY_ANNOTATION_RE = /^\\/\\* @truss @property \\*\\/$/;\n\n/** Regex matching the start of an annotated arbitrary CSS block. */\nconst ARBITRARY_START_RE = /^\\/\\* @truss arbitrary:start \\*\\/$/;\n\n/** Regex matching the end of an annotated arbitrary CSS block. */\nconst ARBITRARY_END_RE = /^\\/\\* @truss arbitrary:end \\*\\/$/;\n\n/** Regex to extract the variable name from `@property --foo { ... }`. */\nconst PROPERTY_VAR_RE = /^@property\\s+(--\\S+)/;\n\n/**\n * Parse an annotated truss.css file into rules, @property declarations,\n * and arbitrary CSS blocks.\n *\n * The file must contain `/* @truss p:<priority> c:<className> *\\/` comments\n * before each CSS rule, and `/* @truss @property *\\/` before each @property declaration.\n */\nexport function parseTrussCss(cssText: string): ParsedTrussCss {\n const lines = cssText.split(\"\\n\");\n const rules: ParsedCssRule[] = [];\n const properties: ParsedPropertyDeclaration[] = [];\n const arbitraryCssBlocks: ParsedArbitraryCssBlock[] = [];\n\n let i = 0;\n while (i < lines.length) {\n const line = lines[i].trim();\n\n // Check for rule annotation\n const ruleMatch = RULE_ANNOTATION_RE.exec(line);\n if (ruleMatch) {\n const priority = parseFloat(ruleMatch[1]);\n const className = ruleMatch[2];\n // Next non-empty line is the CSS rule\n i++;\n while (i < lines.length && lines[i].trim() === \"\") i++;\n if (i < lines.length) {\n rules.push({ priority, className, cssText: lines[i].trim() });\n }\n i++;\n continue;\n }\n\n // Check for @property annotation\n if (PROPERTY_ANNOTATION_RE.test(line)) {\n i++;\n while (i < lines.length && lines[i].trim() === \"\") i++;\n if (i < lines.length) {\n const propLine = lines[i].trim();\n const varMatch = PROPERTY_VAR_RE.exec(propLine);\n if (varMatch) {\n properties.push({ cssText: propLine, varName: varMatch[1] });\n }\n }\n i++;\n continue;\n }\n\n if (ARBITRARY_START_RE.test(line)) {\n i++;\n const blockLines: string[] = [];\n while (i < lines.length && !ARBITRARY_END_RE.test(lines[i].trim())) {\n blockLines.push(lines[i]);\n i++;\n }\n const blockText = blockLines.join(\"\\n\").trim();\n if (blockText.length > 0) {\n arbitraryCssBlocks.push({ cssText: blockText });\n }\n if (i < lines.length && ARBITRARY_END_RE.test(lines[i].trim())) {\n i++;\n }\n continue;\n }\n\n i++;\n }\n\n return { rules, properties, arbitraryCssBlocks };\n}\n\n/**\n * Read and parse an annotated truss.css file from disk.\n *\n * Throws if the file doesn't exist or can't be read.\n */\nexport function readTrussCss(filePath: string): ParsedTrussCss {\n const content = readFileSync(filePath, \"utf8\");\n return parseTrussCss(content);\n}\n\n/** Wrap an arbitrary CSS block in annotations so it survives later Truss merges. */\nexport function annotateArbitraryCssBlock(cssText: string): string {\n const trimmed = cssText.trim();\n if (trimmed.length === 0) {\n return \"\";\n }\n return [\"/* @truss arbitrary:start */\", trimmed, \"/* @truss arbitrary:end */\"].join(\"\\n\");\n}\n\n/**\n * Merge multiple parsed truss CSS sources into a single CSS string.\n *\n * Rules are deduplicated by class name (first occurrence wins, since\n * deterministic output means identical class names produce identical rules),\n * then sorted by priority ascending with alphabetical class name tiebreaker.\n * @property declarations are deduplicated by variable name and appended next.\n * Arbitrary CSS blocks are left opaque and appended in source order at the end.\n */\nexport function mergeTrussCss(sources: ParsedTrussCss[]): string {\n const seenClasses = new Set<string>();\n const allRules: ParsedCssRule[] = [];\n const seenProperties = new Set<string>();\n const allProperties: ParsedPropertyDeclaration[] = [];\n const allArbitraryCssBlocks: ParsedArbitraryCssBlock[] = [];\n\n for (const source of sources) {\n for (const rule of source.rules) {\n if (!seenClasses.has(rule.className)) {\n seenClasses.add(rule.className);\n allRules.push(rule);\n }\n }\n for (const prop of source.properties) {\n if (!seenProperties.has(prop.varName)) {\n seenProperties.add(prop.varName);\n allProperties.push(prop);\n }\n }\n allArbitraryCssBlocks.push(...(source.arbitraryCssBlocks ?? []));\n }\n\n // Sort by priority ascending, tiebreak alphabetically by class name\n allRules.sort((a, b) => {\n const diff = a.priority - b.priority;\n if (diff !== 0) return diff;\n return a.className < b.className ? -1 : a.className > b.className ? 1 : 0;\n });\n\n const lines: string[] = [];\n\n for (const rule of allRules) {\n lines.push(`/* @truss p:${rule.priority} c:${rule.className} */`);\n lines.push(rule.cssText);\n }\n\n for (const prop of allProperties) {\n lines.push(`/* @truss @property */`);\n lines.push(prop.cssText);\n }\n\n for (const block of allArbitraryCssBlocks) {\n lines.push(annotateArbitraryCssBlock(block.cssText));\n }\n\n return lines.join(\"\\n\");\n}\n","import { readFileSync, writeFileSync, mkdirSync } from \"fs\";\nimport { resolve, 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 { loadMapping } from \"./index\";\nimport { annotateArbitraryCssBlock } from \"./merge-css\";\n\nexport interface TrussEsbuildPluginOptions {\n /** Path to the Css.json mapping file (relative to cwd or absolute). */\n mapping: string;\n /** Output path for the generated truss.css (relative to outDir or absolute). Defaults to `truss.css`. */\n outputCss?: string;\n}\n\n/**\n * esbuild plugin that transforms `Css.*.$` expressions, collects `.css.ts` blocks,\n * and emits a `truss.css` file.\n *\n * Designed for library builds using tsup/esbuild. Transforms source files\n * during the build and writes an annotated `truss.css` alongside the output\n * that consuming applications can merge via the Vite plugin's `libraries` option.\n *\n * Usage with tsup:\n * ```ts\n * import { trussEsbuildPlugin } from \"@homebound/truss/plugin\";\n *\n * export default defineConfig({\n * esbuildPlugins: [trussEsbuildPlugin({ mapping: \"./src/Css.json\" })],\n * });\n * ```\n */\nexport function trussEsbuildPlugin(opts: TrussEsbuildPluginOptions) {\n const cssRegistry = new Map<string, AtomicRule>();\n const arbitraryCssRegistry = new Map<string, string>();\n let mapping: TrussMapping | null = null;\n let outDir: string | undefined;\n\n return {\n name: \"truss\",\n setup(build: EsbuildPluginBuild) {\n // Resolve outDir from esbuild config\n outDir = build.initialOptions.outdir ?? build.initialOptions.outdir;\n\n build.onLoad({ filter: /\\.[cm]?[jt]sx?$/ }, (args: { path: string }) => {\n const code = readFileSync(args.path, \"utf8\");\n\n if (args.path.endsWith(\".css.ts\")) {\n if (!mapping) {\n mapping = loadMapping(resolve(process.cwd(), opts.mapping));\n }\n\n const css = annotateArbitraryCssBlock(transformCssTs(code, args.path, mapping));\n if (css.length > 0) {\n arbitraryCssRegistry.set(args.path, css);\n } else {\n arbitraryCssRegistry.delete(args.path);\n }\n\n return { contents: code, loader: loaderForPath(args.path) };\n }\n\n if (!code.includes(\"Css\") && !code.includes(\"css=\")) return undefined;\n\n if (!mapping) {\n mapping = loadMapping(resolve(process.cwd(), opts.mapping));\n }\n\n const result = transformTruss(code, args.path, mapping);\n if (!result) return undefined;\n\n // Merge rules into the shared registry\n if (result.rules) {\n for (const [className, rule] of result.rules) {\n if (!cssRegistry.has(className)) {\n cssRegistry.set(className, rule);\n }\n }\n }\n\n return { contents: result.code, loader: loaderForPath(args.path) };\n });\n\n build.onEnd(() => {\n if (cssRegistry.size === 0 && arbitraryCssRegistry.size === 0) return;\n\n const cssParts = [generateCssText(cssRegistry), ...arbitraryCssRegistry.values()].filter(\n (part) => part.length > 0,\n );\n const css = cssParts.join(\"\\n\");\n const cssFileName = opts.outputCss ?? \"truss.css\";\n const cssPath = resolve(outDir ?? join(process.cwd(), \"dist\"), cssFileName);\n\n mkdirSync(resolve(cssPath, \"..\"), { recursive: true });\n writeFileSync(cssPath, css, \"utf8\");\n });\n },\n };\n}\n\n/** Map file extension to esbuild loader type. */\nfunction loaderForPath(filePath: string): string {\n if (filePath.endsWith(\".tsx\")) return \"tsx\";\n if (filePath.endsWith(\".ts\")) return \"ts\";\n if (filePath.endsWith(\".jsx\")) return \"jsx\";\n return \"js\";\n}\n\n/**\n * Minimal esbuild plugin types so we don't need esbuild as a dependency.\n *\n * These match the subset of the esbuild Plugin API that we use.\n */\ninterface EsbuildPluginBuild {\n initialOptions: { outdir?: string };\n onLoad(\n options: { filter: RegExp },\n callback: (args: { path: string }) => { contents: string; loader: string } | undefined,\n ): void;\n onEnd(callback: () => void): void;\n}\n"],"mappings":";AAAA,SAAS,gBAAAA,eAAc,iBAAAC,gBAAe,YAAY,mBAAmB;AACrE,SAAS,WAAAC,UAAS,SAAS,YAAY,QAAAC,aAAY;AACnD,SAAS,kBAAkB;;;ACF3B,YAAY,OAAO;;;ACWnB,IAAM,mBAAmB,oBAAI,IAAY;AAEzC,IAAM,kBAAkB,oBAAI,IAAY;AAExC,IAAM,wBAAwB,oBAAI,IAAY;AAE9C,IAAM,yBAAyB,oBAAI,IAAY;AAM/C,gBAAgB,IAAI,uBAAuB;AAC3C,gBAAgB,IAAI,WAAW;AAC/B,gBAAgB,IAAI,gBAAgB;AAGpC,uBAAuB,IAAI,WAAW;AACtC,gBAAgB,IAAI,uBAAuB;AAC3C,gBAAgB,IAAI,iBAAiB;AACrC,gBAAgB,IAAI,qBAAqB;AACzC,gBAAgB,IAAI,oBAAoB;AACxC,gBAAgB,IAAI,qBAAqB;AACzC,gBAAgB,IAAI,2BAA2B;AAC/C,gBAAgB,IAAI,gBAAgB;AACpC,gBAAgB,IAAI,sBA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ACF;AAGO,SAAS,YAAY,MAA4B;AACtD,QAAM,MAAMC,cAAa,MAAM,MAAM;AACrC,SAAO,KAAK,MAAM,GAAG;AACvB;","names":["readFileSync","writeFileSync","resolve","join","_traverse","_generate","t","t","resolved","pseudoArg","t","traverse","_traverse","generate","_generate","isRuntimeStyleCssAttribute","parse","t","t","parse","parse","_generate","t","generate","_generate","parse","readFileSync","readFileSync","resolve","readFileSync","join","writeFileSync"]}
|
|
1
|
+
{"version":3,"sources":["../../src/plugin/index.ts","../../src/plugin/emit-truss.ts","../../src/plugin/property-priorities.ts","../../src/plugin/priority.ts","../../src/plugin/css-property-abbreviations.ts","../../src/plugin/transform.ts","../../src/plugin/ast-utils.ts","../../src/plugin/resolve-chain.ts","../../src/plugin/rewrite-sites.ts","../../src/plugin/transform-css.ts","../../src/plugin/css-ts-utils.ts","../../src/plugin/rewrite-css-ts-imports.ts","../../src/plugin/merge-css.ts","../../src/plugin/esbuild-plugin.ts"],"sourcesContent":["import { readFileSync, writeFileSync, existsSync, readdirSync } from \"fs\";\nimport { resolve, dirname, isAbsolute, join } from \"path\";\nimport { createHash } from \"crypto\";\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\";\nimport { readTrussCss, mergeTrussCss, parseTrussCss, type ParsedTrussCss } from \"./merge-css\";\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 /** Paths to pre-compiled truss.css files from libraries to merge into the app's CSS. */\n libraries?: 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/** Placeholder injected into HTML during build; replaced with the hashed CSS filename in generateBundle. */\nconst TRUSS_CSS_PLACEHOLDER = \"__TRUSS_CSS_HASH__\";\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// Test-only bootstrap that injects the same merged collectCss() output used by\n// /virtual:truss.css, but as a virtual module side effect instead of an HTTP\n// fetch. In dev, the browser reaches /virtual:truss.css via transformIndexHtml\n// -> virtual:truss:runtime -> fetch(\"/virtual:truss.css\") -> configureServer.\n// Vitest/jsdom does not boot from index.html or run that browser fetch/HMR path;\n// it imports modules directly into the test environment, so CSS has to enter via\n// a module side effect instead.\nconst VIRTUAL_TEST_CSS_ID = \"virtual:truss:test-css\";\nconst RESOLVED_VIRTUAL_TEST_CSS_ID = \"\\0\" + VIRTUAL_TEST_CSS_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 content-hashed CSS asset (e.g. `assets/truss-abc123.css`) for long-term caching.\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 libraryPaths = opts.libraries ?? [];\n /** The hashed CSS filename emitted during generateBundle, used by writeBundle to patch HTML. */\n let emittedCssFileName: string | null = null;\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 /** Cached parsed library CSS (loaded once per build). */\n let libraryCache: ParsedTrussCss[] | null = null;\n\n /** Load and cache all library truss.css files. */\n function loadLibraries(): ParsedTrussCss[] {\n if (!libraryCache) {\n libraryCache = libraryPaths.map((libPath) => {\n const resolved = resolve(projectRoot || process.cwd(), libPath);\n return readTrussCss(resolved);\n });\n }\n return libraryCache;\n }\n\n /**\n * Generate the full CSS string from the global registry, merged with library CSS.\n *\n * When `libraries` are configured, parses each library's annotated truss.css,\n * combines with the app's own rules, deduplicates by class name, and sorts\n * by priority to produce a unified stylesheet.\n */\n function collectCss(): string {\n const appCss = generateCssText(cssRegistry);\n const libs = loadLibraries();\n if (libs.length === 0) return appCss;\n // Parse the app's own annotated CSS and merge with library sources\n const appParsed = parseTrussCss(appCss);\n return mergeTrussCss([...libs, appParsed]);\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 and library cache at start of each build\n cssRegistry.clear();\n libraryCache = null;\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((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(() => {\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\", () => {\n clearInterval(interval);\n });\n },\n\n transformIndexHtml(html: string) {\n if (isBuild) {\n // Strip any existing truss CSS references so the hook is idempotent when\n // a tool (e.g. Storybook) runs multiple Vite builds with the same plugin.\n // I.e. removes /virtual:truss.css, __TRUSS_CSS_HASH__, and /assets/truss-<hash>.css\n const stripped = html\n .replace(/\\s*<link[^>]*href=[\"'][^\"']*virtual:truss\\.css[\"'][^>]*\\/?>/g, \"\")\n .replace(/\\s*<link[^>]*href=[\"'][^\"']*__TRUSS_CSS_HASH__[\"'][^>]*\\/?>/g, \"\")\n .replace(/\\s*<link[^>]*href=[\"'][^\"']*\\/assets\\/truss-[0-9a-f]+\\.css[\"'][^>]*\\/?>/g, \"\");\n // Inject a stylesheet link with a placeholder; writeBundle replaces it\n // with the content-hashed filename for long-term caching.\n const link = `<link rel=\"stylesheet\" href=\"${TRUSS_CSS_PLACEHOLDER}\">`;\n return stripped.replace(\"</head>\", ` ${link}\\n </head>`);\n }\n // Inject the virtual runtime script for dev mode; it owns style updates.\n const tag = `<script type=\"module\" src=\"/${VIRTUAL_RUNTIME_ID}\"></script>`;\n return html.replace(\"</head>\", ` ${tag}\\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 if (source === VIRTUAL_TEST_CSS_ID || source === \"/\" + VIRTUAL_TEST_CSS_ID) {\n return RESOLVED_VIRTUAL_TEST_CSS_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(() => {\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((r) => r.text())\n .then((css) => { style.textContent = css; })\n .catch(() => {});\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\", () => {\n setTimeout(fetchCss, 50);\n });\n }\n})();\n`;\n }\n if (id === RESOLVED_VIRTUAL_TEST_CSS_ID) {\n // Vitest/jsdom has no dev server stylesheet fetch, so inject the full\n // merged CSS payload once via a virtual side-effect module.\n const css = collectCss();\n return `\nimport { __injectTrussCSS } from \"@homebound/truss/runtime\";\n\n__injectTrussCSS(${JSON.stringify(css)});\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 fileId = stripQueryAndHash(id);\n\n // In tests, we do not boot through index.html and the dev runtime fetch path\n // (`virtual:truss:runtime` -> fetch(\"/virtual:truss.css\")), so we inject the\n // merged application + library CSS through a virtual module side effect instead.\n //\n // We add `import \"virtual:truss:test-css\"` to each eligible transformed module,\n // but ESM module caching should evaluate that virtual module only once per test\n // module graph. Transformed files may still emit per-file `__injectTrussCSS`\n // calls; exact repeated chunks are deduped in the runtime helper.\n const shouldBootstrapTestCss = isTest && libraryPaths.length > 0 && !isNodeModulesFile(fileId);\n const testCssBootstrap = injectTestCssBootstrapImport(rewrittenCode, shouldBootstrapTestCss);\n const transformedCode = testCssBootstrap.code;\n const hasCssDsl = rewrittenCode.includes(\"Css\") || rewrittenCode.includes(\"css=\");\n if (isNodeModulesFile(fileId)) {\n return null;\n }\n if (!hasCssDsl && !rewrittenImports.changed && !testCssBootstrap.changed) return null;\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 || testCssBootstrap.changed ? { code: transformedCode, 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: transformedCode, 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(\n transformedCode,\n fileId,\n ensureMapping(),\n // In test mode (jsdom), inject CSS directly so document.styleSheets has rules\n { debug, injectCss: isTest },\n );\n if (!result) {\n if (!rewrittenImports.changed && !testCssBootstrap.changed) return null;\n return { code: transformedCode, 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 // Compute a content hash so the filename is cache-bustable.\n const hash = createHash(\"sha256\").update(css).digest(\"hex\").slice(0, 8);\n const fileName = `assets/truss-${hash}.css`;\n emittedCssFileName = fileName;\n\n (this as any).emitFile({\n type: \"asset\",\n fileName,\n source: css,\n });\n },\n\n /** Patch HTML files on disk to replace the CSS placeholder with the hashed filename. */\n writeBundle(options: any, _bundle: any) {\n if (!emittedCssFileName) return;\n const outDir = options.dir || join(projectRoot, \"dist\");\n // Find and patch all HTML files in the output directory\n for (const entry of readdirSync(outDir)) {\n if (!entry.endsWith(\".html\")) continue;\n const htmlPath = join(outDir, entry);\n const html = readFileSync(htmlPath, \"utf8\");\n if (html.includes(TRUSS_CSS_PLACEHOLDER)) {\n writeFileSync(htmlPath, html.replace(TRUSS_CSS_PLACEHOLDER, `/${emittedCssFileName}`), \"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 filePath.replace(/\\\\/g, \"/\").includes(\"/node_modules/\");\n}\n\nfunction injectTestCssBootstrapImport(code: string, shouldInject: boolean): { code: string; changed: boolean } {\n // Keep this as a normal ESM import so Vite/Vitest module caching ensures the\n // bootstrap executes once per module graph instead of once per transformed file.\n if (!shouldInject) {\n return { code, changed: false };\n }\n\n return {\n code: `${code}\\nimport \"${VIRTUAL_TEST_CSS_ID}\";`,\n changed: true,\n };\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\";\nexport { trussEsbuildPlugin, type TrussEsbuildPluginOptions } from \"./esbuild-plugin\";\n","import * as t from \"@babel/types\";\nimport type { ResolvedChain } from \"./resolve-chain\";\nimport type { ResolvedSegment, TrussMapping, WhenCondition } from \"./types\";\nimport { computeRulePriority, sortRulesByPriority } from \"./priority\";\nimport { cssPropertyAbbreviations } from \"./css-property-abbreviations\";\n\n// ── Atomic CSS rule model ─────────────────────────────────────────────\n\n/**\n * A single atomic CSS rule: one class, one selector, one or more declarations.\n *\n * I.e. `.black { color: #353535; }` is one AtomicRule with a single declaration,\n * while `sq(x)` produces one AtomicRule with two declarations (`height` + `width`).\n */\nexport interface AtomicRule {\n /** I.e. `\"sm_h_blue\"` — the generated class name including condition prefixes. */\n className: string;\n /**\n * The CSS property/value pairs this rule sets. Always has at least one entry.\n *\n * I.e. `[{ cssProperty: \"color\", cssValue: \"#526675\" }]` for a static rule, or\n * `[{ cssProperty: \"height\", cssValue: \"var(--height)\", cssVarName: \"--height\" },\n * { cssProperty: \"width\", cssValue: \"var(--width)\", cssVarName: \"--width\" }]` for `sq(x)`.\n */\n declarations: Array<{\n cssProperty: string;\n cssValue: string;\n /** I.e. `\"--marginTop\"` — present when this declaration uses a CSS custom property. */\n cssVarName?: string;\n }>;\n pseudoClass?: string;\n mediaQuery?: string;\n pseudoElement?: string;\n /** I.e. `when(row, \"ancestor\", \":hover\")` → `{ relationship: \"ancestor\", markerClass: \"_row_mrk\", pseudo: \":hover\" }`. */\n whenSelector?: {\n relationship: string;\n markerClass: string;\n pseudo: string;\n };\n}\n\n// ── Class-name constants and abbreviation maps ────────────────────────\n\n/** I.e. `:hover` → `_h`, `:focus-visible` → `_fv`. */\nconst PSEUDO_SUFFIX: Record<string, string> = {\n \":hover\": \"_h\",\n \":focus\": \"_f\",\n \":focus-visible\": \"_fv\",\n \":focus-within\": \"_fw\",\n \":active\": \"_a\",\n \":disabled\": \"_d\",\n \":first-of-type\": \"_fot\",\n \":last-of-type\": \"_lot\",\n};\n\n/** I.e. extends PSEUDO_SUFFIX with `:not` → `_n`, `:has` → `_has` for when() class tokens. */\nconst PSEUDO_SELECTOR_SUFFIX: Record<string, string> = {\n ...PSEUDO_SUFFIX,\n \":not\": \"_n\",\n \":is\": \"_is\",\n \":where\": \"_where\",\n \":has\": \"_has\",\n};\n\n/** I.e. `\"ancestor\"` → `\"anc\"`, `\"siblingAfter\"` → `\"sibA\"`. */\nconst RELATIONSHIP_SHORT: Record<string, string> = {\n ancestor: \"anc\",\n descendant: \"desc\",\n siblingAfter: \"sibA\",\n siblingBefore: \"sibB\",\n anySibling: \"anyS\",\n};\n\n// ── Marker class helpers ──────────────────────────────────────────────\n\n/** I.e. the shared default marker class is `_mrk`. */\nexport const DEFAULT_MARKER_CLASS = \"_mrk\";\n\n/** I.e. `markerClassName(row)` → `\"_row_mrk\"`, `markerClassName()` → `\"_mrk\"`. */\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 `_${markerNode.name}_mrk`;\n }\n return \"_marker_mrk\";\n}\n\n// ── Class-name prefix builders ────────────────────────────────────────\n\n/** I.e. `when(marker, \"ancestor\", \":hover\")` → `\"wh_anc_h_\"`, `when(row, …)` → `\"wh_anc_h_row_\"`. */\nfunction whenPrefix(whenPseudo: WhenCondition): string {\n const rel = RELATIONSHIP_SHORT[whenPseudo.relationship ?? \"ancestor\"] ?? \"anc\";\n const pseudoTag = pseudoSelectorTag(whenPseudo.pseudo);\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 * I.e. `conditionPrefix(\":hover\", smMedia, null, breakpoints)` → `\"sm_h_\"`,\n * so the final class reads `sm_h_bgBlack` (\"on sm + 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 // I.e. find breakpoint name: \"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 parts.push(`${pseudoSelectorTag(pseudoClass)}_`);\n }\n return parts.join(\"\");\n}\n\n// ── Pseudo-selector tokenizers ────────────────────────────────────────\n\n/** I.e. `\":hover:not(:disabled)\"` → `\"h_n_d\"` (a safe class-name token). */\nfunction pseudoSelectorTag(pseudo: string): string {\n const replaced = pseudo.trim().replace(/::?[a-zA-Z-]+/g, (match) => {\n return `_${pseudoIdentifierTag(match)}_`;\n });\n const cleaned = replaced\n .replace(/[^a-zA-Z0-9]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n return cleaned || \"pseudo\";\n}\n\n/** I.e. `\":hover\"` → `\"h\"`, `\":focus-visible\"` → `\"fv\"`, `\":first-of-type\"` → `\"fot\"`. */\nfunction pseudoIdentifierTag(pseudo: string): string {\n const normalized = normalizePseudoIdentifier(pseudo);\n const known = PSEUDO_SELECTOR_SUFFIX[normalized];\n if (known) {\n return known.replace(/^_/, \"\");\n }\n return normalized.replace(/^::?/, \"\").replace(/-/g, \"_\");\n}\n\n/** I.e. `\":focusVisible\"` → `\":focus-visible\"` (camelCase → kebab-case after the colon prefix). */\nfunction normalizePseudoIdentifier(pseudo: string): string {\n const prefixMatch = pseudo.match(/^::?/);\n const prefix = prefixMatch?.[0] ?? \"\";\n const name = pseudo.slice(prefix.length).replace(/[A-Z]/g, (match) => {\n return `-${match.toLowerCase()}`;\n });\n return `${prefix}${name}`;\n}\n\n// ── CSS property / value helpers ──────────────────────────────────────\n\n/** I.e. `\"backgroundColor\"` → `\"background-color\"`, `\"WebkitTransform\"` → `\"-webkit-transform\"`. */\nexport function camelToKebab(s: string): string {\n return s.replace(/^(Webkit|Moz|Ms|O)/, (m) => `-${m.toLowerCase()}`).replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);\n}\n\n/** I.e. `\"-8px\"` → `\"neg8px\"`, `\"0 0 0 1px blue\"` → `\"0_0_0_1px_blue\"`. */\nfunction cleanValueForClassName(value: string): string {\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/** I.e. `\"backgroundColor\"` → `\"bg\"` (from the abbreviation table), or the raw name as fallback. */\nfunction getPropertyAbbreviation(cssProp: string): string {\n return cssPropertyAbbreviations[cssProp] ?? cssProp;\n}\n\n// ── Longhand lookup (canonical abbreviation reuse) ────────────────────\n\n/**\n * Build a reverse lookup from `\"cssProperty\\0cssValue\"` → canonical abbreviation name.\n *\n * I.e. `{ paddingTop: \"8px\" }` → `\"pt1\"`, `{ borderStyle: \"solid\" }` → `\"bss\"`.\n * Used so multi-property abbreviations can reuse existing single-property class names.\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/** I.e. returns the cached `buildLonghandLookup` result, rebuilding only when the mapping changes. */\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// ── Static base class-name computation ────────────────────────────────\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 abbr = seg.abbr;\n\n if (seg.argResolved !== undefined) {\n const valuePart = cleanValueForClassName(seg.argResolved);\n if (isMultiProp) {\n const lookup = getLonghandLookup(mapping);\n const canonical = lookup.get(`${cssProp}\\0${cssValue}`);\n if (canonical) return canonical;\n // I.e. lineClamp(\"3\") display:-webkit-box → `d_negwebkit_box`, not `d_3`\n return `${getPropertyAbbreviation(cssProp)}_${cleanValueForClassName(cssValue)}`;\n }\n return `${abbr}_${valuePart}`;\n }\n\n if (isMultiProp) {\n const lookup = getLonghandLookup(mapping);\n const canonical = lookup.get(`${cssProp}\\0${cssValue}`);\n if (canonical) return canonical;\n return `${getPropertyAbbreviation(cssProp)}_${cleanValueForClassName(cssValue)}`;\n }\n\n return abbr;\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 * I.e. walks every segment in every chain part and registers one AtomicRule\n * per CSS declaration, keyed by the prefixed class name.\n */\nexport function collectAtomicRules(chains: ResolvedChain[], mapping: TrussMapping): CollectedRules {\n const rules = new Map<string, AtomicRule>();\n let needsMaybeInc = false;\n\n function collectSegment(seg: ResolvedSegment): void {\n if (seg.error || seg.styleArrayArg || seg.classNameArg || seg.styleArg) return;\n if (seg.typographyLookup) {\n for (const segments of Object.values(seg.typographyLookup.segmentsByName)) {\n for (const nestedSeg of segments) {\n collectSegment(nestedSeg);\n }\n }\n return;\n }\n if (seg.incremented) needsMaybeInc = true;\n if (seg.variableProps) {\n collectVariableRules(rules, seg, mapping);\n } else {\n collectStaticRules(rules, seg, mapping);\n }\n }\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 collectSegment(seg);\n }\n }\n }\n\n return { rules, needsMaybeInc };\n}\n\n/**\n * Compute the class name prefix and optional whenSelector for a segment.\n *\n * I.e. a segment with `pseudoClass: \":hover\"` and `mediaQuery: smMedia` gets\n * prefix `\"sm_h_\"`, while one with `whenPseudo: { relationship: \"ancestor\", pseudo: \":hover\" }`\n * also gets its `whenSelector` populated for CSS rule generation.\n */\nfunction segmentContext(\n seg: ResolvedSegment,\n mapping: TrussMapping,\n): { prefix: string; whenSelector?: AtomicRule[\"whenSelector\"] } {\n const prefix = `${conditionPrefix(seg.pseudoClass, seg.mediaQuery, seg.pseudoElement, mapping.breakpoints)}${seg.whenPseudo ? whenPrefix(seg.whenPseudo) : \"\"}`;\n if (seg.whenPseudo) {\n const wp = seg.whenPseudo;\n return {\n prefix,\n whenSelector: {\n relationship: wp.relationship ?? \"ancestor\",\n markerClass: markerClassName(wp.markerNode),\n pseudo: wp.pseudo,\n },\n };\n }\n return { prefix };\n}\n\n/** I.e. extracts `pseudoClass`, `mediaQuery`, `pseudoElement` from a segment for AtomicRule fields. */\nfunction baseRuleFields(seg: ResolvedSegment): Pick<AtomicRule, \"pseudoClass\" | \"mediaQuery\" | \"pseudoElement\"> {\n return {\n pseudoClass: seg.pseudoClass ?? undefined,\n mediaQuery: seg.mediaQuery ?? undefined,\n pseudoElement: seg.pseudoElement ?? undefined,\n };\n}\n\n/**\n * Collect atomic rules for a static segment (may have multiple CSS properties).\n *\n * I.e. `Css.ba.$` (borderStyle + borderWidth) registers one AtomicRule per longhand property.\n */\nfunction collectStaticRules(rules: Map<string, AtomicRule>, seg: ResolvedSegment, mapping: TrussMapping): void {\n const { prefix, whenSelector } = segmentContext(seg, mapping);\n const isMultiProp = Object.keys(seg.defs).length > 1;\n\n for (const [cssProp, value] of Object.entries(seg.defs)) {\n const cssValue = String(value);\n const baseName = computeStaticBaseName(seg, cssProp, cssValue, isMultiProp, mapping);\n const className = prefix ? `${prefix}${baseName}` : baseName;\n\n if (!rules.has(className)) {\n rules.set(className, {\n className,\n declarations: [{ cssProperty: camelToKebab(cssProp), cssValue }],\n ...baseRuleFields(seg),\n whenSelector,\n });\n }\n }\n}\n\n/**\n * Collect atomic rules for a variable segment.\n *\n * I.e. `Css.mt(x).$` registers a rule with `var(--marginTop)` and an `@property` declaration,\n * plus any extra static defs like `display: -webkit-box` for `lineClamp(n)`.\n */\nfunction collectVariableRules(rules: Map<string, AtomicRule>, seg: ResolvedSegment, mapping: TrussMapping): void {\n const { prefix, whenSelector } = segmentContext(seg, mapping);\n\n for (const prop of seg.variableProps!) {\n const className = prefix ? `${prefix}${seg.abbr}_var` : `${seg.abbr}_var`;\n const varName = toCssVariableName(className, seg.abbr, 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 declarations: [declaration],\n ...baseRuleFields(seg),\n whenSelector,\n });\n continue;\n }\n\n if (\n !existingRule.declarations.some((entry) => {\n return entry.cssProperty === declaration.cssProperty;\n })\n ) {\n existingRule.declarations.push(declaration);\n }\n }\n\n // I.e. lineClamp(n) also needs `display: -webkit-box` alongside the variable props\n if (seg.variableExtraDefs) {\n for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {\n const cssValue = String(value);\n const lookup = getLonghandLookup(mapping);\n const canonical = lookup.get(`${cssProp}\\0${cssValue}`);\n const extraBase = canonical ?? `${getPropertyAbbreviation(cssProp)}_${cleanValueForClassName(cssValue)}`;\n const extraName = prefix ? `${prefix}${extraBase}` : extraBase;\n if (!rules.has(extraName)) {\n rules.set(extraName, {\n className: extraName,\n declarations: [{ cssProperty: camelToKebab(cssProp), cssValue }],\n ...baseRuleFields(seg),\n whenSelector,\n });\n }\n }\n }\n}\n\n// ── CSS text generation ───────────────────────────────────────────────\n\n/**\n * Generate the full CSS text from collected rules, sorted by StyleX priority.\n *\n * I.e. produces output like:\n * ```\n * /* @truss p:3000 c:black *\\/\n * .black { color: #353535; }\n * /* @truss p:3200 c:sm_blue *\\/\n * @media screen and (max-width: 599px) { .sm_blue.sm_blue { color: #526675; } }\n * ```\n */\nexport function generateCssText(rules: Map<string, AtomicRule>): string {\n const allRules = Array.from(rules.values());\n\n sortRulesByPriority(allRules);\n\n const priorities = allRules.map(computeRulePriority);\n const lines: string[] = [];\n\n for (let i = 0; i < allRules.length; i++) {\n const rule = allRules[i];\n const priority = priorities[i];\n lines.push(`/* @truss p:${priority} c:${rule.className} */`);\n lines.push(formatRule(rule));\n }\n\n // I.e. `@property --marginTop { syntax: \"*\"; inherits: false; }` for variable rules\n for (const rule of allRules) {\n for (const declaration of getRuleDeclarations(rule)) {\n if (declaration.cssVarName) {\n lines.push(`/* @truss @property */`);\n lines.push(`@property ${declaration.cssVarName} { syntax: \"*\"; inherits: false; }`);\n }\n }\n }\n\n return lines.join(\"\\n\");\n}\n\n// ── CSS rule formatting ───────────────────────────────────────────────\n\n/**\n * Format a single rule into its CSS text, dispatching by rule kind.\n *\n * I.e. a base rule → `.black { color: #353535; }`,\n * a media rule → `@media (...) { .sm_blue.sm_blue { color: #526675; } }`,\n * a when rule → `._mrk:hover .wh_anc_h_blue { color: #526675; }`.\n */\nfunction formatRule(rule: AtomicRule): string {\n const whenSelector = rule.whenSelector;\n if (whenSelector) return formatWhenRule(rule, whenSelector);\n const selector = buildTargetSelector(rule, !!rule.mediaQuery);\n return formatRuleWithOptionalMedia(rule, selector);\n}\n\n/**\n * Format a when()-relationship rule with the correct combinator per relationship kind.\n *\n * I.e. ancestor → `._mrk:hover .target { … }`,\n * descendant → `.target:has(._mrk:hover) { … }`,\n * anySibling → `.target:has(~ ._mrk:hover), ._mrk:hover ~ .target { … }`.\n */\nfunction formatWhenRule(rule: AtomicRule, whenSelector: NonNullable<AtomicRule[\"whenSelector\"]>): string {\n const markerSelector = `.${whenSelector.markerClass}${whenSelector.pseudo}`;\n const duplicateClassName = !!rule.mediaQuery;\n\n if (whenSelector.relationship === \"ancestor\") {\n return formatRuleWithOptionalMedia(rule, `${markerSelector} ${buildTargetSelector(rule, duplicateClassName)}`);\n }\n if (whenSelector.relationship === \"descendant\") {\n return formatRuleWithOptionalMedia(rule, buildTargetSelector(rule, duplicateClassName, `:has(${markerSelector})`));\n }\n if (whenSelector.relationship === \"siblingAfter\") {\n return formatRuleWithOptionalMedia(\n rule,\n buildTargetSelector(rule, duplicateClassName, `:has(~ ${markerSelector})`),\n );\n }\n if (whenSelector.relationship === \"siblingBefore\") {\n return formatRuleWithOptionalMedia(rule, `${markerSelector} ~ ${buildTargetSelector(rule, duplicateClassName)}`);\n }\n if (whenSelector.relationship === \"anySibling\") {\n const afterSelector = buildTargetSelector(rule, duplicateClassName, `:has(~ ${markerSelector})`);\n const beforeSelector = `${markerSelector} ~ ${buildTargetSelector(rule, duplicateClassName)}`;\n return formatRuleWithOptionalMedia(rule, `${afterSelector}, ${beforeSelector}`);\n }\n\n // I.e. unknown relationship falls back to ancestor-style descendant combinator\n return formatRuleWithOptionalMedia(rule, `${markerSelector} ${buildTargetSelector(rule, duplicateClassName)}`);\n}\n\n/**\n * Assemble the target element's CSS selector from all active condition slots.\n *\n * I.e. `buildTargetSelector(rule, true)` → `.sm_h_blue.sm_h_blue:hover`,\n * `buildTargetSelector(rule, false, \":has(._mrk:hover)\")` → `.wh_anc_h_blue:has(._mrk:hover)`.\n */\nfunction buildTargetSelector(rule: AtomicRule, duplicateClassName: boolean, extraPseudoClass?: string): string {\n const classSelector = duplicateClassName ? `.${rule.className}.${rule.className}` : `.${rule.className}`;\n const pseudoClass = rule.pseudoClass ?? \"\";\n const relationshipPseudoClass = extraPseudoClass ?? \"\";\n const pseudoElement = rule.pseudoElement ?? \"\";\n return `${classSelector}${pseudoClass}${relationshipPseudoClass}${pseudoElement}`;\n}\n\n/** I.e. wraps the selector in a media-query block when `rule.mediaQuery` is set. */\nfunction formatRuleWithOptionalMedia(rule: AtomicRule, selector: string): string {\n if (rule.mediaQuery) {\n return formatNestedRuleBlock(rule.mediaQuery, selector, rule);\n }\n return formatRuleBlock(selector, rule);\n}\n\n/** I.e. returns the rule's declarations array (always has at least one entry). */\nfunction getRuleDeclarations(rule: AtomicRule): Array<{ cssProperty: string; cssValue: string; cssVarName?: string }> {\n return rule.declarations;\n}\n\n/** I.e. `.black { color: #353535; }`. */\nfunction formatRuleBlock(selector: string, rule: AtomicRule): string {\n const body = getRuleDeclarations(rule)\n .map((declaration) => {\n return `${declaration.cssProperty}: ${declaration.cssValue};`;\n })\n .join(\" \");\n return `${selector} { ${body} }`;\n}\n\n/** I.e. `@media (...) { .sm_blue.sm_blue { color: #526675; } }`. */\nfunction formatNestedRuleBlock(wrapper: string, selector: string, rule: AtomicRule): string {\n const body = getRuleDeclarations(rule)\n .map((declaration) => {\n return `${declaration.cssProperty}: ${declaration.cssValue};`;\n })\n .join(\" \");\n return `${wrapper} { ${selector} { ${body} } }`;\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 * I.e. `[blue, h_white]` → `{ color: \"blue h_white\" }`.\n *\n * Variable entries produce tuples: `{ marginTop: [\"mt_var\", { \"--marginTop\": __maybeInc(x) }] }`.\n */\nexport function buildStyleHashProperties(\n segments: ResolvedSegment[],\n mapping: TrussMapping,\n maybeIncHelperName?: string | null,\n): t.ObjectProperty[] {\n // I.e. cssProperty → list of { className, isVariable, isConditional, varName, argNode, ... }\n const propGroups = new Map<\n string,\n Array<{\n className: string;\n isVariable: boolean;\n /** Whether this entry has a condition prefix (pseudo/media/when). */\n isConditional: boolean;\n varName?: string;\n argNode?: unknown;\n incremented?: boolean;\n appendPx?: boolean;\n }>\n >();\n\n /**\n * Push an entry, replacing earlier base-level entries when a new base-level entry\n * overrides the same property.\n *\n * I.e. `Css.blue.black.$` → the later `black` replaces `blue` for `color`,\n * but `Css.blue.onHover.black.$` accumulates both because `onHover.black` is conditional.\n */\n function pushEntry(cssProp: string, entry: typeof propGroups extends Map<string, Array<infer E>> ? E : never): void {\n if (!propGroups.has(cssProp)) propGroups.set(cssProp, []);\n const entries = propGroups.get(cssProp)!;\n if (!entry.isConditional) {\n for (let i = entries.length - 1; i >= 0; i--) {\n if (!entries[i].isConditional) {\n entries.splice(i, 1);\n }\n }\n }\n entries.push(entry);\n }\n\n for (const seg of segments) {\n if (seg.error || seg.styleArrayArg || seg.typographyLookup || seg.classNameArg || seg.styleArg) continue;\n\n const { prefix } = segmentContext(seg, mapping);\n const isConditional = prefix !== \"\";\n\n if (seg.variableProps) {\n for (const prop of seg.variableProps) {\n const className = prefix ? `${prefix}${seg.abbr}_var` : `${seg.abbr}_var`;\n const varName = toCssVariableName(className, seg.abbr, prop);\n\n pushEntry(prop, {\n className,\n isVariable: true,\n isConditional,\n varName,\n argNode: seg.argNode,\n incremented: seg.incremented,\n appendPx: seg.appendPx,\n });\n }\n\n // I.e. lineClamp(n) also contributes static extra defs like `display: -webkit-box`\n if (seg.variableExtraDefs) {\n for (const [cssProp, value] of Object.entries(seg.variableExtraDefs)) {\n const cssValue = String(value);\n const lookup = getLonghandLookup(mapping);\n const canonical = lookup.get(`${cssProp}\\0${cssValue}`);\n const extraBase = canonical ?? `${getPropertyAbbreviation(cssProp)}_${cleanValueForClassName(cssValue)}`;\n const extraName = prefix ? `${prefix}${extraBase}` : extraBase;\n pushEntry(cssProp, { className: extraName, isVariable: false, isConditional });\n }\n }\n } else {\n const isMultiProp = Object.keys(seg.defs).length > 1;\n\n for (const [cssProp, val] of Object.entries(seg.defs)) {\n const baseName = computeStaticBaseName(seg, cssProp, String(val), isMultiProp, mapping);\n const className = prefix ? `${prefix}${baseName}` : baseName;\n\n pushEntry(cssProp, { className, isVariable: false, isConditional });\n }\n }\n }\n\n // Build AST ObjectProperty nodes\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 // I.e. `{ marginTop: [\"mt_var\", { \"--marginTop\": __maybeInc(x) }] }`\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 // I.e. wrap with `__maybeInc(x)` for increment-based values\n valueExpr = t.callExpression(t.identifier(maybeIncHelperName ?? \"__maybeInc\"), [valueExpr]);\n } else if (dyn.appendPx) {\n // I.e. wrap with `` `${v}px` `` for Px delegate values\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 properties.push(t.objectProperty(toPropertyKey(cssProp), tuple));\n } else {\n // I.e. static: `{ color: \"blue h_white\" }`\n properties.push(t.objectProperty(toPropertyKey(cssProp), t.stringLiteral(classNames)));\n }\n }\n\n return properties;\n}\n\n// ── CSS variable naming ───────────────────────────────────────────────\n\n/** I.e. `toCssVariableName(\"sm_mt_var\", \"mt\", \"marginTop\")` → `\"--sm_marginTop\"`. */\nfunction toCssVariableName(className: string, baseKey: string, cssProp: string): string {\n const baseClassName = `${baseKey}_var`;\n const cp = className.endsWith(baseClassName) ? className.slice(0, -baseClassName.length) : \"\";\n return `--${cp}${cssProp}`;\n}\n\n// ── Helper AST declarations ───────────────────────────────────────────\n\n/**\n * Build the per-file increment helper declaration.\n *\n * I.e. `const __maybeInc = (inc) => { return typeof inc === \"string\" ? inc : \\`${inc * 8}px\\`; };`\n */\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/** I.e. `\"color\"` → `t.identifier(\"color\")`, `\"box-shadow\"` → `t.stringLiteral(\"box-shadow\")`. */\nfunction toPropertyKey(key: string): t.Identifier | t.StringLiteral {\n return isValidIdentifier(key) ? t.identifier(key) : t.stringLiteral(key);\n}\n\n/** I.e. `\"color\"` → true, `\"box-shadow\"` → false. */\nfunction isValidIdentifier(s: string): boolean {\n return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(s);\n}\n\n/**\n * Build a runtime lookup table declaration for typography.\n *\n * I.e. `const __typography = { f24: { fontSize: \"f24\", lineHeight: \"lh32\" }, ... };`\n */\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","/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * Converted from Flow to TypeScript; otherwise kept as-is for easy updates from upstream.\n * Source: https://github.com/facebook/stylex/blob/1ddee1dde1d55134c7d4f6889d8cbf34091e72fd/packages/%40stylexjs/shared/src/utils/property-priorities.js\n */\n\n// Physical properties that have logical equivalents:\nconst longHandPhysical = new Set<string>();\n// Logical properties *and* all other long hand properties:\nconst longHandLogical = new Set<string>();\n// Shorthand properties that override longhand properties:\nconst shorthandsOfLonghands = new Set<string>();\n// Shorthand properties that override other shorthand properties:\nconst shorthandsOfShorthands = new Set<string>();\n\n// Using MDN data as a source of truth to populate the above sets\n// by group in alphabetical order:\n\n// Composition and Blending\nlongHandLogical.add(\"background-blend-mode\");\nlongHandLogical.add(\"isolation\");\nlongHandLogical.add(\"mix-blend-mode\");\n\n// CSS Animations\nshorthandsOfShorthands.add(\"animation\");\nlongHandLogical.add(\"animation-composition\");\nlongHandLogical.add(\"animation-delay\");\nlongHandLogical.add(\"animation-direction\");\nlongHandLogical.add(\"animation-duration\");\nlongHandLogical.add(\"animation-fill-mode\");\nlongHandLogical.add(\"animation-iteration-count\");\nlongHandLogical.add(\"animation-name\");\nlongHandLogical.add(\"animation-play-state\");\nshorthandsOfLonghands.add(\"animation-range\");\nlongHandLogical.add(\"animation-range-end\");\nlongHandLogical.add(\"animation-range-start\");\nlongHandLogical.add(\"animation-timing-function\");\nlongHandLogical.add(\"animation-timeline\");\n\nshorthandsOfLonghands.add(\"scroll-timeline\");\nlongHandLogical.add(\"scroll-timeline-axis\");\nlongHandLogical.add(\"scroll-timeline-name\");\n\nlongHandLogical.add(\"timeline-scope\");\n\nshorthandsOfLonghands.add(\"view-timeline\");\nlongHandLogical.add(\"view-timeline-axis\");\nlongHandLogical.add(\"view-timeline-inset\");\nlongHandLogical.add(\"view-timeline-name\");\n\n// CSS Backgrounds and Borders\nshorthandsOfShorthands.add(\"background\");\nlongHandLogical.add(\"background-attachment\");\nlongHandLogical.add(\"background-clip\");\nlongHandLogical.add(\"background-color\");\nlongHandLogical.add(\"background-image\");\nlongHandLogical.add(\"background-origin\");\nlongHandLogical.add(\"background-repeat\");\nlongHandLogical.add(\"background-size\");\nshorthandsOfLonghands.add(\"background-position\");\nlongHandLogical.add(\"background-position-x\");\nlongHandLogical.add(\"background-position-y\");\n\nshorthandsOfShorthands.add(\"border\"); // OF SHORTHANDS!\nshorthandsOfLonghands.add(\"border-color\");\nshorthandsOfLonghands.add(\"border-style\");\nshorthandsOfLonghands.add(\"border-width\");\nshorthandsOfShorthands.add(\"border-block\"); // Logical Properties\nlongHandLogical.add(\"border-block-color\"); // Logical Properties\nlongHandLogical.add(\"border-block-stylex\"); // Logical Properties\nlongHandLogical.add(\"border-block-width\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-block-start\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-top\");\nlongHandLogical.add(\"border-block-start-color\"); // Logical Properties\nlongHandPhysical.add(\"border-top-color\");\nlongHandLogical.add(\"border-block-start-style\"); // Logical Properties\nlongHandPhysical.add(\"border-top-style\");\nlongHandLogical.add(\"border-block-start-width\"); // Logical Properties\nlongHandPhysical.add(\"border-top-width\");\nshorthandsOfLonghands.add(\"border-block-end\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-bottom\");\nlongHandLogical.add(\"border-block-end-color\"); // Logical Properties\nlongHandPhysical.add(\"border-bottom-color\");\nlongHandLogical.add(\"border-block-end-style\"); // Logical Properties\nlongHandPhysical.add(\"border-bottom-style\");\nlongHandLogical.add(\"border-block-end-width\"); // Logical Properties\nlongHandPhysical.add(\"border-bottom-width\");\nshorthandsOfShorthands.add(\"border-inline\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-inline-color\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-inline-style\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-inline-width\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-inline-start\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-left\");\nlongHandLogical.add(\"border-inline-start-color\"); // Logical Properties\nlongHandPhysical.add(\"border-left-color\");\nlongHandLogical.add(\"border-inline-start-style\"); // Logical Properties\nlongHandPhysical.add(\"border-left-style\");\nlongHandLogical.add(\"border-inline-start-width\"); // Logical Properties\nlongHandPhysical.add(\"border-left-width\");\nshorthandsOfLonghands.add(\"border-inline-end\"); // Logical Properties\nshorthandsOfLonghands.add(\"border-right\");\nlongHandLogical.add(\"border-inline-end-color\"); // Logical Properties\nlongHandPhysical.add(\"border-right-color\");\nlongHandLogical.add(\"border-inline-end-style\"); // Logical Properties\nlongHandPhysical.add(\"border-right-style\");\nlongHandLogical.add(\"border-inline-end-width\"); // Logical Properties\nlongHandPhysical.add(\"border-right-width\");\n\nshorthandsOfLonghands.add(\"border-image\");\nlongHandLogical.add(\"border-image-outset\");\nlongHandLogical.add(\"border-image-repeat\");\nlongHandLogical.add(\"border-image-slice\");\nlongHandLogical.add(\"border-image-source\");\nlongHandLogical.add(\"border-image-width\");\n\nshorthandsOfLonghands.add(\"border-radius\");\nlongHandLogical.add(\"border-start-end-radius\"); // Logical Properties\nlongHandLogical.add(\"border-start-start-radius\"); // Logical Properties\nlongHandLogical.add(\"border-end-end-radius\"); // Logical Properties\nlongHandLogical.add(\"border-end-start-radius\"); // Logical Properties\nlongHandPhysical.add(\"border-top-left-radius\");\nlongHandPhysical.add(\"border-top-right-radius\");\nlongHandPhysical.add(\"border-bottom-left-radius\");\nlongHandPhysical.add(\"border-bottom-right-radius\");\n\nshorthandsOfLonghands.add(\"corner-shape\");\nlongHandLogical.add(\"corner-start-start-shape\"); // Logical Properties\nlongHandLogical.add(\"corner-start-end-shape\"); // Logical Properties\nlongHandLogical.add(\"corner-end-start-shape\"); // Logical Properties\nlongHandLogical.add(\"corner-end-end-shape\"); // Logical Properties\nlongHandPhysical.add(\"corner-top-left-shape\");\nlongHandPhysical.add(\"corner-top-right-shape\");\nlongHandPhysical.add(\"corner-bottom-left-shape\");\nlongHandPhysical.add(\"corner-bottom-right-shape\");\n\nlongHandLogical.add(\"box-shadow\");\n\n// CSS Basic User Interface\nlongHandLogical.add(\"accent-color\");\nlongHandLogical.add(\"appearance\");\nlongHandLogical.add(\"aspect-ratio\");\n\nshorthandsOfLonghands.add(\"caret\");\nlongHandLogical.add(\"caret-color\");\nlongHandLogical.add(\"caret-shape\");\n\nlongHandLogical.add(\"cursor\");\nlongHandLogical.add(\"ime-mode\");\nlongHandLogical.add(\"input-security\");\n\nshorthandsOfLonghands.add(\"outline\");\nlongHandLogical.add(\"outline-color\");\nlongHandLogical.add(\"outline-offset\");\nlongHandLogical.add(\"outline-style\");\nlongHandLogical.add(\"outline-width\");\n\nlongHandLogical.add(\"pointer-events\");\nlongHandLogical.add(\"resize\"); // horizontal, vertical, block, inline, both\nlongHandLogical.add(\"text-overflow\");\nlongHandLogical.add(\"user-select\");\n\n// CSS Box Alignment\nshorthandsOfLonghands.add(\"grid-gap\"); // alias for `gap`\nshorthandsOfLonghands.add(\"gap\");\nlongHandLogical.add(\"grid-row-gap\"); // alias for `row-gap`\nlongHandLogical.add(\"row-gap\");\nlongHandLogical.add(\"grid-column-gap\"); // alias for `column-gap`\nlongHandLogical.add(\"column-gap\");\n\nshorthandsOfLonghands.add(\"place-content\");\nlongHandLogical.add(\"align-content\");\nlongHandLogical.add(\"justify-content\");\n\nshorthandsOfLonghands.add(\"place-items\");\nlongHandLogical.add(\"align-items\");\nlongHandLogical.add(\"justify-items\");\n\nshorthandsOfLonghands.add(\"place-self\");\nlongHandLogical.add(\"align-self\");\nlongHandLogical.add(\"justify-self\");\n\n// CSS Box Model\nlongHandLogical.add(\"box-sizing\");\n\nlongHandLogical.add(\"block-size\"); // Logical Properties\nlongHandPhysical.add(\"height\");\nlongHandLogical.add(\"inline-size\"); // Logical Properties\nlongHandPhysical.add(\"width\");\n\nlongHandLogical.add(\"max-block-size\"); // Logical Properties\nlongHandPhysical.add(\"max-height\");\nlongHandLogical.add(\"max-inline-size\"); // Logical Properties\nlongHandPhysical.add(\"max-width\");\nlongHandLogical.add(\"min-block-size\"); // Logical Properties\nlongHandPhysical.add(\"min-height\");\nlongHandLogical.add(\"min-inline-size\"); // Logical Properties\nlongHandPhysical.add(\"min-width\");\n\nshorthandsOfShorthands.add(\"margin\");\nshorthandsOfLonghands.add(\"margin-block\"); // Logical Properties\nlongHandLogical.add(\"margin-block-start\"); // Logical Properties\nlongHandPhysical.add(\"margin-top\");\nlongHandLogical.add(\"margin-block-end\"); // Logical Properties\nlongHandPhysical.add(\"margin-bottom\");\nshorthandsOfLonghands.add(\"margin-inline\"); // Logical Properties\nlongHandLogical.add(\"margin-inline-start\"); // Logical Properties\nlongHandPhysical.add(\"margin-left\");\nlongHandLogical.add(\"margin-inline-end\"); // Logical Properties\nlongHandPhysical.add(\"margin-right\");\n\nlongHandLogical.add(\"margin-trim\");\n\nshorthandsOfLonghands.add(\"overscroll-behavior\");\nlongHandLogical.add(\"overscroll-behavior-block\");\nlongHandPhysical.add(\"overscroll-behavior-y\");\nlongHandLogical.add(\"overscroll-behavior-inline\");\nlongHandPhysical.add(\"overscroll-behavior-x\");\n\nshorthandsOfShorthands.add(\"padding\");\nshorthandsOfLonghands.add(\"padding-block\"); // Logical Properties\nlongHandLogical.add(\"padding-block-start\"); // Logical Properties\nlongHandPhysical.add(\"padding-top\");\nlongHandLogical.add(\"padding-block-end\"); // Logical Properties\nlongHandPhysical.add(\"padding-bottom\");\nshorthandsOfLonghands.add(\"padding-inline\"); // Logical Properties\nlongHandLogical.add(\"padding-inline-start\"); // Logical Properties\nlongHandPhysical.add(\"padding-left\");\nlongHandLogical.add(\"padding-inline-end\"); // Logical Properties\nlongHandPhysical.add(\"padding-right\");\n\nlongHandLogical.add(\"visibility\");\n\n// CSS Color\nlongHandLogical.add(\"color\");\nlongHandLogical.add(\"color-scheme\");\nlongHandLogical.add(\"forced-color-adjust\");\nlongHandLogical.add(\"opacity\");\nlongHandLogical.add(\"print-color-adjust\");\n\n// CSS Columns\nshorthandsOfLonghands.add(\"columns\");\nlongHandLogical.add(\"column-count\");\nlongHandLogical.add(\"column-width\");\n\nlongHandLogical.add(\"column-fill\");\nlongHandLogical.add(\"column-span\");\n\nshorthandsOfLonghands.add(\"column-rule\");\nlongHandLogical.add(\"column-rule-color\");\nlongHandLogical.add(\"column-rule-style\");\nlongHandLogical.add(\"column-rule-width\");\n\n// CSS Containment\nlongHandLogical.add(\"contain\");\n\nshorthandsOfLonghands.add(\"contain-intrinsic-size\");\nlongHandLogical.add(\"contain-intrinsic-block-size\");\nlongHandLogical.add(\"contain-intrinsic-width\");\nlongHandLogical.add(\"contain-intrinsic-height\");\nlongHandLogical.add(\"contain-intrinsic-inline-size\");\n\nshorthandsOfLonghands.add(\"container\");\nlongHandLogical.add(\"container-name\");\nlongHandLogical.add(\"container-type\");\n\nlongHandLogical.add(\"content-visibility\");\n\n// CSS Counter Styles\nlongHandLogical.add(\"counter-increment\");\nlongHandLogical.add(\"counter-reset\");\nlongHandLogical.add(\"counter-set\");\n\n// CSS Display\nlongHandLogical.add(\"display\");\n\n// CSS Flexible Box Layout\nshorthandsOfLonghands.add(\"flex\");\nlongHandLogical.add(\"flex-basis\");\nlongHandLogical.add(\"flex-grow\");\nlongHandLogical.add(\"flex-shrink\");\n\nshorthandsOfLonghands.add(\"flex-flow\");\nlongHandLogical.add(\"flex-direction\");\nlongHandLogical.add(\"flex-wrap\");\n\nlongHandLogical.add(\"order\");\n\n// CSS Fonts\nshorthandsOfShorthands.add(\"font\");\nlongHandLogical.add(\"font-family\");\nlongHandLogical.add(\"font-size\");\nlongHandLogical.add(\"font-stretch\");\nlongHandLogical.add(\"font-style\");\nlongHandLogical.add(\"font-weight\");\nlongHandLogical.add(\"line-height\");\nshorthandsOfLonghands.add(\"font-variant\");\nlongHandLogical.add(\"font-variant-alternates\");\nlongHandLogical.add(\"font-variant-caps\");\nlongHandLogical.add(\"font-variant-east-asian\");\nlongHandLogical.add(\"font-variant-emoji\");\nlongHandLogical.add(\"font-variant-ligatures\");\nlongHandLogical.add(\"font-variant-numeric\");\nlongHandLogical.add(\"font-variant-position\");\n\nlongHandLogical.add(\"font-feature-settings\");\nlongHandLogical.add(\"font-kerning\");\nlongHandLogical.add(\"font-language-override\");\nlongHandLogical.add(\"font-optical-sizing\");\nlongHandLogical.add(\"font-palette\");\nlongHandLogical.add(\"font-variation-settings\");\nlongHandLogical.add(\"font-size-adjust\");\nlongHandLogical.add(\"font-smooth\"); // Non-standard\nlongHandLogical.add(\"font-synthesis-position\");\nlongHandLogical.add(\"font-synthesis-small-caps\");\nlongHandLogical.add(\"font-synthesis-style\");\nlongHandLogical.add(\"font-synthesis-weight\");\n\nlongHandLogical.add(\"line-height-step\");\n\n// CSS Fragmentation\nlongHandLogical.add(\"box-decoration-break\");\nlongHandLogical.add(\"break-after\");\nlongHandLogical.add(\"break-before\");\nlongHandLogical.add(\"break-inside\");\nlongHandLogical.add(\"orphans\");\nlongHandLogical.add(\"widows\");\n\n// CSS Generated Content\nlongHandLogical.add(\"content\");\nlongHandLogical.add(\"quotes\");\n\n// CSS Grid Layout\nshorthandsOfShorthands.add(\"grid\");\nlongHandLogical.add(\"grid-auto-flow\");\nlongHandLogical.add(\"grid-auto-rows\");\nlongHandLogical.add(\"grid-auto-columns\");\nshorthandsOfShorthands.add(\"grid-template\");\nshorthandsOfLonghands.add(\"grid-template-areas\");\nlongHandLogical.add(\"grid-template-columns\");\nlongHandLogical.add(\"grid-template-rows\");\n\nshorthandsOfShorthands.add(\"grid-area\");\nshorthandsOfLonghands.add(\"grid-row\");\nlongHandLogical.add(\"grid-row-start\");\nlongHandLogical.add(\"grid-row-end\");\nshorthandsOfLonghands.add(\"grid-column\");\nlongHandLogical.add(\"grid-column-start\");\nlongHandLogical.add(\"grid-column-end\");\n\nlongHandLogical.add(\"align-tracks\");\nlongHandLogical.add(\"justify-tracks\");\nlongHandLogical.add(\"masonry-auto-flow\");\n\n// CSS Images\nlongHandLogical.add(\"image-orientation\");\nlongHandLogical.add(\"image-rendering\");\nlongHandLogical.add(\"image-resolution\");\nlongHandLogical.add(\"object-fit\");\nlongHandLogical.add(\"object-position\");\n\n// CSS Inline\nlongHandLogical.add(\"initial-letter\");\nlongHandLogical.add(\"initial-letter-align\");\n\n// CSS Lists and Counters\nshorthandsOfLonghands.add(\"list-style\");\nlongHandLogical.add(\"list-style-image\");\nlongHandLogical.add(\"list-style-position\");\nlongHandLogical.add(\"list-style-type\");\n\n// CSS Masking\nlongHandLogical.add(\"clip\"); // @deprecated\nlongHandLogical.add(\"clip-path\");\n\nshorthandsOfLonghands.add(\"mask\");\nlongHandLogical.add(\"mask-clip\");\nlongHandLogical.add(\"mask-composite\");\nlongHandLogical.add(\"mask-image\");\nlongHandLogical.add(\"mask-mode\");\nlongHandLogical.add(\"mask-origin\");\nlongHandLogical.add(\"mask-position\");\nlongHandLogical.add(\"mask-repeat\");\nlongHandLogical.add(\"mask-size\");\n\nlongHandLogical.add(\"mask-type\");\n\nshorthandsOfLonghands.add(\"mask-border\");\nlongHandLogical.add(\"mask-border-mode\");\nlongHandLogical.add(\"mask-border-outset\");\nlongHandLogical.add(\"mask-border-repeat\");\nlongHandLogical.add(\"mask-border-slice\");\nlongHandLogical.add(\"mask-border-source\");\nlongHandLogical.add(\"mask-border-width\");\n\n// CSS Miscellaneous\nshorthandsOfShorthands.add(\"all\"); // avoid!\nlongHandLogical.add(\"text-rendering\");\n\n// CSS Motion Path\nshorthandsOfLonghands.add(\"offset\");\nlongHandLogical.add(\"offset-anchor\");\nlongHandLogical.add(\"offset-distance\");\nlongHandLogical.add(\"offset-path\");\nlongHandLogical.add(\"offset-position\");\nlongHandLogical.add(\"offset-rotate\");\n\n// CSS Overflow\nlongHandLogical.add(\"-webkit-box-orient\");\nlongHandLogical.add(\"-webkit-line-clamp\");\n\nshorthandsOfLonghands.add(\"overflow\");\nlongHandLogical.add(\"overflow-block\");\nlongHandPhysical.add(\"overflow-y\");\nlongHandLogical.add(\"overflow-inline\");\nlongHandPhysical.add(\"overflow-x\");\n\nlongHandLogical.add(\"overflow-clip-margin\"); // partial support\n\nlongHandLogical.add(\"scroll-gutter\");\nlongHandLogical.add(\"scroll-behavior\");\n\n// CSS Pages\nlongHandLogical.add(\"page\");\nlongHandLogical.add(\"page-break-after\");\nlongHandLogical.add(\"page-break-before\");\nlongHandLogical.add(\"page-break-inside\");\n\n// CSS Positioning\nshorthandsOfShorthands.add(\"inset\"); // Logical Properties\nshorthandsOfLonghands.add(\"inset-block\"); // Logical Properties\nlongHandLogical.add(\"inset-block-start\"); // Logical Properties\nlongHandPhysical.add(\"top\");\nlongHandLogical.add(\"inset-block-end\"); // Logical Properties\nlongHandPhysical.add(\"bottom\");\nshorthandsOfLonghands.add(\"inset-inline\"); // Logical Properties\nlongHandLogical.add(\"inset-inline-start\"); // Logical Properties\nlongHandPhysical.add(\"left\");\nlongHandLogical.add(\"inset-inline-end\"); // Logical Properties\nlongHandPhysical.add(\"right\");\n\nlongHandLogical.add(\"clear\");\nlongHandLogical.add(\"float\");\nlongHandLogical.add(\"position\");\nlongHandLogical.add(\"z-index\");\n\n// CSS Ruby\nlongHandLogical.add(\"ruby-align\");\nlongHandLogical.add(\"ruby-merge\");\nlongHandLogical.add(\"ruby-position\");\n\n// CSS Scroll Anchoring\nlongHandLogical.add(\"overflow-anchor\");\n\n// CSS Scroll Snap\nshorthandsOfShorthands.add(\"scroll-margin\");\nshorthandsOfLonghands.add(\"scroll-margin-block\");\nlongHandLogical.add(\"scroll-margin-block-start\");\nlongHandPhysical.add(\"scroll-margin-top\");\nlongHandLogical.add(\"scroll-margin-block-end\");\nlongHandPhysical.add(\"scroll-margin-bottom\");\nshorthandsOfLonghands.add(\"scroll-margin-inline\");\nlongHandLogical.add(\"scroll-margin-inline-start\");\nlongHandPhysical.add(\"scroll-margin-left\");\nlongHandLogical.add(\"scroll-margin-inline-end\");\nlongHandPhysical.add(\"scroll-margin-right\");\n\nshorthandsOfShorthands.add(\"scroll-padding\");\nshorthandsOfLonghands.add(\"scroll-padding-block\");\nlongHandLogical.add(\"scroll-padding-block-start\");\nlongHandPhysical.add(\"scroll-padding-top\");\nlongHandLogical.add(\"scroll-padding-block-end\");\nlongHandPhysical.add(\"scroll-padding-bottom\");\nshorthandsOfLonghands.add(\"scroll-padding-inline\");\nlongHandLogical.add(\"scroll-padding-inline-start\");\nlongHandPhysical.add(\"scroll-padding-left\");\nlongHandLogical.add(\"scroll-padding-inline-end\");\nlongHandPhysical.add(\"scroll-padding-right\");\n\nlongHandLogical.add(\"scroll-snap-align\");\nlongHandLogical.add(\"scroll-snap-stop\");\nshorthandsOfLonghands.add(\"scroll-snap-type\");\n\n// CSS Scrollbars\nlongHandLogical.add(\"scrollbar-color\");\nlongHandLogical.add(\"scrollbar-width\");\n\n// CSS Shapes\nlongHandLogical.add(\"shape-image-threshold\");\nlongHandLogical.add(\"shape-margin\");\nlongHandLogical.add(\"shape-outside\");\n\n// CSS Speech\nlongHandLogical.add(\"azimuth\");\n\n// CSS Table\nlongHandLogical.add(\"border-collapse\");\nlongHandLogical.add(\"border-spacing\");\nlongHandLogical.add(\"caption-side\");\nlongHandLogical.add(\"empty-cells\");\nlongHandLogical.add(\"table-layout\");\nlongHandLogical.add(\"vertical-align\");\n\n// CSS Text Decoration\nshorthandsOfLonghands.add(\"text-decoration\");\nlongHandLogical.add(\"text-decoration-color\");\nlongHandLogical.add(\"text-decoration-line\");\nlongHandLogical.add(\"text-decoration-skip\");\nlongHandLogical.add(\"text-decoration-skip-ink\");\nlongHandLogical.add(\"text-decoration-style\");\nlongHandLogical.add(\"text-decoration-thickness\");\n\nshorthandsOfLonghands.add(\"text-emphasis\");\nlongHandLogical.add(\"text-emphasis-color\");\nlongHandLogical.add(\"text-emphasis-position\");\nlongHandLogical.add(\"text-emphasis-style\");\nlongHandLogical.add(\"text-shadow\");\nlongHandLogical.add(\"text-underline-offset\");\nlongHandLogical.add(\"text-underline-position\");\n\n// CSS Text\nlongHandLogical.add(\"hanging-punctuation\");\nlongHandLogical.add(\"hyphenate-character\");\nlongHandLogical.add(\"hyphenate-limit-chars\");\nlongHandLogical.add(\"hyphens\");\nlongHandLogical.add(\"letter-spacing\");\nlongHandLogical.add(\"line-break\");\nlongHandLogical.add(\"overflow-wrap\");\nlongHandLogical.add(\"paint-order\");\nlongHandLogical.add(\"tab-size\");\nlongHandLogical.add(\"text-align\");\nlongHandLogical.add(\"text-align-last\");\nlongHandLogical.add(\"text-indent\");\nlongHandLogical.add(\"text-justify\");\nlongHandLogical.add(\"text-size-adjust\");\nlongHandLogical.add(\"text-transform\");\nlongHandLogical.add(\"text-wrap\");\nlongHandLogical.add(\"white-space\");\nlongHandLogical.add(\"white-space-collapse\");\nlongHandLogical.add(\"word-break\");\nlongHandLogical.add(\"word-spacing\");\nlongHandLogical.add(\"word-wrap\");\n\n// CSS Transforms\nlongHandLogical.add(\"backface-visibility\");\nlongHandLogical.add(\"perspective\");\nlongHandLogical.add(\"perspective-origin\");\nlongHandLogical.add(\"rotate\");\nlongHandLogical.add(\"scale\");\nlongHandLogical.add(\"transform\");\nlongHandLogical.add(\"transform-box\");\nlongHandLogical.add(\"transform-origin\");\nlongHandLogical.add(\"transform-style\");\nlongHandLogical.add(\"translate\");\n\n// CSS Transitions\nshorthandsOfLonghands.add(\"transition\");\nlongHandLogical.add(\"transition-delay\");\nlongHandLogical.add(\"transition-duration\");\nlongHandLogical.add(\"transition-property\");\nlongHandLogical.add(\"transition-timing-function\");\n\n// CSS View Transitions\nlongHandLogical.add(\"view-transition-name\");\n\n// CSS Will Change\nlongHandLogical.add(\"will-change\");\n\n// CSS Writing Modes\nlongHandLogical.add(\"direction\");\nlongHandLogical.add(\"text-combine-upright\");\nlongHandLogical.add(\"text-orientation\");\nlongHandLogical.add(\"unicode-bidi\");\nlongHandLogical.add(\"writing-mode\");\n\n// CSS Filter Effects\nlongHandLogical.add(\"backdrop-filter\");\nlongHandLogical.add(\"filter\");\n\n// MathML\nlongHandLogical.add(\"math-depth\");\nlongHandLogical.add(\"math-shift\");\nlongHandLogical.add(\"math-style\");\n\n// CSS Pointer Events\nlongHandLogical.add(\"touch-action\");\n\nexport const PSEUDO_CLASS_PRIORITIES: Readonly<Record<string, number>> = {\n \":is\": 40,\n \":where\": 40,\n \":not\": 40,\n \":has\": 45,\n \":dir\": 50,\n \":lang\": 51,\n \":first-child\": 52,\n \":first-of-type\": 53,\n \":last-child\": 54,\n \":last-of-type\": 55,\n \":only-child\": 56,\n \":only-of-type\": 57,\n \":nth-child\": 60,\n \":nth-last-child\": 61,\n \":nth-of-type\": 62,\n \":nth-last-of-type\": 63,\n \":empty\": 70,\n \":link\": 80,\n \":any-link\": 81,\n \":local-link\": 82,\n \":target-within\": 83,\n \":target\": 84,\n \":visited\": 85,\n \":enabled\": 91,\n \":disabled\": 92,\n \":required\": 93,\n \":optional\": 94,\n \":read-only\": 95,\n \":read-write\": 96,\n \":placeholder-shown\": 97,\n \":in-range\": 98,\n \":out-of-range\": 99,\n \":default\": 100,\n \":checked\": 101,\n \":indeterminate\": 101,\n \":blank\": 102,\n \":valid\": 103,\n \":invalid\": 104,\n \":user-invalid\": 105,\n \":autofill\": 110,\n \":picture-in-picture\": 120,\n \":modal\": 121,\n \":fullscreen\": 122,\n \":paused\": 123,\n \":playing\": 124,\n \":current\": 125,\n \":past\": 126,\n \":future\": 127,\n \":hover\": 130,\n \":focus-within\": 140,\n \":focus\": 150,\n \":focus-visible\": 160,\n \":active\": 170,\n};\n\nexport const AT_RULE_PRIORITIES: Readonly<Record<string, number>> = {\n \"@supports\": 30,\n \"@media\": 200,\n \"@container\": 300,\n};\n\nexport const PSEUDO_ELEMENT_PRIORITY: number = 5000;\n\n/** Get the property tier for a CSS property (kebab-case). */\nexport function getPropertyPriority(property: string): number {\n if (shorthandsOfShorthands.has(property)) return 1000;\n if (shorthandsOfLonghands.has(property)) return 2000;\n if (longHandLogical.has(property)) return 3000;\n if (longHandPhysical.has(property)) return 4000;\n // Unknown properties default to 3000 (longhand) — safest default\n return 3000;\n}\n\n/** Get the priority for a pseudo-class selector. */\nexport function getPseudoClassPriority(pseudo: string): number {\n const leadingPseudo = pseudo.trim().match(/^::?[a-zA-Z-]+/)?.[0] ?? pseudo.split(\"(\")[0];\n const base = leadingPseudo.replace(/[A-Z]/g, (match) => {\n return `-${match.toLowerCase()}`;\n });\n return PSEUDO_CLASS_PRIORITIES[base] ?? 40;\n}\n\n/** Get the priority for an at-rule. */\nexport function getAtRulePriority(atRule: string): number {\n if (atRule.startsWith(\"--\")) return 1;\n if (atRule.startsWith(\"@supports\")) return AT_RULE_PRIORITIES[\"@supports\"];\n if (atRule.startsWith(\"@media\")) return AT_RULE_PRIORITIES[\"@media\"];\n if (atRule.startsWith(\"@container\")) return AT_RULE_PRIORITIES[\"@container\"];\n return 0;\n}\n","/**\n * Computes CSS rule priority using StyleX's priority system.\n *\n * Priority is an additive sum: propertyPriority + pseudoPriority + atRulePriority + pseudoElementPriority.\n * Rules are sorted by this number before emission, guaranteeing longhands beat shorthands,\n * pseudo-classes follow LVFHA order, and at-rules override base styles — all deterministically.\n */\n\nimport {\n getPropertyPriority,\n getPseudoClassPriority,\n getAtRulePriority,\n PSEUDO_ELEMENT_PRIORITY,\n} from \"./property-priorities\";\nimport type { AtomicRule } from \"./emit-truss\";\n\n/** Relationship base priorities for when() selectors, matching StyleX's relational selector system. */\nconst RELATIONSHIP_BASE: Record<string, number> = {\n ancestor: 10,\n descendant: 15,\n anySibling: 20,\n siblingBefore: 30,\n siblingAfter: 40,\n};\n\n/**\n * Compute the numeric priority for a single AtomicRule.\n *\n * I.e. a rule with `declarations: [{ cssProperty: \"border-top-color\", ... }]`, `pseudoClass: \":hover\"`,\n * `mediaQuery: \"@media ...\"` → 4000 (physical longhand) + 130 (:hover) + 200 (@media) = 4330\n */\nexport function computeRulePriority(rule: AtomicRule): number {\n let priority = getPropertyPriority(rule.declarations[0].cssProperty);\n\n if (rule.pseudoElement) {\n priority += PSEUDO_ELEMENT_PRIORITY;\n }\n\n if (rule.pseudoClass) {\n priority += getPseudoClassPriority(rule.pseudoClass);\n }\n\n if (rule.mediaQuery) {\n priority += getAtRulePriority(rule.mediaQuery);\n }\n\n if (rule.whenSelector) {\n const relBase = RELATIONSHIP_BASE[rule.whenSelector.relationship] ?? 10;\n const pseudoFraction = getPseudoClassPriority(rule.whenSelector.pseudo) / 100;\n priority += relBase + pseudoFraction;\n }\n\n // Variable rules get a small bonus (+0.5) so they sort after static rules for the same property\n if (isVariableRule(rule)) {\n priority += 0.5;\n }\n\n return priority;\n}\n\n/** Returns true if this rule uses CSS custom property var() values. */\nfunction isVariableRule(rule: AtomicRule): boolean {\n return rule.declarations.some((d) => d.cssVarName !== undefined);\n}\n\n/**\n * Sort an array of AtomicRules in-place by their computed priority.\n *\n * When two rules have the same priority (e.g. two different longhands both at 3000),\n * we tiebreak by class name so the output is fully deterministic regardless of\n * file processing order (which differs between dev HMR and production builds).\n *\n * Uses a decorate-sort-undecorate pattern so each rule's priority is computed\n * once upfront rather than re-evaluated on every comparator call.\n */\nexport function sortRulesByPriority(rules: AtomicRule[]): void {\n // Pre-compute priorities so the O(n log n) comparisons are just number/string compares\n const decorated = rules.map((rule, i) => {\n return { rule, priority: computeRulePriority(rule), index: i };\n });\n decorated.sort((a, b) => {\n const diff = a.priority - b.priority;\n if (diff !== 0) return diff;\n // Alphabetical tiebreaker ensures identical output in dev and production\n return a.rule.className < b.rule.className ? -1 : a.rule.className > b.rule.className ? 1 : 0;\n });\n for (let i = 0; i < decorated.length; i++) {\n rules[i] = decorated[i].rule;\n }\n}\n","/**\n * Static mapping of CSS property names (camelCase) to unique short abbreviations.\n *\n * Used by the Truss compiler to generate compact, deterministic class names\n * when no user-defined canonical abbreviation exists for a given property+value.\n *\n * Convention: first letter of each camelCase word, with conflict resolution\n * via extra characters where needed. I.e. `borderBottomWidth` → `bbw`,\n * `flexDirection` → `fxd`, `fontSize` → `fz`.\n *\n * User-defined abbreviations (from the longhand lookup) always take priority\n * over these — this mapping is only the fallback.\n */\nexport const cssPropertyAbbreviations: Record<string, string> = {\n // Alignment\n alignContent: \"ac\",\n alignItems: \"ai\",\n alignSelf: \"als\",\n\n // Animation\n animation: \"anim\",\n animationDelay: \"animd\",\n animationDirection: \"animdr\",\n animationDuration: \"animdu\",\n animationFillMode: \"animfm\",\n animationIterationCount: \"animic\",\n animationName: \"animn\",\n animationPlayState: \"animps\",\n animationTimingFunction: \"animtf\",\n\n // Appearance\n appearance: \"app\",\n\n // Aspect ratio\n aspectRatio: \"ar\",\n\n // Backdrop filter\n backdropFilter: \"bdf\",\n\n // Background\n background: \"bg\",\n backgroundAttachment: \"bga\",\n backgroundBlendMode: \"bgbm\",\n backgroundClip: \"bgcl\",\n backgroundColor: \"bgc\",\n backgroundImage: \"bgi\",\n backgroundOrigin: \"bgo\",\n backgroundPosition: \"bgp\",\n backgroundRepeat: \"bgr\",\n backgroundSize: \"bgs\",\n\n // Border – shorthand\n border: \"bd\",\n borderCollapse: \"bdcl\",\n borderColor: \"bdc\",\n borderImage: \"bdi\",\n borderRadius: \"bra\",\n borderSpacing: \"bdsp\",\n borderStyle: \"bs\",\n borderWidth: \"bw\",\n\n // Border – top\n borderTop: \"bdt\",\n borderTopColor: \"btc\",\n borderTopLeftRadius: \"btlr\",\n borderTopRightRadius: \"btrr\",\n borderTopStyle: \"bts\",\n borderTopWidth: \"btw\",\n\n // Border – right\n borderRight: \"bdr\",\n borderRightColor: \"brc\",\n borderRightStyle: \"brs\",\n borderRightWidth: \"brw\",\n\n // Border – bottom\n borderBottom: \"bdb\",\n borderBottomColor: \"bbc\",\n borderBottomLeftRadius: \"bblr\",\n borderBottomRightRadius: \"bbrr\",\n borderBottomStyle: \"bbs\",\n borderBottomWidth: \"bbw\",\n\n // Border – left\n borderLeft: \"bdl\",\n borderLeftColor: \"blc\",\n borderLeftStyle: \"bls\",\n borderLeftWidth: \"blw\",\n\n // Box\n boxDecorationBreak: \"bxdb\",\n boxShadow: \"bxs\",\n boxSizing: \"bxz\",\n\n // Break\n breakAfter: \"bka\",\n breakBefore: \"bkb\",\n breakInside: \"bki\",\n\n // Caret / caption\n captionSide: \"cps\",\n caretColor: \"cac\",\n\n // Clear / clip\n clear: \"clr\",\n clip: \"cli\",\n clipPath: \"clp\",\n\n // Color\n color: \"c\",\n colorScheme: \"cs\",\n\n // Columns\n columnCount: \"cc\",\n columnFill: \"cf\",\n columnGap: \"cg\",\n columnRule: \"cr\",\n columnRuleColor: \"crc\",\n columnRuleStyle: \"crs\",\n columnRuleWidth: \"crw\",\n columnSpan: \"csp\",\n columnWidth: \"cw\",\n columns: \"cols\",\n\n // Contain / container\n contain: \"ctn\",\n containerName: \"ctnm\",\n containerType: \"ctnt\",\n content: \"cnt\",\n contentVisibility: \"cv\",\n\n // Counter\n counterIncrement: \"coi\",\n counterReset: \"cor\",\n\n // Cursor\n cursor: \"cur\",\n\n // Direction\n direction: \"dir\",\n\n // Display\n display: \"d\",\n\n // Empty cells\n emptyCells: \"ec\",\n\n // Fill (SVG)\n fill: \"fi\",\n fillOpacity: \"fio\",\n fillRule: \"fir\",\n\n // Filter\n filter: \"flt\",\n\n // Flex\n flex: \"fx\",\n flexBasis: \"fxb\",\n flexDirection: \"fxd\",\n flexFlow: \"fxf\",\n flexGrow: \"fxg\",\n flexShrink: \"fxs\",\n flexWrap: \"fxw\",\n\n // Float\n float: \"fl\",\n\n // Font\n font: \"fnt\",\n fontDisplay: \"fntd\",\n fontFamily: \"ff\",\n fontFeatureSettings: \"ffs\",\n fontKerning: \"fk\",\n fontSize: \"fz\",\n fontSizeAdjust: \"fza\",\n fontStretch: \"fst\",\n fontStyle: \"fsy\",\n fontSynthesis: \"fsyn\",\n fontVariant: \"fv\",\n fontVariantCaps: \"fvc\",\n fontVariantLigatures: \"fvl\",\n fontVariantNumeric: \"fvn\",\n fontWeight: \"fw\",\n\n // Gap\n gap: \"g\",\n\n // Grid\n grid: \"gd\",\n gridArea: \"ga\",\n gridAutoColumns: \"gac\",\n gridAutoFlow: \"gaf\",\n gridAutoRows: \"gar\",\n gridColumn: \"gc\",\n gridColumnEnd: \"gce\",\n gridColumnGap: \"gcg\",\n gridColumnStart: \"gcs\",\n gridGap: \"gg\",\n gridRow: \"gr\",\n gridRowEnd: \"gre\",\n gridRowGap: \"grg\",\n gridRowStart: \"grs\",\n gridTemplate: \"gt\",\n gridTemplateAreas: \"gta\",\n gridTemplateColumns: \"gtc\",\n gridTemplateRows: \"gtr\",\n\n // Height\n height: \"h\",\n maxHeight: \"mxh\",\n minHeight: \"mnh\",\n\n // Hyphens\n hyphens: \"hyp\",\n\n // Image rendering\n imageRendering: \"ir\",\n\n // Inset\n inset: \"ins\",\n insetBlock: \"insb\",\n insetBlockEnd: \"insbe\",\n insetBlockStart: \"insbs\",\n insetInline: \"insi\",\n insetInlineEnd: \"insie\",\n insetInlineStart: \"insis\",\n\n // Isolation\n isolation: \"iso\",\n\n // Justify\n justifyContent: \"jc\",\n justifyItems: \"ji\",\n justifySelf: \"jfs\",\n\n // Left\n left: \"l\",\n\n // Letter spacing\n letterSpacing: \"ls\",\n\n // Line\n lineBreak: \"lb\",\n lineHeight: \"lh\",\n\n // List\n listStyle: \"lis\",\n listStyleImage: \"lsi\",\n listStylePosition: \"lsp\",\n listStyleType: \"lst\",\n\n // Margin\n margin: \"m\",\n marginBlock: \"mbl\",\n marginBlockEnd: \"mble\",\n marginBlockStart: \"mbls\",\n marginBottom: \"mb\",\n marginInline: \"mil\",\n marginInlineEnd: \"mile\",\n marginInlineStart: \"mils\",\n marginLeft: \"ml\",\n marginRight: \"mr\",\n marginTop: \"mt\",\n\n // Mask\n mask: \"msk\",\n maskImage: \"mski\",\n maskPosition: \"mskp\",\n maskRepeat: \"mskr\",\n maskSize: \"msks\",\n\n // Max / min width\n maxWidth: \"mxw\",\n minWidth: \"mnw\",\n\n // Mix blend mode\n mixBlendMode: \"mbm\",\n\n // Object\n objectFit: \"obf\",\n objectPosition: \"obp\",\n\n // Offset\n offset: \"ofs\",\n offsetPath: \"ofsp\",\n\n // Opacity\n opacity: \"op\",\n\n // Order\n order: \"ord\",\n\n // Orphans / widows\n orphans: \"orp\",\n widows: \"wid\",\n\n // Outline\n outline: \"ol\",\n outlineColor: \"olc\",\n outlineOffset: \"olo\",\n outlineStyle: \"ols\",\n outlineWidth: \"olw\",\n\n // Overflow\n overflow: \"ov\",\n overflowAnchor: \"ova\",\n overflowWrap: \"ovw\",\n overflowX: \"ovx\",\n overflowY: \"ovy\",\n overscrollBehavior: \"osb\",\n overscrollBehaviorX: \"osbx\",\n overscrollBehaviorY: \"osby\",\n\n // Padding\n padding: \"p\",\n paddingBlock: \"pbl\",\n paddingBlockEnd: \"pble\",\n paddingBlockStart: \"pbls\",\n paddingBottom: \"pb\",\n paddingInline: \"pil\",\n paddingInlineEnd: \"pile\",\n paddingInlineStart: \"pils\",\n paddingLeft: \"pl\",\n paddingRight: \"pr\",\n paddingTop: \"pt\",\n\n // Page break\n pageBreakAfter: \"pgba\",\n pageBreakBefore: \"pgbb\",\n pageBreakInside: \"pgbi\",\n\n // Perspective\n perspective: \"per\",\n perspectiveOrigin: \"pero\",\n\n // Place\n placeContent: \"plc\",\n placeItems: \"pli\",\n placeSelf: \"pls\",\n\n // Pointer events\n pointerEvents: \"pe\",\n\n // Position\n position: \"pos\",\n\n // Quotes\n quotes: \"q\",\n\n // Resize\n resize: \"rsz\",\n\n // Right\n right: \"r\",\n\n // Rotate / scale\n rotate: \"rot\",\n scale: \"sc\",\n\n // Row gap\n rowGap: \"rg\",\n\n // Scroll\n scrollBehavior: \"scb\",\n scrollMargin: \"scm\",\n scrollPadding: \"scp\",\n scrollSnapAlign: \"ssa\",\n scrollSnapStop: \"sss\",\n scrollSnapType: \"sst\",\n\n // Shape\n shapeImageThreshold: \"sit\",\n shapeMargin: \"sm\",\n shapeOutside: \"so\",\n\n // Stroke (SVG)\n stroke: \"stk\",\n strokeDasharray: \"sda\",\n strokeDashoffset: \"sdo\",\n strokeLinecap: \"slc\",\n strokeLinejoin: \"slj\",\n strokeOpacity: \"sop\",\n strokeWidth: \"sw\",\n\n // Tab size\n tabSize: \"ts\",\n\n // Table layout\n tableLayout: \"tl\",\n\n // Text\n textAlign: \"ta\",\n textAlignLast: \"tal\",\n textDecoration: \"td\",\n textDecorationColor: \"tdc\",\n textDecorationLine: \"tdl\",\n textDecorationStyle: \"tds\",\n textDecorationThickness: \"tdt\",\n textEmphasis: \"te\",\n textIndent: \"ti\",\n textJustify: \"tj\",\n textOrientation: \"tor\",\n textOverflow: \"to\",\n textRendering: \"tr\",\n textShadow: \"tsh\",\n textTransform: \"tt\",\n textUnderlineOffset: \"tuo\",\n textUnderlinePosition: \"tup\",\n textWrap: \"twp\",\n\n // Top\n top: \"tp\",\n\n // Touch action\n touchAction: \"tca\",\n\n // Transform\n transform: \"tf\",\n transformOrigin: \"tfo\",\n transformStyle: \"tfs\",\n\n // Transition\n transition: \"tsn\",\n transitionDelay: \"tsnd\",\n transitionDuration: \"tsndu\",\n transitionProperty: \"tsnp\",\n transitionTimingFunction: \"tsntf\",\n\n // Translate\n translate: \"tsl\",\n\n // Unicode / user select\n unicodeBidi: \"ub\",\n userSelect: \"us\",\n\n // Vertical align\n verticalAlign: \"va\",\n\n // Visibility\n visibility: \"vis\",\n\n // Webkit\n WebkitAppearance: \"wkapp\",\n WebkitBackdropFilter: \"wkbdf\",\n WebkitBoxOrient: \"wbo\",\n WebkitFontSmoothing: \"wkfs\",\n WebkitLineClamp: \"wlc\",\n WebkitMaskImage: \"wkmi\",\n WebkitOverflowScrolling: \"wkos\",\n WebkitTapHighlightColor: \"wkthc\",\n WebkitTextFillColor: \"wktfc\",\n WebkitTextStrokeColor: \"wktsc\",\n WebkitTextStrokeWidth: \"wktsw\",\n\n // White space\n whiteSpace: \"ws\",\n\n // Width\n width: \"w\",\n\n // Will change\n willChange: \"wc\",\n\n // Word\n wordBreak: \"wdb\",\n wordSpacing: \"wds\",\n wordWrap: \"wdw\",\n writingMode: \"wm\",\n\n // Z-index\n zIndex: \"zi\",\n\n // Bottom (positioned after \"border*\" to avoid scan confusion)\n bottom: \"bot\",\n};\n\n// Validate uniqueness at module load time\nconst seen = new Map<string, string>();\nfor (const [prop, abbr] of Object.entries(cssPropertyAbbreviations)) {\n const existing = seen.get(abbr);\n if (existing) {\n throw new Error(`CSS property abbreviation conflict: \"${abbr}\" is used by both \"${existing}\" and \"${prop}\"`);\n }\n seen.set(abbr, prop);\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 CssChainReferenceResolver, type ResolvedChain } from \"./resolve-chain\";\nimport {\n collectTopLevelBindings,\n reservePreferredName,\n findCssImportBinding,\n findCssBuilderBinding,\n removeCssImport,\n findNamedImportBinding,\n findImportDeclaration,\n replaceCssImportWithNamedImports,\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 or use JSX css= attributes\n if (!code.includes(\"Css\") && !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 binding name — either from an import or a local `new CssBuilder(...)` declaration.\n // May be null when the file only has JSX css= attributes without importing Css.\n const cssImportBinding = findCssImportBinding(ast);\n const cssBindingName = cssImportBinding ?? findCssBuilderBinding(ast);\n const cssIsImported = cssImportBinding !== null;\n\n // Step 2: Collect all Css.*.$ expression sites AND detect Css.props() / JSX css= in a single pass.\n const sites: ExpressionSite[] = [];\n const errorMessages: Array<{ message: string; line: number | null }> = [];\n let hasCssPropsCall = false;\n let hasBuildtimeJsxCssAttribute = false;\n let hasRuntimeStyleCssUsage = false;\n\n traverse(ast, {\n // -- Css.*.$ chain collection --\n MemberExpression(path: NodePath<t.MemberExpression>) {\n if (!cssBindingName) return;\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 if (isInsideRuntimeStyleCssObject(path)) {\n hasRuntimeStyleCssUsage = true;\n return;\n }\n if (isInsideWhenObjectValue(path, cssBindingName)) {\n return;\n }\n\n const parentPath = path.parentPath;\n if (parentPath && parentPath.isMemberExpression() && t.isIdentifier(parentPath.node.property, { name: \"$\" })) {\n return;\n }\n\n const resolveCssChainReference = buildCssChainReferenceResolver(path, cssBindingName);\n const resolvedChain = resolveFullChain({ mapping, cssBindingName, resolveCssChainReference }, chain);\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 // -- Css.props() detection (so we don't bail early when there are no Css.*.$ sites) --\n CallExpression(path: NodePath<t.CallExpression>) {\n if (!cssBindingName || hasCssPropsCall) return;\n const callee = path.node.callee;\n if (\n t.isMemberExpression(callee) &&\n !callee.computed &&\n t.isIdentifier(callee.object, { name: cssBindingName }) &&\n t.isIdentifier(callee.property, { name: \"props\" })\n ) {\n hasCssPropsCall = true;\n }\n },\n // -- JSX css={...} attribute detection (so we don't bail when there are only css props) --\n JSXAttribute(path: NodePath<t.JSXAttribute>) {\n if (!t.isJSXIdentifier(path.node.name, { name: \"css\" })) return;\n if (isRuntimeStyleCssAttribute(path)) return;\n hasBuildtimeJsxCssAttribute = true;\n },\n });\n\n if (sites.length === 0 && !hasCssPropsCall && !hasBuildtimeJsxCssAttribute) 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: 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 runtimeLookupNames,\n });\n\n // Step 6: Prepare runtime imports before removing the Css import.\n const runtimeImports: Array<{ importedName: string; localName: string }> = [];\n if (needsTrussPropsHelper.current && !existingTrussPropsHelperName) {\n runtimeImports.push({ importedName: \"trussProps\", localName: trussPropsHelperName });\n }\n if (needsMergePropsHelper.current && !existingMergePropsHelperName) {\n runtimeImports.push({ importedName: \"mergeProps\", localName: mergePropsHelperName });\n }\n if (needsTrussDebugInfo.current && !existingTrussDebugInfoName) {\n runtimeImports.push({ importedName: \"TrussDebugInfo\", localName: trussDebugInfoName });\n }\n if (options.injectCss) {\n runtimeImports.push({ importedName: \"__injectTrussCSS\", localName: \"__injectTrussCSS\" });\n }\n\n // Step 7: Remove/replace the Css import and inject runtime imports.\n // When Css comes from a local `new CssBuilder(...)` (tsup bundles), skip import removal.\n let reusedCssImportLine = false;\n if (cssIsImported && !hasRuntimeStyleCssUsage) {\n reusedCssImportLine =\n runtimeImports.length > 0 &&\n findImportDeclaration(ast, \"@homebound/truss/runtime\") === null &&\n replaceCssImportWithNamedImports(ast, cssImportBinding!, \"@homebound/truss/runtime\", runtimeImports);\n\n if (!reusedCssImportLine) {\n removeCssImport(ast, cssImportBinding!);\n }\n }\n\n if (runtimeImports.length > 0 && !reusedCssImportLine) {\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((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 sourceMaps: true,\n retainLines: false,\n });\n\n const outputCode = preserveBlankLineAfterImports(code, output.code);\n\n return { code: outputCode, map: output.map, css: cssText, rules };\n}\n\nfunction isInsideRuntimeStyleCssObject(path: NodePath<t.MemberExpression>): boolean {\n let current: NodePath<t.Node> | null = path.parentPath;\n\n while (current) {\n // JSX path: <RuntimeStyle css={{ \".sel\": Css.blue.$ }} />\n if (current.isJSXExpressionContainer()) {\n const attrPath = current.parentPath;\n if (!attrPath || !attrPath.isJSXAttribute()) return false;\n return t.isObjectExpression(current.node.expression) && isRuntimeStyleCssAttribute(attrPath);\n }\n // Hook path: useRuntimeStyle({ \".sel\": Css.blue.$ })\n if (current.isCallExpression() && isUseRuntimeStyleCall(current.node)) {\n return true;\n }\n current = current.parentPath;\n }\n\n return false;\n}\n\n/** Match `useRuntimeStyle(...)` call expressions. */\nfunction isUseRuntimeStyleCall(node: t.CallExpression): boolean {\n return t.isIdentifier(node.callee, { name: \"useRuntimeStyle\" });\n}\n\nfunction isRuntimeStyleCssAttribute(path: NodePath<t.JSXAttribute>): boolean {\n if (!t.isJSXIdentifier(path.node.name, { name: \"css\" })) return false;\n\n const openingElementPath = path.parentPath;\n if (!openingElementPath || !openingElementPath.isJSXOpeningElement()) return false;\n return t.isJSXIdentifier(openingElementPath.node.name, { name: \"RuntimeStyle\" });\n}\n\nfunction isInsideWhenObjectValue(path: NodePath<t.MemberExpression>, cssBindingName: string): boolean {\n let current: NodePath<t.Node> | null = path.parentPath;\n\n while (current) {\n if (current.isObjectExpression()) {\n const parent = current.parentPath;\n if (\n parent?.isCallExpression() &&\n parent.node.arguments[0] === current.node &&\n t.isMemberExpression(parent.node.callee) &&\n !parent.node.callee.computed &&\n t.isIdentifier(parent.node.callee.property, { name: \"when\" }) &&\n extractChain(parent.node.callee.object as t.Expression, cssBindingName)\n ) {\n return true;\n }\n }\n\n current = current.parentPath;\n }\n\n return false;\n}\n\nfunction buildCssChainReferenceResolver(\n path: NodePath<t.MemberExpression>,\n cssBindingName: string,\n): CssChainReferenceResolver {\n return (node) => {\n return resolveCssChainReference(path, node, cssBindingName, new Set<string>());\n };\n}\n\n/**\n * Follow lexical bindings like `const same = Css.blue.$` back to their original\n * `Css.*.$` expression so `when({ \":hover\": same })` can resolve the same as\n * an inline value. This stays in the transform layer because it depends on Babel\n * scope/NodePath lookup, not just chain semantics.\n */\nfunction resolveCssChainReference(\n path: NodePath<t.Node>,\n node: t.Expression,\n cssBindingName: string,\n seen: Set<string>,\n): ReturnType<typeof extractChain> {\n const value = unwrapReferenceExpression(node);\n\n if (t.isMemberExpression(value) && !value.computed && t.isIdentifier(value.property, { name: \"$\" })) {\n return extractChain(value.object as t.Expression, cssBindingName);\n }\n\n if (!t.isIdentifier(value) || seen.has(value.name)) {\n return null;\n }\n\n const binding = path.scope.getBinding(value.name);\n if (!binding?.constant || !binding.path.isVariableDeclarator()) {\n return null;\n }\n\n const init = binding.path.node.init;\n if (!init || !t.isExpression(init)) {\n return null;\n }\n\n seen.add(value.name);\n return resolveCssChainReference(binding.path, init, cssBindingName, seen);\n}\n\n/** Strip TS/paren wrappers before checking whether a reference points at `Css.*.$`. */\nfunction unwrapReferenceExpression(node: t.Expression): t.Expression {\n let current = node;\n\n while (true) {\n if (\n t.isParenthesizedExpression(current) ||\n t.isTSAsExpression(current) ||\n t.isTSTypeAssertion(current) ||\n t.isTSNonNullExpression(current) ||\n t.isTSSatisfiesExpression(current)\n ) {\n current = current.expression;\n continue;\n }\n\n return current;\n }\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\nfunction preserveBlankLineAfterImports(input: string, output: string): string {\n const inputLines = input.split(\"\\n\");\n const outputLines = output.split(\"\\n\");\n const lastInputImportLine = findLastImportLine(inputLines);\n const lastOutputImportLine = findLastImportLine(outputLines);\n\n if (lastInputImportLine === -1 || lastOutputImportLine === -1) {\n return output;\n }\n\n const inputHasBlankLineAfterImports = inputLines[lastInputImportLine + 1]?.trim() === \"\";\n const outputHasBlankLineAfterImports = outputLines[lastOutputImportLine + 1]?.trim() === \"\";\n if (!inputHasBlankLineAfterImports || outputHasBlankLineAfterImports) {\n return output;\n }\n\n outputLines.splice(lastOutputImportLine + 1, 0, \"\");\n return outputLines.join(\"\\n\");\n}\n\nfunction findLastImportLine(lines: string[]): number {\n let lastImportLine = -1;\n for (let index = 0; index < lines.length; index++) {\n if (lines[index].trimStart().startsWith(\"import \")) {\n lastImportLine = index;\n }\n }\n return lastImportLine;\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/**\n * Find a local binding where `Css` is created via `new CssBuilder(...)`.\n *\n * This handles tsup-bundled libraries where Css is not imported but declared as:\n * var Css = new CssBuilder({ ... });\n */\nexport function findCssBuilderBinding(ast: t.File): string | null {\n for (const node of ast.program.body) {\n if (!t.isVariableDeclaration(node)) continue;\n for (const decl of node.declarations) {\n if (\n t.isIdentifier(decl.id) &&\n decl.init &&\n t.isNewExpression(decl.init) &&\n t.isIdentifier(decl.init.callee, { name: \"CssBuilder\" })\n ) {\n return decl.id.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/** 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\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 findImportDeclaration(ast: t.File, source: string): t.ImportDeclaration | null {\n for (const node of ast.program.body) {\n if (t.isImportDeclaration(node) && node.source.value === source) {\n return node;\n }\n }\n return null;\n}\n\nexport function replaceCssImportWithNamedImports(\n ast: t.File,\n cssBinding: string,\n source: string,\n imports: Array<{ importedName: string; localName: string }>,\n): boolean {\n for (const node of ast.program.body) {\n if (!t.isImportDeclaration(node)) continue;\n\n const cssSpecIndex = node.specifiers.findIndex((spec) => {\n return t.isImportSpecifier(spec) && spec.local.name === cssBinding;\n });\n if (cssSpecIndex === -1 || node.specifiers.length !== 1) continue;\n\n node.source = t.stringLiteral(source);\n node.specifiers = imports.map((entry) => {\n return t.importSpecifier(t.identifier(entry.localName), t.identifier(entry.importedName));\n });\n return true;\n }\n\n return false;\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((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((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 type * as t from \"@babel/types\";\nimport type {\n MarkerSegment,\n ResolvedConditionContext,\n ResolvedSegment,\n TrussMapping,\n TrussMappingEntry,\n WhenCondition,\n} from \"./types\";\nimport { extractChain } from \"./ast-utils\";\n\n/**\n * Optional hook for resolving identifier references like `const same = Css.blue.$`\n * back into a `ChainNode[]`, so the core chain resolver can stay decoupled from\n * Babel scope/AST traversal concerns.\n */\nexport type CssChainReferenceResolver = (node: t.Expression) => ChainNode[] | null;\n\nexport interface ResolveChainCtx {\n /** The Truss mapping that defines abbreviations, breakpoints, and typography resolution. */\n mapping: TrussMapping;\n /** The local identifier bound to the generated `Css` export, if one exists in this file. */\n cssBindingName?: string;\n /** The starting modifier state for this resolution pass, i.e. inherited media/pseudo context. */\n initialContext?: ResolvedConditionContext;\n /** Optional lexical binding resolver for `const same = Css.blue.$` style references. */\n resolveCssChainReference?: CssChainReferenceResolver;\n}\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\nfunction emptyConditionContext(): ResolvedConditionContext {\n return {\n mediaQuery: null,\n pseudoClass: null,\n pseudoElement: null,\n whenPseudo: null,\n };\n}\n\nfunction cloneConditionContext(context: ResolvedConditionContext): ResolvedConditionContext {\n return {\n mediaQuery: context.mediaQuery,\n pseudoClass: context.pseudoClass,\n pseudoElement: context.pseudoElement,\n whenPseudo: context.whenPseudo ? { ...context.whenPseudo } : null,\n };\n}\n\nfunction resetConditionContext(context: ResolvedConditionContext): void {\n context.mediaQuery = null;\n context.pseudoClass = null;\n context.pseudoElement = null;\n context.whenPseudo = null;\n}\n\nfunction segmentWithConditionContext(\n segment: Omit<ResolvedSegment, \"mediaQuery\" | \"pseudoClass\" | \"pseudoElement\" | \"whenPseudo\">,\n context: ResolvedConditionContext,\n): ResolvedSegment {\n return {\n ...segment,\n mediaQuery: context.mediaQuery,\n pseudoClass: context.pseudoClass,\n pseudoElement: context.pseudoElement,\n whenPseudo: context.whenPseudo,\n };\n}\n\nfunction applyModifierNodeToConditionContext(\n context: ResolvedConditionContext,\n node: ChainNode,\n mapping: TrussMapping,\n): void {\n if ((node as any).type === \"__mediaQuery\") {\n context.mediaQuery = (node as any).mediaQuery;\n return;\n }\n\n if (node.type === \"getter\") {\n if (node.name === \"end\") {\n resetConditionContext(context);\n return;\n }\n if (isPseudoMethod(node.name)) {\n context.pseudoClass = pseudoSelector(node.name);\n return;\n }\n if (mapping.breakpoints && node.name in mapping.breakpoints) {\n context.mediaQuery = mapping.breakpoints[node.name];\n }\n return;\n }\n\n if (node.type !== \"call\") {\n return;\n }\n\n if (node.name === \"ifContainer\") {\n try {\n context.mediaQuery = containerSelectorFromCall(node);\n } catch {\n // Ignore invalid modifiers here; resolveChain() will report the real error.\n }\n return;\n }\n\n if (node.name === \"element\") {\n if (node.args.length === 1 && node.args[0].type === \"StringLiteral\") {\n context.pseudoElement = node.args[0].value;\n }\n return;\n }\n\n if (node.name === \"when\") {\n try {\n const resolved = resolveWhenCall(node);\n if (resolved.kind === \"selector\") {\n context.pseudoClass = resolved.pseudo;\n } else {\n context.whenPseudo = resolved;\n }\n } catch {\n // Ignore invalid modifiers here; resolveChain() will report the real error.\n }\n return;\n }\n\n if (isPseudoMethod(node.name)) {\n context.pseudoClass = pseudoSelector(node.name);\n }\n}\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 * applies both conditions.\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 for subsequent styles.\n *\n * - **`when(\":hover\")`** — Same-element selector pseudo. Behaves like a custom\n * pseudo-class context and stacks with media queries.\n *\n * - **`when({ \":hover\": Css.blue.$ })`** — Object form. Each value is resolved\n * like an inline `Css.*.$` chain using the selector key as its initial\n * pseudo-class context, while inheriting the current media/when context.\n *\n * - **`when(marker, \"ancestor\", \":hover\")`** — Relationship selector. Sets the\n * relationship selector context and stacks with same-element pseudos, pseudo-elements,\n * and media queries.\n *\n * - **`ifContainer({ gt, lt })`** — Container query. Sets the media query\n * context to an `@container` query string.\n *\n * - **`end`** — Resets the active media query, pseudo-class, pseudo-element,\n * and `when(...)` relationship-selector context so subsequent styles start\n * from the base condition state again.\n *\n * Contexts accumulate left-to-right until explicitly replaced within the same\n * axis or cleared with `end`. A media query set by `ifSm` persists through\n * `onHover` and `when(...)`.\n * A boolean `if(bool)` nests the chain but inherits the currently-active\n * modifier axes into both branches.\n */\nexport function resolveFullChain(ctx: ResolveChainCtx, chain: ChainNode[]): ResolvedChain {\n const { mapping } = ctx;\n const initialContext = ctx.initialContext ?? emptyConditionContext();\n const parts: ResolvedChainPart[] = [];\n const markers: MarkerSegment[] = [];\n const nestedErrors: string[] = [];\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 let currentContext = cloneConditionContext(initialContext);\n let currentNodesStartContext = cloneConditionContext(initialContext);\n\n function flushCurrentNodes(): void {\n if (currentNodes.length === 0) {\n return;\n }\n\n parts.push({\n type: \"unconditional\",\n segments: resolveChain({ ...ctx, initialContext: currentNodesStartContext }, currentNodes),\n });\n currentNodes = [];\n currentNodesStartContext = cloneConditionContext(currentContext);\n }\n\n function pushCurrentNode(nodeToPush: ChainNode): void {\n if (currentNodes.length === 0) {\n currentNodesStartContext = cloneConditionContext(currentContext);\n }\n\n currentNodes.push(nodeToPush);\n applyModifierNodeToConditionContext(currentContext, nodeToPush, mapping);\n }\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 flushCurrentNodes();\n const branchContext = cloneConditionContext(currentContext);\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({ ...ctx, initialContext: branchContext }, thenNodes);\n const elseSegs = resolveChain({ ...ctx, initialContext: branchContext }, elseNodes);\n parts.push({ type: \"unconditional\", segments: [...thenSegs, ...elseSegs] });\n i = filteredChain.length;\n break;\n }\n }\n\n if (isWhenObjectCall(node)) {\n flushCurrentNodes();\n const resolved = resolveWhenObjectSelectors(ctx, node, currentContext);\n parts.push(...resolved.parts);\n markers.push(...resolved.markers);\n nestedErrors.push(...resolved.errors);\n i++;\n continue;\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 pushCurrentNode({ type: \"__mediaQuery\" as any, mediaQuery } as any);\n i++;\n continue;\n }\n\n // Flush any accumulated unconditional nodes\n flushCurrentNodes();\n const branchContext = cloneConditionContext(currentContext);\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({ ...ctx, initialContext: branchContext }, thenNodes);\n const elseSegs = resolveChain({ ...ctx, initialContext: branchContext }, elseNodes);\n parts.push({\n type: \"conditional\",\n conditionNode: node.conditionNode,\n thenSegments: thenSegs,\n elseSegments: elseSegs,\n });\n } else {\n pushCurrentNode(node);\n i++;\n }\n }\n\n // Flush remaining unconditional nodes\n flushCurrentNodes();\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: [...new Set([...scanErrors, ...nestedErrors, ...segmentErrors])] };\n}\n\n/** Detect `when({ ... })` so object-form selector groups can be resolved specially. */\nfunction isWhenObjectCall(node: ChainNode): node is CallChainNode {\n return (\n node.type === \"call\" && node.name === \"when\" && node.args.length === 1 && node.args[0].type === \"ObjectExpression\"\n );\n}\n\n/**\n * Resolve `when({ \":hover\": Css.blue.$, ... })` by recursively resolving each\n * nested `Css.*.$` value with the selector key as its initial pseudo-class.\n */\nfunction resolveWhenObjectSelectors(\n ctx: ResolveChainCtx,\n node: CallChainNode,\n initialContext: ResolvedConditionContext,\n): ResolvedChain {\n const { cssBindingName } = ctx;\n if (!cssBindingName) {\n return {\n parts: [],\n markers: [],\n errors: [new UnsupportedPatternError(`when({ ... }) requires a resolvable Css binding`).message],\n };\n }\n\n const objectArg = node.args[0];\n if (objectArg.type !== \"ObjectExpression\") {\n throw new UnsupportedPatternError(`when({ ... }) requires an object literal argument`);\n }\n\n const parts: ResolvedChainPart[] = [];\n const markers: MarkerSegment[] = [];\n const errors: string[] = [];\n\n for (const property of objectArg.properties) {\n try {\n if (property.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(`when({ ... }) does not support spread properties`);\n }\n if (property.type !== \"ObjectProperty\") {\n throw new UnsupportedPatternError(`when({ ... }) only supports plain object properties`);\n }\n if (property.computed || property.key.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when({ ... }) selector keys must be string literals`);\n }\n\n const value = unwrapExpression(property.value as t.Expression);\n const innerChain = resolveWhenObjectValueChain(ctx, value);\n if (!innerChain) {\n throw new UnsupportedPatternError(`when({ ... }) values must be Css.*.$ expressions`);\n }\n\n const selectorContext = cloneConditionContext(initialContext);\n selectorContext.pseudoClass = property.key.value;\n const resolved = resolveFullChain({ ...ctx, initialContext: selectorContext }, innerChain);\n parts.push(...resolved.parts);\n markers.push(...resolved.markers);\n errors.push(...resolved.errors);\n } catch (err) {\n if (err instanceof UnsupportedPatternError) {\n errors.push(err.message);\n } else {\n throw err;\n }\n }\n }\n\n return { parts, markers, errors: [...new Set(errors)] };\n}\n\n/**\n * Resolve a `when({ ... })` value into an inner `ChainNode[]`.\n *\n * I.e. this accepts either a direct `Css.blue.$` member expression or a\n * transform-provided reference resolver for identifiers like `const same = Css.blue.$`.\n * The reference lookup itself stays outside this file because it depends on\n * Babel scope/NodePath traversal state, while `resolve-chain.ts` is kept focused\n * on chain semantics rather than lexical binding analysis.\n */\nfunction resolveWhenObjectValueChain(ctx: ResolveChainCtx, value: t.Expression): ChainNode[] | null {\n const { cssBindingName, resolveCssChainReference } = ctx;\n if (\n cssBindingName &&\n value.type === \"MemberExpression\" &&\n !value.computed &&\n value.property.type === \"Identifier\" &&\n value.property.name === \"$\"\n ) {\n return extractChain(value.object as t.Expression, cssBindingName);\n }\n\n return resolveCssChainReference?.(value) ?? null;\n}\n\n/** Flatten nested `when({ ... })` parts back into plain segments for `resolveChain()`. */\nfunction flattenWhenObjectParts(resolved: ResolvedChain): ResolvedSegment[] {\n const segments: ResolvedSegment[] = [];\n\n // I.e. `resolveChain()` needs a flat segment list, even though `when({ ... })` is resolved via `resolveFullChain()`.\n for (const part of resolved.parts) {\n if (part.type !== \"unconditional\") {\n throw new UnsupportedPatternError(`when({ ... }) values cannot use if()/else in this context`);\n }\n\n segments.push(...part.segments);\n }\n\n for (const err of resolved.errors) {\n segments.push({ abbr: \"__error\", defs: {}, error: err });\n }\n\n return segments;\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 with flat defs (no condition nesting).\n * Does NOT handle if/else — use resolveFullChain for that.\n */\nexport function resolveChain(ctx: ResolveChainCtx, chain: ChainNode[]): ResolvedSegment[] {\n const { mapping, cssBindingName } = ctx;\n const initialContext = ctx.initialContext ?? emptyConditionContext();\n const segments: ResolvedSegment[] = [];\n const context = cloneConditionContext(initialContext);\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 context.mediaQuery = (node as any).mediaQuery;\n continue;\n }\n\n if (node.type === \"getter\") {\n const abbr = node.name;\n\n if (abbr === \"end\") {\n resetConditionContext(context);\n continue;\n }\n\n // Pseudo-class getters: onHover, onFocus, etc.\n if (isPseudoMethod(abbr)) {\n context.pseudoClass = pseudoSelector(abbr);\n continue;\n }\n\n // Breakpoint getters: ifSm, ifMd, ifLg, etc.\n if (mapping.breakpoints && abbr in mapping.breakpoints) {\n context.mediaQuery = mapping.breakpoints[abbr];\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 context.mediaQuery,\n context.pseudoClass,\n context.pseudoElement,\n context.whenPseudo,\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 context.mediaQuery = containerSelectorFromCall(node);\n continue;\n }\n\n // add(prop, value) / addCss(cssProp)\n if (abbr === \"add\" || abbr === \"addCss\") {\n const seg = resolveAddCall(\n node,\n mapping,\n context.mediaQuery,\n context.pseudoClass,\n context.pseudoElement,\n context.whenPseudo,\n );\n segments.push(seg);\n continue;\n }\n\n // Raw class passthrough, i.e. `Css.className(buttonClass).df.$`\n if (abbr === \"className\") {\n const seg = resolveClassNameCall(\n node,\n context.mediaQuery,\n context.pseudoClass,\n context.pseudoElement,\n context.whenPseudo,\n );\n segments.push(seg);\n continue;\n }\n\n // Raw inline style passthrough, i.e. `Css.mt(x).style(vars).$`\n if (abbr === \"style\") {\n const seg = resolveStyleCall(\n node,\n context.mediaQuery,\n context.pseudoClass,\n context.pseudoElement,\n context.whenPseudo,\n );\n segments.push(seg);\n continue;\n }\n\n if (abbr === \"typography\") {\n const resolved = resolveTypographyCall(\n node,\n mapping,\n context.mediaQuery,\n context.pseudoClass,\n context.pseudoElement,\n context.whenPseudo,\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 context.pseudoElement = (node.args[0] as any).value;\n continue;\n }\n\n // Generic when(selector) or when(marker, relationship, pseudo)\n if (abbr === \"when\") {\n if (isWhenObjectCall(node)) {\n const resolved = resolveWhenObjectSelectors(ctx, node, context);\n segments.push(...flattenWhenObjectParts(resolved));\n continue;\n }\n\n const resolved = resolveWhenCall(node);\n if (resolved.kind === \"selector\") {\n context.pseudoClass = resolved.pseudo;\n } else {\n context.whenPseudo = resolved;\n }\n continue;\n }\n\n // Simple pseudo-class calls (backward compat — pseudos are now getters)\n if (isPseudoMethod(abbr)) {\n context.pseudoClass = pseudoSelector(abbr);\n if (node.args.length > 0) {\n throw new UnsupportedPatternError(\n `${abbr}() does not take arguments -- use when(marker, \"ancestor\", \":hover\") for relationship selectors`,\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 context.mediaQuery,\n context.pseudoClass,\n context.pseudoElement,\n context.whenPseudo,\n );\n segments.push(seg);\n } else if (entry.kind === \"delegate\") {\n const seg = resolveDelegateCall(\n abbr,\n entry,\n node,\n mapping,\n context.mediaQuery,\n context.pseudoClass,\n context.pseudoElement,\n context.whenPseudo,\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({ abbr: \"__error\", defs: {}, error: err.message });\n } else {\n throw err;\n }\n }\n }\n\n return segments;\n}\n\n/**\n * Build a typography lookup key suffix from condition context.\n *\n * I.e. `typography(key)` → `\"typography\"`, `ifSm.typography(key)` → `\"typography__sm\"`.\n */\nfunction typographyLookupKeySuffix(\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo: WhenCondition | null,\n breakpoints?: Record<string, string>,\n): string {\n const parts: string[] = [];\n if (pseudoElement) parts.push(pseudoElement.replace(/^::/, \"\"));\n if (mediaQuery && breakpoints) {\n const bp = Object.entries(breakpoints).find(([, v]) => v === mediaQuery)?.[0];\n parts.push(bp ? bp.replace(/^if/, \"\").replace(/^./, (c) => c.toLowerCase()) : \"mq\");\n } else if (mediaQuery) {\n parts.push(\"mq\");\n }\n if (pseudoClass) parts.push(pseudoClass.replace(/^:+/, \"\").replace(/-/g, \"_\"));\n if (whenPseudo) parts.push(whenLookupKeyPart(whenPseudo));\n return parts.join(\"_\");\n}\n\nfunction whenLookupKeyPart(whenPseudo: WhenCondition): string {\n const parts = [\"when\", whenPseudo.relationship ?? \"ancestor\", sanitizeLookupToken(whenPseudo.pseudo)];\n\n if (whenPseudo.markerNode?.type === \"Identifier\" && whenPseudo.markerNode.name) {\n parts.push(whenPseudo.markerNode.name);\n }\n\n return parts.join(\"_\");\n}\n\nfunction sanitizeLookupToken(value: string): string {\n return (\n value\n .replace(/[^a-zA-Z0-9]+/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_|_$/g, \"\") || \"value\"\n );\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 whenPseudo: WhenCondition | 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, whenPseudo);\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 = typographyLookupKeySuffix(mediaQuery, pseudoClass, pseudoElement, whenPseudo, 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, whenPseudo);\n }\n\n return [\n {\n abbr: 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 whenPseudo: WhenCondition | 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, whenPseudo);\n for (const segment of resolved) {\n if (segment.variableProps) {\n throw new UnsupportedPatternError(`Typography abbreviation \"${name}\" cannot require runtime arguments`);\n }\n }\n return resolved;\n}\n\n/** Resolve a static or alias entry (from a getter access). Defs are always flat. */\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: WhenCondition | null,\n): ResolvedSegment[] {\n const context: ResolvedConditionContext = {\n mediaQuery,\n pseudoClass,\n pseudoElement,\n whenPseudo,\n };\n\n switch (entry.kind) {\n case \"static\": {\n return [segmentWithConditionContext({ abbr, defs: entry.defs }, context)];\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: WhenCondition | null,\n): ResolvedSegment {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n const literalValue = tryEvaluateLiteral(node.args[0], entry.incremented, mapping.increment);\n return buildParameterizedSegment({\n abbr,\n props: entry.props,\n incremented: entry.incremented,\n extraDefs: entry.extraDefs,\n argAst: node.args[0],\n literalValue,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n whenPseudo,\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: WhenCondition | 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 if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`${abbr}() expects exactly 1 argument, got ${node.args.length}`);\n }\n const literalValue = tryEvaluatePxLiteral(node.args[0]);\n // Use the target abbreviation name for delegate segments (i.e. mtPx → mt)\n return buildParameterizedSegment({\n abbr: entry.target,\n props: targetEntry.props,\n incremented: false,\n appendPx: true,\n extraDefs: targetEntry.extraDefs,\n argAst: node.args[0],\n literalValue,\n mediaQuery,\n pseudoClass,\n pseudoElement,\n whenPseudo,\n });\n}\n\n/** Shared builder for variable and delegate call segments. */\nfunction buildParameterizedSegment(params: {\n abbr: string;\n props: string[];\n incremented: boolean;\n appendPx?: boolean;\n extraDefs?: Record<string, unknown>;\n argAst: t.Expression | t.SpreadElement;\n literalValue: string | null;\n mediaQuery: string | null;\n pseudoClass: string | null;\n pseudoElement: string | null;\n whenPseudo: WhenCondition | null;\n}): ResolvedSegment {\n const { abbr, props, incremented, appendPx, extraDefs, argAst, literalValue, whenPseudo } = params;\n const context: ResolvedConditionContext = {\n mediaQuery: params.mediaQuery,\n pseudoClass: params.pseudoClass,\n pseudoElement: params.pseudoElement,\n whenPseudo,\n };\n\n if (literalValue !== null) {\n const defs: Record<string, unknown> = {};\n for (const prop of props) {\n defs[prop] = literalValue;\n }\n if (extraDefs) Object.assign(defs, extraDefs);\n return segmentWithConditionContext({ abbr, defs, argResolved: literalValue }, context);\n }\n\n const base = segmentWithConditionContext(\n {\n abbr,\n defs: {},\n variableProps: props,\n incremented,\n variableExtraDefs: extraDefs,\n argNode: argAst,\n },\n context,\n );\n if (appendPx) base.appendPx = true;\n return base;\n}\n\nfunction resolveClassNameCall(\n node: CallChainNode,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo: WhenCondition | null,\n): ResolvedSegment {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`className() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const arg = node.args[0];\n if (arg.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(`className() does not support spread arguments`);\n }\n\n if (mediaQuery || pseudoClass || pseudoElement || whenPseudo) {\n // I.e. `ifSm.className(\"x\")` cannot be represented as a runtime-only class append.\n throw new UnsupportedPatternError(\n `className() cannot be used inside media query, pseudo-class, pseudo-element, or when() contexts`,\n );\n }\n\n return {\n // I.e. this is metadata for the rewriter/runtime, not an atomic CSS rule.\n abbr: \"className\",\n defs: {},\n classNameArg: arg,\n };\n}\n\nfunction resolveStyleCall(\n node: CallChainNode,\n mediaQuery: string | null,\n pseudoClass: string | null,\n pseudoElement: string | null,\n whenPseudo: WhenCondition | null,\n): ResolvedSegment {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(`style() expects exactly 1 argument, got ${node.args.length}`);\n }\n\n const arg = node.args[0];\n if (arg.type === \"SpreadElement\") {\n throw new UnsupportedPatternError(`style() does not support spread arguments`);\n }\n\n if (mediaQuery || pseudoClass || pseudoElement || whenPseudo) {\n throw new UnsupportedPatternError(\n `style() cannot be used inside media query, pseudo-class, pseudo-element, or when() contexts`,\n );\n }\n\n return {\n abbr: \"style\",\n defs: {},\n styleArg: arg,\n };\n}\n\n/**\n * Resolve an `add(...)` or `addCss(...)` call.\n *\n * Supported overloads:\n * - `add(cssProp)` to inline an existing CssProp array into the chain output\n * - `addCss(cssProp)` to inline an existing Truss style hash 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: WhenCondition | null,\n): ResolvedSegment {\n const isAddCss = node.name === \"addCss\";\n\n if (isAddCss) {\n if (node.args.length !== 1) {\n throw new UnsupportedPatternError(\n `addCss() requires exactly 1 argument (an existing CssProp/style hash expression)`,\n );\n }\n\n const styleArg = node.args[0];\n if (styleArg.type === \"SpreadElement\") {\n // I.e. reject call-arg spread like `addCss(...xss)`; callers should use `addCss(xss)` or `addCss({ ...xss })`.\n throw new UnsupportedPatternError(`addCss() does not support spread arguments`);\n }\n return {\n abbr: \"__composed_css_prop\",\n defs: {},\n styleArrayArg: styleArg,\n isAddCss: true,\n };\n }\n\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 abbr: \"__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), addCss(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 const literalValue = tryEvaluateAddLiteral(valueArg);\n\n const context: ResolvedConditionContext = {\n mediaQuery,\n pseudoClass,\n pseudoElement,\n whenPseudo,\n };\n\n if (literalValue !== null) {\n return segmentWithConditionContext(\n { abbr: propName, defs: { [propName]: literalValue }, argResolved: literalValue },\n context,\n );\n }\n\n return segmentWithConditionContext(\n {\n abbr: propName,\n defs: {},\n variableProps: [propName],\n incremented: false,\n argNode: valueArg,\n },\n context,\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(selector)` or `when(marker, relationship, pseudo)` call.\n *\n * - 1 arg: `when(\":hover\")` — same-element selector, must be a string literal\n * - 3 args: `when(marker, \"ancestor\", \":hover\")` — marker must be a marker variable or\n * the shared `marker` token, relationship/pseudo must be string literals\n */\nfunction resolveWhenCall(\n node: CallChainNode,\n):\n | { kind: \"selector\"; pseudo: string }\n | { kind: \"relationship\"; pseudo: string; markerNode?: any; relationship: string } {\n if (node.args.length !== 1 && node.args.length !== 3) {\n throw new UnsupportedPatternError(\n `when() expects 1 or 3 arguments (selector) or (marker, relationship, pseudo), got ${node.args.length}`,\n );\n }\n\n if (node.args.length === 1) {\n const pseudoArg = node.args[0];\n if (pseudoArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() selector must be a string literal`);\n }\n return { kind: \"selector\", pseudo: (pseudoArg as any).value };\n }\n\n const markerArg = node.args[0];\n const markerNode = resolveWhenMarker(markerArg);\n const relationshipArg = node.args[1];\n if (relationshipArg.type !== \"StringLiteral\") {\n throw new UnsupportedPatternError(`when() relationship argument must be a string literal`);\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 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 { kind: \"relationship\", pseudo: (pseudoArg as any).value, markerNode, relationship };\n}\n\nfunction resolveWhenMarker(node: t.Expression | t.SpreadElement): any | undefined {\n if (isDefaultMarkerNode(node)) {\n return undefined;\n }\n if (node.type === \"Identifier\") {\n return node;\n }\n throw new UnsupportedPatternError(`when() marker must be a marker variable or marker`);\n}\n\nfunction isDefaultMarkerNode(node: t.Expression | t.SpreadElement): boolean {\n if (node.type === \"Identifier\" && (node.name === \"marker\" || node.name === \"defaultMarker\")) {\n return true;\n }\n return isLegacyDefaultMarkerExpression(node);\n}\n\nfunction isLegacyDefaultMarkerExpression(node: t.Expression | t.SpreadElement): boolean {\n return (\n node.type === \"CallExpression\" &&\n node.arguments.length === 0 &&\n node.callee.type === \"MemberExpression\" &&\n !node.callee.computed &&\n node.callee.property.type === \"Identifier\" &&\n node.callee.property.name === \"defaultMarker\"\n );\n}\n\n// ── Helpers ───────────────────────────────────────────────────────────\n\nconst PSEUDO_METHODS: Record<string, string> = {\n onHover: \":hover\",\n onFocus: \":focus\",\n onFocusVisible: \":focus-visible\",\n onFocusWithin: \":focus-within\",\n onActive: \":active\",\n onDisabled: \":disabled\",\n ifFirstOfType: \":first-of-type\",\n ifLastOfType: \":last-of-type\",\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 * 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 container query 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\n/** Unwrap TS/paren wrappers so nested `when({ ... })` values can be validated uniformly. */\nfunction unwrapExpression(node: t.Expression): t.Expression {\n let current = node;\n\n while (true) {\n if (\n current.type === \"ParenthesizedExpression\" ||\n current.type === \"TSAsExpression\" ||\n current.type === \"TSTypeAssertion\" ||\n current.type === \"TSNonNullExpression\" ||\n current.type === \"TSSatisfiesExpression\"\n ) {\n current = current.expression;\n continue;\n }\n\n return current;\n }\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 _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 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 → static className when possible, otherwise spread trussProps/mergeProps\n if (\n !options.debug &&\n isFullyStaticStyleHash(styleHash) &&\n !hasExistingAttribute(cssAttrPath, \"className\") &&\n !hasExistingAttribute(cssAttrPath, \"style\")\n ) {\n const classNames = extractStaticClassNames(styleHash);\n cssAttrPath.replaceWith(t.jsxAttribute(t.jsxIdentifier(\"className\"), t.stringLiteral(classNames)));\n } else {\n cssAttrPath.replaceWith(t.jsxSpreadAttribute(buildCssSpreadExpression(cssAttrPath, styleHash, line, options)));\n }\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 // Single pass: rewrite Css.props(...) calls and remaining css={...} attributes together\n rewriteCssPropsAndCssAttributes(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 const pendingUnconditionalSegments: ResolvedSegment[] = [];\n\n function flushPendingUnconditionalSegments(): void {\n // I.e. `Css.black.when({ \":hover\": Css.blue.$ }).$` becomes one merged `color: \"black h_blue\"` entry.\n if (pendingUnconditionalSegments.length === 0) {\n return;\n }\n\n const partMembers = buildStyleHashMembers(pendingUnconditionalSegments, 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 pendingUnconditionalSegments.length = 0;\n }\n\n if (chain.markers.length > 0) {\n const markerClasses = chain.markers.map((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 pendingUnconditionalSegments.push(...part.segments);\n } else {\n flushPendingUnconditionalSegments();\n // Conditional: ...(cond ? { then } : { else })\n const thenMembers = mergeConditionalBranchMembers(\n buildStyleHashMembers(part.thenSegments, options),\n previousProperties,\n collectConditionalOnlyProps(part.thenSegments),\n );\n const elseMembers = mergeConditionalBranchMembers(\n buildStyleHashMembers(part.elseSegments, options),\n previousProperties,\n collectConditionalOnlyProps(part.elseSegments),\n );\n members.push(\n t.spreadElement(\n t.conditionalExpression(part.conditionNode, t.objectExpression(thenMembers), t.objectExpression(elseMembers)),\n ),\n );\n }\n }\n\n flushPendingUnconditionalSegments();\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, classNameArg, styleArg) produce\n * spread members or reserved metadata properties.\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 const classNameArgs: t.Expression[] = [];\n const styleKeyCounts = new Map<string, number>();\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.classNameArg) {\n // I.e. `Css.className(cls).df.$` becomes `className_cls: cls` in the style hash.\n classNameArgs.push(t.cloneNode(seg.classNameArg, true) as t.Expression);\n continue;\n }\n\n if (seg.styleArg) {\n flushNormal();\n members.push(buildInlineStyleMember(seg.styleArg as t.Expression, styleKeyCounts));\n continue;\n }\n\n if (seg.styleArrayArg) {\n flushNormal();\n if (seg.isAddCss && t.isObjectExpression(seg.styleArrayArg)) {\n members.push(...buildAddCssObjectMembers(seg.styleArrayArg));\n } else {\n members.push(t.spreadElement(seg.styleArrayArg as t.Expression));\n }\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 // In debug mode, add the abbreviation name as a marker className for multi-property\n // segments so engineers can see the origin in the DOM. I.e. `Css.bb.$` adds \"bb\"\n // alongside \"bbs_solid bbw_1px\", and `Css.lineClamp(n).$` adds \"lineClamp\".\n if (options.debug && !seg.classNameArg && !seg.styleArg && !seg.styleArrayArg && !seg.typographyLookup) {\n const isMultiProp = Object.keys(seg.defs).length > 1;\n const hasExtraDefs = seg.variableExtraDefs && Object.keys(seg.variableExtraDefs).length > 0;\n if (isMultiProp || hasExtraDefs) {\n classNameArgs.push(t.stringLiteral(seg.abbr));\n }\n }\n\n normalSegs.push(seg);\n }\n\n flushNormal();\n if (classNameArgs.length > 0) {\n // Prepend so markers/custom classes appear first in the DOM,\n // I.e. `className=\"bb bbs_solid bbw_1px\"` rather than at the end.\n // Uses unique `className_${key}` keys so spreading preserves all entries.\n members.unshift(...buildCustomClassNameMembers(classNameArgs));\n }\n return members;\n}\n\nfunction buildCustomClassNameMembers(classNameArgs: t.Expression[]): t.ObjectProperty[] {\n const counts = new Map<string, number>();\n\n return classNameArgs.map((arg) => {\n const baseKey = `className_${sanitizeMetadataKey(arg)}`;\n const count = (counts.get(baseKey) ?? 0) + 1;\n counts.set(baseKey, count);\n const key = count === 1 ? baseKey : `${baseKey}_${count}`;\n return t.objectProperty(t.identifier(key), t.cloneNode(arg, true));\n });\n}\n\nfunction buildInlineStyleMember(arg: t.Expression, counts: Map<string, number>): t.ObjectProperty {\n const baseKey = `style_${sanitizeMetadataKey(arg)}`;\n const count = (counts.get(baseKey) ?? 0) + 1;\n counts.set(baseKey, count);\n const key = count === 1 ? baseKey : `${baseKey}_${count}`;\n return t.objectProperty(t.identifier(key), t.cloneNode(arg, true));\n}\n\n/** Derive a valid JS identifier suffix from metadata args. I.e. `\"my-btn\"` → `my_btn`, `vars` → `vars`. */\nfunction sanitizeMetadataKey(arg: t.Expression): string {\n const raw = t.isStringLiteral(arg)\n ? arg.value\n : t.isTemplateLiteral(arg) && arg.expressions.length === 0 && arg.quasis.length === 1\n ? (arg.quasis[0].value.cooked ?? \"\")\n : generate(arg).code;\n\n const sanitized = raw\n .replace(/[^a-zA-Z0-9_$]/g, \"_\")\n .replace(/_+/g, \"_\")\n .replace(/^_+|_+$/g, \"\");\n return sanitized || \"value\";\n}\n\nfunction buildAddCssObjectMembers(styleObject: t.ObjectExpression): (t.ObjectProperty | t.SpreadElement)[] {\n const members: (t.ObjectProperty | t.SpreadElement)[] = [];\n\n for (const property of styleObject.properties) {\n if (t.isSpreadElement(property)) {\n members.push(t.spreadElement(t.cloneNode(property.argument, true) as t.Expression));\n continue;\n }\n\n if (!t.isObjectProperty(property) || property.computed) {\n members.push(t.spreadElement(t.objectExpression([t.cloneNode(property, true)])));\n continue;\n }\n\n const value = property.value;\n if (t.isIdentifier(value) || t.isMemberExpression(value) || t.isOptionalMemberExpression(value)) {\n members.push(\n t.spreadElement(\n t.conditionalExpression(\n t.binaryExpression(\"===\", t.cloneNode(value, true), t.identifier(\"undefined\")),\n t.objectExpression([]),\n t.objectExpression([t.objectProperty(clonePropertyKey(property.key), t.cloneNode(value, true))]),\n ),\n ),\n );\n continue;\n }\n\n members.push(t.spreadElement(t.objectExpression([t.cloneNode(property, true)])));\n }\n\n return members;\n}\n\n/**\n * Collect the set of CSS properties where ALL contributing segments have a condition\n * (pseudo-class, media query, pseudo-element, or when relationship).\n *\n * I.e. `onHover.white` → `color` is conditional-only (needs base merged in),\n * but `bgWhite` → `backgroundColor` is a plain replacement (should NOT merge).\n */\nfunction collectConditionalOnlyProps(segments: ResolvedSegment[]): Set<string> {\n const allProps = new Map<string, boolean>();\n for (const seg of segments) {\n if (seg.error || seg.styleArrayArg || seg.typographyLookup || seg.classNameArg || seg.styleArg) continue;\n const hasCondition = !!(seg.pseudoClass || seg.mediaQuery || seg.pseudoElement || seg.whenPseudo);\n const props = seg.variableProps ?? Object.keys(seg.defs);\n for (const prop of props) {\n const current = allProps.get(prop);\n // If any segment for this property is unconditional, it's not conditional-only\n allProps.set(prop, current === undefined ? hasCondition : current && hasCondition);\n }\n }\n const result = new Set<string>();\n for (const [prop, isConditionalOnly] of allProps) {\n if (isConditionalOnly) result.add(prop);\n }\n return result;\n}\n\n/**\n * Merge prior base properties into conditional branch members, but only for\n * properties that are purely conditional (pseudo/media overlays). Plain\n * base-level replacements should NOT be merged — the spread will correctly\n * override the base when the condition is true.\n */\nfunction mergeConditionalBranchMembers(\n members: (t.ObjectProperty | t.SpreadElement)[],\n previousProperties: Map<string, t.ObjectProperty>,\n conditionalOnlyProps: Set<string>,\n): (t.ObjectProperty | t.SpreadElement)[] {\n return members.map((member) => {\n if (!t.isObjectProperty(member)) {\n return member;\n }\n\n const prop = propertyName(member.key);\n const prior = previousProperties.get(prop);\n if (!prior || !conditionalOnlyProps.has(prop)) {\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((property) => {\n return t.cloneNode(property, true);\n }),\n ...currentVars.properties.map((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((p) => {\n return (\n t.isObjectProperty(p) &&\n !(\n (t.isIdentifier(p.key) && p.key.name.startsWith(\"className_\")) ||\n (t.isStringLiteral(p.key) && p.key.value.startsWith(\"className_\")) ||\n (t.isIdentifier(p.key) && p.key.name.startsWith(\"style_\")) ||\n (t.isStringLiteral(p.key) && p.key.value.startsWith(\"style_\")) ||\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// ---------------------------------------------------------------------------\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// Combined pass: Css.props(...) rewriting + remaining css={...} attributes\n// ---------------------------------------------------------------------------\n\n/**\n * Single traversal that rewrites both `Css.props(expr)` calls and remaining\n * `css={expr}` JSX attributes, avoiding two separate full-AST passes.\n */\nfunction rewriteCssPropsAndCssAttributes(options: RewriteSitesOptions): void {\n traverse(options.ast, {\n // -- Css.props(expr) → trussProps(expr) or mergeProps(...) --\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 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 // -- Remaining css={expr} JSX attributes → {...trussProps(expr)} spreads --\n // I.e. css={someVariable}, css={{ ...a, ...b }}, css={cond ? a : b}\n JSXAttribute(path: NodePath<t.JSXAttribute>) {\n if (!t.isJSXIdentifier(path.node.name, { name: \"css\" })) return;\n if (isRuntimeStyleCssAttribute(path)) 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\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\nfunction isRuntimeStyleCssAttribute(path: NodePath<t.JSXAttribute>): boolean {\n const openingElementPath = path.parentPath;\n if (!openingElementPath || !openingElementPath.isJSXOpeningElement()) return false;\n return t.isJSXIdentifier(openingElementPath.node.name, { name: \"RuntimeStyle\" });\n}\n\n// ---------------------------------------------------------------------------\n// Static style hash detection\n// ---------------------------------------------------------------------------\n\n/** Check whether a style hash has only static string values (no spreads, no tuples). */\nfunction isFullyStaticStyleHash(hash: t.ObjectExpression): boolean {\n for (const prop of hash.properties) {\n if (!t.isObjectProperty(prop)) return false;\n if (!t.isStringLiteral(prop.value)) return false;\n }\n return true;\n}\n\n/** Extract all static class names from a fully-static style hash, joined with spaces. */\nfunction extractStaticClassNames(hash: t.ObjectExpression): string {\n const classNames: string[] = [];\n for (const prop of hash.properties) {\n if (t.isObjectProperty(prop) && t.isStringLiteral(prop.value)) {\n classNames.push(prop.value.value);\n }\n }\n return classNames.join(\" \");\n}\n\n/** Check whether a sibling JSX attribute exists without removing it. */\nfunction hasExistingAttribute(path: NodePath<t.JSXAttribute>, attrName: string): boolean {\n const openingElement = path.parentPath;\n if (!openingElement || !openingElement.isJSXOpeningElement()) return false;\n return openingElement.node.attributes.some((attr) => {\n return t.isJSXAttribute(attr) && t.isJSXIdentifier(attr.name, { name: attrName });\n });\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\";\nimport { camelToKebab } from \"./emit-truss\";\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 * body: `\n * margin: 0;\n * font-size: 14px !important;\n * `,\n * };\n * ```\n *\n * Each key is a CSS selector (string literal), each value is either a `Css.*.$`\n * chain or a string literal / template literal containing raw CSS declarations.\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 // Css import is optional — only needed when Css.*.$ chains are used\n const cssBindingName = findCssImportBinding(ast);\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 const valueNode = prop.value;\n\n // String literal or template literal → pass through as raw CSS\n const rawCss = extractStaticStringValue(valueNode, cssBindingName);\n if (rawCss !== null) {\n rules.push(formatRawCssRule(selector, rawCss));\n continue;\n }\n\n // Otherwise value must be a Css.*.$ expression\n if (!t.isExpression(valueNode)) {\n rules.push(`/* [truss] unsupported: \"${selector}\" value is not an expression */`);\n continue;\n }\n\n if (!cssBindingName) {\n rules.push(`/* [truss] unsupported: \"${selector}\" — Css.*.$ chain requires a Css import */`);\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\n/**\n * Extract a static string from a StringLiteral, a no-expression TemplateLiteral,\n * or a `Css.raw` tagged template literal (i.e. `Css.raw\\`...\\``).\n */\nfunction extractStaticStringValue(node: t.Node, cssBindingName: string | null): string | null {\n if (t.isStringLiteral(node)) return node.value;\n if (t.isTemplateLiteral(node) && node.expressions.length === 0 && node.quasis.length === 1) {\n return node.quasis[0].value.cooked ?? node.quasis[0].value.raw;\n }\n // Css.raw`...` tagged template literal\n if (\n t.isTaggedTemplateExpression(node) &&\n t.isMemberExpression(node.tag) &&\n !node.tag.computed &&\n t.isIdentifier(node.tag.property, { name: \"raw\" }) &&\n t.isIdentifier(node.tag.object, { name: cssBindingName ?? \"\" }) &&\n node.quasi.expressions.length === 0 &&\n node.quasi.quasis.length === 1\n ) {\n return node.quasi.quasis[0].value.cooked ?? node.quasi.quasis[0].value.raw;\n }\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 if (n.type === \"call\" && n.name === \"when\") {\n return { error: \"when() modifiers are not supported in .css.ts files\" };\n }\n }\n\n const resolved = resolveFullChain({ mapping, cssBindingName }, chain);\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 if (seg.styleArg) {\n return { error: `style() 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/** Format a CSS rule block from a raw CSS string, passed through as-is. */\nfunction formatRawCssRule(selector: string, raw: string): string {\n const trimmed = raw.trim();\n if (!trimmed) return `${selector} {}`;\n // Indent each non-empty line by two spaces\n const body = trimmed\n .split(\"\\n\")\n .map((line) => ` ${line.trim()}`)\n .filter((line) => line.trim().length > 0)\n .join(\"\\n\");\n return `${selector} {\\n${body}\\n}`;\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","import { readFileSync } from \"fs\";\n\n/** A parsed CSS rule extracted from an annotated truss.css file. */\nexport interface ParsedCssRule {\n priority: number;\n className: string;\n cssText: string;\n}\n\n/** A parsed @property declaration extracted from an annotated truss.css file. */\nexport interface ParsedPropertyDeclaration {\n cssText: string;\n /** The variable name, i.e. `--marginTop`. */\n varName: string;\n}\n\n/** A parsed arbitrary CSS block extracted from an annotated truss.css file. */\nexport interface ParsedArbitraryCssBlock {\n cssText: string;\n}\n\n/** The result of parsing an annotated truss.css file. */\nexport interface ParsedTrussCss {\n rules: ParsedCssRule[];\n properties: ParsedPropertyDeclaration[];\n arbitraryCssBlocks?: ParsedArbitraryCssBlock[];\n}\n\n/** Regex matching `/* @truss p:<priority> c:<className> *\\/` annotations. */\nconst RULE_ANNOTATION_RE = /^\\/\\* @truss p:([\\d.]+) c:(\\S+) \\*\\/$/;\n\n/** Regex matching `/* @truss @property *\\/` annotations. */\nconst PROPERTY_ANNOTATION_RE = /^\\/\\* @truss @property \\*\\/$/;\n\n/** Regex matching the start of an annotated arbitrary CSS block. */\nconst ARBITRARY_START_RE = /^\\/\\* @truss arbitrary:start \\*\\/$/;\n\n/** Regex matching the end of an annotated arbitrary CSS block. */\nconst ARBITRARY_END_RE = /^\\/\\* @truss arbitrary:end \\*\\/$/;\n\n/** Regex to extract the variable name from `@property --foo { ... }`. */\nconst PROPERTY_VAR_RE = /^@property\\s+(--\\S+)/;\n\n/**\n * Parse an annotated truss.css file into rules, @property declarations,\n * and arbitrary CSS blocks.\n *\n * The file must contain `/* @truss p:<priority> c:<className> *\\/` comments\n * before each CSS rule, and `/* @truss @property *\\/` before each @property declaration.\n */\nexport function parseTrussCss(cssText: string): ParsedTrussCss {\n const lines = cssText.split(\"\\n\");\n const rules: ParsedCssRule[] = [];\n const properties: ParsedPropertyDeclaration[] = [];\n const arbitraryCssBlocks: ParsedArbitraryCssBlock[] = [];\n\n let i = 0;\n while (i < lines.length) {\n const line = lines[i].trim();\n\n // Check for rule annotation\n const ruleMatch = RULE_ANNOTATION_RE.exec(line);\n if (ruleMatch) {\n const priority = parseFloat(ruleMatch[1]);\n const className = ruleMatch[2];\n // Next non-empty line is the CSS rule\n i++;\n while (i < lines.length && lines[i].trim() === \"\") i++;\n if (i < lines.length) {\n rules.push({ priority, className, cssText: lines[i].trim() });\n }\n i++;\n continue;\n }\n\n // Check for @property annotation\n if (PROPERTY_ANNOTATION_RE.test(line)) {\n i++;\n while (i < lines.length && lines[i].trim() === \"\") i++;\n if (i < lines.length) {\n const propLine = lines[i].trim();\n const varMatch = PROPERTY_VAR_RE.exec(propLine);\n if (varMatch) {\n properties.push({ cssText: propLine, varName: varMatch[1] });\n }\n }\n i++;\n continue;\n }\n\n if (ARBITRARY_START_RE.test(line)) {\n i++;\n const blockLines: string[] = [];\n while (i < lines.length && !ARBITRARY_END_RE.test(lines[i].trim())) {\n blockLines.push(lines[i]);\n i++;\n }\n const blockText = blockLines.join(\"\\n\").trim();\n if (blockText.length > 0) {\n arbitraryCssBlocks.push({ cssText: blockText });\n }\n if (i < lines.length && ARBITRARY_END_RE.test(lines[i].trim())) {\n i++;\n }\n continue;\n }\n\n i++;\n }\n\n return { rules, properties, arbitraryCssBlocks };\n}\n\n/**\n * Read and parse an annotated truss.css file from disk.\n *\n * Throws if the file doesn't exist or can't be read.\n */\nexport function readTrussCss(filePath: string): ParsedTrussCss {\n const content = readFileSync(filePath, \"utf8\");\n return parseTrussCss(content);\n}\n\n/** Wrap an arbitrary CSS block in annotations so it survives later Truss merges. */\nexport function annotateArbitraryCssBlock(cssText: string): string {\n const trimmed = cssText.trim();\n if (trimmed.length === 0) {\n return \"\";\n }\n return [\"/* @truss arbitrary:start */\", trimmed, \"/* @truss arbitrary:end */\"].join(\"\\n\");\n}\n\n/**\n * Merge multiple parsed truss CSS sources into a single CSS string.\n *\n * Rules are deduplicated by class name (first occurrence wins, since\n * deterministic output means identical class names produce identical rules),\n * then sorted by priority ascending with alphabetical class name tiebreaker.\n * @property declarations are deduplicated by variable name and appended next.\n * Arbitrary CSS blocks are left opaque and appended in source order at the end.\n */\nexport function mergeTrussCss(sources: ParsedTrussCss[]): string {\n const seenClasses = new Set<string>();\n const allRules: ParsedCssRule[] = [];\n const seenProperties = new Set<string>();\n const allProperties: ParsedPropertyDeclaration[] = [];\n const allArbitraryCssBlocks: ParsedArbitraryCssBlock[] = [];\n\n for (const source of sources) {\n for (const rule of source.rules) {\n if (!seenClasses.has(rule.className)) {\n seenClasses.add(rule.className);\n allRules.push(rule);\n }\n }\n for (const prop of source.properties) {\n if (!seenProperties.has(prop.varName)) {\n seenProperties.add(prop.varName);\n allProperties.push(prop);\n }\n }\n allArbitraryCssBlocks.push(...(source.arbitraryCssBlocks ?? []));\n }\n\n // Sort by priority ascending, tiebreak alphabetically by class name\n allRules.sort((a, b) => {\n const diff = a.priority - b.priority;\n if (diff !== 0) return diff;\n return a.className < b.className ? -1 : a.className > b.className ? 1 : 0;\n });\n\n const lines: string[] = [];\n\n for (const rule of allRules) {\n lines.push(`/* @truss p:${rule.priority} c:${rule.className} */`);\n lines.push(rule.cssText);\n }\n\n for (const prop of allProperties) {\n lines.push(`/* @truss @property */`);\n lines.push(prop.cssText);\n }\n\n for (const block of allArbitraryCssBlocks) {\n lines.push(annotateArbitraryCssBlock(block.cssText));\n }\n\n return lines.join(\"\\n\");\n}\n","import { readFileSync, writeFileSync, mkdirSync } from \"fs\";\nimport { resolve, 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 { loadMapping } from \"./index\";\nimport { annotateArbitraryCssBlock } from \"./merge-css\";\n\nexport interface TrussEsbuildPluginOptions {\n /** Path to the Css.json mapping file (relative to cwd or absolute). */\n mapping: string;\n /** Output path for the generated truss.css (relative to outDir or absolute). Defaults to `truss.css`. */\n outputCss?: string;\n}\n\n/**\n * esbuild plugin that transforms `Css.*.$` expressions, collects `.css.ts` blocks,\n * and emits a `truss.css` file.\n *\n * Designed for library builds using tsup/esbuild. Transforms source files\n * during the build and writes an annotated `truss.css` alongside the output\n * that consuming applications can merge via the Vite plugin's `libraries` option.\n *\n * Usage with tsup:\n * ```ts\n * import { trussEsbuildPlugin } from \"@homebound/truss/plugin\";\n *\n * export default defineConfig({\n * esbuildPlugins: [trussEsbuildPlugin({ mapping: \"./src/Css.json\" })],\n * });\n * ```\n */\nexport function trussEsbuildPlugin(opts: TrussEsbuildPluginOptions) {\n const cssRegistry = new Map<string, AtomicRule>();\n const arbitraryCssRegistry = new Map<string, string>();\n let mapping: TrussMapping | null = null;\n let outDir: string | undefined;\n\n return {\n name: \"truss\",\n setup(build: EsbuildPluginBuild) {\n // Resolve outDir from esbuild config\n outDir = build.initialOptions.outdir ?? build.initialOptions.outdir;\n\n build.onLoad({ filter: /\\.[cm]?[jt]sx?$/ }, (args: { path: string }) => {\n const code = readFileSync(args.path, \"utf8\");\n\n if (args.path.endsWith(\".css.ts\")) {\n if (!mapping) {\n mapping = loadMapping(resolve(process.cwd(), opts.mapping));\n }\n\n const css = annotateArbitraryCssBlock(transformCssTs(code, args.path, mapping));\n if (css.length > 0) {\n arbitraryCssRegistry.set(args.path, css);\n } else {\n arbitraryCssRegistry.delete(args.path);\n }\n\n return { contents: code, loader: loaderForPath(args.path) };\n }\n\n if (!code.includes(\"Css\") && !code.includes(\"css=\")) return undefined;\n\n if (!mapping) {\n mapping = loadMapping(resolve(process.cwd(), opts.mapping));\n }\n\n const result = transformTruss(code, args.path, mapping);\n if (!result) return undefined;\n\n // Merge rules into the shared registry\n if (result.rules) {\n for (const [className, rule] of result.rules) {\n if (!cssRegistry.has(className)) {\n cssRegistry.set(className, rule);\n }\n }\n }\n\n return { contents: result.code, loader: loaderForPath(args.path) };\n });\n\n build.onEnd(() => {\n if (cssRegistry.size === 0 && arbitraryCssRegistry.size === 0) return;\n\n const cssParts = [generateCssText(cssRegistry), ...arbitraryCssRegistry.values()].filter(\n (part) => part.length > 0,\n );\n const css = cssParts.join(\"\\n\");\n const cssFileName = opts.outputCss ?? \"truss.css\";\n const cssPath = resolve(outDir ?? join(process.cwd(), \"dist\"), cssFileName);\n\n mkdirSync(resolve(cssPath, \"..\"), { recursive: true });\n writeFileSync(cssPath, css, \"utf8\");\n });\n },\n };\n}\n\n/** Map file extension to esbuild loader type. */\nfunction loaderForPath(filePath: string): string {\n if (filePath.endsWith(\".tsx\")) return \"tsx\";\n if (filePath.endsWith(\".ts\")) return \"ts\";\n if (filePath.endsWith(\".jsx\")) return \"jsx\";\n return \"js\";\n}\n\n/**\n * Minimal esbuild plugin types so we don't need esbuild as a dependency.\n *\n * These match the subset of the esbuild Plugin API that we use.\n */\ninterface EsbuildPluginBuild {\n initialOptions: { outdir?: string };\n onLoad(\n options: { filter: RegExp },\n callback: (args: { path: string }) => { contents: string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,qBAAqB,GAAG;AACxC,UAAAE,eAAc,UAAU,KAAK,QAAQ,uBAAuB,IAAI,kBAAkB,EAAE,GAAG,MAAM;AAAA,QAC/F;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;AAEA,SAAS,kBAAkB,QAAgB,UAA8B,aAAyC;AAChH,MAAI,WAAW,MAAM,GAAG;AACtB,WAAO;AAAA,EACT;AAEA,MAAI,UAAU;AACZ,WAAOH,SAAQ,QAAQ,QAAQ,GAAG,MAAM;AAAA,EAC1C;AAEA,SAAOA,SAAQ,eAAe,QAAQ,IAAI,GAAG,MAAM;AACrD;AAGA,SAAS,kBAAkB,IAAoB;AAC7C,QAAM,aAAa,GAAG,QAAQ,GAAG;AACjC,QAAM,YAAY,GAAG,QAAQ,GAAG;AAEhC,MAAI,MAAM,GAAG;AACb,MAAI,cAAc,EAAG,OAAM,KAAK,IAAI,KAAK,UAAU;AACnD,MAAI,aAAa,EAAG,OAAM,KAAK,IAAI,KAAK,SAAS;AAEjD,QAAM,UAAU,GAAG,MAAM,GAAG,GAAG;AAE/B,MAAI,QAAQ,WAAW,OAAO,GAAG;AAC/B,WAAO,QAAQ,MAAM,CAAC;AAAA,EACxB;AACA,SAAO;AACT;AAEA,SAAS,kBAAkB,UAA2B;AACpD,SAAO,SAAS,QAAQ,OAAO,GAAG,EAAE,SAAS,gBAAgB;AAC/D;AAEA,SAAS,6BAA6B,MAAc,cAA2D;AAG7G,MAAI,CAAC,cAAc;AACjB,WAAO,EAAE,MAAM,SAAS,MAAM;AAAA,EAChC;AAEA,SAAO;AAAA,IACL,MAAM,GAAG,IAAI;AAAA,UAAa,mBAAmB;AAAA,IAC7C,SAAS;AAAA,EACX;AACF;AAGO,SAAS,YAAY,MAA4B;AACtD,QAAM,MAAMC,cAAa,MAAM,MAAM;AACrC,SAAO,KAAK,MAAM,GAAG;AACvB;","names":["readFileSync","writeFileSync","resolve","join","_traverse","_generate","t","t","resolveCssChainReference","resolved","pseudoArg","t","traverse","_traverse","generate","_generate","resolveCssChainReference","isRuntimeStyleCssAttribute","seen","parse","t","t","parse","parse","_generate","t","generate","_generate","parse","readFileSync","readFileSync","resolve","readFileSync","join","writeFileSync"]}
|