@theme-registry/refract-styled-components 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +5 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +3 -3
- package/dist/index.esm.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var e=require("@theme-registry/refract"),t=require("styled-components");const n={link:":link",visited:":visited",hover:":hover",focus:":focus",active:":active",disabled:"[disabled]",pressed:"[aria-pressed]"},
|
|
1
|
+
"use strict";var e=require("@theme-registry/refract"),t=require("styled-components");const n={link:":link",visited:":visited",hover:":hover",focus:":focus",active:":active",disabled:"[disabled]",pressed:"[aria-pressed]"},s=Object.keys(n),o=s.reduce((e,t,n)=>(e[t]=n,e),{}),r=e=>e.map((e,t)=>({override:e,index:t})).sort((e,t)=>{var n,s;const r=null!==(n=o[e.override.state])&&void 0!==n?n:Number.MAX_SAFE_INTEGER,i=null!==(s=o[t.override.state])&&void 0!==s?s:Number.MAX_SAFE_INTEGER;if(r!==i)return r-i;const a=e.override.breakpoint?1:0,c=t.override.breakpoint?1:0;return a!==c?a-c:e.index-t.index}).map(({override:e})=>e),i="exact",a=e=>e.split(/[^a-zA-Z0-9]+/).filter(Boolean),c=e=>{const t=e.flatMap(a);if(!t.length)return"_";const n=t.map((e,t)=>{return 0===t?(n=e).charAt(0).toLowerCase()+n.slice(1):(e=>e.charAt(0).toUpperCase()+e.slice(1))(e);var n}).join("");return/^[0-9]/.test(n)?`_${n}`:n},l=e=>c(e),d=e=>{const[t,...n]=e.split(".");return{subsystem:t,key:l(n)}},m=e=>{const t=new Map;return{recipeExportName(n,s,o){const r=[n,s,o];let i=c(r);if(null==e?void 0:e.className){const t=r.map(e=>a(e).join("-")).join("-"),l=e.className({kind:"recipe",subsystem:n,group:s,variant:o},{classToken:"",name:t});if(i=c(a(l)),!i||"_"===i)throw new Error(`styled-components emit: className override returned an empty/invalid identifier for "${n}.${s}.${o}"`)}return((e,n)=>{const s=t.get(e);if(void 0!==s&&s!==n)throw new Error(`styled-components emit: recipe identifier "${e}" is produced by both "${s}" and "${n}" — the naming override must map distinct recipes to distinct identifiers`);t.set(e,n)})(i,`${n}.${s}.${o}`),i}}},p=(e,t,n)=>{if(void 0!==e.struct)return;if(void 0!==e.external)return`var(${e.external})`;const s=void 0!==e.value?e.value:n(t);return void 0!==e.unit?`${s}${e.unit}`:s},u=" ",h=(e,t)=>{const n=u.repeat(t),s=u.repeat(t+1);return`{\n${Object.entries(e).map(([e,t])=>{return`${s}${e}: ${n=t,"number"==typeof n?String(n):JSON.stringify(n)},`;var n}).join("\n")}\n${n}}`},f=(e,t)=>Object.entries(e).map(([e,n])=>`${u.repeat(t)}${e}: ${h(n,t)},`),v=(e,t)=>{const n=["{"];if(n.push(...f(e.tree,1)),e.modeNames.length){n.push(`${u}modes: {`);for(const t of e.modeNames)n.push(`${u.repeat(2)}${t}: {`),n.push(...f(e.modes[t],3)),n.push(`${u.repeat(2)}},`);n.push(`${u}},`)}for(const e of t)n.push(`${u}${e},`);return n.push("}"),n.join("\n")},y=e=>null==e?"":String(e),$=(e,t)=>{if(void 0===e.ref)return[{lit:y(e.value)}];if(!t.tokenPaths.has(e.ref))return;const n={ref:e.ref};return e.wrap?[{lit:`${e.wrap}(`},n,{lit:")"}]:[n]},b=(e,t)=>{const n=[];for(const[s,o]of Object.entries(null!=e?e:{})){const e=$(o,t);e&&n.push({type:"decl",property:s,value:e})}return n},g=e=>{const[t,n]=e.split(":");if(!t||!n)return;const s=n.indexOf(".");return s<0?void 0:{subsystem:t,group:n.slice(0,s),variant:n.slice(s+1)}},j=(e,t)=>{const n="dark"===e||"light"===e;return{media:n&&("media"===t||"both"===t),attribute:"attribute"===t||"both"===t||"media"===t&&!n}},k=(e,t,n)=>{const s=n.modeOverridePaths[t];if(!s)return[];const o=[];for(const[n,r]of Object.entries(null!=e?e:{}))void 0!==r.ref&&s.has(r.ref)&&o.push({type:"decl",property:n,value:[{modeRef:{mode:t,path:r.ref}}]});return o},O=(e,t)=>{var s,o,a;const c=[];for(const t of null!==(s=e.references)&&void 0!==s?s:[]){const e=g(t);e&&c.push({type:"spread",...e})}c.push(...b(e.declarations,t.data));for(const n of e.overrides){if(void 0!==n.state||!n.breakpoint)continue;const e=b(n.declarations,t.data);e.length&&c.push({type:"media",breakpoint:n.breakpoint,query:null!==(o=n.query)&&void 0!==o?o:i,orientation:n.orientation,children:e})}const l=e.overrides.filter(e=>void 0!==e.state);for(const e of r(l)){const s=n[e.state],o=b(e.declarations,t.data);if(!s||!o.length)continue;const r={type:"block",selector:`&${s}`,children:o};e.breakpoint?c.push({type:"media",breakpoint:e.breakpoint,query:null!==(a=e.query)&&void 0!==a?a:i,orientation:e.orientation,children:[r]}):c.push(r)}for(const s of t.data.modeNames){const o=k(e.declarations,s,t.data),i=[];for(const e of r(l)){const o=n[e.state];if(!o)continue;const r=k(e.declarations,s,t.data);r.length&&i.push({type:"block",selector:`&${o}`,children:r})}const a=[...o,...i];if(!a.length)continue;const{media:d,attribute:m}=j(s,t.scheme);d&&c.push({type:"scheme",mode:s,children:a}),m&&c.push({type:"block",selector:`[data-theme="${s}"] &`,children:a})}return c},x=" ",S=(e,t)=>{const{subsystem:n,key:s}=d(e);return t?`theme.modes.${t}.${n}.${s}`:`theme.${n}.${s}`},N=(e,t,n,s)=>{switch(e.type){case"decl":return`${t}${e.property}: ${((e,t)=>e.map(e=>{if("lit"in e)return e.lit;const n="ref"in e?S(e.ref):S(e.modeRef.path,e.modeRef.mode);return t?`\${${n}}`:`\${({ theme }) => ${n}}`}).join(""))(e.value,n)};`;case"spread":return`${t}\${${s.spreadName(e.subsystem,e.group,e.variant)}}`;case"block":{const o=e.children.map(e=>N(e,t+x,n,s)).join("\n");return`${t}${e.selector} {\n${o}\n${t}}`}case"media":{const n=e.orientation?`theme.media.${e.query}(${JSON.stringify(e.breakpoint)}, { orientation: ${JSON.stringify(e.orientation)} })`:`theme.media.${e.breakpoint}.${e.query}`,o=e.children.map(e=>N(e,t+x,!0,s)).join("\n");return`${t}\${({ theme }) => ${n}\`\n${o}\n${t}\`}`}case"scheme":{const n=e.children.map(e=>N(e,t+x,!0,s)).join("\n");return`${t}\${({ theme }) => theme.scheme.${e.mode}\`\n${n}\n${t}\`}`}}},w=(e,t)=>e.map(e=>N(e,x,!1,t)).join("\n"),q=(e,t,n)=>{var s,o;const{subsystem:r,key:i}=d(t),a=n?null===(s=null==e?void 0:e.modes)||void 0===s?void 0:s[n]:e;return null===(o=null==a?void 0:a[r])||void 0===o?void 0:o[i]},E=(e,t,n,s)=>{var o;switch(e.type){case"decl":return`${e.property}: ${((e,t)=>e.map(e=>"lit"in e?e.lit:y("ref"in e?q(t,e.ref):q(t,e.modeRef.path,e.modeRef.mode))).join(""))(e.value,t)};`;case"spread":return s(e.subsystem,e.group,e.variant,t);case"block":{const o=e.children.map(e=>E(e,t,n,s)).join(" ");return`${e.selector} { ${o} }`}case"media":{const o=((e,t,n,s)=>{var o,r;if(!s)return null!==(r=null===(o=e[t])||void 0===o?void 0:o[n])&&void 0!==r?r:"";const i={orientation:s};return"min"===n?e.min(t,i):"max"===n?e.max(t,i):e.exact(t,i)})(n.media,e.breakpoint,e.query,e.orientation),r=e.children.map(e=>E(e,t,n,s)).join(" ");return o?`${o} { ${r} }`:r}case"scheme":{const r=null!==(o=n.prefers[e.mode])&&void 0!==o?o:"",i=e.children.map(e=>E(e,t,n,s)).join(" ");return r?`${r} { ${i} }`:i}}},B=(e,t,n,s)=>e.map(e=>E(e,t,n,s)).join("\n"),A=new Set(["min","max","between","exact"]),M=e=>{const t={min:(t,n)=>J(e.min(t,n)),max:(t,n)=>J(e.max(t,n)),between:(t,n,s)=>J(e.between(t,n,s))};for(const n of Object.keys(e))A.has(n)||(t[n]=R(e[n]));return t},R=e=>{const t={};return Object.keys(e).forEach(n=>{t[n]=J(e[n])}),t},J=e=>Object.assign(T(e),{query:e}),T=e=>e?(n,...s)=>t.css`
|
|
2
2
|
${e} {
|
|
3
|
-
${t.css(n,...
|
|
3
|
+
${t.css(n,...s)}
|
|
4
4
|
}
|
|
5
5
|
`:(e,...n)=>t.css`
|
|
6
6
|
${t.css(e,...n)}
|
|
7
|
-
`,P={dark:"@media (prefers-color-scheme: dark)",light:"@media (prefers-color-scheme: light)"},
|
|
7
|
+
`,P={dark:"@media (prefers-color-scheme: dark)",light:"@media (prefers-color-scheme: light)"},G=e=>e.filter(e=>e in P),_=e=>(n,...s)=>t.css`
|
|
8
8
|
${e} {
|
|
9
|
-
${t.css(n,...
|
|
9
|
+
${t.css(n,...s)}
|
|
10
10
|
}
|
|
11
|
-
`,C=["min","max","exact"],z=["lighten","darken","alpha"],
|
|
11
|
+
`,C=["min","max","exact"],z=["lighten","darken","alpha"],F=(e,t)=>`// Vendored, self-contained styled-components media helper (generated by @theme-registry/refract).\n// Only dependency: styled-components. Concrete @media strings are baked in for this theme's breakpoints.\nimport { css } from "styled-components";\n\nconst wrap = (query) => {\n const fn = query\n ? (styles, ...interpolations) => css\`\${query} { \${css(styles, ...interpolations)} }\`\n : (styles, ...interpolations) => css\`\${css(styles, ...interpolations)}\`;\n fn.query = query;\n return fn;\n};\n\nexport const media = {\n${Object.keys(e).sort((t,n)=>e[t]-e[n]).map(e=>{const n=t[e],s=C.map(e=>{var t;return` ${e}: wrap(${JSON.stringify(null!==(t=null==n?void 0:n[e])&&void 0!==t?t:"")}),`}).join("\n");return` ${JSON.stringify(e)}: {\n${s}\n },`}).join("\n")}\n};\n\nexport default media;\n`,I=(e,t)=>`import { ${[e?"css":"",t?"createGlobalStyle":""].filter(Boolean).join(", ")} } from "styled-components";`,V=e=>{const t=['import { media } from "./media";'];return e.usesScheme&&t.push('import { scheme } from "./scheme";'),e.helpers.includes("color-math")&&t.push(`import { ${z.join(", ")} } from "./color-math";`),t},W=e=>`export const theme = ${e} as const;`,Z=e=>e.map(e=>`export const ${e.exportName} = css\`\n${e.body}\n\`;`).join("\n\n"),D=e=>`export const recipes = ${e} as const;`,U=e=>`export const GlobalStyle = createGlobalStyle\`\n${e}\n\`;`,X=e=>(e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e))(e)?e:JSON.stringify(e),H=(e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const s=n();return Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0}),s}})};exports.createStyledComponentsAdapter=(n={})=>{var o,r,i;const a=null!==(o=n.language)&&void 0!==o?o:"ts",c=null!==(r=n.scheme)&&void 0!==r?r:"media",d=null!==(i=n.helpers)&&void 0!==i?i:[],u={name:"styled-components",version:1,allowedStates:s,bind(e,s){var o,r;const i=s.media,u=m(n.naming),h=((e,t)=>{var n,s,o,r,i,a,c,d,m,u;const h={},f={},v=[],y=new Set,$={},b=(e,n,s,o)=>{var r;const i=p(o,s,t);void 0!==i&&((null!==(r=h[e])&&void 0!==r?r:h[e]={})[n]=i,y.add(s))};for(const[h,y]of Object.entries(e.subsystems))for(const[e,g]of Object.entries(null!==(n=y.properties)&&void 0!==n?n:{})){b(h,l([e]),`${h}.${e}`,g.base);for(const[t,n]of Object.entries(null!==(s=g.extras)&&void 0!==s?s:{}))b(h,l([e,t]),`${h}.${e}.${t}`,n);for(const[t,n]of Object.entries(null!==(o=g.variants)&&void 0!==o?o:{})){b(h,l([e,t]),`${h}.${e}.${t}`,n.base);for(const[s,o]of Object.entries(null!==(r=n.extras)&&void 0!==r?r:{}))b(h,l([e,t,s]),`${h}.${e}.${t}.${s}`,o)}for(const n of null!==(i=g.modes)&&void 0!==i?i:[]){const s=n.mode;if(void 0===s)continue;const o=n.target,r=o?[e,o]:[e],i=o?`${h}.${e}.${o}`:`${h}.${e}`;for(const[o,y]of Object.entries(null!==(a=n.overrides)&&void 0!==a?a:{})){const n=p(y,`${h}.${e}`,t);if(void 0===n)continue;const a=l("base"===o?r:[...r,o]),b="base"===o?i:`${i}.${o}`;v.includes(s)||v.push(s),(null!==(d=(u=null!==(c=f[s])&&void 0!==c?c:f[s]={})[h])&&void 0!==d?d:u[h]={})[a]=n,(null!==(m=$[s])&&void 0!==m?m:$[s]=new Set).add(b)}}}return{tree:h,modes:f,modeNames:v,tokenPaths:y,modeOverridePaths:$}})(e,s.resolve),f={model:e,media:i,data:h,scheme:c,prefers:P},y=("media"===c||"both"===c)&&G(h.modeNames).length>0,$=(e,t,n)=>`${e}.${t}.${n}`,g=new Map,j=[];for(const[t,n]of Object.entries(e.subsystems))if("globals"!==t)for(const[e,s]of Object.entries(null!==(o=n.ruleSets)&&void 0!==o?o:{}))for(const[n,o]of Object.entries(s))g.set($(t,e,n),O(o,f)),j.push({subsystem:t,group:e,variant:n});const k=(e,t,n,s)=>{const o=g.get($(e,t,n));return o?B(o,s,f,k):""},x=(e,n,s)=>{var o;const r=null!==(o=g.get($(e,n,s)))&&void 0!==o?o:[];return t.css`${({theme:e})=>B(r,e,f,k)}`},S=M(i),N=y?(e=>{const t={};for(const n of G(e)){const e=P[n];t[n]=Object.assign(_(e),{query:e})}return t})(h.modeNames):void 0,q={media:S};N&&(q.scheme=N);const E=((e,t)=>{const n={};for(const[t,s]of Object.entries(e.tree))n[t]={...s};if(e.modeNames.length){const t={};for(const n of e.modeNames){const s={};for(const[t,o]of Object.entries(e.modes[n]))s[t]={...o};t[n]=s}n.modes=t}return Object.assign(n,t),n})(h,q),A=()=>{var e,t;const n={};for(const{subsystem:s,group:o,variant:r}of j){const i=null!==(e=n[s])&&void 0!==e?e:n[s]={},a=null!==(t=i[o])&&void 0!==t?t:i[o]={};H(a,r,()=>x(s,o,r))}return n},R=((e,t)=>{var n;const s=[];for(const o of Object.values(null!=e?e:{}))for(const e of Object.values(o))if(e.selector)if("globals"===e.kind){const o=O(e,t);for(const[s,r]of Object.entries(null!==(n=e.variants)&&void 0!==n?n:{})){const n={kind:"globals",selector:e.selector,declarations:r.declarations,overrides:r.overrides},i=O(n,t);i.length&&o.push({type:"block",selector:`&.${s}`,children:i})}o.length&&s.push({type:"block",selector:e.selector,children:o})}else{const n=b(e.declarations,t.data);n.length&&s.push({type:"block",selector:e.selector,children:n})}return s})(null===(r=e.subsystems.globals)||void 0===r?void 0:r.ruleSets,f),J=R.length?t.createGlobalStyle`${({theme:e})=>B(R,e,f,k)}`:void 0;return{recipeName:(e,t,n)=>u.recipeExportName(e,t,n),describePreview:()=>({stylesheets:[],unavailable:"This target emits JavaScript modules that render through React + styled-components, so there is no stylesheet a browser can load. Token values below are exact. For a live render, add a CSS target to the same config — it compiles the same recipes."}),describeUsage:()=>({format:"styled-components",summary:["This theme is emitted as TypeScript/JavaScript modules: a literal `theme` object plus tree-shakeable `css` recipe exports (and a `GlobalStyle` if the theme defines globals).",'Wrap your app once in styled-components\' `ThemeProvider` with the exported `theme`: `import { theme } from "./theme";` then `<ThemeProvider theme={theme}>`.',"Apply a recipe by spreading its `css` export into a styled component: ``styled.button`${componentsButtonsPrimary}` ``. Recipes read their values from `props.theme`, so there is no `var()` and no separate stylesheet.","If the theme defines globals, render `<GlobalStyle />` once inside the provider."],recipes:j.map(({subsystem:e,group:t,variant:n})=>({subsystem:e,group:t,variant:n,name:u.recipeExportName(e,t,n)}))}),renderRecipe:(n,s,o)=>((t,n,s)=>{var o,r,i;return null===(i=null===(r=null===(o=e.subsystems[t])||void 0===o?void 0:o.ruleSets)||void 0===r?void 0:r[n])||void 0===i?void 0:i[s]})(n,s,o)?x(n,s,o):t.css``,renderVariables:()=>t.css``,join:e=>e.flat(),extend(){const e={theme:E,recipes:A(),media:S};return N&&(e.scheme=N),J&&(e.GlobalStyle=J),e},emit:t=>{var n,s,o;const r=null!==(n=null==t?void 0:t.type)&&void 0!==n?n:"single";if("single"!==r&&"split"!==r)throw new Error(`styled-components adapter: emit mode '${r}' is not supported — the TS/JS target emits 'single' or 'split' (ES modules tree-shake per export; 'subsystem'/'components' are CSS-only concerns).`);const c=(e,t,n)=>u.recipeExportName(e,t,n),l=j.map(({subsystem:e,group:t,variant:n})=>{var s;return{exportName:u.recipeExportName(e,t,n),body:w(null!==(s=g.get($(e,t,n)))&&void 0!==s?s:[],{spreadName:c})}}),m=["{"],p=new Map;for(const e of j)(null!==(s=p.get(e.subsystem))&&void 0!==s?s:p.set(e.subsystem,[]).get(e.subsystem)).push(e);for(const[e,t]of p){m.push(` ${e}: {`);const n=new Map;for(const{group:e,variant:s}of t)(null!==(o=n.get(e))&&void 0!==o?o:n.set(e,[]).get(e)).push(s);for(const[t,s]of n){m.push(` ${X(t)}: {`);for(const n of s)m.push(` ${X(n)}: ${u.recipeExportName(e,t,n)},`);m.push(" },")}m.push(" },")}m.push("}");const f=["media",...y?["scheme"]:[],...d.includes("color-math")?z:[]];var b;return(e=>{const t={},n={"media.ts":e.vendorMedia};e.vendorScheme&&(n["scheme.ts"]=e.vendorScheme);const s=e.recipes.length>0,o=void 0!==e.resetBody;if("single"===e.emitMode){const n=[];n.push([I(s,o),...V(e)].join("\n")),n.push(W(e.themeObjectBody)),s&&(n.push(Z(e.recipes)),n.push(D(e.recipesBarrelBody))),o&&n.push(U(e.resetBody)),t["theme.ts"]=n.join("\n\n")+"\n"}else t["theme.ts"]=[V(e).join("\n"),W(e.themeObjectBody)].join("\n\n")+"\n",s&&(t["recipes.ts"]=[I(!0,!1),Z(e.recipes),D(e.recipesBarrelBody)].join("\n\n")+"\n"),o&&(t["global.ts"]=[I(!1,!0),U(e.resetBody)].join("\n\n")+"\n");if("ts"===e.language&&(t["theme.d.ts"]='import "styled-components";\nimport type { theme } from "./theme";\n\ndeclare module "styled-components" {\n export interface DefaultTheme extends Readonly<typeof theme> {}\n}\n'),"js"===e.language){for(const e of Object.keys(t))e.endsWith(".ts")&&!e.endsWith(".d.ts")&&(t[e.replace(/\.ts$/,".js")]=t[e],delete t[e]);for(const e of Object.keys(n))n[e.replace(/\.ts$/,".js")]=n[e],delete n[e]}return{files:t,vendorHelpers:n}})({language:a,emitMode:r,helpers:d,usesScheme:y,themeObjectBody:v(h,f),recipes:l,recipesBarrelBody:m.join("\n"),resetBody:R.length?w(R,{spreadName:c}):void 0,vendorMedia:F(e.breakpoints,i),vendorScheme:y?(b=h.modeNames,`// Vendored, self-contained styled-components colour-scheme helper (generated by @theme-registry/refract).\n// Only dependency: styled-components. Realizes appearance modes as prefers-color-scheme media blocks.\nimport { css } from "styled-components";\n\nconst wrap = (query) => {\n const fn = (styles, ...interpolations) => css\`\${query} { \${css(styles, ...interpolations)} }\`;\n fn.query = query;\n return fn;\n};\n\nexport const scheme = {\n${G(b).map(e=>` ${JSON.stringify(e)}: wrap(${JSON.stringify(P[e])}),`).join("\n")}\n};\n\nexport default scheme;\n`):void 0})}}}};return e.defineAdapter(u)},exports.wrapMediaDescriptor=M;
|
|
12
12
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/lowering.ts","../src/identifiers.ts","../src/theme-object.ts","../src/recipe.ts","../src/media.ts","../src/scheme.ts","../src/emit.ts","../src/index.ts"],"sourcesContent":["/**\n * Shared lowering helpers for the styled-components adapter — the format-neutral bits the recipe IR\n * builder ({@link ../recipe}) and both sinks (emit-source / runtime-live) lean on: the state-selector\n * table the adapter owns, canonical LVHA state ordering, and breakpoint → concrete `@media` string\n * resolution. It imports **only** core (Model + media types), so the adapter stays liftable to its own\n * package (Step 11).\n *\n * The SC target emits TS/JS modules (a literal theme object + `css` recipes), not a stylesheet, so\n * there is no CSS-variable / class-name lowering here — recipe values read straight from the theme\n * (`${({ theme }) => theme.…}`) and the theme object *is* the indirection.\n */\nimport type { MediaDescriptor, MediaVariant } from \"@theme-registry/refract\";\nimport type { Orientation, RuleSetOverride } from \"@theme-registry/refract\";\n\n// ---------------------------------------------------------------------------\n// State selector table (adapter-owned)\n// ---------------------------------------------------------------------------\n\nexport const SC_STATE_SELECTORS: Record<string, string> = {\n link: \":link\",\n visited: \":visited\",\n hover: \":hover\",\n focus: \":focus\",\n active: \":active\",\n disabled: \"[disabled]\",\n pressed: \"[aria-pressed]\",\n};\n\n/** The states the SC adapter can render (the validation set core threads into normalization). */\nexport const SC_KNOWN_STATES: ReadonlyArray<string> = Object.keys(SC_STATE_SELECTORS);\n\nconst STATE_ORDER: Record<string, number> = SC_KNOWN_STATES.reduce<Record<string, number>>(\n (acc, name, index) => {\n acc[name] = index;\n return acc;\n },\n {},\n);\n\n/** Order state overrides in canonical LVHA order (breakpoint-scoped ones after the base state). */\nexport const orderStateOverrides = (overrides: RuleSetOverride[]): RuleSetOverride[] =>\n overrides\n .map((override, index) => ({ override, index }))\n .sort((a, b) => {\n const oa = STATE_ORDER[a.override.state as string] ?? Number.MAX_SAFE_INTEGER;\n const ob = STATE_ORDER[b.override.state as string] ?? Number.MAX_SAFE_INTEGER;\n if (oa !== ob) return oa - ob;\n const bpa = a.override.breakpoint ? 1 : 0;\n const bpb = b.override.breakpoint ? 1 : 0;\n if (bpa !== bpb) return bpa - bpb;\n return a.index - b.index;\n })\n .map(({ override }) => override);\n\n// ---------------------------------------------------------------------------\n// Breakpoint → concrete @media query resolution\n// ---------------------------------------------------------------------------\n\nexport const DEFAULT_MEDIA_QUERY: MediaVariant = \"exact\";\n\n/** Resolve a breakpoint + query kind (+ orientation) to its concrete `@media (...)` string. */\nexport const resolveMediaQuery = <TBreakpoint extends string>(\n media: MediaDescriptor<TBreakpoint>,\n breakpoint: TBreakpoint,\n query: MediaVariant,\n orientation?: Orientation,\n): string => {\n if (!orientation) return media[breakpoint]?.[query] ?? \"\";\n const opts = { orientation };\n if (query === \"min\") return media.min(breakpoint, opts);\n if (query === \"max\") return media.max(breakpoint, opts);\n return media.exact(breakpoint, opts);\n};\n","/**\n * JS-identifier naming for the styled-components TS/JS emit (§8).\n *\n * The SC target emits a **literal theme object** and **flat `css` recipe consts**, so its names are\n * JavaScript identifiers, not CSS variables/classes. This module is the SC analogue of the shared\n * `../naming` namer: it reuses that module's `sanitizeSegment` + collision-guard discipline (§7B) but\n * produces a **camelCase identifier form** instead of a kebab class/var.\n *\n * theme key: `themeKey([\"primary\", \"text\"])` → `primaryText` (folds a variant/extra\n * into its group under `theme.<subsystem>`)\n * theme access: `themeAccess(\"colors.primary.text\")` → `{ subsystem: \"colors\", key: \"primaryText\" }`\n * recipe export: `recipeExportName(\"components\",\"buttons\",\"primary\")` → `componentsButtonsPrimary`\n *\n * Unlike the CSS/SC class names, SC identifiers carry **no prefix** (the artifact's `colorsSolidPrimary`,\n * not `dtColorsSolidPrimary`) — the literal theme object *is* the isolation boundary. The §7B\n * `naming.className` override still remaps a recipe's identity (its export name); `naming.variableName`\n * has no coherent target on a nested object and is accepted-but-structural (theme keys stay derived).\n */\nimport type { NamingOverrides } from \"@theme-registry/refract/adapter-kit\";\n\n/** Split an authored segment into alphanumeric words (`\"button-lg\"` → `[\"button\",\"lg\"]`). Interior\n * case is preserved so an already-camelCase property (`fontSize`) survives as one word. */\nconst splitWords = (segment: string): string[] => segment.split(/[^a-zA-Z0-9]+/).filter(Boolean);\n\nconst lowerFirst = (word: string): string => word.charAt(0).toLowerCase() + word.slice(1);\nconst upperFirst = (word: string): string => word.charAt(0).toUpperCase() + word.slice(1);\n\n/**\n * camelCase-join a list of address segments into one identifier: the first word lower-cased, every\n * later word upper-cased and concatenated. A leading digit (invalid identifier start) is prefixed `_`.\n */\nexport const camelJoin = (segments: string[]): string => {\n const words = segments.flatMap(splitWords);\n if (!words.length) return \"_\";\n const joined = words.map((w, i) => (i === 0 ? lowerFirst(w) : upperFirst(w))).join(\"\");\n return /^[0-9]/.test(joined) ? `_${joined}` : joined;\n};\n\n/** A token's key under `theme.<subsystem>` — the property + its variant/extra segments camel-folded. */\nexport const themeKey = (segmentsAfterSubsystem: string[]): string => camelJoin(segmentsAfterSubsystem);\n\n/** A dotted token path → its `theme.<subsystem>.<key>` address parts. `colors.primary.text` →\n * `{ subsystem: \"colors\", key: \"primaryText\" }`; `borders.radius` → `{ subsystem: \"borders\", key: \"radius\" }`. */\nexport const themeAccess = (path: string): { subsystem: string; key: string } => {\n const [subsystem, ...rest] = path.split(\".\");\n return { subsystem, key: themeKey(rest) };\n};\n\n/**\n * A bound identifier minter for one theme: the recipe-export namer with the §7B collision guard.\n * Distinct addresses producing the same identifier throw; the same address re-resolving is fine.\n */\nexport interface ScIdentifiers {\n /** The camelCase export name for a recipe (`components`,`buttons`,`primary` → `componentsButtonsPrimary`). */\n recipeExportName(subsystem: string, group: string, variant: string): string;\n}\n\nexport const createIdentifiers = (overrides?: NamingOverrides): ScIdentifiers => {\n const seen = new Map<string, string>(); // identifier → source address key\n\n const track = (name: string, key: string): void => {\n const prev = seen.get(name);\n if (prev !== undefined && prev !== key) {\n throw new Error(\n `styled-components emit: recipe identifier \"${name}\" is produced by both \"${prev}\" and ` +\n `\"${key}\" — the naming override must map distinct recipes to distinct identifiers`,\n );\n }\n seen.set(name, key);\n };\n\n return {\n recipeExportName(subsystem, group, variant) {\n const segments = [subsystem, group, variant];\n let name = camelJoin(segments);\n if (overrides?.className) {\n // Feed the override a PREFIX-FREE default (SC identifiers carry no prefix), so a no-op\n // decorator round-trips to the structural name and only a real remap changes identity.\n const fallback = segments.map(s => splitWords(s).join(\"-\")).join(\"-\");\n const out = overrides.className(\n { kind: \"recipe\", subsystem, group, variant },\n { classToken: \"\", name: fallback },\n );\n name = camelJoin(splitWords(out));\n if (!name || name === \"_\") {\n throw new Error(\n `styled-components emit: className override returned an empty/invalid identifier for ` +\n `\"${subsystem}.${group}.${variant}\"`,\n );\n }\n }\n track(name, `${subsystem}.${group}.${variant}`);\n return name;\n },\n };\n};\n","/**\n * The literal theme object (§8) — the SC target's replacement for CSS `:root` variables.\n *\n * `buildThemeData` walks the Model's property tokens into a nested `{ [subsystem]: { [camelKey]: literal } }`\n * tree (variants/extras fold into their group as camelCased keys — `primary` → `primaryText`), plus a\n * parallel `modes` tree (§10.3 appearance-mode overrides — only the fields a mode redefines). The object\n * **is** the indirection: values are resolved literals, no `var()`. The same data serves two sinks — a\n * live JS object for the runtime `theme` (recipes read it from styled-components context) and an\n * object-literal source string for `emit()`.\n *\n * Structured compound tokens (§15 shadow / transition `Ref.struct`) are **skipped** — the SC adapter's\n * structured composition is deferred, exactly as the prior stylesheet lane skipped their `:root` vars.\n */\nimport type { ThemeModel, Ref, Literal } from \"@theme-registry/refract\";\nimport { themeKey } from \"./identifiers\";\n\n/** A resolved literal in the theme object: a number stays a number (`fontWeight`), a length/colour is a string. */\nexport type ThemeLiteral = string | number;\ntype ThemeTree = Record<string, Record<string, ThemeLiteral>>;\ntype ModesTree = Record<string, ThemeTree>;\n\nexport interface ThemeData {\n /** `subsystem → key → literal` (no `modes` / helpers — those are attached by the caller). */\n readonly tree: ThemeTree;\n /** `mode → subsystem → key → literal` — only the fields each mode redefines. */\n readonly modes: ModesTree;\n /** The mode names present (`[\"dark\"]`), in first-seen order. */\n readonly modeNames: string[];\n /** Every dotted token path that made it into the tree (non-struct) — recipe refs check membership. */\n readonly tokenPaths: Set<string>;\n /** `mode → set of dotted token paths that carry an override` — the recipe scheme block reads this. */\n readonly modeOverridePaths: Record<string, Set<string>>;\n}\n\n/** Format one token `Ref` to its theme-object literal. Returns `undefined` for a structured token (skipped). */\nconst formatValue = (ref: Ref, path: string, resolve: (path: string) => Literal): ThemeLiteral | undefined => {\n if (ref.struct !== undefined) return undefined;\n if (ref.external !== undefined) return `var(${ref.external})`; // §W6b — the theme entry IS the parent var\n\n const raw: Literal = ref.value !== undefined ? ref.value : resolve(path);\n // §21: a length leaf carries its resolved unit — emit `value + unit` as a string. A unit-less number\n // (fontWeight / lineHeight / opacity) has no `unit` and stays a JS number, so the theme object types\n // it as `number`.\n if (ref.unit !== undefined) return `${raw}${ref.unit}`;\n return raw;\n};\n\n/** Walk the Model into the nested theme tree + modes tree. `resolve` fills in pure-alias tokens. */\nexport const buildThemeData = (model: ThemeModel, resolve: (path: string) => Literal): ThemeData => {\n const tree: ThemeTree = {};\n const modes: ModesTree = {};\n const modeNames: string[] = [];\n const tokenPaths = new Set<string>();\n const modeOverridePaths: Record<string, Set<string>> = {};\n\n const put = (subsystem: string, key: string, path: string, ref: Ref): void => {\n const value = formatValue(ref, path, resolve);\n if (value === undefined) return; // structured token — deferred\n (tree[subsystem] ??= {})[key] = value;\n tokenPaths.add(path);\n };\n\n for (const [subsystem, sub] of Object.entries(model.subsystems)) {\n for (const [property, pm] of Object.entries(sub.properties ?? {})) {\n put(subsystem, themeKey([property]), `${subsystem}.${property}`, pm.base);\n for (const [extra, ref] of Object.entries(pm.extras ?? {})) {\n put(subsystem, themeKey([property, extra]), `${subsystem}.${property}.${extra}`, ref);\n }\n for (const [variant, v] of Object.entries(pm.variants ?? {})) {\n put(subsystem, themeKey([property, variant]), `${subsystem}.${property}.${variant}`, v.base);\n // dec.3 — a variant's own extras map to `<property><Variant><Extra>` in the SC theme object.\n for (const [extra, ref] of Object.entries(v.extras ?? {})) {\n put(subsystem, themeKey([property, variant, extra]), `${subsystem}.${property}.${variant}.${extra}`, ref);\n }\n }\n // §10.3 appearance modes — a LIST of `{ mode, target?, overrides }`. Each field maps to the\n // property key (or a variant key when `target` scopes it); an extra field appends `<Extra>`.\n // The recipe scheme block re-reads exactly these paths.\n for (const entry of pm.modes ?? []) {\n const mode = entry.mode;\n if (mode === undefined) continue;\n const target = entry.target;\n const segments = target ? [property, target] : [property];\n const basePath = target ? `${subsystem}.${property}.${target}` : `${subsystem}.${property}`;\n for (const [field, ref] of Object.entries(entry.overrides ?? {})) {\n const value = formatValue(ref, `${subsystem}.${property}`, resolve);\n if (value === undefined) continue;\n const key = field === \"base\" ? themeKey(segments) : themeKey([...segments, field]);\n const path = field === \"base\" ? basePath : `${basePath}.${field}`;\n if (!modeNames.includes(mode)) modeNames.push(mode);\n (((modes[mode] ??= {})[subsystem] ??= {}))[key] = value;\n (modeOverridePaths[mode] ??= new Set()).add(path);\n }\n }\n }\n }\n\n return { tree, modes, modeNames, tokenPaths, modeOverridePaths };\n};\n\n// ---------------------------------------------------------------------------\n// Serialization to object-literal source (emit)\n// ---------------------------------------------------------------------------\n\nconst INDENT = \" \";\n\n/** A theme literal → its JS source (`600` stays a number literal; a string is JSON-quoted). */\nconst literalSource = (value: ThemeLiteral): string =>\n typeof value === \"number\" ? String(value) : JSON.stringify(value);\n\nconst serializeLeafMap = (map: Record<string, ThemeLiteral>, depth: number): string => {\n const pad = INDENT.repeat(depth);\n const inner = INDENT.repeat(depth + 1);\n const entries = Object.entries(map).map(([k, v]) => `${inner}${k}: ${literalSource(v)},`);\n return `{\\n${entries.join(\"\\n\")}\\n${pad}}`;\n};\n\nconst serializeTree = (tree: ThemeTree, depth: number): string[] =>\n Object.entries(tree).map(\n ([subsystem, map]) => `${INDENT.repeat(depth)}${subsystem}: ${serializeLeafMap(map, depth)},`,\n );\n\n/**\n * Serialize the theme object literal body (the `{ … }`), including the subsystem trees, the optional\n * `modes` tree, and any trailing bare-identifier refs (`media`, `scheme`, helper fns) the caller wires.\n */\nexport const serializeThemeObject = (data: ThemeData, trailingRefs: string[]): string => {\n const lines: string[] = [\"{\"];\n lines.push(...serializeTree(data.tree, 1));\n\n if (data.modeNames.length) {\n lines.push(`${INDENT}modes: {`);\n for (const mode of data.modeNames) {\n lines.push(`${INDENT.repeat(2)}${mode}: {`);\n lines.push(...serializeTree(data.modes[mode], 3));\n lines.push(`${INDENT.repeat(2)}},`);\n }\n lines.push(`${INDENT}},`);\n }\n\n for (const ref of trailingRefs) lines.push(`${INDENT}${ref},`);\n lines.push(\"}\");\n return lines.join(\"\\n\");\n};\n\n/**\n * Assemble the **live** runtime theme object: the token tree + `modes` + the wrapped `media` / `scheme`\n * tagged-template helpers + any opted-in color-math fns. This is what a consumer passes to\n * `<ThemeProvider>`; recipes read every value off it via styled-components context.\n */\nexport const buildRuntimeThemeObject = (\n data: ThemeData,\n attach: Record<string, unknown>,\n): Record<string, unknown> => {\n const obj: Record<string, unknown> = {};\n for (const [subsystem, map] of Object.entries(data.tree)) obj[subsystem] = { ...map };\n if (data.modeNames.length) {\n const modes: Record<string, unknown> = {};\n for (const mode of data.modeNames) {\n const bySub: Record<string, unknown> = {};\n for (const [subsystem, map] of Object.entries(data.modes[mode])) bySub[subsystem] = { ...map };\n modes[mode] = bySub;\n }\n obj.modes = modes;\n }\n Object.assign(obj, attach);\n return obj;\n};\n","/**\n * The shared recipe renderer (§8) — one lowering, two sinks.\n *\n * A recipe {@link RuleSet} lowers to a format-neutral node tree ({@link RecipeNode}) — base\n * declarations, composition spreads, state / breakpoint / colour-scheme conditional blocks — that\n * BOTH sinks walk:\n * - **`recipeSource`** serializes it to `css\\`…\\`` **source** (`${({ theme }) => theme.…}` value\n * reads, `${sibling}` composition spreads, `theme.media` / `theme.scheme` tagged-template blocks)\n * for `emit()`.\n * - **`recipePlainCss`** renders it to a **live CSS string** off a runtime theme object (values\n * resolved from `props.theme`, breakpoints as concrete `@media`, dark as `prefers-color-scheme` /\n * `[data-theme]`) — the body of a lazy `css` block for the runtime surface.\n *\n * Values read from the theme, never `var()`; dark mode lives *in the recipe block* (§10.3), so it\n * tree-shakes with the recipe and switches with a plain CSS recalc — no `:root`, no provider swap.\n */\nimport type { MediaDescriptor, MediaVariant } from \"@theme-registry/refract\";\nimport type { Ref, RuleSet, RuleSetGroup, ThemeModel } from \"@theme-registry/refract\";\nimport { SC_STATE_SELECTORS, orderStateOverrides, resolveMediaQuery, DEFAULT_MEDIA_QUERY } from \"./lowering\";\nimport { themeAccess } from \"./identifiers\";\nimport type { ThemeData } from \"./theme-object\";\n\n/** How `model.modes` are realized into a recipe (§8): OS media, a `[data-theme]` toggle, or both. */\nexport type SchemeOption = \"media\" | \"attribute\" | \"both\";\n\n// ---------------------------------------------------------------------------\n// Node tree (the shared lowering)\n// ---------------------------------------------------------------------------\n\n/** One fragment of a declaration value: literal text, a theme token read, or an appearance-mode read. */\ntype Fragment =\n | { lit: string }\n | { ref: string }\n | { modeRef: { mode: string; path: string } };\n\ntype RecipeNode =\n | { type: \"decl\"; property: string; value: Fragment[] }\n /** A nested selector block (`&:hover`, `[data-theme=\"dark\"] &`) — arrow-form value reads. */\n | { type: \"block\"; selector: string; children: RecipeNode[] }\n /** A breakpoint block realized via `theme.media.<bp>.<query>` (captured-form reads inside). */\n | { type: \"media\"; breakpoint: string; query: MediaVariant; orientation?: \"landscape\" | \"portrait\"; children: RecipeNode[] }\n /** A colour-scheme block realized via `theme.scheme.<mode>` (captured-form reads inside). */\n | { type: \"scheme\"; mode: string; children: RecipeNode[] }\n /** A composition spread of a sibling recipe (`${componentsButtonsPrimary}` / inline its CSS). */\n | { type: \"spread\"; subsystem: string; group: string; variant: string };\n\n/** Context threaded into the IR builder + both sinks. */\nexport interface RecipeContext {\n readonly model: ThemeModel;\n readonly media: MediaDescriptor<string>;\n readonly data: ThemeData;\n readonly scheme: SchemeOption;\n /** The concrete `@media (prefers-color-scheme: <mode>)` string per realizable mode. */\n readonly prefers: Record<string, string>;\n}\n\nconst str = (value: unknown): string => (value == null ? \"\" : String(value));\n\n/** A rule-set declaration `Ref` → its value fragments. Returns `undefined` to SKIP the declaration\n * (a structured token the theme object doesn't carry). A literal is emitted as-is; a token ref (with\n * optional adapter `wrap`, e.g. `blur(…)`) becomes a theme read. */\nconst refFragments = (ref: Ref, data: ThemeData): Fragment[] | undefined => {\n if (ref.ref === undefined) return [{ lit: str(ref.value) }];\n if (!data.tokenPaths.has(ref.ref)) return undefined; // structured / absent token — deferred\n const read: Fragment = { ref: ref.ref };\n return ref.wrap ? [{ lit: `${ref.wrap}(` }, read, { lit: \")\" }] : [read];\n};\n\nconst declNodes = (declarations: Record<string, Ref> | undefined, data: ThemeData): RecipeNode[] => {\n const nodes: RecipeNode[] = [];\n for (const [property, ref] of Object.entries(declarations ?? {})) {\n const value = refFragments(ref, data);\n if (value) nodes.push({ type: \"decl\", property, value });\n }\n return nodes;\n};\n\n/** Parse a component composition reference (`\"colors:solid.primary\"`) into its address. */\nconst parseReference = (\n reference: string,\n): { subsystem: string; group: string; variant: string } | undefined => {\n const [subsystem, rest] = reference.split(\":\");\n if (!subsystem || !rest) return undefined;\n const dot = rest.indexOf(\".\");\n if (dot < 0) return undefined;\n return { subsystem, group: rest.slice(0, dot), variant: rest.slice(dot + 1) };\n};\n\n/** Which realizations (media / attribute) a mode uses under the current `scheme` option. Only `dark`\n * / `light` can ride `prefers-color-scheme`; any other named mode falls back to `[data-theme]`. */\nconst schemeRealizations = (mode: string, scheme: SchemeOption): { media: boolean; attribute: boolean } => {\n const mediaEligible = mode === \"dark\" || mode === \"light\";\n const media = mediaEligible && (scheme === \"media\" || scheme === \"both\");\n const attribute =\n scheme === \"attribute\" || scheme === \"both\" || (scheme === \"media\" && !mediaEligible);\n return { media, attribute };\n};\n\n/** Mode-override declarations for a set of declarations, reading `theme.modes.<mode>.…`. */\nconst modeDeclNodes = (\n declarations: Record<string, Ref> | undefined,\n mode: string,\n data: ThemeData,\n): RecipeNode[] => {\n const overridden = data.modeOverridePaths[mode];\n if (!overridden) return [];\n const nodes: RecipeNode[] = [];\n for (const [property, ref] of Object.entries(declarations ?? {})) {\n if (ref.ref !== undefined && overridden.has(ref.ref)) {\n nodes.push({ type: \"decl\", property, value: [{ modeRef: { mode, path: ref.ref } }] });\n }\n }\n return nodes;\n};\n\n/**\n * Lower one recipe {@link RuleSet} (+ optional composition `references`) to the shared node tree:\n * spreads → base declarations → breakpoint blocks → state blocks → colour-scheme blocks.\n */\nexport const buildRecipeIR = (ruleSet: RuleSet, ctx: RecipeContext): RecipeNode[] => {\n const nodes: RecipeNode[] = [];\n\n // Composition (components): spread each referenced sibling recipe first.\n for (const reference of ruleSet.references ?? []) {\n const parsed = parseReference(reference);\n if (parsed) nodes.push({ type: \"spread\", ...parsed });\n }\n\n // Base declarations.\n nodes.push(...declNodes(ruleSet.declarations, ctx.data));\n\n // Breakpoint-only overrides → a media block.\n for (const override of ruleSet.overrides) {\n if (override.state !== undefined || !override.breakpoint) continue;\n const children = declNodes(override.declarations, ctx.data);\n if (children.length) {\n nodes.push({\n type: \"media\",\n breakpoint: override.breakpoint,\n query: (override.query ?? DEFAULT_MEDIA_QUERY) as MediaVariant,\n orientation: override.orientation,\n children,\n });\n }\n }\n\n // State (+ state×breakpoint) overrides → a `&:hover`-style block, canonical LVHA order.\n const stateOverrides = ruleSet.overrides.filter(o => o.state !== undefined);\n for (const override of orderStateOverrides(stateOverrides)) {\n const stateSelector = SC_STATE_SELECTORS[override.state as string];\n const children = declNodes(override.declarations, ctx.data);\n if (!stateSelector || !children.length) continue;\n const block: RecipeNode = { type: \"block\", selector: `&${stateSelector}`, children };\n if (override.breakpoint) {\n nodes.push({\n type: \"media\",\n breakpoint: override.breakpoint,\n query: (override.query ?? DEFAULT_MEDIA_QUERY) as MediaVariant,\n orientation: override.orientation,\n children: [block],\n });\n } else {\n nodes.push(block);\n }\n }\n\n // Colour-scheme blocks (§10.3) — one per mode whose fields this recipe reads.\n for (const mode of ctx.data.modeNames) {\n const baseMode = modeDeclNodes(ruleSet.declarations, mode, ctx.data);\n const stateModeBlocks: RecipeNode[] = [];\n for (const override of orderStateOverrides(stateOverrides)) {\n const stateSelector = SC_STATE_SELECTORS[override.state as string];\n if (!stateSelector) continue;\n const children = modeDeclNodes(override.declarations, mode, ctx.data);\n if (children.length) stateModeBlocks.push({ type: \"block\", selector: `&${stateSelector}`, children });\n }\n const children = [...baseMode, ...stateModeBlocks];\n if (!children.length) continue;\n\n const { media, attribute } = schemeRealizations(mode, ctx.scheme);\n if (media) nodes.push({ type: \"scheme\", mode, children });\n if (attribute) nodes.push({ type: \"block\", selector: `[data-theme=\"${mode}\"] &`, children });\n }\n\n return nodes;\n};\n\n/**\n * Lower the `globals` subsystem's rule-sets (§9) into `block` nodes for the `GlobalStyle` — one raw\n * `<selector> { … }` per rule-set. Two kinds:\n * - `kind:\"reset\"` (preset `static` / `defaults`) — declaration-only (literals as-is, token refs as\n * theme reads).\n * - `kind:\"globals\"` (themed `elements`) — the element's base declarations PLUS its state/breakpoint/\n * colour-scheme blocks (via {@link buildRecipeIR}) and each delta-only variant nested as a\n * `&.<variant>` block. Dark rides the referenced token's own modes — realized *inside* the element\n * block as a `theme.scheme.<mode>` / `[data-theme]` conditional (same as recipes), no `:root`.\n * Feeds the `GlobalStyle` emitter + the runtime `GlobalStyle`.\n */\nexport const buildGlobalsIR = (\n groups: Record<string, RuleSetGroup> | undefined,\n ctx: RecipeContext,\n): RecipeNode[] => {\n const nodes: RecipeNode[] = [];\n for (const group of Object.values(groups ?? {})) {\n for (const ruleSet of Object.values(group)) {\n if (!ruleSet.selector) continue;\n if (ruleSet.kind === \"globals\") {\n const children = buildRecipeIR(ruleSet, ctx);\n for (const [variantName, variant] of Object.entries(ruleSet.variants ?? {})) {\n const variantRuleSet: RuleSet = {\n kind: \"globals\",\n selector: ruleSet.selector,\n declarations: variant.declarations,\n overrides: variant.overrides,\n };\n const variantChildren = buildRecipeIR(variantRuleSet, ctx);\n if (variantChildren.length) {\n children.push({ type: \"block\", selector: `&.${variantName}`, children: variantChildren });\n }\n }\n if (children.length) nodes.push({ type: \"block\", selector: ruleSet.selector, children });\n } else {\n const children = declNodes(ruleSet.declarations, ctx.data);\n if (children.length) nodes.push({ type: \"block\", selector: ruleSet.selector, children });\n }\n }\n }\n return nodes;\n};\n\n// ---------------------------------------------------------------------------\n// Sink 1 — source serialization (emit)\n// ---------------------------------------------------------------------------\n\nconst INDENT = \" \";\n\n/** A theme read `theme.<subsystem>.<key>` (optionally under `modes.<mode>`). */\nconst accessExpr = (path: string, mode?: string): string => {\n const { subsystem, key } = themeAccess(path);\n return mode ? `theme.modes.${mode}.${subsystem}.${key}` : `theme.${subsystem}.${key}`;\n};\n\n/** Serialize one declaration's value fragments. `captured` = inside a media/scheme tagged template\n * (the outer arrow already bound `theme`, so reads are bare `${theme.…}` not `${({theme})=>…}`). */\nconst fragmentsSource = (fragments: Fragment[], captured: boolean): string =>\n fragments\n .map(fragment => {\n if (\"lit\" in fragment) return fragment.lit;\n const expr = \"ref\" in fragment ? accessExpr(fragment.ref) : accessExpr(fragment.modeRef.path, fragment.modeRef.mode);\n return captured ? `\\${${expr}}` : `\\${({ theme }) => ${expr}}`;\n })\n .join(\"\");\n\ninterface SourceOptions {\n /** The export identifier for a spread reference (`components`,`buttons`,`primary` → `componentsButtonsPrimary`). */\n spreadName(subsystem: string, group: string, variant: string): string;\n}\n\nconst nodeSource = (node: RecipeNode, indent: string, captured: boolean, opts: SourceOptions): string => {\n switch (node.type) {\n case \"decl\":\n return `${indent}${node.property}: ${fragmentsSource(node.value, captured)};`;\n case \"spread\":\n return `${indent}\\${${opts.spreadName(node.subsystem, node.group, node.variant)}}`;\n case \"block\": {\n const inner = node.children.map(c => nodeSource(c, indent + INDENT, captured, opts)).join(\"\\n\");\n return `${indent}${node.selector} {\\n${inner}\\n${indent}}`;\n }\n case \"media\": {\n const target = node.orientation\n ? `theme.media.${node.query}(${JSON.stringify(node.breakpoint)}, { orientation: ${JSON.stringify(node.orientation)} })`\n : `theme.media.${node.breakpoint}.${node.query}`;\n const inner = node.children.map(c => nodeSource(c, indent + INDENT, true, opts)).join(\"\\n\");\n return `${indent}\\${({ theme }) => ${target}\\`\\n${inner}\\n${indent}\\`}`;\n }\n case \"scheme\": {\n const inner = node.children.map(c => nodeSource(c, indent + INDENT, true, opts)).join(\"\\n\");\n return `${indent}\\${({ theme }) => theme.scheme.${node.mode}\\`\\n${inner}\\n${indent}\\`}`;\n }\n }\n};\n\n/** Serialize a recipe's node tree to the body of a `css\\`…\\`` template (2-space indented). */\nexport const recipeSource = (nodes: RecipeNode[], opts: SourceOptions): string =>\n nodes.map(node => nodeSource(node, INDENT, false, opts)).join(\"\\n\");\n\n// ---------------------------------------------------------------------------\n// Sink 2 — live plain-CSS rendering (runtime)\n// ---------------------------------------------------------------------------\n\n/** Read a value off the runtime theme object: `theme[subsystem][key]` (optionally under `modes.<mode>`). */\nconst readTheme = (theme: Record<string, any>, path: string, mode?: string): unknown => {\n const { subsystem, key } = themeAccess(path);\n const root = mode ? theme?.modes?.[mode] : theme;\n return root?.[subsystem]?.[key];\n};\n\nconst fragmentsValue = (fragments: Fragment[], theme: Record<string, any>): string =>\n fragments\n .map(fragment => {\n if (\"lit\" in fragment) return fragment.lit;\n if (\"ref\" in fragment) return str(readTheme(theme, fragment.ref));\n return str(readTheme(theme, fragment.modeRef.path, fragment.modeRef.mode));\n })\n .join(\"\");\n\n/** Resolve a sibling recipe's live CSS (composition) — injected by the adapter's lazy registry. */\nexport type SpreadRenderer = (\n subsystem: string,\n group: string,\n variant: string,\n theme: Record<string, any>,\n) => string;\n\nconst nodePlainCss = (\n node: RecipeNode,\n theme: Record<string, any>,\n ctx: RecipeContext,\n spread: SpreadRenderer,\n): string => {\n switch (node.type) {\n case \"decl\":\n return `${node.property}: ${fragmentsValue(node.value, theme)};`;\n case \"spread\":\n return spread(node.subsystem, node.group, node.variant, theme);\n case \"block\": {\n const inner = node.children.map(c => nodePlainCss(c, theme, ctx, spread)).join(\" \");\n return `${node.selector} { ${inner} }`;\n }\n case \"media\": {\n const query = resolveMediaQuery(ctx.media, node.breakpoint, node.query, node.orientation);\n const inner = node.children.map(c => nodePlainCss(c, theme, ctx, spread)).join(\" \");\n return query ? `${query} { ${inner} }` : inner;\n }\n case \"scheme\": {\n const query = ctx.prefers[node.mode] ?? \"\";\n const inner = node.children.map(c => nodePlainCss(c, theme, ctx, spread)).join(\" \");\n return query ? `${query} { ${inner} }` : inner;\n }\n }\n};\n\n/** Render a recipe's node tree to a live CSS string off a runtime theme object. */\nexport const recipePlainCss = (\n nodes: RecipeNode[],\n theme: Record<string, any>,\n ctx: RecipeContext,\n spread: SpreadRenderer,\n): string => nodes.map(node => nodePlainCss(node, theme, ctx, spread)).join(\"\\n\");\n","/**\n * SC-decorated media — the `wrapMedia` half of the adapter contract's media pattern.\n *\n * Core builds the plain {@link MediaDescriptor} (breakpoints → `@media (min-width:…)` strings);\n * this decorates it into styled-components **tagged-template** helpers so a consumer writes\n * `theme.media.md.min\\`color: red;\\`` (or `theme.media.min(\"md\")\\`…\\``) and gets an SC `css` block\n * scoped to that query. Re-ported from the dormant legacy SC adapter onto the clean-room\n * `core/media` (imports only core — self-contained for the Step 9 package extraction).\n */\nimport { css } from \"styled-components\";\nimport type { Interpolation, RuleSet } from \"styled-components\";\nimport type {\n MediaDescriptor,\n MediaGroupDescriptor,\n MediaQueryOptions,\n MediaVariant,\n} from \"@theme-registry/refract\";\n\ntype MediaTemplate = (\n styles: TemplateStringsArray,\n ...interpolations: Interpolation<object>[]\n) => RuleSet<object>;\n\n/** A media tagged-template that also carries the raw `@media` query string it wraps. */\nexport type MediaTemplateWithQuery = MediaTemplate & { readonly query: string };\n\nexport type WrappedMediaGroup = Record<MediaVariant, MediaTemplateWithQuery>;\n\n/** The SC-decorated media descriptor put on `theme.media` — tagged templates instead of strings. */\nexport type WrappedMediaDescriptor<TBreakpoint extends string> = {\n min: (key: TBreakpoint, options?: MediaOrientationOptions) => MediaTemplateWithQuery;\n max: (key: TBreakpoint, options?: MediaOrientationOptions) => MediaTemplateWithQuery;\n between: (\n from: TBreakpoint,\n to: TBreakpoint,\n options?: MediaOrientationOptions,\n ) => MediaTemplateWithQuery;\n} & Record<TBreakpoint, WrappedMediaGroup>;\n\ntype MediaOrientationOptions = Pick<MediaQueryOptions, \"orientation\">;\n\nconst RESERVED_DESCRIPTOR_KEYS = new Set([\"min\", \"max\", \"between\", \"exact\"]);\n\n/** Decorate a core {@link MediaDescriptor} into SC tagged-template helpers. */\nexport const wrapMediaDescriptor = <TBreakpoint extends string>(\n descriptor: MediaDescriptor<TBreakpoint>,\n): WrappedMediaDescriptor<TBreakpoint> => {\n const wrapped = {\n min: (key: TBreakpoint, options?: MediaOrientationOptions) =>\n wrapQuery(descriptor.min(key, options)),\n max: (key: TBreakpoint, options?: MediaOrientationOptions) =>\n wrapQuery(descriptor.max(key, options)),\n between: (from: TBreakpoint, to: TBreakpoint, options?: MediaOrientationOptions) =>\n wrapQuery(descriptor.between(from, to, options)),\n } as WrappedMediaDescriptor<TBreakpoint>;\n\n for (const key of Object.keys(descriptor) as TBreakpoint[]) {\n if (RESERVED_DESCRIPTOR_KEYS.has(key)) continue;\n (wrapped as Record<string, unknown>)[key] = wrapMediaGroup(\n descriptor[key] as MediaGroupDescriptor,\n );\n }\n\n return wrapped;\n};\n\nexport const wrapMediaGroup = (group: MediaGroupDescriptor): WrappedMediaGroup => {\n const wrapped = {} as WrappedMediaGroup;\n (Object.keys(group) as MediaVariant[]).forEach(variant => {\n wrapped[variant] = wrapQuery(group[variant]);\n });\n return wrapped;\n};\n\nconst wrapQuery = (query: string): MediaTemplateWithQuery =>\n Object.assign(buildTemplate(query), { query }) as MediaTemplateWithQuery;\n\nconst buildTemplate = (query: string): MediaTemplate => {\n if (!query) {\n return (styles, ...interpolations) => css`\n ${css(styles, ...interpolations)}\n `;\n }\n return (styles, ...interpolations) => css`\n ${query} {\n ${css(styles, ...interpolations)}\n }\n `;\n};\n","/**\n * SC colour-scheme tagged templates (§8) — the `theme.scheme.dark\\`…\\`` half of the appearance-mode\n * (§10.3) realization, parallel to `media.ts`. A recipe's dark block interpolates\n * `${({ theme }) => theme.scheme.dark\\`…\\`}`, which wraps its body in\n * `@media (prefers-color-scheme: dark) { … }`. Only `dark` / `light` ride `prefers-color-scheme`\n * (a `[data-theme]` toggle handles any other named mode — that path uses a plain nested selector,\n * not this helper).\n *\n * Two forms, like media: a **runtime** wrapper (`wrapSchemeHelper`) put on the live `theme.scheme`,\n * and a **vendored** self-contained module (`vendorSchemeHelper`) written by `emit()` so a downstream\n * app keeps `theme.scheme` after it drops refract (its only dependency is `styled-components`).\n */\nimport { css } from \"styled-components\";\nimport type { Interpolation, RuleSet } from \"styled-components\";\n\n/** The concrete `@media (prefers-color-scheme: …)` string for a realizable mode. */\nexport const PREFERS: Record<string, string> = {\n dark: \"@media (prefers-color-scheme: dark)\",\n light: \"@media (prefers-color-scheme: light)\",\n};\n\n/** Which authored modes ride `prefers-color-scheme` (the ones this helper realizes). */\nexport const mediaEligibleModes = (modeNames: readonly string[]): string[] =>\n modeNames.filter(mode => mode in PREFERS);\n\ntype SchemeTemplate = (\n styles: TemplateStringsArray,\n ...interpolations: Interpolation<object>[]\n) => RuleSet<object>;\n\n/** A scheme tagged-template that also carries the raw `@media (prefers-color-scheme: …)` it wraps. */\nexport type SchemeTemplateWithQuery = SchemeTemplate & { readonly query: string };\n\n/** The wrapped `theme.scheme` — one tagged template per realizable mode (`dark` / `light`). */\nexport type SchemeHelper = Record<string, SchemeTemplateWithQuery>;\n\nconst buildTemplate = (query: string): SchemeTemplate => (styles, ...interpolations) =>\n css`\n ${query} {\n ${css(styles, ...interpolations)}\n }\n `;\n\n/** Build the runtime `theme.scheme` for the given realizable modes. */\nexport const wrapSchemeHelper = (modeNames: readonly string[]): SchemeHelper => {\n const helper: SchemeHelper = {};\n for (const mode of mediaEligibleModes(modeNames)) {\n const query = PREFERS[mode];\n helper[mode] = Object.assign(buildTemplate(query), { query }) as SchemeTemplateWithQuery;\n }\n return helper;\n};\n\n/** Generate the self-contained vendored `scheme.ts` source for the given realizable modes. */\nexport const vendorSchemeHelper = (modeNames: readonly string[]): string => {\n const entries = mediaEligibleModes(modeNames)\n .map(mode => ` ${JSON.stringify(mode)}: wrap(${JSON.stringify(PREFERS[mode])}),`)\n .join(\"\\n\");\n\n return `// Vendored, self-contained styled-components colour-scheme helper (generated by @theme-registry/refract).\n// Only dependency: styled-components. Realizes appearance modes as prefers-color-scheme media blocks.\nimport { css } from \"styled-components\";\n\nconst wrap = (query) => {\n const fn = (styles, ...interpolations) => css\\`\\${query} { \\${css(styles, ...interpolations)} }\\`;\n fn.query = query;\n return fn;\n};\n\nexport const scheme = {\n${entries}\n};\n\nexport default scheme;\n`;\n};\n","/**\n * The styled-components `emit()` module assembler (§8) — writes **TS/JS modules**, not a stylesheet.\n *\n * What lands on disk (self-contained — a downstream app imports these and drops refract at runtime):\n * - **theme.ts** — the literal theme object (`export const theme = { … } as const`) + the flat, tree-\n * shakeable `css` recipe consts + a grouped `recipes` barrel + (if the raw defines `globals`) a\n * `GlobalStyle`. `emit: \"split\"` peels the recipes into `recipes.ts` and the `GlobalStyle` into\n * `global.ts`.\n * - **media.ts** (always) / **scheme.ts** (iff modes ride `prefers-color-scheme`) — vendored tagged\n * templates with this theme's concrete `@media` strings baked in.\n * - **theme.d.ts** (iff `language: \"ts\"`) — augments styled-components' `DefaultTheme` from `typeof theme`.\n * - **color-math.ts** is materialized by the shared build plumbing (`emitTheme` + `VENDOR_HELPERS`),\n * not here — this module only wires the `import`.\n */\nimport type { EmitOutput } from \"@theme-registry/refract\";\nimport type { MediaDescriptor, MediaVariant } from \"@theme-registry/refract\";\n\nconst VARIANTS: ReadonlyArray<MediaVariant> = [\"min\", \"max\", \"exact\"];\n\n/** color-math exports surfaced on `theme` when `helpers: [\"color-math\"]` is opted in. */\nexport const COLOR_MATH_ATTACH: ReadonlyArray<string> = [\"lighten\", \"darken\", \"alpha\"];\n\n/**\n * Generate a self-contained SC media-helper module (source text) for `breakpoints`, reading the\n * concrete `@media` query strings from the already-built core {@link MediaDescriptor}.\n */\nexport const vendorMediaHelper = <TBreakpoint extends string>(\n breakpoints: Record<TBreakpoint, number>,\n media: MediaDescriptor<TBreakpoint>,\n): string => {\n const keys = (Object.keys(breakpoints) as TBreakpoint[]).sort(\n (a, b) => breakpoints[a] - breakpoints[b],\n );\n\n const groups = keys\n .map(key => {\n const group = media[key];\n const variants = VARIANTS.map(\n variant => ` ${variant}: wrap(${JSON.stringify(group?.[variant] ?? \"\")}),`,\n ).join(\"\\n\");\n return ` ${JSON.stringify(key)}: {\\n${variants}\\n },`;\n })\n .join(\"\\n\");\n\n return `// Vendored, self-contained styled-components media helper (generated by @theme-registry/refract).\n// Only dependency: styled-components. Concrete @media strings are baked in for this theme's breakpoints.\nimport { css } from \"styled-components\";\n\nconst wrap = (query) => {\n const fn = query\n ? (styles, ...interpolations) => css\\`\\${query} { \\${css(styles, ...interpolations)} }\\`\n : (styles, ...interpolations) => css\\`\\${css(styles, ...interpolations)}\\`;\n fn.query = query;\n return fn;\n};\n\nexport const media = {\n${groups}\n};\n\nexport default media;\n`;\n};\n\n// ---------------------------------------------------------------------------\n// Module assembly\n// ---------------------------------------------------------------------------\n\n/** One recipe ready to serialize: its export identifier + its `css\\`…\\`` body source. */\nexport interface RecipeEmit {\n readonly exportName: string;\n readonly body: string;\n}\n\n/** Everything the assembler needs, prepared by the adapter's bind. */\nexport interface ScEmitInputs {\n readonly language: \"ts\" | \"js\";\n readonly emitMode: \"single\" | \"split\";\n readonly helpers: readonly string[];\n readonly usesScheme: boolean;\n /** The `export const theme = <this> as const` body (subsystems + modes + trailing refs). */\n readonly themeObjectBody: string;\n /** Recipes in dependency-safe order (a composed recipe's references precede it). */\n readonly recipes: readonly RecipeEmit[];\n /** The grouped `export const recipes = { … } as const` barrel body. */\n readonly recipesBarrelBody: string;\n /** The `createGlobalStyle\\`…\\`` body, if the raw defines `globals`. */\n readonly resetBody?: string;\n readonly vendorMedia: string;\n readonly vendorScheme?: string;\n}\n\nconst usesColorMath = (helpers: readonly string[]): boolean => helpers.includes(\"color-math\");\n\n/** The `import … from \"styled-components\"` line for the file that carries recipes / GlobalStyle. */\nconst scImport = (needsCss: boolean, needsGlobal: boolean): string => {\n const names = [needsCss ? \"css\" : \"\", needsGlobal ? \"createGlobalStyle\" : \"\"].filter(Boolean);\n return `import { ${names.join(\", \")} } from \"styled-components\";`;\n};\n\n/** The imports the theme object needs (`media`, optional `scheme`, optional color-math helpers). */\nconst themeImports = (inputs: ScEmitInputs): string[] => {\n const lines = [`import { media } from \"./media\";`];\n if (inputs.usesScheme) lines.push(`import { scheme } from \"./scheme\";`);\n if (usesColorMath(inputs.helpers)) {\n lines.push(`import { ${COLOR_MATH_ATTACH.join(\", \")} } from \"./color-math\";`);\n }\n return lines;\n};\n\nconst themeConst = (body: string): string => `export const theme = ${body} as const;`;\n\nconst recipeConsts = (recipes: readonly RecipeEmit[]): string =>\n recipes.map(r => `export const ${r.exportName} = css\\`\\n${r.body}\\n\\`;`).join(\"\\n\\n\");\n\nconst recipesBarrel = (body: string): string => `export const recipes = ${body} as const;`;\n\nconst globalStyle = (body: string): string => `export const GlobalStyle = createGlobalStyle\\`\\n${body}\\n\\`;`;\n\nconst themeDts = (): string =>\n `import \"styled-components\";\nimport type { theme } from \"./theme\";\n\ndeclare module \"styled-components\" {\n export interface DefaultTheme extends Readonly<typeof theme> {}\n}\n`;\n\n/** Assemble the SC emit output (files + vendored helpers) from the prepared inputs. */\nexport const buildScEmit = (inputs: ScEmitInputs): EmitOutput => {\n const files: Record<string, string> = {};\n const vendorHelpers: Record<string, string> = { \"media.ts\": inputs.vendorMedia };\n if (inputs.vendorScheme) vendorHelpers[\"scheme.ts\"] = inputs.vendorScheme;\n\n const hasRecipes = inputs.recipes.length > 0;\n const hasReset = inputs.resetBody !== undefined;\n\n if (inputs.emitMode === \"single\") {\n const parts: string[] = [];\n parts.push([scImport(hasRecipes, hasReset), ...themeImports(inputs)].join(\"\\n\"));\n parts.push(themeConst(inputs.themeObjectBody));\n if (hasRecipes) {\n parts.push(recipeConsts(inputs.recipes));\n parts.push(recipesBarrel(inputs.recipesBarrelBody));\n }\n if (hasReset) parts.push(globalStyle(inputs.resetBody!));\n files[\"theme.ts\"] = parts.join(\"\\n\\n\") + \"\\n\";\n } else {\n // split — theme / recipes / global in separate files.\n files[\"theme.ts\"] = [themeImports(inputs).join(\"\\n\"), themeConst(inputs.themeObjectBody)].join(\"\\n\\n\") + \"\\n\";\n if (hasRecipes) {\n files[\"recipes.ts\"] =\n [scImport(true, false), recipeConsts(inputs.recipes), recipesBarrel(inputs.recipesBarrelBody)].join(\"\\n\\n\") + \"\\n\";\n }\n if (hasReset) {\n files[\"global.ts\"] = [scImport(false, true), globalStyle(inputs.resetBody!)].join(\"\\n\\n\") + \"\\n\";\n }\n }\n\n if (inputs.language === \"ts\") files[\"theme.d.ts\"] = themeDts();\n\n // A `js` emit writes `.js` module names (the source is plain JS — no annotations are generated).\n if (inputs.language === \"js\") {\n for (const name of Object.keys(files)) {\n if (name.endsWith(\".ts\") && !name.endsWith(\".d.ts\")) {\n files[name.replace(/\\.ts$/, \".js\")] = files[name];\n delete files[name];\n }\n }\n for (const name of Object.keys(vendorHelpers)) {\n vendorHelpers[name.replace(/\\.ts$/, \".js\")] = vendorHelpers[name];\n delete vendorHelpers[name];\n }\n }\n\n return { files, vendorHelpers };\n};\n","/**\n * The styled-components adapter (§8) — lowers the format-neutral {@link ThemeModel} to **TS/JS\n * modules**, not a stylesheet. Worked reference: `src/adapters/css/`; imports only core (+ the\n * `styled-components` peer) so it can be lifted to its own package (Step 11).\n *\n * One renderer, two sinks (see `./recipe`): the same recipe lowering feeds `emit()` (serialize to\n * `css\\`…\\`` source on disk) and the runtime surface (`createTheme(raw, { adapter })` → a live `css`\n * block per recipe, lowered on first access and cached). Both project the SAME shapes:\n *\n * - **theme** — a literal object (`theme.colors.primary`, `theme.modes.dark.…`, `theme.media`,\n * `theme.scheme`, opted-in color-math fns). No `var()`; the object IS the indirection. This is\n * what a consumer passes to `<ThemeProvider>`.\n * - **recipes** — flat, tree-shakeable `css` blocks reading values off the theme (`${({ theme }) =>\n * theme.…}`); composition = a `css` spread of the referenced siblings. Grouped `recipes` barrel too.\n * - **GlobalStyle** — the globals subsystem as a `createGlobalStyle` (present iff the raw defines `globals`).\n * - **media** / **scheme** — SC tagged templates (breakpoints / `prefers-color-scheme`).\n */\nimport type { RuleSet as ModelRuleSet, ThemeModel } from \"@theme-registry/refract\";\nimport type { AdapterSpec, RenderContext, ThemeAdapter, NormalizedEmit, EmitOutput } from \"@theme-registry/refract\";\nimport type { UsageDescriptor } from \"@theme-registry/refract\";\nimport type { MediaDescriptor } from \"@theme-registry/refract\";\nimport { defineAdapter } from \"@theme-registry/refract\";\nimport { css, createGlobalStyle } from \"styled-components\";\nimport type { RuleSet } from \"styled-components\";\nimport type { NamingOverrides } from \"@theme-registry/refract/adapter-kit\";\nimport { SC_KNOWN_STATES } from \"./lowering\";\nimport { createIdentifiers } from \"./identifiers\";\nimport { buildThemeData, buildRuntimeThemeObject, serializeThemeObject } from \"./theme-object\";\nimport {\n buildRecipeIR,\n buildGlobalsIR,\n recipeSource,\n recipePlainCss,\n type RecipeContext,\n type SchemeOption,\n type SpreadRenderer,\n} from \"./recipe\";\nimport { wrapMediaDescriptor } from \"./media\";\nimport { wrapSchemeHelper, vendorSchemeHelper, mediaEligibleModes, PREFERS } from \"./scheme\";\nimport { vendorMediaHelper, buildScEmit, COLOR_MATH_ATTACH, type RecipeEmit, type ScEmitInputs } from \"./emit\";\n\n/** The output unit for this adapter — the return of the styled-components `css` tagged template. */\nexport type StyledComponentsUnit = RuleSet<object>;\n\n/** styled-components adapter options (§8). */\nexport type StyledComponentsAdapterOptions = {\n /**\n * Emit `.ts` (default) or `.js` modules. `ts` additionally emits `theme.d.ts` augmenting\n * styled-components' `DefaultTheme` from `typeof theme`, so `props.theme.…` is typed.\n */\n language?: \"ts\" | \"js\";\n /**\n * How appearance modes (§10.3) are realized in recipes: `\"media\"` (default) →\n * `@media (prefers-color-scheme: dark)` (follows the OS); `\"attribute\"` → `[data-theme=\"dark\"] &`\n * (a manual toggle overrides the OS); `\"both\"` → both blocks.\n */\n scheme?: SchemeOption;\n /**\n * Shared vendorable helpers surfaced on `theme` — `[\"color-math\"]` wires the `lighten`/`darken`/`alpha`\n * import (the module itself is materialized by the build plumbing, `emitTheme` + `VENDOR_HELPERS`).\n */\n helpers?: readonly string[];\n /** Accepted for parity with the CSS adapter's namer. SC identifiers carry no prefix (the literal\n * theme object is the isolation boundary), so these do not alter identifiers in v1. */\n prefix?: string;\n classPrefix?: string;\n /**\n * §7B — swap how names are generated (shared type with the CSS adapter). `className` remaps a\n * recipe's export identity (camelCased); `variableName` has no coherent target on the nested theme\n * object and is accepted-but-structural (theme keys stay derived from the token address).\n */\n naming?: NamingOverrides;\n};\n\nconst isValidIdentifier = (name: string): boolean => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);\nconst objectKey = (name: string): string => (isValidIdentifier(name) ? name : JSON.stringify(name));\n\n/** Memoize an object property: build the value on first access, then replace the getter with it. */\nconst lazy = (obj: Record<string, unknown>, key: string, compute: () => unknown): void => {\n Object.defineProperty(obj, key, {\n configurable: true,\n enumerable: true,\n get() {\n const value = compute();\n Object.defineProperty(obj, key, { value, enumerable: true, configurable: true });\n return value;\n },\n });\n};\n\nexport const createStyledComponentsAdapter = (\n options: StyledComponentsAdapterOptions = {},\n): ThemeAdapter<StyledComponentsUnit> => {\n const language = options.language ?? \"ts\";\n const scheme: SchemeOption = options.scheme ?? \"media\";\n const helpers = options.helpers ?? [];\n\n const spec: AdapterSpec<StyledComponentsUnit> = {\n name: \"styled-components\",\n version: 1,\n allowedStates: SC_KNOWN_STATES,\n bind(model: ThemeModel, ctx: RenderContext) {\n const media = ctx.media as MediaDescriptor<string>;\n const ids = createIdentifiers(options.naming);\n\n // The literal theme object data (tokens + modes) — the shared source for both sinks.\n const data = buildThemeData(model, ctx.resolve);\n const recipeCtx: RecipeContext = { model, media, data, scheme, prefers: PREFERS };\n\n // Do any recipes reference `theme.scheme`? (Only dark/light under media/both do.)\n const usesScheme = (scheme === \"media\" || scheme === \"both\") && mediaEligibleModes(data.modeNames).length > 0;\n\n // ── Recipe IR registry (every rule-set except globals), addressed by \"subsystem.group.variant\". ──\n const addressKey = (subsystem: string, group: string, variant: string): string =>\n `${subsystem}.${group}.${variant}`;\n const registry = new Map<string, ReturnType<typeof buildRecipeIR>>();\n const recipeAddresses: Array<{ subsystem: string; group: string; variant: string }> = [];\n for (const [subsystem, sub] of Object.entries(model.subsystems)) {\n if (subsystem === \"globals\") continue;\n for (const [group, ruleSetGroup] of Object.entries(sub.ruleSets ?? {})) {\n for (const [variant, ruleSet] of Object.entries(ruleSetGroup)) {\n registry.set(addressKey(subsystem, group, variant), buildRecipeIR(ruleSet, recipeCtx));\n recipeAddresses.push({ subsystem, group, variant });\n }\n }\n }\n\n const ruleSetOf = (subsystem: string, group: string, variant: string): ModelRuleSet | undefined =>\n model.subsystems[subsystem]?.ruleSets?.[group]?.[variant];\n\n // ── Runtime sinks ──\n // Composition spreads inline the referenced recipe's live CSS (recursively).\n const spreadRenderer: SpreadRenderer = (subsystem, group, variant, theme) => {\n const nodes = registry.get(addressKey(subsystem, group, variant));\n return nodes ? recipePlainCss(nodes, theme, recipeCtx, spreadRenderer) : \"\";\n };\n\n const buildLiveRecipe = (subsystem: string, group: string, variant: string): RuleSet<object> => {\n const nodes = registry.get(addressKey(subsystem, group, variant)) ?? [];\n return css`${({ theme }: { theme: Record<string, any> }) => recipePlainCss(nodes, theme, recipeCtx, spreadRenderer)}`;\n };\n\n const wrappedMedia = wrapMediaDescriptor(media);\n const wrappedScheme = usesScheme ? wrapSchemeHelper(data.modeNames) : undefined;\n\n // The live theme object put on `theme` (recipes read it from styled-components context).\n const attach: Record<string, unknown> = { media: wrappedMedia };\n if (wrappedScheme) attach.scheme = wrappedScheme;\n const runtimeTheme = buildRuntimeThemeObject(data, attach);\n\n // Lazy + cached `recipes.<subsystem>.<group>.<variant>` — each lowered on first access.\n const buildRecipesTree = (): Record<string, unknown> => {\n const tree: Record<string, unknown> = {};\n for (const { subsystem, group, variant } of recipeAddresses) {\n const groups = (tree[subsystem] ??= {}) as Record<string, Record<string, unknown>>;\n const variants = (groups[group] ??= {});\n lazy(variants, variant, () => buildLiveRecipe(subsystem, group, variant));\n }\n return tree;\n };\n\n // Globals → a live GlobalStyle (present iff the raw defines the globals subsystem).\n const resetNodes = buildGlobalsIR(model.subsystems.globals?.ruleSets, recipeCtx);\n const GlobalStyle = resetNodes.length\n ? createGlobalStyle`${({ theme }: { theme: Record<string, any> }) => recipePlainCss(resetNodes, theme, recipeCtx, spreadRenderer)}`\n : undefined;\n\n // ── Emit sink ──\n const emit = (plan?: NormalizedEmit): EmitOutput => {\n const type = plan?.type ?? \"single\";\n if (type !== \"single\" && type !== \"split\") {\n throw new Error(\n `styled-components adapter: emit mode '${type}' is not supported — the TS/JS target ` +\n `emits 'single' or 'split' (ES modules tree-shake per export; 'subsystem'/'components' ` +\n `are CSS-only concerns).`,\n );\n }\n\n const spreadName = (subsystem: string, group: string, variant: string): string =>\n ids.recipeExportName(subsystem, group, variant);\n\n // Recipes in dependency-safe order (a composed component's references precede it in the list).\n const recipes: RecipeEmit[] = recipeAddresses.map(({ subsystem, group, variant }) => ({\n exportName: ids.recipeExportName(subsystem, group, variant),\n body: recipeSource(registry.get(addressKey(subsystem, group, variant)) ?? [], { spreadName }),\n }));\n\n // Grouped barrel referencing the flat consts.\n const barrelLines: string[] = [\"{\"];\n const bySubsystem = new Map<string, Array<{ group: string; variant: string }>>();\n for (const addr of recipeAddresses) {\n (bySubsystem.get(addr.subsystem) ?? bySubsystem.set(addr.subsystem, []).get(addr.subsystem)!).push(addr);\n }\n for (const [subsystem, addrs] of bySubsystem) {\n barrelLines.push(` ${subsystem}: {`);\n const byGroup = new Map<string, string[]>();\n for (const { group, variant } of addrs) {\n (byGroup.get(group) ?? byGroup.set(group, []).get(group)!).push(variant);\n }\n for (const [group, variants] of byGroup) {\n barrelLines.push(` ${objectKey(group)}: {`);\n for (const variant of variants) {\n barrelLines.push(` ${objectKey(variant)}: ${ids.recipeExportName(subsystem, group, variant)},`);\n }\n barrelLines.push(` },`);\n }\n barrelLines.push(` },`);\n }\n barrelLines.push(\"}\");\n\n const trailingRefs = [\n \"media\",\n ...(usesScheme ? [\"scheme\"] : []),\n ...(helpers.includes(\"color-math\") ? COLOR_MATH_ATTACH : []),\n ];\n\n const inputs: ScEmitInputs = {\n language,\n emitMode: type,\n helpers,\n usesScheme,\n themeObjectBody: serializeThemeObject(data, trailingRefs),\n recipes,\n recipesBarrelBody: barrelLines.join(\"\\n\"),\n resetBody: resetNodes.length ? recipeSource(resetNodes, { spreadName }) : undefined,\n vendorMedia: vendorMediaHelper(model.breakpoints, media),\n vendorScheme: usesScheme ? vendorSchemeHelper(data.modeNames) : undefined,\n };\n return buildScEmit(inputs);\n };\n\n return {\n recipeName(subsystem, group, variant) {\n return ids.recipeExportName(subsystem, group, variant);\n },\n\n // Self-documentation: the REAL export identifiers (the tree-shakeable `css` consts) plus\n // SC-specific wiring prose for the emitted guide (llms.txt).\n describeUsage(): UsageDescriptor {\n return {\n format: \"styled-components\",\n summary: [\n \"This theme is emitted as TypeScript/JavaScript modules: a literal `theme` object plus tree-shakeable `css` recipe exports (and a `GlobalStyle` if the theme defines globals).\",\n 'Wrap your app once in styled-components\\' `ThemeProvider` with the exported `theme`: `import { theme } from \"./theme\";` then `<ThemeProvider theme={theme}>`.',\n \"Apply a recipe by spreading its `css` export into a styled component: ``styled.button`${componentsButtonsPrimary}` ``. Recipes read their values from `props.theme`, so there is no `var()` and no separate stylesheet.\",\n \"If the theme defines globals, render `<GlobalStyle />` once inside the provider.\",\n ],\n recipes: recipeAddresses.map(({ subsystem, group, variant }) => ({\n subsystem,\n group,\n variant,\n name: ids.recipeExportName(subsystem, group, variant),\n })),\n };\n },\n renderRecipe(subsystem, group, variant) {\n return ruleSetOf(subsystem, group, variant)\n ? buildLiveRecipe(subsystem, group, variant)\n : css``;\n },\n // The SC target has no CSS variables (the theme object is the indirection).\n renderVariables() {\n return css``;\n },\n join(parts) {\n return parts.flat() as RuleSet<object>;\n },\n\n // The runtime surface: the literal theme object + lazy recipes + GlobalStyle + media/scheme.\n extend() {\n const surface: Record<string, unknown> = {\n theme: runtimeTheme,\n recipes: buildRecipesTree(),\n media: wrappedMedia,\n };\n if (wrappedScheme) surface.scheme = wrappedScheme;\n if (GlobalStyle) surface.GlobalStyle = GlobalStyle;\n return surface;\n },\n\n emit,\n };\n },\n };\n return defineAdapter(spec);\n};\n\n// Public glue re-exports.\nexport { wrapMediaDescriptor } from \"./media\";\nexport type {\n WrappedMediaDescriptor,\n WrappedMediaGroup,\n MediaTemplateWithQuery,\n} from \"./media\";\nexport type { SchemeHelper, SchemeTemplateWithQuery } from \"./scheme\";\n"],"names":["SC_STATE_SELECTORS","link","visited","hover","focus","active","disabled","pressed","SC_KNOWN_STATES","Object","keys","STATE_ORDER","reduce","acc","name","index","orderStateOverrides","overrides","map","override","sort","a","b","oa","_a","state","Number","MAX_SAFE_INTEGER","ob","_b","bpa","breakpoint","bpb","DEFAULT_MEDIA_QUERY","splitWords","segment","split","filter","Boolean","camelJoin","segments","words","flatMap","length","joined","w","i","word","charAt","toLowerCase","slice","toUpperCase","upperFirst","join","test","themeKey","segmentsAfterSubsystem","themeAccess","path","subsystem","rest","key","createIdentifiers","seen","Map","recipeExportName","group","variant","className","fallback","s","out","kind","classToken","Error","prev","get","undefined","set","track","formatValue","ref","resolve","struct","external","raw","value","unit","INDENT","serializeLeafMap","depth","pad","repeat","inner","entries","k","v","String","JSON","stringify","serializeTree","tree","serializeThemeObject","data","trailingRefs","lines","push","modeNames","mode","modes","str","refFragments","lit","tokenPaths","has","read","wrap","declNodes","declarations","nodes","property","type","parseReference","reference","dot","indexOf","schemeRealizations","scheme","mediaEligible","media","attribute","modeDeclNodes","overridden","modeOverridePaths","modeRef","buildRecipeIR","ruleSet","ctx","references","parsed","children","query","orientation","stateOverrides","o","stateSelector","block","selector","_c","baseMode","stateModeBlocks","accessExpr","nodeSource","node","indent","captured","opts","fragments","fragment","expr","fragmentsSource","spreadName","c","target","recipeSource","readTheme","theme","root","nodePlainCss","spread","fragmentsValue","min","max","exact","resolveMediaQuery","prefers","recipePlainCss","RESERVED_DESCRIPTOR_KEYS","Set","wrapMediaDescriptor","descriptor","wrapped","options","wrapQuery","between","from","to","wrapMediaGroup","forEach","assign","buildTemplate","styles","interpolations","css","PREFERS","dark","light","mediaEligibleModes","VARIANTS","COLOR_MATH_ATTACH","vendorMediaHelper","breakpoints","variants","scImport","needsCss","needsGlobal","themeImports","inputs","usesScheme","helpers","includes","themeConst","body","recipeConsts","recipes","r","exportName","recipesBarrel","globalStyle","objectKey","isValidIdentifier","lazy","obj","compute","defineProperty","configurable","enumerable","language","spec","version","allowedStates","bind","model","ids","naming","put","add","sub","subsystems","pm","properties","base","extra","extras","_d","entry","_e","basePath","field","_f","_h","_k","_g","_j","buildThemeData","recipeCtx","addressKey","registry","recipeAddresses","ruleSetGroup","ruleSets","spreadRenderer","buildLiveRecipe","wrappedMedia","wrappedScheme","helper","wrapSchemeHelper","attach","runtimeTheme","bySub","buildRuntimeThemeObject","buildRecipesTree","groups","resetNodes","values","variantName","variantRuleSet","variantChildren","buildGlobalsIR","globals","GlobalStyle","createGlobalStyle","recipeName","describeUsage","format","summary","renderRecipe","ruleSetOf","renderVariables","parts","flat","extend","surface","emit","plan","barrelLines","bySubsystem","addr","addrs","byGroup","files","vendorHelpers","vendorMedia","vendorScheme","hasRecipes","hasReset","resetBody","emitMode","themeObjectBody","recipesBarrelBody","endsWith","replace","buildScEmit","defineAdapter"],"mappings":"qFAkBO,MAAMA,EAA6C,CACxDC,KAAM,QACNC,QAAS,WACTC,MAAO,SACPC,MAAO,SACPC,OAAQ,UACRC,SAAU,aACVC,QAAS,kBAIEC,EAAyCC,OAAOC,KAAKV,GAE5DW,EAAsCH,EAAgBI,OAC1D,CAACC,EAAKC,EAAMC,KACVF,EAAIC,GAAQC,EACLF,GAET,CAAE,GAISG,EAAuBC,GAClCA,EACGC,IAAI,CAACC,EAAUJ,KAAW,CAAEI,WAAUJ,WACtCK,KAAK,CAACC,EAAGC,aACR,MAAMC,EAA4C,QAAvCC,EAAAb,EAAYU,EAAEF,SAASM,cAAgB,IAAAD,EAAAA,EAAIE,OAAOC,iBACvDC,EAA4C,QAAvCC,EAAAlB,EAAYW,EAAEH,SAASM,cAAgB,IAAAI,EAAAA,EAAIH,OAAOC,iBAC7D,GAAIJ,IAAOK,EAAI,OAAOL,EAAKK,EAC3B,MAAME,EAAMT,EAAEF,SAASY,WAAa,EAAI,EAClCC,EAAMV,EAAEH,SAASY,WAAa,EAAI,EACxC,OAAID,IAAQE,EAAYF,EAAME,EACvBX,EAAEN,MAAQO,EAAEP,QAEpBG,IAAI,EAAGC,cAAeA,GAMd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KqBJ,EAAKI,UFvKpD,scAJS0F,EAAmB1F,GAChCzF,IAAI0F,GAAQ,KAAKV,KAAKC,UAAUS,YAAeV,KAAKC,UAAU+F,EAAQtF,SACtEvD,KAAK,8CEyKgEwB,KAwDrE,GAEH,OAAO4O,EAAAA,cAAcrF"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/lowering.ts","../src/identifiers.ts","../src/theme-object.ts","../src/recipe.ts","../src/media.ts","../src/scheme.ts","../src/emit.ts","../src/index.ts"],"sourcesContent":["/**\n * Shared lowering helpers for the styled-components adapter — the format-neutral bits the recipe IR\n * builder ({@link ../recipe}) and both sinks (emit-source / runtime-live) lean on: the state-selector\n * table the adapter owns, canonical LVHA state ordering, and breakpoint → concrete `@media` string\n * resolution. It imports **only** core (Model + media types), so the adapter stays liftable to its own\n * package (Step 11).\n *\n * The SC target emits TS/JS modules (a literal theme object + `css` recipes), not a stylesheet, so\n * there is no CSS-variable / class-name lowering here — recipe values read straight from the theme\n * (`${({ theme }) => theme.…}`) and the theme object *is* the indirection.\n */\nimport type { MediaDescriptor, MediaVariant } from \"@theme-registry/refract\";\nimport type { Orientation, RuleSetOverride } from \"@theme-registry/refract\";\n\n// ---------------------------------------------------------------------------\n// State selector table (adapter-owned)\n// ---------------------------------------------------------------------------\n\nexport const SC_STATE_SELECTORS: Record<string, string> = {\n link: \":link\",\n visited: \":visited\",\n hover: \":hover\",\n focus: \":focus\",\n active: \":active\",\n disabled: \"[disabled]\",\n pressed: \"[aria-pressed]\",\n};\n\n/** The states the SC adapter can render (the validation set core threads into normalization). */\nexport const SC_KNOWN_STATES: ReadonlyArray<string> = Object.keys(SC_STATE_SELECTORS);\n\nconst STATE_ORDER: Record<string, number> = SC_KNOWN_STATES.reduce<Record<string, number>>(\n (acc, name, index) => {\n acc[name] = index;\n return acc;\n },\n {},\n);\n\n/** Order state overrides in canonical LVHA order (breakpoint-scoped ones after the base state). */\nexport const orderStateOverrides = (overrides: RuleSetOverride[]): RuleSetOverride[] =>\n overrides\n .map((override, index) => ({ override, index }))\n .sort((a, b) => {\n const oa = STATE_ORDER[a.override.state as string] ?? Number.MAX_SAFE_INTEGER;\n const ob = STATE_ORDER[b.override.state as string] ?? Number.MAX_SAFE_INTEGER;\n if (oa !== ob) return oa - ob;\n const bpa = a.override.breakpoint ? 1 : 0;\n const bpb = b.override.breakpoint ? 1 : 0;\n if (bpa !== bpb) return bpa - bpb;\n return a.index - b.index;\n })\n .map(({ override }) => override);\n\n// ---------------------------------------------------------------------------\n// Breakpoint → concrete @media query resolution\n// ---------------------------------------------------------------------------\n\nexport const DEFAULT_MEDIA_QUERY: MediaVariant = \"exact\";\n\n/** Resolve a breakpoint + query kind (+ orientation) to its concrete `@media (...)` string. */\nexport const resolveMediaQuery = <TBreakpoint extends string>(\n media: MediaDescriptor<TBreakpoint>,\n breakpoint: TBreakpoint,\n query: MediaVariant,\n orientation?: Orientation,\n): string => {\n if (!orientation) return media[breakpoint]?.[query] ?? \"\";\n const opts = { orientation };\n if (query === \"min\") return media.min(breakpoint, opts);\n if (query === \"max\") return media.max(breakpoint, opts);\n return media.exact(breakpoint, opts);\n};\n","/**\n * JS-identifier naming for the styled-components TS/JS emit (§8).\n *\n * The SC target emits a **literal theme object** and **flat `css` recipe consts**, so its names are\n * JavaScript identifiers, not CSS variables/classes. This module is the SC analogue of the shared\n * `../naming` namer: it reuses that module's `sanitizeSegment` + collision-guard discipline (§7B) but\n * produces a **camelCase identifier form** instead of a kebab class/var.\n *\n * theme key: `themeKey([\"primary\", \"text\"])` → `primaryText` (folds a variant/extra\n * into its group under `theme.<subsystem>`)\n * theme access: `themeAccess(\"colors.primary.text\")` → `{ subsystem: \"colors\", key: \"primaryText\" }`\n * recipe export: `recipeExportName(\"components\",\"buttons\",\"primary\")` → `componentsButtonsPrimary`\n *\n * Unlike the CSS/SC class names, SC identifiers carry **no prefix** (the artifact's `colorsSolidPrimary`,\n * not `dtColorsSolidPrimary`) — the literal theme object *is* the isolation boundary. The §7B\n * `naming.className` override still remaps a recipe's identity (its export name); `naming.variableName`\n * has no coherent target on a nested object and is accepted-but-structural (theme keys stay derived).\n */\nimport type { NamingOverrides } from \"@theme-registry/refract/adapter-kit\";\n\n/** Split an authored segment into alphanumeric words (`\"button-lg\"` → `[\"button\",\"lg\"]`). Interior\n * case is preserved so an already-camelCase property (`fontSize`) survives as one word. */\nconst splitWords = (segment: string): string[] => segment.split(/[^a-zA-Z0-9]+/).filter(Boolean);\n\nconst lowerFirst = (word: string): string => word.charAt(0).toLowerCase() + word.slice(1);\nconst upperFirst = (word: string): string => word.charAt(0).toUpperCase() + word.slice(1);\n\n/**\n * camelCase-join a list of address segments into one identifier: the first word lower-cased, every\n * later word upper-cased and concatenated. A leading digit (invalid identifier start) is prefixed `_`.\n */\nexport const camelJoin = (segments: string[]): string => {\n const words = segments.flatMap(splitWords);\n if (!words.length) return \"_\";\n const joined = words.map((w, i) => (i === 0 ? lowerFirst(w) : upperFirst(w))).join(\"\");\n return /^[0-9]/.test(joined) ? `_${joined}` : joined;\n};\n\n/** A token's key under `theme.<subsystem>` — the property + its variant/extra segments camel-folded. */\nexport const themeKey = (segmentsAfterSubsystem: string[]): string => camelJoin(segmentsAfterSubsystem);\n\n/** A dotted token path → its `theme.<subsystem>.<key>` address parts. `colors.primary.text` →\n * `{ subsystem: \"colors\", key: \"primaryText\" }`; `borders.radius` → `{ subsystem: \"borders\", key: \"radius\" }`. */\nexport const themeAccess = (path: string): { subsystem: string; key: string } => {\n const [subsystem, ...rest] = path.split(\".\");\n return { subsystem, key: themeKey(rest) };\n};\n\n/**\n * A bound identifier minter for one theme: the recipe-export namer with the §7B collision guard.\n * Distinct addresses producing the same identifier throw; the same address re-resolving is fine.\n */\nexport interface ScIdentifiers {\n /** The camelCase export name for a recipe (`components`,`buttons`,`primary` → `componentsButtonsPrimary`). */\n recipeExportName(subsystem: string, group: string, variant: string): string;\n}\n\nexport const createIdentifiers = (overrides?: NamingOverrides): ScIdentifiers => {\n const seen = new Map<string, string>(); // identifier → source address key\n\n const track = (name: string, key: string): void => {\n const prev = seen.get(name);\n if (prev !== undefined && prev !== key) {\n throw new Error(\n `styled-components emit: recipe identifier \"${name}\" is produced by both \"${prev}\" and ` +\n `\"${key}\" — the naming override must map distinct recipes to distinct identifiers`,\n );\n }\n seen.set(name, key);\n };\n\n return {\n recipeExportName(subsystem, group, variant) {\n const segments = [subsystem, group, variant];\n let name = camelJoin(segments);\n if (overrides?.className) {\n // Feed the override a PREFIX-FREE default (SC identifiers carry no prefix), so a no-op\n // decorator round-trips to the structural name and only a real remap changes identity.\n const fallback = segments.map(s => splitWords(s).join(\"-\")).join(\"-\");\n const out = overrides.className(\n { kind: \"recipe\", subsystem, group, variant },\n { classToken: \"\", name: fallback },\n );\n name = camelJoin(splitWords(out));\n if (!name || name === \"_\") {\n throw new Error(\n `styled-components emit: className override returned an empty/invalid identifier for ` +\n `\"${subsystem}.${group}.${variant}\"`,\n );\n }\n }\n track(name, `${subsystem}.${group}.${variant}`);\n return name;\n },\n };\n};\n","/**\n * The literal theme object (§8) — the SC target's replacement for CSS `:root` variables.\n *\n * `buildThemeData` walks the Model's property tokens into a nested `{ [subsystem]: { [camelKey]: literal } }`\n * tree (variants/extras fold into their group as camelCased keys — `primary` → `primaryText`), plus a\n * parallel `modes` tree (§10.3 appearance-mode overrides — only the fields a mode redefines). The object\n * **is** the indirection: values are resolved literals, no `var()`. The same data serves two sinks — a\n * live JS object for the runtime `theme` (recipes read it from styled-components context) and an\n * object-literal source string for `emit()`.\n *\n * Structured compound tokens (§15 shadow / transition `Ref.struct`) are **skipped** — the SC adapter's\n * structured composition is deferred, exactly as the prior stylesheet lane skipped their `:root` vars.\n */\nimport type { ThemeModel, Ref, Literal } from \"@theme-registry/refract\";\nimport { themeKey } from \"./identifiers\";\n\n/** A resolved literal in the theme object: a number stays a number (`fontWeight`), a length/colour is a string. */\nexport type ThemeLiteral = string | number;\ntype ThemeTree = Record<string, Record<string, ThemeLiteral>>;\ntype ModesTree = Record<string, ThemeTree>;\n\nexport interface ThemeData {\n /** `subsystem → key → literal` (no `modes` / helpers — those are attached by the caller). */\n readonly tree: ThemeTree;\n /** `mode → subsystem → key → literal` — only the fields each mode redefines. */\n readonly modes: ModesTree;\n /** The mode names present (`[\"dark\"]`), in first-seen order. */\n readonly modeNames: string[];\n /** Every dotted token path that made it into the tree (non-struct) — recipe refs check membership. */\n readonly tokenPaths: Set<string>;\n /** `mode → set of dotted token paths that carry an override` — the recipe scheme block reads this. */\n readonly modeOverridePaths: Record<string, Set<string>>;\n}\n\n/** Format one token `Ref` to its theme-object literal. Returns `undefined` for a structured token (skipped). */\nconst formatValue = (ref: Ref, path: string, resolve: (path: string) => Literal): ThemeLiteral | undefined => {\n if (ref.struct !== undefined) return undefined;\n if (ref.external !== undefined) return `var(${ref.external})`; // §W6b — the theme entry IS the parent var\n\n const raw: Literal = ref.value !== undefined ? ref.value : resolve(path);\n // §21: a length leaf carries its resolved unit — emit `value + unit` as a string. A unit-less number\n // (fontWeight / lineHeight / opacity) has no `unit` and stays a JS number, so the theme object types\n // it as `number`.\n if (ref.unit !== undefined) return `${raw}${ref.unit}`;\n return raw;\n};\n\n/** Walk the Model into the nested theme tree + modes tree. `resolve` fills in pure-alias tokens. */\nexport const buildThemeData = (model: ThemeModel, resolve: (path: string) => Literal): ThemeData => {\n const tree: ThemeTree = {};\n const modes: ModesTree = {};\n const modeNames: string[] = [];\n const tokenPaths = new Set<string>();\n const modeOverridePaths: Record<string, Set<string>> = {};\n\n const put = (subsystem: string, key: string, path: string, ref: Ref): void => {\n const value = formatValue(ref, path, resolve);\n if (value === undefined) return; // structured token — deferred\n (tree[subsystem] ??= {})[key] = value;\n tokenPaths.add(path);\n };\n\n for (const [subsystem, sub] of Object.entries(model.subsystems)) {\n for (const [property, pm] of Object.entries(sub.properties ?? {})) {\n put(subsystem, themeKey([property]), `${subsystem}.${property}`, pm.base);\n for (const [extra, ref] of Object.entries(pm.extras ?? {})) {\n put(subsystem, themeKey([property, extra]), `${subsystem}.${property}.${extra}`, ref);\n }\n for (const [variant, v] of Object.entries(pm.variants ?? {})) {\n put(subsystem, themeKey([property, variant]), `${subsystem}.${property}.${variant}`, v.base);\n // dec.3 — a variant's own extras map to `<property><Variant><Extra>` in the SC theme object.\n for (const [extra, ref] of Object.entries(v.extras ?? {})) {\n put(subsystem, themeKey([property, variant, extra]), `${subsystem}.${property}.${variant}.${extra}`, ref);\n }\n }\n // §10.3 appearance modes — a LIST of `{ mode, target?, overrides }`. Each field maps to the\n // property key (or a variant key when `target` scopes it); an extra field appends `<Extra>`.\n // The recipe scheme block re-reads exactly these paths.\n for (const entry of pm.modes ?? []) {\n const mode = entry.mode;\n if (mode === undefined) continue;\n const target = entry.target;\n const segments = target ? [property, target] : [property];\n const basePath = target ? `${subsystem}.${property}.${target}` : `${subsystem}.${property}`;\n for (const [field, ref] of Object.entries(entry.overrides ?? {})) {\n const value = formatValue(ref, `${subsystem}.${property}`, resolve);\n if (value === undefined) continue;\n const key = field === \"base\" ? themeKey(segments) : themeKey([...segments, field]);\n const path = field === \"base\" ? basePath : `${basePath}.${field}`;\n if (!modeNames.includes(mode)) modeNames.push(mode);\n (((modes[mode] ??= {})[subsystem] ??= {}))[key] = value;\n (modeOverridePaths[mode] ??= new Set()).add(path);\n }\n }\n }\n }\n\n return { tree, modes, modeNames, tokenPaths, modeOverridePaths };\n};\n\n// ---------------------------------------------------------------------------\n// Serialization to object-literal source (emit)\n// ---------------------------------------------------------------------------\n\nconst INDENT = \" \";\n\n/** A theme literal → its JS source (`600` stays a number literal; a string is JSON-quoted). */\nconst literalSource = (value: ThemeLiteral): string =>\n typeof value === \"number\" ? String(value) : JSON.stringify(value);\n\nconst serializeLeafMap = (map: Record<string, ThemeLiteral>, depth: number): string => {\n const pad = INDENT.repeat(depth);\n const inner = INDENT.repeat(depth + 1);\n const entries = Object.entries(map).map(([k, v]) => `${inner}${k}: ${literalSource(v)},`);\n return `{\\n${entries.join(\"\\n\")}\\n${pad}}`;\n};\n\nconst serializeTree = (tree: ThemeTree, depth: number): string[] =>\n Object.entries(tree).map(\n ([subsystem, map]) => `${INDENT.repeat(depth)}${subsystem}: ${serializeLeafMap(map, depth)},`,\n );\n\n/**\n * Serialize the theme object literal body (the `{ … }`), including the subsystem trees, the optional\n * `modes` tree, and any trailing bare-identifier refs (`media`, `scheme`, helper fns) the caller wires.\n */\nexport const serializeThemeObject = (data: ThemeData, trailingRefs: string[]): string => {\n const lines: string[] = [\"{\"];\n lines.push(...serializeTree(data.tree, 1));\n\n if (data.modeNames.length) {\n lines.push(`${INDENT}modes: {`);\n for (const mode of data.modeNames) {\n lines.push(`${INDENT.repeat(2)}${mode}: {`);\n lines.push(...serializeTree(data.modes[mode], 3));\n lines.push(`${INDENT.repeat(2)}},`);\n }\n lines.push(`${INDENT}},`);\n }\n\n for (const ref of trailingRefs) lines.push(`${INDENT}${ref},`);\n lines.push(\"}\");\n return lines.join(\"\\n\");\n};\n\n/**\n * Assemble the **live** runtime theme object: the token tree + `modes` + the wrapped `media` / `scheme`\n * tagged-template helpers + any opted-in color-math fns. This is what a consumer passes to\n * `<ThemeProvider>`; recipes read every value off it via styled-components context.\n */\nexport const buildRuntimeThemeObject = (\n data: ThemeData,\n attach: Record<string, unknown>,\n): Record<string, unknown> => {\n const obj: Record<string, unknown> = {};\n for (const [subsystem, map] of Object.entries(data.tree)) obj[subsystem] = { ...map };\n if (data.modeNames.length) {\n const modes: Record<string, unknown> = {};\n for (const mode of data.modeNames) {\n const bySub: Record<string, unknown> = {};\n for (const [subsystem, map] of Object.entries(data.modes[mode])) bySub[subsystem] = { ...map };\n modes[mode] = bySub;\n }\n obj.modes = modes;\n }\n Object.assign(obj, attach);\n return obj;\n};\n","/**\n * The shared recipe renderer (§8) — one lowering, two sinks.\n *\n * A recipe {@link RuleSet} lowers to a format-neutral node tree ({@link RecipeNode}) — base\n * declarations, composition spreads, state / breakpoint / colour-scheme conditional blocks — that\n * BOTH sinks walk:\n * - **`recipeSource`** serializes it to `css\\`…\\`` **source** (`${({ theme }) => theme.…}` value\n * reads, `${sibling}` composition spreads, `theme.media` / `theme.scheme` tagged-template blocks)\n * for `emit()`.\n * - **`recipePlainCss`** renders it to a **live CSS string** off a runtime theme object (values\n * resolved from `props.theme`, breakpoints as concrete `@media`, dark as `prefers-color-scheme` /\n * `[data-theme]`) — the body of a lazy `css` block for the runtime surface.\n *\n * Values read from the theme, never `var()`; dark mode lives *in the recipe block* (§10.3), so it\n * tree-shakes with the recipe and switches with a plain CSS recalc — no `:root`, no provider swap.\n */\nimport type { MediaDescriptor, MediaVariant } from \"@theme-registry/refract\";\nimport type { Ref, RuleSet, RuleSetGroup, ThemeModel } from \"@theme-registry/refract\";\nimport { SC_STATE_SELECTORS, orderStateOverrides, resolveMediaQuery, DEFAULT_MEDIA_QUERY } from \"./lowering\";\nimport { themeAccess } from \"./identifiers\";\nimport type { ThemeData } from \"./theme-object\";\n\n/** How `model.modes` are realized into a recipe (§8): OS media, a `[data-theme]` toggle, or both. */\nexport type SchemeOption = \"media\" | \"attribute\" | \"both\";\n\n// ---------------------------------------------------------------------------\n// Node tree (the shared lowering)\n// ---------------------------------------------------------------------------\n\n/** One fragment of a declaration value: literal text, a theme token read, or an appearance-mode read. */\ntype Fragment =\n | { lit: string }\n | { ref: string }\n | { modeRef: { mode: string; path: string } };\n\ntype RecipeNode =\n | { type: \"decl\"; property: string; value: Fragment[] }\n /** A nested selector block (`&:hover`, `[data-theme=\"dark\"] &`) — arrow-form value reads. */\n | { type: \"block\"; selector: string; children: RecipeNode[] }\n /** A breakpoint block realized via `theme.media.<bp>.<query>` (captured-form reads inside). */\n | { type: \"media\"; breakpoint: string; query: MediaVariant; orientation?: \"landscape\" | \"portrait\"; children: RecipeNode[] }\n /** A colour-scheme block realized via `theme.scheme.<mode>` (captured-form reads inside). */\n | { type: \"scheme\"; mode: string; children: RecipeNode[] }\n /** A composition spread of a sibling recipe (`${componentsButtonsPrimary}` / inline its CSS). */\n | { type: \"spread\"; subsystem: string; group: string; variant: string };\n\n/** Context threaded into the IR builder + both sinks. */\nexport interface RecipeContext {\n readonly model: ThemeModel;\n readonly media: MediaDescriptor<string>;\n readonly data: ThemeData;\n readonly scheme: SchemeOption;\n /** The concrete `@media (prefers-color-scheme: <mode>)` string per realizable mode. */\n readonly prefers: Record<string, string>;\n}\n\nconst str = (value: unknown): string => (value == null ? \"\" : String(value));\n\n/** A rule-set declaration `Ref` → its value fragments. Returns `undefined` to SKIP the declaration\n * (a structured token the theme object doesn't carry). A literal is emitted as-is; a token ref (with\n * optional adapter `wrap`, e.g. `blur(…)`) becomes a theme read. */\nconst refFragments = (ref: Ref, data: ThemeData): Fragment[] | undefined => {\n if (ref.ref === undefined) return [{ lit: str(ref.value) }];\n if (!data.tokenPaths.has(ref.ref)) return undefined; // structured / absent token — deferred\n const read: Fragment = { ref: ref.ref };\n return ref.wrap ? [{ lit: `${ref.wrap}(` }, read, { lit: \")\" }] : [read];\n};\n\nconst declNodes = (declarations: Record<string, Ref> | undefined, data: ThemeData): RecipeNode[] => {\n const nodes: RecipeNode[] = [];\n for (const [property, ref] of Object.entries(declarations ?? {})) {\n const value = refFragments(ref, data);\n if (value) nodes.push({ type: \"decl\", property, value });\n }\n return nodes;\n};\n\n/** Parse a component composition reference (`\"colors:solid.primary\"`) into its address. */\nconst parseReference = (\n reference: string,\n): { subsystem: string; group: string; variant: string } | undefined => {\n const [subsystem, rest] = reference.split(\":\");\n if (!subsystem || !rest) return undefined;\n const dot = rest.indexOf(\".\");\n if (dot < 0) return undefined;\n return { subsystem, group: rest.slice(0, dot), variant: rest.slice(dot + 1) };\n};\n\n/** Which realizations (media / attribute) a mode uses under the current `scheme` option. Only `dark`\n * / `light` can ride `prefers-color-scheme`; any other named mode falls back to `[data-theme]`. */\nconst schemeRealizations = (mode: string, scheme: SchemeOption): { media: boolean; attribute: boolean } => {\n const mediaEligible = mode === \"dark\" || mode === \"light\";\n const media = mediaEligible && (scheme === \"media\" || scheme === \"both\");\n const attribute =\n scheme === \"attribute\" || scheme === \"both\" || (scheme === \"media\" && !mediaEligible);\n return { media, attribute };\n};\n\n/** Mode-override declarations for a set of declarations, reading `theme.modes.<mode>.…`. */\nconst modeDeclNodes = (\n declarations: Record<string, Ref> | undefined,\n mode: string,\n data: ThemeData,\n): RecipeNode[] => {\n const overridden = data.modeOverridePaths[mode];\n if (!overridden) return [];\n const nodes: RecipeNode[] = [];\n for (const [property, ref] of Object.entries(declarations ?? {})) {\n if (ref.ref !== undefined && overridden.has(ref.ref)) {\n nodes.push({ type: \"decl\", property, value: [{ modeRef: { mode, path: ref.ref } }] });\n }\n }\n return nodes;\n};\n\n/**\n * Lower one recipe {@link RuleSet} (+ optional composition `references`) to the shared node tree:\n * spreads → base declarations → breakpoint blocks → state blocks → colour-scheme blocks.\n */\nexport const buildRecipeIR = (ruleSet: RuleSet, ctx: RecipeContext): RecipeNode[] => {\n const nodes: RecipeNode[] = [];\n\n // Composition (components): spread each referenced sibling recipe first.\n for (const reference of ruleSet.references ?? []) {\n const parsed = parseReference(reference);\n if (parsed) nodes.push({ type: \"spread\", ...parsed });\n }\n\n // Base declarations.\n nodes.push(...declNodes(ruleSet.declarations, ctx.data));\n\n // Breakpoint-only overrides → a media block.\n for (const override of ruleSet.overrides) {\n if (override.state !== undefined || !override.breakpoint) continue;\n const children = declNodes(override.declarations, ctx.data);\n if (children.length) {\n nodes.push({\n type: \"media\",\n breakpoint: override.breakpoint,\n query: (override.query ?? DEFAULT_MEDIA_QUERY) as MediaVariant,\n orientation: override.orientation,\n children,\n });\n }\n }\n\n // State (+ state×breakpoint) overrides → a `&:hover`-style block, canonical LVHA order.\n const stateOverrides = ruleSet.overrides.filter(o => o.state !== undefined);\n for (const override of orderStateOverrides(stateOverrides)) {\n const stateSelector = SC_STATE_SELECTORS[override.state as string];\n const children = declNodes(override.declarations, ctx.data);\n if (!stateSelector || !children.length) continue;\n const block: RecipeNode = { type: \"block\", selector: `&${stateSelector}`, children };\n if (override.breakpoint) {\n nodes.push({\n type: \"media\",\n breakpoint: override.breakpoint,\n query: (override.query ?? DEFAULT_MEDIA_QUERY) as MediaVariant,\n orientation: override.orientation,\n children: [block],\n });\n } else {\n nodes.push(block);\n }\n }\n\n // Colour-scheme blocks (§10.3) — one per mode whose fields this recipe reads.\n for (const mode of ctx.data.modeNames) {\n const baseMode = modeDeclNodes(ruleSet.declarations, mode, ctx.data);\n const stateModeBlocks: RecipeNode[] = [];\n for (const override of orderStateOverrides(stateOverrides)) {\n const stateSelector = SC_STATE_SELECTORS[override.state as string];\n if (!stateSelector) continue;\n const children = modeDeclNodes(override.declarations, mode, ctx.data);\n if (children.length) stateModeBlocks.push({ type: \"block\", selector: `&${stateSelector}`, children });\n }\n const children = [...baseMode, ...stateModeBlocks];\n if (!children.length) continue;\n\n const { media, attribute } = schemeRealizations(mode, ctx.scheme);\n if (media) nodes.push({ type: \"scheme\", mode, children });\n if (attribute) nodes.push({ type: \"block\", selector: `[data-theme=\"${mode}\"] &`, children });\n }\n\n return nodes;\n};\n\n/**\n * Lower the `globals` subsystem's rule-sets (§9) into `block` nodes for the `GlobalStyle` — one raw\n * `<selector> { … }` per rule-set. Two kinds:\n * - `kind:\"reset\"` (preset `static` / `defaults`) — declaration-only (literals as-is, token refs as\n * theme reads).\n * - `kind:\"globals\"` (themed `elements`) — the element's base declarations PLUS its state/breakpoint/\n * colour-scheme blocks (via {@link buildRecipeIR}) and each delta-only variant nested as a\n * `&.<variant>` block. Dark rides the referenced token's own modes — realized *inside* the element\n * block as a `theme.scheme.<mode>` / `[data-theme]` conditional (same as recipes), no `:root`.\n * Feeds the `GlobalStyle` emitter + the runtime `GlobalStyle`.\n */\nexport const buildGlobalsIR = (\n groups: Record<string, RuleSetGroup> | undefined,\n ctx: RecipeContext,\n): RecipeNode[] => {\n const nodes: RecipeNode[] = [];\n for (const group of Object.values(groups ?? {})) {\n for (const ruleSet of Object.values(group)) {\n if (!ruleSet.selector) continue;\n if (ruleSet.kind === \"globals\") {\n const children = buildRecipeIR(ruleSet, ctx);\n for (const [variantName, variant] of Object.entries(ruleSet.variants ?? {})) {\n const variantRuleSet: RuleSet = {\n kind: \"globals\",\n selector: ruleSet.selector,\n declarations: variant.declarations,\n overrides: variant.overrides,\n };\n const variantChildren = buildRecipeIR(variantRuleSet, ctx);\n if (variantChildren.length) {\n children.push({ type: \"block\", selector: `&.${variantName}`, children: variantChildren });\n }\n }\n if (children.length) nodes.push({ type: \"block\", selector: ruleSet.selector, children });\n } else {\n const children = declNodes(ruleSet.declarations, ctx.data);\n if (children.length) nodes.push({ type: \"block\", selector: ruleSet.selector, children });\n }\n }\n }\n return nodes;\n};\n\n// ---------------------------------------------------------------------------\n// Sink 1 — source serialization (emit)\n// ---------------------------------------------------------------------------\n\nconst INDENT = \" \";\n\n/** A theme read `theme.<subsystem>.<key>` (optionally under `modes.<mode>`). */\nconst accessExpr = (path: string, mode?: string): string => {\n const { subsystem, key } = themeAccess(path);\n return mode ? `theme.modes.${mode}.${subsystem}.${key}` : `theme.${subsystem}.${key}`;\n};\n\n/** Serialize one declaration's value fragments. `captured` = inside a media/scheme tagged template\n * (the outer arrow already bound `theme`, so reads are bare `${theme.…}` not `${({theme})=>…}`). */\nconst fragmentsSource = (fragments: Fragment[], captured: boolean): string =>\n fragments\n .map(fragment => {\n if (\"lit\" in fragment) return fragment.lit;\n const expr = \"ref\" in fragment ? accessExpr(fragment.ref) : accessExpr(fragment.modeRef.path, fragment.modeRef.mode);\n return captured ? `\\${${expr}}` : `\\${({ theme }) => ${expr}}`;\n })\n .join(\"\");\n\ninterface SourceOptions {\n /** The export identifier for a spread reference (`components`,`buttons`,`primary` → `componentsButtonsPrimary`). */\n spreadName(subsystem: string, group: string, variant: string): string;\n}\n\nconst nodeSource = (node: RecipeNode, indent: string, captured: boolean, opts: SourceOptions): string => {\n switch (node.type) {\n case \"decl\":\n return `${indent}${node.property}: ${fragmentsSource(node.value, captured)};`;\n case \"spread\":\n return `${indent}\\${${opts.spreadName(node.subsystem, node.group, node.variant)}}`;\n case \"block\": {\n const inner = node.children.map(c => nodeSource(c, indent + INDENT, captured, opts)).join(\"\\n\");\n return `${indent}${node.selector} {\\n${inner}\\n${indent}}`;\n }\n case \"media\": {\n const target = node.orientation\n ? `theme.media.${node.query}(${JSON.stringify(node.breakpoint)}, { orientation: ${JSON.stringify(node.orientation)} })`\n : `theme.media.${node.breakpoint}.${node.query}`;\n const inner = node.children.map(c => nodeSource(c, indent + INDENT, true, opts)).join(\"\\n\");\n return `${indent}\\${({ theme }) => ${target}\\`\\n${inner}\\n${indent}\\`}`;\n }\n case \"scheme\": {\n const inner = node.children.map(c => nodeSource(c, indent + INDENT, true, opts)).join(\"\\n\");\n return `${indent}\\${({ theme }) => theme.scheme.${node.mode}\\`\\n${inner}\\n${indent}\\`}`;\n }\n }\n};\n\n/** Serialize a recipe's node tree to the body of a `css\\`…\\`` template (2-space indented). */\nexport const recipeSource = (nodes: RecipeNode[], opts: SourceOptions): string =>\n nodes.map(node => nodeSource(node, INDENT, false, opts)).join(\"\\n\");\n\n// ---------------------------------------------------------------------------\n// Sink 2 — live plain-CSS rendering (runtime)\n// ---------------------------------------------------------------------------\n\n/** Read a value off the runtime theme object: `theme[subsystem][key]` (optionally under `modes.<mode>`). */\nconst readTheme = (theme: Record<string, any>, path: string, mode?: string): unknown => {\n const { subsystem, key } = themeAccess(path);\n const root = mode ? theme?.modes?.[mode] : theme;\n return root?.[subsystem]?.[key];\n};\n\nconst fragmentsValue = (fragments: Fragment[], theme: Record<string, any>): string =>\n fragments\n .map(fragment => {\n if (\"lit\" in fragment) return fragment.lit;\n if (\"ref\" in fragment) return str(readTheme(theme, fragment.ref));\n return str(readTheme(theme, fragment.modeRef.path, fragment.modeRef.mode));\n })\n .join(\"\");\n\n/** Resolve a sibling recipe's live CSS (composition) — injected by the adapter's lazy registry. */\nexport type SpreadRenderer = (\n subsystem: string,\n group: string,\n variant: string,\n theme: Record<string, any>,\n) => string;\n\nconst nodePlainCss = (\n node: RecipeNode,\n theme: Record<string, any>,\n ctx: RecipeContext,\n spread: SpreadRenderer,\n): string => {\n switch (node.type) {\n case \"decl\":\n return `${node.property}: ${fragmentsValue(node.value, theme)};`;\n case \"spread\":\n return spread(node.subsystem, node.group, node.variant, theme);\n case \"block\": {\n const inner = node.children.map(c => nodePlainCss(c, theme, ctx, spread)).join(\" \");\n return `${node.selector} { ${inner} }`;\n }\n case \"media\": {\n const query = resolveMediaQuery(ctx.media, node.breakpoint, node.query, node.orientation);\n const inner = node.children.map(c => nodePlainCss(c, theme, ctx, spread)).join(\" \");\n return query ? `${query} { ${inner} }` : inner;\n }\n case \"scheme\": {\n const query = ctx.prefers[node.mode] ?? \"\";\n const inner = node.children.map(c => nodePlainCss(c, theme, ctx, spread)).join(\" \");\n return query ? `${query} { ${inner} }` : inner;\n }\n }\n};\n\n/** Render a recipe's node tree to a live CSS string off a runtime theme object. */\nexport const recipePlainCss = (\n nodes: RecipeNode[],\n theme: Record<string, any>,\n ctx: RecipeContext,\n spread: SpreadRenderer,\n): string => nodes.map(node => nodePlainCss(node, theme, ctx, spread)).join(\"\\n\");\n","/**\n * SC-decorated media — the `wrapMedia` half of the adapter contract's media pattern.\n *\n * Core builds the plain {@link MediaDescriptor} (breakpoints → `@media (min-width:…)` strings);\n * this decorates it into styled-components **tagged-template** helpers so a consumer writes\n * `theme.media.md.min\\`color: red;\\`` (or `theme.media.min(\"md\")\\`…\\``) and gets an SC `css` block\n * scoped to that query. Re-ported from the dormant legacy SC adapter onto the clean-room\n * `core/media` (imports only core — self-contained for the Step 9 package extraction).\n */\nimport { css } from \"styled-components\";\nimport type { Interpolation, RuleSet } from \"styled-components\";\nimport type {\n MediaDescriptor,\n MediaGroupDescriptor,\n MediaQueryOptions,\n MediaVariant,\n} from \"@theme-registry/refract\";\n\ntype MediaTemplate = (\n styles: TemplateStringsArray,\n ...interpolations: Interpolation<object>[]\n) => RuleSet<object>;\n\n/** A media tagged-template that also carries the raw `@media` query string it wraps. */\nexport type MediaTemplateWithQuery = MediaTemplate & { readonly query: string };\n\nexport type WrappedMediaGroup = Record<MediaVariant, MediaTemplateWithQuery>;\n\n/** The SC-decorated media descriptor put on `theme.media` — tagged templates instead of strings. */\nexport type WrappedMediaDescriptor<TBreakpoint extends string> = {\n min: (key: TBreakpoint, options?: MediaOrientationOptions) => MediaTemplateWithQuery;\n max: (key: TBreakpoint, options?: MediaOrientationOptions) => MediaTemplateWithQuery;\n between: (\n from: TBreakpoint,\n to: TBreakpoint,\n options?: MediaOrientationOptions,\n ) => MediaTemplateWithQuery;\n} & Record<TBreakpoint, WrappedMediaGroup>;\n\ntype MediaOrientationOptions = Pick<MediaQueryOptions, \"orientation\">;\n\nconst RESERVED_DESCRIPTOR_KEYS = new Set([\"min\", \"max\", \"between\", \"exact\"]);\n\n/** Decorate a core {@link MediaDescriptor} into SC tagged-template helpers. */\nexport const wrapMediaDescriptor = <TBreakpoint extends string>(\n descriptor: MediaDescriptor<TBreakpoint>,\n): WrappedMediaDescriptor<TBreakpoint> => {\n const wrapped = {\n min: (key: TBreakpoint, options?: MediaOrientationOptions) =>\n wrapQuery(descriptor.min(key, options)),\n max: (key: TBreakpoint, options?: MediaOrientationOptions) =>\n wrapQuery(descriptor.max(key, options)),\n between: (from: TBreakpoint, to: TBreakpoint, options?: MediaOrientationOptions) =>\n wrapQuery(descriptor.between(from, to, options)),\n } as WrappedMediaDescriptor<TBreakpoint>;\n\n for (const key of Object.keys(descriptor) as TBreakpoint[]) {\n if (RESERVED_DESCRIPTOR_KEYS.has(key)) continue;\n (wrapped as Record<string, unknown>)[key] = wrapMediaGroup(\n descriptor[key] as MediaGroupDescriptor,\n );\n }\n\n return wrapped;\n};\n\nexport const wrapMediaGroup = (group: MediaGroupDescriptor): WrappedMediaGroup => {\n const wrapped = {} as WrappedMediaGroup;\n (Object.keys(group) as MediaVariant[]).forEach(variant => {\n wrapped[variant] = wrapQuery(group[variant]);\n });\n return wrapped;\n};\n\nconst wrapQuery = (query: string): MediaTemplateWithQuery =>\n Object.assign(buildTemplate(query), { query }) as MediaTemplateWithQuery;\n\nconst buildTemplate = (query: string): MediaTemplate => {\n if (!query) {\n return (styles, ...interpolations) => css`\n ${css(styles, ...interpolations)}\n `;\n }\n return (styles, ...interpolations) => css`\n ${query} {\n ${css(styles, ...interpolations)}\n }\n `;\n};\n","/**\n * SC colour-scheme tagged templates (§8) — the `theme.scheme.dark\\`…\\`` half of the appearance-mode\n * (§10.3) realization, parallel to `media.ts`. A recipe's dark block interpolates\n * `${({ theme }) => theme.scheme.dark\\`…\\`}`, which wraps its body in\n * `@media (prefers-color-scheme: dark) { … }`. Only `dark` / `light` ride `prefers-color-scheme`\n * (a `[data-theme]` toggle handles any other named mode — that path uses a plain nested selector,\n * not this helper).\n *\n * Two forms, like media: a **runtime** wrapper (`wrapSchemeHelper`) put on the live `theme.scheme`,\n * and a **vendored** self-contained module (`vendorSchemeHelper`) written by `emit()` so a downstream\n * app keeps `theme.scheme` after it drops refract (its only dependency is `styled-components`).\n */\nimport { css } from \"styled-components\";\nimport type { Interpolation, RuleSet } from \"styled-components\";\n\n/** The concrete `@media (prefers-color-scheme: …)` string for a realizable mode. */\nexport const PREFERS: Record<string, string> = {\n dark: \"@media (prefers-color-scheme: dark)\",\n light: \"@media (prefers-color-scheme: light)\",\n};\n\n/** Which authored modes ride `prefers-color-scheme` (the ones this helper realizes). */\nexport const mediaEligibleModes = (modeNames: readonly string[]): string[] =>\n modeNames.filter(mode => mode in PREFERS);\n\ntype SchemeTemplate = (\n styles: TemplateStringsArray,\n ...interpolations: Interpolation<object>[]\n) => RuleSet<object>;\n\n/** A scheme tagged-template that also carries the raw `@media (prefers-color-scheme: …)` it wraps. */\nexport type SchemeTemplateWithQuery = SchemeTemplate & { readonly query: string };\n\n/** The wrapped `theme.scheme` — one tagged template per realizable mode (`dark` / `light`). */\nexport type SchemeHelper = Record<string, SchemeTemplateWithQuery>;\n\nconst buildTemplate = (query: string): SchemeTemplate => (styles, ...interpolations) =>\n css`\n ${query} {\n ${css(styles, ...interpolations)}\n }\n `;\n\n/** Build the runtime `theme.scheme` for the given realizable modes. */\nexport const wrapSchemeHelper = (modeNames: readonly string[]): SchemeHelper => {\n const helper: SchemeHelper = {};\n for (const mode of mediaEligibleModes(modeNames)) {\n const query = PREFERS[mode];\n helper[mode] = Object.assign(buildTemplate(query), { query }) as SchemeTemplateWithQuery;\n }\n return helper;\n};\n\n/** Generate the self-contained vendored `scheme.ts` source for the given realizable modes. */\nexport const vendorSchemeHelper = (modeNames: readonly string[]): string => {\n const entries = mediaEligibleModes(modeNames)\n .map(mode => ` ${JSON.stringify(mode)}: wrap(${JSON.stringify(PREFERS[mode])}),`)\n .join(\"\\n\");\n\n return `// Vendored, self-contained styled-components colour-scheme helper (generated by @theme-registry/refract).\n// Only dependency: styled-components. Realizes appearance modes as prefers-color-scheme media blocks.\nimport { css } from \"styled-components\";\n\nconst wrap = (query) => {\n const fn = (styles, ...interpolations) => css\\`\\${query} { \\${css(styles, ...interpolations)} }\\`;\n fn.query = query;\n return fn;\n};\n\nexport const scheme = {\n${entries}\n};\n\nexport default scheme;\n`;\n};\n","/**\n * The styled-components `emit()` module assembler (§8) — writes **TS/JS modules**, not a stylesheet.\n *\n * What lands on disk (self-contained — a downstream app imports these and drops refract at runtime):\n * - **theme.ts** — the literal theme object (`export const theme = { … } as const`) + the flat, tree-\n * shakeable `css` recipe consts + a grouped `recipes` barrel + (if the raw defines `globals`) a\n * `GlobalStyle`. `emit: \"split\"` peels the recipes into `recipes.ts` and the `GlobalStyle` into\n * `global.ts`.\n * - **media.ts** (always) / **scheme.ts** (iff modes ride `prefers-color-scheme`) — vendored tagged\n * templates with this theme's concrete `@media` strings baked in.\n * - **theme.d.ts** (iff `language: \"ts\"`) — augments styled-components' `DefaultTheme` from `typeof theme`.\n * - **color-math.ts** is materialized by the shared build plumbing (`emitTheme` + `VENDOR_HELPERS`),\n * not here — this module only wires the `import`.\n */\nimport type { EmitOutput } from \"@theme-registry/refract\";\nimport type { MediaDescriptor, MediaVariant } from \"@theme-registry/refract\";\n\nconst VARIANTS: ReadonlyArray<MediaVariant> = [\"min\", \"max\", \"exact\"];\n\n/** color-math exports surfaced on `theme` when `helpers: [\"color-math\"]` is opted in. */\nexport const COLOR_MATH_ATTACH: ReadonlyArray<string> = [\"lighten\", \"darken\", \"alpha\"];\n\n/**\n * Generate a self-contained SC media-helper module (source text) for `breakpoints`, reading the\n * concrete `@media` query strings from the already-built core {@link MediaDescriptor}.\n */\nexport const vendorMediaHelper = <TBreakpoint extends string>(\n breakpoints: Record<TBreakpoint, number>,\n media: MediaDescriptor<TBreakpoint>,\n): string => {\n const keys = (Object.keys(breakpoints) as TBreakpoint[]).sort(\n (a, b) => breakpoints[a] - breakpoints[b],\n );\n\n const groups = keys\n .map(key => {\n const group = media[key];\n const variants = VARIANTS.map(\n variant => ` ${variant}: wrap(${JSON.stringify(group?.[variant] ?? \"\")}),`,\n ).join(\"\\n\");\n return ` ${JSON.stringify(key)}: {\\n${variants}\\n },`;\n })\n .join(\"\\n\");\n\n return `// Vendored, self-contained styled-components media helper (generated by @theme-registry/refract).\n// Only dependency: styled-components. Concrete @media strings are baked in for this theme's breakpoints.\nimport { css } from \"styled-components\";\n\nconst wrap = (query) => {\n const fn = query\n ? (styles, ...interpolations) => css\\`\\${query} { \\${css(styles, ...interpolations)} }\\`\n : (styles, ...interpolations) => css\\`\\${css(styles, ...interpolations)}\\`;\n fn.query = query;\n return fn;\n};\n\nexport const media = {\n${groups}\n};\n\nexport default media;\n`;\n};\n\n// ---------------------------------------------------------------------------\n// Module assembly\n// ---------------------------------------------------------------------------\n\n/** One recipe ready to serialize: its export identifier + its `css\\`…\\`` body source. */\nexport interface RecipeEmit {\n readonly exportName: string;\n readonly body: string;\n}\n\n/** Everything the assembler needs, prepared by the adapter's bind. */\nexport interface ScEmitInputs {\n readonly language: \"ts\" | \"js\";\n readonly emitMode: \"single\" | \"split\";\n readonly helpers: readonly string[];\n readonly usesScheme: boolean;\n /** The `export const theme = <this> as const` body (subsystems + modes + trailing refs). */\n readonly themeObjectBody: string;\n /** Recipes in dependency-safe order (a composed recipe's references precede it). */\n readonly recipes: readonly RecipeEmit[];\n /** The grouped `export const recipes = { … } as const` barrel body. */\n readonly recipesBarrelBody: string;\n /** The `createGlobalStyle\\`…\\`` body, if the raw defines `globals`. */\n readonly resetBody?: string;\n readonly vendorMedia: string;\n readonly vendorScheme?: string;\n}\n\nconst usesColorMath = (helpers: readonly string[]): boolean => helpers.includes(\"color-math\");\n\n/** The `import … from \"styled-components\"` line for the file that carries recipes / GlobalStyle. */\nconst scImport = (needsCss: boolean, needsGlobal: boolean): string => {\n const names = [needsCss ? \"css\" : \"\", needsGlobal ? \"createGlobalStyle\" : \"\"].filter(Boolean);\n return `import { ${names.join(\", \")} } from \"styled-components\";`;\n};\n\n/** The imports the theme object needs (`media`, optional `scheme`, optional color-math helpers). */\nconst themeImports = (inputs: ScEmitInputs): string[] => {\n const lines = [`import { media } from \"./media\";`];\n if (inputs.usesScheme) lines.push(`import { scheme } from \"./scheme\";`);\n if (usesColorMath(inputs.helpers)) {\n lines.push(`import { ${COLOR_MATH_ATTACH.join(\", \")} } from \"./color-math\";`);\n }\n return lines;\n};\n\nconst themeConst = (body: string): string => `export const theme = ${body} as const;`;\n\nconst recipeConsts = (recipes: readonly RecipeEmit[]): string =>\n recipes.map(r => `export const ${r.exportName} = css\\`\\n${r.body}\\n\\`;`).join(\"\\n\\n\");\n\nconst recipesBarrel = (body: string): string => `export const recipes = ${body} as const;`;\n\nconst globalStyle = (body: string): string => `export const GlobalStyle = createGlobalStyle\\`\\n${body}\\n\\`;`;\n\nconst themeDts = (): string =>\n `import \"styled-components\";\nimport type { theme } from \"./theme\";\n\ndeclare module \"styled-components\" {\n export interface DefaultTheme extends Readonly<typeof theme> {}\n}\n`;\n\n/** Assemble the SC emit output (files + vendored helpers) from the prepared inputs. */\nexport const buildScEmit = (inputs: ScEmitInputs): EmitOutput => {\n const files: Record<string, string> = {};\n const vendorHelpers: Record<string, string> = { \"media.ts\": inputs.vendorMedia };\n if (inputs.vendorScheme) vendorHelpers[\"scheme.ts\"] = inputs.vendorScheme;\n\n const hasRecipes = inputs.recipes.length > 0;\n const hasReset = inputs.resetBody !== undefined;\n\n if (inputs.emitMode === \"single\") {\n const parts: string[] = [];\n parts.push([scImport(hasRecipes, hasReset), ...themeImports(inputs)].join(\"\\n\"));\n parts.push(themeConst(inputs.themeObjectBody));\n if (hasRecipes) {\n parts.push(recipeConsts(inputs.recipes));\n parts.push(recipesBarrel(inputs.recipesBarrelBody));\n }\n if (hasReset) parts.push(globalStyle(inputs.resetBody!));\n files[\"theme.ts\"] = parts.join(\"\\n\\n\") + \"\\n\";\n } else {\n // split — theme / recipes / global in separate files.\n files[\"theme.ts\"] = [themeImports(inputs).join(\"\\n\"), themeConst(inputs.themeObjectBody)].join(\"\\n\\n\") + \"\\n\";\n if (hasRecipes) {\n files[\"recipes.ts\"] =\n [scImport(true, false), recipeConsts(inputs.recipes), recipesBarrel(inputs.recipesBarrelBody)].join(\"\\n\\n\") + \"\\n\";\n }\n if (hasReset) {\n files[\"global.ts\"] = [scImport(false, true), globalStyle(inputs.resetBody!)].join(\"\\n\\n\") + \"\\n\";\n }\n }\n\n if (inputs.language === \"ts\") files[\"theme.d.ts\"] = themeDts();\n\n // A `js` emit writes `.js` module names (the source is plain JS — no annotations are generated).\n if (inputs.language === \"js\") {\n for (const name of Object.keys(files)) {\n if (name.endsWith(\".ts\") && !name.endsWith(\".d.ts\")) {\n files[name.replace(/\\.ts$/, \".js\")] = files[name];\n delete files[name];\n }\n }\n for (const name of Object.keys(vendorHelpers)) {\n vendorHelpers[name.replace(/\\.ts$/, \".js\")] = vendorHelpers[name];\n delete vendorHelpers[name];\n }\n }\n\n return { files, vendorHelpers };\n};\n","/**\n * The styled-components adapter (§8) — lowers the format-neutral {@link ThemeModel} to **TS/JS\n * modules**, not a stylesheet. Worked reference: `src/adapters/css/`; imports only core (+ the\n * `styled-components` peer) so it can be lifted to its own package (Step 11).\n *\n * One renderer, two sinks (see `./recipe`): the same recipe lowering feeds `emit()` (serialize to\n * `css\\`…\\`` source on disk) and the runtime surface (`createTheme(raw, { adapter })` → a live `css`\n * block per recipe, lowered on first access and cached). Both project the SAME shapes:\n *\n * - **theme** — a literal object (`theme.colors.primary`, `theme.modes.dark.…`, `theme.media`,\n * `theme.scheme`, opted-in color-math fns). No `var()`; the object IS the indirection. This is\n * what a consumer passes to `<ThemeProvider>`.\n * - **recipes** — flat, tree-shakeable `css` blocks reading values off the theme (`${({ theme }) =>\n * theme.…}`); composition = a `css` spread of the referenced siblings. Grouped `recipes` barrel too.\n * - **GlobalStyle** — the globals subsystem as a `createGlobalStyle` (present iff the raw defines `globals`).\n * - **media** / **scheme** — SC tagged templates (breakpoints / `prefers-color-scheme`).\n */\nimport type { RuleSet as ModelRuleSet, ThemeModel } from \"@theme-registry/refract\";\nimport type { AdapterSpec, RenderContext, ThemeAdapter, NormalizedEmit, EmitOutput } from \"@theme-registry/refract\";\nimport type { PreviewDescriptor, UsageDescriptor } from \"@theme-registry/refract\";\nimport type { MediaDescriptor } from \"@theme-registry/refract\";\nimport { defineAdapter } from \"@theme-registry/refract\";\nimport { css, createGlobalStyle } from \"styled-components\";\nimport type { RuleSet } from \"styled-components\";\nimport type { NamingOverrides } from \"@theme-registry/refract/adapter-kit\";\nimport { SC_KNOWN_STATES } from \"./lowering\";\nimport { createIdentifiers } from \"./identifiers\";\nimport { buildThemeData, buildRuntimeThemeObject, serializeThemeObject } from \"./theme-object\";\nimport {\n buildRecipeIR,\n buildGlobalsIR,\n recipeSource,\n recipePlainCss,\n type RecipeContext,\n type SchemeOption,\n type SpreadRenderer,\n} from \"./recipe\";\nimport { wrapMediaDescriptor } from \"./media\";\nimport { wrapSchemeHelper, vendorSchemeHelper, mediaEligibleModes, PREFERS } from \"./scheme\";\nimport { vendorMediaHelper, buildScEmit, COLOR_MATH_ATTACH, type RecipeEmit, type ScEmitInputs } from \"./emit\";\n\n/** The output unit for this adapter — the return of the styled-components `css` tagged template. */\nexport type StyledComponentsUnit = RuleSet<object>;\n\n/** styled-components adapter options (§8). */\nexport type StyledComponentsAdapterOptions = {\n /**\n * Emit `.ts` (default) or `.js` modules. `ts` additionally emits `theme.d.ts` augmenting\n * styled-components' `DefaultTheme` from `typeof theme`, so `props.theme.…` is typed.\n */\n language?: \"ts\" | \"js\";\n /**\n * How appearance modes (§10.3) are realized in recipes: `\"media\"` (default) →\n * `@media (prefers-color-scheme: dark)` (follows the OS); `\"attribute\"` → `[data-theme=\"dark\"] &`\n * (a manual toggle overrides the OS); `\"both\"` → both blocks.\n */\n scheme?: SchemeOption;\n /**\n * Shared vendorable helpers surfaced on `theme` — `[\"color-math\"]` wires the `lighten`/`darken`/`alpha`\n * import (the module itself is materialized by the build plumbing, `emitTheme` + `VENDOR_HELPERS`).\n */\n helpers?: readonly string[];\n /** Accepted for parity with the CSS adapter's namer. SC identifiers carry no prefix (the literal\n * theme object is the isolation boundary), so these do not alter identifiers in v1. */\n prefix?: string;\n classPrefix?: string;\n /**\n * §7B — swap how names are generated (shared type with the CSS adapter). `className` remaps a\n * recipe's export identity (camelCased); `variableName` has no coherent target on the nested theme\n * object and is accepted-but-structural (theme keys stay derived from the token address).\n */\n naming?: NamingOverrides;\n};\n\nconst isValidIdentifier = (name: string): boolean => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);\nconst objectKey = (name: string): string => (isValidIdentifier(name) ? name : JSON.stringify(name));\n\n/** Memoize an object property: build the value on first access, then replace the getter with it. */\nconst lazy = (obj: Record<string, unknown>, key: string, compute: () => unknown): void => {\n Object.defineProperty(obj, key, {\n configurable: true,\n enumerable: true,\n get() {\n const value = compute();\n Object.defineProperty(obj, key, { value, enumerable: true, configurable: true });\n return value;\n },\n });\n};\n\nexport const createStyledComponentsAdapter = (\n options: StyledComponentsAdapterOptions = {},\n): ThemeAdapter<StyledComponentsUnit> => {\n const language = options.language ?? \"ts\";\n const scheme: SchemeOption = options.scheme ?? \"media\";\n const helpers = options.helpers ?? [];\n\n const spec: AdapterSpec<StyledComponentsUnit> = {\n name: \"styled-components\",\n version: 1,\n allowedStates: SC_KNOWN_STATES,\n bind(model: ThemeModel, ctx: RenderContext) {\n const media = ctx.media as MediaDescriptor<string>;\n const ids = createIdentifiers(options.naming);\n\n // The literal theme object data (tokens + modes) — the shared source for both sinks.\n const data = buildThemeData(model, ctx.resolve);\n const recipeCtx: RecipeContext = { model, media, data, scheme, prefers: PREFERS };\n\n // Do any recipes reference `theme.scheme`? (Only dark/light under media/both do.)\n const usesScheme = (scheme === \"media\" || scheme === \"both\") && mediaEligibleModes(data.modeNames).length > 0;\n\n // ── Recipe IR registry (every rule-set except globals), addressed by \"subsystem.group.variant\". ──\n const addressKey = (subsystem: string, group: string, variant: string): string =>\n `${subsystem}.${group}.${variant}`;\n const registry = new Map<string, ReturnType<typeof buildRecipeIR>>();\n const recipeAddresses: Array<{ subsystem: string; group: string; variant: string }> = [];\n for (const [subsystem, sub] of Object.entries(model.subsystems)) {\n if (subsystem === \"globals\") continue;\n for (const [group, ruleSetGroup] of Object.entries(sub.ruleSets ?? {})) {\n for (const [variant, ruleSet] of Object.entries(ruleSetGroup)) {\n registry.set(addressKey(subsystem, group, variant), buildRecipeIR(ruleSet, recipeCtx));\n recipeAddresses.push({ subsystem, group, variant });\n }\n }\n }\n\n const ruleSetOf = (subsystem: string, group: string, variant: string): ModelRuleSet | undefined =>\n model.subsystems[subsystem]?.ruleSets?.[group]?.[variant];\n\n // ── Runtime sinks ──\n // Composition spreads inline the referenced recipe's live CSS (recursively).\n const spreadRenderer: SpreadRenderer = (subsystem, group, variant, theme) => {\n const nodes = registry.get(addressKey(subsystem, group, variant));\n return nodes ? recipePlainCss(nodes, theme, recipeCtx, spreadRenderer) : \"\";\n };\n\n const buildLiveRecipe = (subsystem: string, group: string, variant: string): RuleSet<object> => {\n const nodes = registry.get(addressKey(subsystem, group, variant)) ?? [];\n return css`${({ theme }: { theme: Record<string, any> }) => recipePlainCss(nodes, theme, recipeCtx, spreadRenderer)}`;\n };\n\n const wrappedMedia = wrapMediaDescriptor(media);\n const wrappedScheme = usesScheme ? wrapSchemeHelper(data.modeNames) : undefined;\n\n // The live theme object put on `theme` (recipes read it from styled-components context).\n const attach: Record<string, unknown> = { media: wrappedMedia };\n if (wrappedScheme) attach.scheme = wrappedScheme;\n const runtimeTheme = buildRuntimeThemeObject(data, attach);\n\n // Lazy + cached `recipes.<subsystem>.<group>.<variant>` — each lowered on first access.\n const buildRecipesTree = (): Record<string, unknown> => {\n const tree: Record<string, unknown> = {};\n for (const { subsystem, group, variant } of recipeAddresses) {\n const groups = (tree[subsystem] ??= {}) as Record<string, Record<string, unknown>>;\n const variants = (groups[group] ??= {});\n lazy(variants, variant, () => buildLiveRecipe(subsystem, group, variant));\n }\n return tree;\n };\n\n // Globals → a live GlobalStyle (present iff the raw defines the globals subsystem).\n const resetNodes = buildGlobalsIR(model.subsystems.globals?.ruleSets, recipeCtx);\n const GlobalStyle = resetNodes.length\n ? createGlobalStyle`${({ theme }: { theme: Record<string, any> }) => recipePlainCss(resetNodes, theme, recipeCtx, spreadRenderer)}`\n : undefined;\n\n // ── Emit sink ──\n const emit = (plan?: NormalizedEmit): EmitOutput => {\n const type = plan?.type ?? \"single\";\n if (type !== \"single\" && type !== \"split\") {\n throw new Error(\n `styled-components adapter: emit mode '${type}' is not supported — the TS/JS target ` +\n `emits 'single' or 'split' (ES modules tree-shake per export; 'subsystem'/'components' ` +\n `are CSS-only concerns).`,\n );\n }\n\n const spreadName = (subsystem: string, group: string, variant: string): string =>\n ids.recipeExportName(subsystem, group, variant);\n\n // Recipes in dependency-safe order (a composed component's references precede it in the list).\n const recipes: RecipeEmit[] = recipeAddresses.map(({ subsystem, group, variant }) => ({\n exportName: ids.recipeExportName(subsystem, group, variant),\n body: recipeSource(registry.get(addressKey(subsystem, group, variant)) ?? [], { spreadName }),\n }));\n\n // Grouped barrel referencing the flat consts.\n const barrelLines: string[] = [\"{\"];\n const bySubsystem = new Map<string, Array<{ group: string; variant: string }>>();\n for (const addr of recipeAddresses) {\n (bySubsystem.get(addr.subsystem) ?? bySubsystem.set(addr.subsystem, []).get(addr.subsystem)!).push(addr);\n }\n for (const [subsystem, addrs] of bySubsystem) {\n barrelLines.push(` ${subsystem}: {`);\n const byGroup = new Map<string, string[]>();\n for (const { group, variant } of addrs) {\n (byGroup.get(group) ?? byGroup.set(group, []).get(group)!).push(variant);\n }\n for (const [group, variants] of byGroup) {\n barrelLines.push(` ${objectKey(group)}: {`);\n for (const variant of variants) {\n barrelLines.push(` ${objectKey(variant)}: ${ids.recipeExportName(subsystem, group, variant)},`);\n }\n barrelLines.push(` },`);\n }\n barrelLines.push(` },`);\n }\n barrelLines.push(\"}\");\n\n const trailingRefs = [\n \"media\",\n ...(usesScheme ? [\"scheme\"] : []),\n ...(helpers.includes(\"color-math\") ? COLOR_MATH_ATTACH : []),\n ];\n\n const inputs: ScEmitInputs = {\n language,\n emitMode: type,\n helpers,\n usesScheme,\n themeObjectBody: serializeThemeObject(data, trailingRefs),\n recipes,\n recipesBarrelBody: barrelLines.join(\"\\n\"),\n resetBody: resetNodes.length ? recipeSource(resetNodes, { spreadName }) : undefined,\n vendorMedia: vendorMediaHelper(model.breakpoints, media),\n vendorScheme: usesScheme ? vendorSchemeHelper(data.modeNames) : undefined,\n };\n return buildScEmit(inputs);\n };\n\n return {\n recipeName(subsystem, group, variant) {\n return ids.recipeExportName(subsystem, group, variant);\n },\n\n // Preview (§20): the output is JS modules that need React + styled-components to render, so\n // there is no stylesheet to load. Token plates still work; for a live design-review page add a\n // CSS target to the same config — same recipes through the same core IR, so it's faithful.\n describePreview(): PreviewDescriptor {\n return {\n stylesheets: [],\n unavailable:\n \"This target emits JavaScript modules that render through React + styled-components, \" +\n \"so there is no stylesheet a browser can load. Token values below are exact. For a live \" +\n \"render, add a CSS target to the same config — it compiles the same recipes.\",\n };\n },\n\n // Self-documentation: the REAL export identifiers (the tree-shakeable `css` consts) plus\n // SC-specific wiring prose for the emitted guide (llms.txt).\n describeUsage(): UsageDescriptor {\n return {\n format: \"styled-components\",\n summary: [\n \"This theme is emitted as TypeScript/JavaScript modules: a literal `theme` object plus tree-shakeable `css` recipe exports (and a `GlobalStyle` if the theme defines globals).\",\n 'Wrap your app once in styled-components\\' `ThemeProvider` with the exported `theme`: `import { theme } from \"./theme\";` then `<ThemeProvider theme={theme}>`.',\n \"Apply a recipe by spreading its `css` export into a styled component: ``styled.button`${componentsButtonsPrimary}` ``. Recipes read their values from `props.theme`, so there is no `var()` and no separate stylesheet.\",\n \"If the theme defines globals, render `<GlobalStyle />` once inside the provider.\",\n ],\n recipes: recipeAddresses.map(({ subsystem, group, variant }) => ({\n subsystem,\n group,\n variant,\n name: ids.recipeExportName(subsystem, group, variant),\n })),\n };\n },\n renderRecipe(subsystem, group, variant) {\n return ruleSetOf(subsystem, group, variant)\n ? buildLiveRecipe(subsystem, group, variant)\n : css``;\n },\n // The SC target has no CSS variables (the theme object is the indirection).\n renderVariables() {\n return css``;\n },\n join(parts) {\n return parts.flat() as RuleSet<object>;\n },\n\n // The runtime surface: the literal theme object + lazy recipes + GlobalStyle + media/scheme.\n extend() {\n const surface: Record<string, unknown> = {\n theme: runtimeTheme,\n recipes: buildRecipesTree(),\n media: wrappedMedia,\n };\n if (wrappedScheme) surface.scheme = wrappedScheme;\n if (GlobalStyle) surface.GlobalStyle = GlobalStyle;\n return surface;\n },\n\n emit,\n };\n },\n };\n return defineAdapter(spec);\n};\n\n// Public glue re-exports.\nexport { wrapMediaDescriptor } from \"./media\";\nexport type {\n WrappedMediaDescriptor,\n WrappedMediaGroup,\n MediaTemplateWithQuery,\n} from \"./media\";\nexport type { SchemeHelper, SchemeTemplateWithQuery } from \"./scheme\";\n"],"names":["SC_STATE_SELECTORS","link","visited","hover","focus","active","disabled","pressed","SC_KNOWN_STATES","Object","keys","STATE_ORDER","reduce","acc","name","index","orderStateOverrides","overrides","map","override","sort","a","b","oa","_a","state","Number","MAX_SAFE_INTEGER","ob","_b","bpa","breakpoint","bpb","DEFAULT_MEDIA_QUERY","splitWords","segment","split","filter","Boolean","camelJoin","segments","words","flatMap","length","joined","w","i","word","charAt","toLowerCase","slice","toUpperCase","upperFirst","join","test","themeKey","segmentsAfterSubsystem","themeAccess","path","subsystem","rest","key","createIdentifiers","seen","Map","recipeExportName","group","variant","className","fallback","s","out","kind","classToken","Error","prev","get","undefined","set","track","formatValue","ref","resolve","struct","external","raw","value","unit","INDENT","serializeLeafMap","depth","pad","repeat","inner","entries","k","v","String","JSON","stringify","serializeTree","tree","serializeThemeObject","data","trailingRefs","lines","push","modeNames","mode","modes","str","refFragments","lit","tokenPaths","has","read","wrap","declNodes","declarations","nodes","property","type","parseReference","reference","dot","indexOf","schemeRealizations","scheme","mediaEligible","media","attribute","modeDeclNodes","overridden","modeOverridePaths","modeRef","buildRecipeIR","ruleSet","ctx","references","parsed","children","query","orientation","stateOverrides","o","stateSelector","block","selector","_c","baseMode","stateModeBlocks","accessExpr","nodeSource","node","indent","captured","opts","fragments","fragment","expr","fragmentsSource","spreadName","c","target","recipeSource","readTheme","theme","root","nodePlainCss","spread","fragmentsValue","min","max","exact","resolveMediaQuery","prefers","recipePlainCss","RESERVED_DESCRIPTOR_KEYS","Set","wrapMediaDescriptor","descriptor","wrapped","options","wrapQuery","between","from","to","wrapMediaGroup","forEach","assign","buildTemplate","styles","interpolations","css","PREFERS","dark","light","mediaEligibleModes","VARIANTS","COLOR_MATH_ATTACH","vendorMediaHelper","breakpoints","variants","scImport","needsCss","needsGlobal","themeImports","inputs","usesScheme","helpers","includes","themeConst","body","recipeConsts","recipes","r","exportName","recipesBarrel","globalStyle","objectKey","isValidIdentifier","lazy","obj","compute","defineProperty","configurable","enumerable","language","spec","version","allowedStates","bind","model","ids","naming","put","add","sub","subsystems","pm","properties","base","extra","extras","_d","entry","_e","basePath","field","_f","_h","_k","_g","_j","buildThemeData","recipeCtx","addressKey","registry","recipeAddresses","ruleSetGroup","ruleSets","spreadRenderer","buildLiveRecipe","wrappedMedia","wrappedScheme","helper","wrapSchemeHelper","attach","runtimeTheme","bySub","buildRuntimeThemeObject","buildRecipesTree","groups","resetNodes","values","variantName","variantRuleSet","variantChildren","buildGlobalsIR","globals","GlobalStyle","createGlobalStyle","recipeName","describePreview","stylesheets","unavailable","describeUsage","format","summary","renderRecipe","ruleSetOf","renderVariables","parts","flat","extend","surface","emit","plan","barrelLines","bySubsystem","addr","addrs","byGroup","files","vendorHelpers","vendorMedia","vendorScheme","hasRecipes","hasReset","resetBody","emitMode","themeObjectBody","recipesBarrelBody","endsWith","replace","buildScEmit","defineAdapter"],"mappings":"qFAkBO,MAAMA,EAA6C,CACxDC,KAAM,QACNC,QAAS,WACTC,MAAO,SACPC,MAAO,SACPC,OAAQ,UACRC,SAAU,aACVC,QAAS,kBAIEC,EAAyCC,OAAOC,KAAKV,GAE5DW,EAAsCH,EAAgBI,OAC1D,CAACC,EAAKC,EAAMC,KACVF,EAAIC,GAAQC,EACLF,GAET,CAAE,GAISG,EAAuBC,GAClCA,EACGC,IAAI,CAACC,EAAUJ,KAAW,CAAEI,WAAUJ,WACtCK,KAAK,CAACC,EAAGC,aACR,MAAMC,EAA4C,QAAvCC,EAAAb,EAAYU,EAAEF,SAASM,cAAgB,IAAAD,EAAAA,EAAIE,OAAOC,iBACvDC,EAA4C,QAAvCC,EAAAlB,EAAYW,EAAEH,SAASM,cAAgB,IAAAI,EAAAA,EAAIH,OAAOC,iBAC7D,GAAIJ,IAAOK,EAAI,OAAOL,EAAKK,EAC3B,MAAME,EAAMT,EAAEF,SAASY,WAAa,EAAI,EAClCC,EAAMV,EAAEH,SAASY,WAAa,EAAI,EACxC,OAAID,IAAQE,EAAYF,EAAME,EACvBX,EAAEN,MAAQO,EAAEP,QAEpBG,IAAI,EAAGC,cAAeA,GAMdc,EAAoC,QCpC3CC,EAAcC,GAA8BA,EAAQC,MAAM,iBAAiBC,OAAOC,SAS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1F,GAChCzF,IAAI0F,GAAQ,KAAKV,KAAKC,UAAUS,YAAeV,KAAKC,UAAU+F,EAAQtF,SACtEvD,KAAK,8CEyKgEwB,KAqErE,GAEH,OAAO+O,EAAAA,cAAcxF"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import{defineAdapter as e}from"@theme-registry/refract";import{css as t,createGlobalStyle as n}from"styled-components";const o={link:":link",visited:":visited",hover:":hover",focus:":focus",active:":active",disabled:"[disabled]",pressed:"[aria-pressed]"},r=Object.keys(o),s=r.reduce((e,t,n)=>(e[t]=n,e),{}),i=e=>e.map((e,t)=>({override:e,index:t})).sort((e,t)=>{var n,o;const r=null!==(n=s[e.override.state])&&void 0!==n?n:Number.MAX_SAFE_INTEGER,i=null!==(o=s[t.override.state])&&void 0!==o?o:Number.MAX_SAFE_INTEGER;if(r!==i)return r-i;const a=e.override.breakpoint?1:0,c=t.override.breakpoint?1:0;return a!==c?a-c:e.index-t.index}).map(({override:e})=>e),a="exact",c=e=>e.split(/[^a-zA-Z0-9]+/).filter(Boolean),l=e=>{const t=e.flatMap(c);if(!t.length)return"_";const n=t.map((e,t)=>{return 0===t?(n=e).charAt(0).toLowerCase()+n.slice(1):(e=>e.charAt(0).toUpperCase()+e.slice(1))(e);var n}).join("");return/^[0-9]/.test(n)?`_${n}`:n},d=e=>l(e),m=e=>{const[t,...n]=e.split(".");return{subsystem:t,key:d(n)}},p=e=>{const t=new Map;return{recipeExportName(n,o,r){const s=[n,o,r];let i=l(s);if(null==e?void 0:e.className){const t=s.map(e=>c(e).join("-")).join("-"),a=e.className({kind:"recipe",subsystem:n,group:o,variant:r},{classToken:"",name:t});if(i=l(c(a)),!i||"_"===i)throw new Error(`styled-components emit: className override returned an empty/invalid identifier for "${n}.${o}.${r}"`)}return((e,n)=>{const o=t.get(e);if(void 0!==o&&o!==n)throw new Error(`styled-components emit: recipe identifier "${e}" is produced by both "${o}" and "${n}" — the naming override must map distinct recipes to distinct identifiers`);t.set(e,n)})(i,`${n}.${o}.${r}`),i}}},u=(e,t,n)=>{if(void 0!==e.struct)return;if(void 0!==e.external)return`var(${e.external})`;const o=void 0!==e.value?e.value:n(t);return void 0!==e.unit?`${o}${e.unit}`:o},h=" ",f=(e,t)=>{const n=h.repeat(t),o=h.repeat(t+1);return`{\n${Object.entries(e).map(([e,t])=>{return`${o}${e}: ${n=t,"number"==typeof n?String(n):JSON.stringify(n)},`;var n}).join("\n")}\n${n}}`},v=(e,t)=>Object.entries(e).map(([e,n])=>`${h.repeat(t)}${e}: ${f(n,t)},`),y=(e,t)=>{const n=["{"];if(n.push(...v(e.tree,1)),e.modeNames.length){n.push(`${h}modes: {`);for(const t of e.modeNames)n.push(`${h.repeat(2)}${t}: {`),n.push(...v(e.modes[t],3)),n.push(`${h.repeat(2)}},`);n.push(`${h}},`)}for(const e of t)n.push(`${h}${e},`);return n.push("}"),n.join("\n")},$=e=>null==e?"":String(e),b=(e,t)=>{if(void 0===e.ref)return[{lit:$(e.value)}];if(!t.tokenPaths.has(e.ref))return;const n={ref:e.ref};return e.wrap?[{lit:`${e.wrap}(`},n,{lit:")"}]:[n]},g=(e,t)=>{const n=[];for(const[o,r]of Object.entries(null!=e?e:{})){const e=b(r,t);e&&n.push({type:"decl",property:o,value:e})}return n},j=e=>{const[t,n]=e.split(":");if(!t||!n)return;const o=n.indexOf(".");return o<0?void 0:{subsystem:t,group:n.slice(0,o),variant:n.slice(o+1)}},k=(e,t)=>{const n="dark"===e||"light"===e;return{media:n&&("media"===t||"both"===t),attribute:"attribute"===t||"both"===t||"media"===t&&!n}},O=(e,t,n)=>{const o=n.modeOverridePaths[t];if(!o)return[];const r=[];for(const[n,s]of Object.entries(null!=e?e:{}))void 0!==s.ref&&o.has(s.ref)&&r.push({type:"decl",property:n,value:[{modeRef:{mode:t,path:s.ref}}]});return r},x=(e,t)=>{var n,r,s;const c=[];for(const t of null!==(n=e.references)&&void 0!==n?n:[]){const e=j(t);e&&c.push({type:"spread",...e})}c.push(...g(e.declarations,t.data));for(const n of e.overrides){if(void 0!==n.state||!n.breakpoint)continue;const e=g(n.declarations,t.data);e.length&&c.push({type:"media",breakpoint:n.breakpoint,query:null!==(r=n.query)&&void 0!==r?r:a,orientation:n.orientation,children:e})}const l=e.overrides.filter(e=>void 0!==e.state);for(const e of i(l)){const n=o[e.state],r=g(e.declarations,t.data);if(!n||!r.length)continue;const i={type:"block",selector:`&${n}`,children:r};e.breakpoint?c.push({type:"media",breakpoint:e.breakpoint,query:null!==(s=e.query)&&void 0!==s?s:a,orientation:e.orientation,children:[i]}):c.push(i)}for(const n of t.data.modeNames){const r=O(e.declarations,n,t.data),s=[];for(const e of i(l)){const r=o[e.state];if(!r)continue;const i=O(e.declarations,n,t.data);i.length&&s.push({type:"block",selector:`&${r}`,children:i})}const a=[...r,...s];if(!a.length)continue;const{media:d,attribute:m}=k(n,t.scheme);d&&c.push({type:"scheme",mode:n,children:a}),m&&c.push({type:"block",selector:`[data-theme="${n}"] &`,children:a})}return c},S=" ",N=(e,t)=>{const{subsystem:n,key:o}=m(e);return t?`theme.modes.${t}.${n}.${o}`:`theme.${n}.${o}`},w=(e,t,n,o)=>{switch(e.type){case"decl":return`${t}${e.property}: ${((e,t)=>e.map(e=>{if("lit"in e)return e.lit;const n="ref"in e?N(e.ref):N(e.modeRef.path,e.modeRef.mode);return t?`\${${n}}`:`\${({ theme }) => ${n}}`}).join(""))(e.value,n)};`;case"spread":return`${t}\${${o.spreadName(e.subsystem,e.group,e.variant)}}`;case"block":{const r=e.children.map(e=>w(e,t+S,n,o)).join("\n");return`${t}${e.selector} {\n${r}\n${t}}`}case"media":{const n=e.orientation?`theme.media.${e.query}(${JSON.stringify(e.breakpoint)}, { orientation: ${JSON.stringify(e.orientation)} })`:`theme.media.${e.breakpoint}.${e.query}`,r=e.children.map(e=>w(e,t+S,!0,o)).join("\n");return`${t}\${({ theme }) => ${n}\`\n${r}\n${t}\`}`}case"scheme":{const n=e.children.map(e=>w(e,t+S,!0,o)).join("\n");return`${t}\${({ theme }) => theme.scheme.${e.mode}\`\n${n}\n${t}\`}`}}},q=(e,t)=>e.map(e=>w(e,S,!1,t)).join("\n"),E=(e,t,n)=>{var o,r;const{subsystem:s,key:i}=m(t),a=n?null===(o=null==e?void 0:e.modes)||void 0===o?void 0:o[n]:e;return null===(r=null==a?void 0:a[s])||void 0===r?void 0:r[i]},B=(e,t,n,o)=>{var r;switch(e.type){case"decl":return`${e.property}: ${((e,t)=>e.map(e=>"lit"in e?e.lit:$("ref"in e?E(t,e.ref):E(t,e.modeRef.path,e.modeRef.mode))).join(""))(e.value,t)};`;case"spread":return o(e.subsystem,e.group,e.variant,t);case"block":{const r=e.children.map(e=>B(e,t,n,o)).join(" ");return`${e.selector} { ${r} }`}case"media":{const r=((e,t,n,o)=>{var r,s;if(!o)return null!==(s=null===(r=e[t])||void 0===r?void 0:r[n])&&void 0!==s?s:"";const i={orientation:o};return"min"===n?e.min(t,i):"max"===n?e.max(t,i):e.exact(t,i)})(n.media,e.breakpoint,e.query,e.orientation),s=e.children.map(e=>B(e,t,n,o)).join(" ");return r?`${r} { ${s} }`:s}case"scheme":{const s=null!==(r=n.prefers[e.mode])&&void 0!==r?r:"",i=e.children.map(e=>B(e,t,n,o)).join(" ");return s?`${s} { ${i} }`:i}}},
|
|
1
|
+
import{defineAdapter as e}from"@theme-registry/refract";import{css as t,createGlobalStyle as n}from"styled-components";const o={link:":link",visited:":visited",hover:":hover",focus:":focus",active:":active",disabled:"[disabled]",pressed:"[aria-pressed]"},r=Object.keys(o),s=r.reduce((e,t,n)=>(e[t]=n,e),{}),i=e=>e.map((e,t)=>({override:e,index:t})).sort((e,t)=>{var n,o;const r=null!==(n=s[e.override.state])&&void 0!==n?n:Number.MAX_SAFE_INTEGER,i=null!==(o=s[t.override.state])&&void 0!==o?o:Number.MAX_SAFE_INTEGER;if(r!==i)return r-i;const a=e.override.breakpoint?1:0,c=t.override.breakpoint?1:0;return a!==c?a-c:e.index-t.index}).map(({override:e})=>e),a="exact",c=e=>e.split(/[^a-zA-Z0-9]+/).filter(Boolean),l=e=>{const t=e.flatMap(c);if(!t.length)return"_";const n=t.map((e,t)=>{return 0===t?(n=e).charAt(0).toLowerCase()+n.slice(1):(e=>e.charAt(0).toUpperCase()+e.slice(1))(e);var n}).join("");return/^[0-9]/.test(n)?`_${n}`:n},d=e=>l(e),m=e=>{const[t,...n]=e.split(".");return{subsystem:t,key:d(n)}},p=e=>{const t=new Map;return{recipeExportName(n,o,r){const s=[n,o,r];let i=l(s);if(null==e?void 0:e.className){const t=s.map(e=>c(e).join("-")).join("-"),a=e.className({kind:"recipe",subsystem:n,group:o,variant:r},{classToken:"",name:t});if(i=l(c(a)),!i||"_"===i)throw new Error(`styled-components emit: className override returned an empty/invalid identifier for "${n}.${o}.${r}"`)}return((e,n)=>{const o=t.get(e);if(void 0!==o&&o!==n)throw new Error(`styled-components emit: recipe identifier "${e}" is produced by both "${o}" and "${n}" — the naming override must map distinct recipes to distinct identifiers`);t.set(e,n)})(i,`${n}.${o}.${r}`),i}}},u=(e,t,n)=>{if(void 0!==e.struct)return;if(void 0!==e.external)return`var(${e.external})`;const o=void 0!==e.value?e.value:n(t);return void 0!==e.unit?`${o}${e.unit}`:o},h=" ",f=(e,t)=>{const n=h.repeat(t),o=h.repeat(t+1);return`{\n${Object.entries(e).map(([e,t])=>{return`${o}${e}: ${n=t,"number"==typeof n?String(n):JSON.stringify(n)},`;var n}).join("\n")}\n${n}}`},v=(e,t)=>Object.entries(e).map(([e,n])=>`${h.repeat(t)}${e}: ${f(n,t)},`),y=(e,t)=>{const n=["{"];if(n.push(...v(e.tree,1)),e.modeNames.length){n.push(`${h}modes: {`);for(const t of e.modeNames)n.push(`${h.repeat(2)}${t}: {`),n.push(...v(e.modes[t],3)),n.push(`${h.repeat(2)}},`);n.push(`${h}},`)}for(const e of t)n.push(`${h}${e},`);return n.push("}"),n.join("\n")},$=e=>null==e?"":String(e),b=(e,t)=>{if(void 0===e.ref)return[{lit:$(e.value)}];if(!t.tokenPaths.has(e.ref))return;const n={ref:e.ref};return e.wrap?[{lit:`${e.wrap}(`},n,{lit:")"}]:[n]},g=(e,t)=>{const n=[];for(const[o,r]of Object.entries(null!=e?e:{})){const e=b(r,t);e&&n.push({type:"decl",property:o,value:e})}return n},j=e=>{const[t,n]=e.split(":");if(!t||!n)return;const o=n.indexOf(".");return o<0?void 0:{subsystem:t,group:n.slice(0,o),variant:n.slice(o+1)}},k=(e,t)=>{const n="dark"===e||"light"===e;return{media:n&&("media"===t||"both"===t),attribute:"attribute"===t||"both"===t||"media"===t&&!n}},O=(e,t,n)=>{const o=n.modeOverridePaths[t];if(!o)return[];const r=[];for(const[n,s]of Object.entries(null!=e?e:{}))void 0!==s.ref&&o.has(s.ref)&&r.push({type:"decl",property:n,value:[{modeRef:{mode:t,path:s.ref}}]});return r},x=(e,t)=>{var n,r,s;const c=[];for(const t of null!==(n=e.references)&&void 0!==n?n:[]){const e=j(t);e&&c.push({type:"spread",...e})}c.push(...g(e.declarations,t.data));for(const n of e.overrides){if(void 0!==n.state||!n.breakpoint)continue;const e=g(n.declarations,t.data);e.length&&c.push({type:"media",breakpoint:n.breakpoint,query:null!==(r=n.query)&&void 0!==r?r:a,orientation:n.orientation,children:e})}const l=e.overrides.filter(e=>void 0!==e.state);for(const e of i(l)){const n=o[e.state],r=g(e.declarations,t.data);if(!n||!r.length)continue;const i={type:"block",selector:`&${n}`,children:r};e.breakpoint?c.push({type:"media",breakpoint:e.breakpoint,query:null!==(s=e.query)&&void 0!==s?s:a,orientation:e.orientation,children:[i]}):c.push(i)}for(const n of t.data.modeNames){const r=O(e.declarations,n,t.data),s=[];for(const e of i(l)){const r=o[e.state];if(!r)continue;const i=O(e.declarations,n,t.data);i.length&&s.push({type:"block",selector:`&${r}`,children:i})}const a=[...r,...s];if(!a.length)continue;const{media:d,attribute:m}=k(n,t.scheme);d&&c.push({type:"scheme",mode:n,children:a}),m&&c.push({type:"block",selector:`[data-theme="${n}"] &`,children:a})}return c},S=" ",N=(e,t)=>{const{subsystem:n,key:o}=m(e);return t?`theme.modes.${t}.${n}.${o}`:`theme.${n}.${o}`},w=(e,t,n,o)=>{switch(e.type){case"decl":return`${t}${e.property}: ${((e,t)=>e.map(e=>{if("lit"in e)return e.lit;const n="ref"in e?N(e.ref):N(e.modeRef.path,e.modeRef.mode);return t?`\${${n}}`:`\${({ theme }) => ${n}}`}).join(""))(e.value,n)};`;case"spread":return`${t}\${${o.spreadName(e.subsystem,e.group,e.variant)}}`;case"block":{const r=e.children.map(e=>w(e,t+S,n,o)).join("\n");return`${t}${e.selector} {\n${r}\n${t}}`}case"media":{const n=e.orientation?`theme.media.${e.query}(${JSON.stringify(e.breakpoint)}, { orientation: ${JSON.stringify(e.orientation)} })`:`theme.media.${e.breakpoint}.${e.query}`,r=e.children.map(e=>w(e,t+S,!0,o)).join("\n");return`${t}\${({ theme }) => ${n}\`\n${r}\n${t}\`}`}case"scheme":{const n=e.children.map(e=>w(e,t+S,!0,o)).join("\n");return`${t}\${({ theme }) => theme.scheme.${e.mode}\`\n${n}\n${t}\`}`}}},q=(e,t)=>e.map(e=>w(e,S,!1,t)).join("\n"),E=(e,t,n)=>{var o,r;const{subsystem:s,key:i}=m(t),a=n?null===(o=null==e?void 0:e.modes)||void 0===o?void 0:o[n]:e;return null===(r=null==a?void 0:a[s])||void 0===r?void 0:r[i]},B=(e,t,n,o)=>{var r;switch(e.type){case"decl":return`${e.property}: ${((e,t)=>e.map(e=>"lit"in e?e.lit:$("ref"in e?E(t,e.ref):E(t,e.modeRef.path,e.modeRef.mode))).join(""))(e.value,t)};`;case"spread":return o(e.subsystem,e.group,e.variant,t);case"block":{const r=e.children.map(e=>B(e,t,n,o)).join(" ");return`${e.selector} { ${r} }`}case"media":{const r=((e,t,n,o)=>{var r,s;if(!o)return null!==(s=null===(r=e[t])||void 0===r?void 0:r[n])&&void 0!==s?s:"";const i={orientation:o};return"min"===n?e.min(t,i):"max"===n?e.max(t,i):e.exact(t,i)})(n.media,e.breakpoint,e.query,e.orientation),s=e.children.map(e=>B(e,t,n,o)).join(" ");return r?`${r} { ${s} }`:s}case"scheme":{const s=null!==(r=n.prefers[e.mode])&&void 0!==r?r:"",i=e.children.map(e=>B(e,t,n,o)).join(" ");return s?`${s} { ${i} }`:i}}},R=(e,t,n,o)=>e.map(e=>B(e,t,n,o)).join("\n"),J=new Set(["min","max","between","exact"]),M=e=>{const t={min:(t,n)=>A(e.min(t,n)),max:(t,n)=>A(e.max(t,n)),between:(t,n,o)=>A(e.between(t,n,o))};for(const n of Object.keys(e))J.has(n)||(t[n]=T(e[n]));return t},T=e=>{const t={};return Object.keys(e).forEach(n=>{t[n]=A(e[n])}),t},A=e=>Object.assign(P(e),{query:e}),P=e=>e?(n,...o)=>t`
|
|
2
2
|
${e} {
|
|
3
3
|
${t(n,...o)}
|
|
4
4
|
}
|
|
5
5
|
`:(e,...n)=>t`
|
|
6
6
|
${t(e,...n)}
|
|
7
|
-
`,_={dark:"@media (prefers-color-scheme: dark)",light:"@media (prefers-color-scheme: light)"},G=e=>e.filter(e=>e in _),
|
|
7
|
+
`,_={dark:"@media (prefers-color-scheme: dark)",light:"@media (prefers-color-scheme: light)"},G=e=>e.filter(e=>e in _),C=e=>(n,...o)=>t`
|
|
8
8
|
${e} {
|
|
9
9
|
${t(n,...o)}
|
|
10
10
|
}
|
|
11
|
-
`,
|
|
11
|
+
`,z=["min","max","exact"],F=["lighten","darken","alpha"],I=(e,t)=>`// Vendored, self-contained styled-components media helper (generated by @theme-registry/refract).\n// Only dependency: styled-components. Concrete @media strings are baked in for this theme's breakpoints.\nimport { css } from "styled-components";\n\nconst wrap = (query) => {\n const fn = query\n ? (styles, ...interpolations) => css\`\${query} { \${css(styles, ...interpolations)} }\`\n : (styles, ...interpolations) => css\`\${css(styles, ...interpolations)}\`;\n fn.query = query;\n return fn;\n};\n\nexport const media = {\n${Object.keys(e).sort((t,n)=>e[t]-e[n]).map(e=>{const n=t[e],o=z.map(e=>{var t;return` ${e}: wrap(${JSON.stringify(null!==(t=null==n?void 0:n[e])&&void 0!==t?t:"")}),`}).join("\n");return` ${JSON.stringify(e)}: {\n${o}\n },`}).join("\n")}\n};\n\nexport default media;\n`,V=(e,t)=>`import { ${[e?"css":"",t?"createGlobalStyle":""].filter(Boolean).join(", ")} } from "styled-components";`,W=e=>{const t=['import { media } from "./media";'];return e.usesScheme&&t.push('import { scheme } from "./scheme";'),e.helpers.includes("color-math")&&t.push(`import { ${F.join(", ")} } from "./color-math";`),t},Z=e=>`export const theme = ${e} as const;`,U=e=>e.map(e=>`export const ${e.exportName} = css\`\n${e.body}\n\`;`).join("\n\n"),X=e=>`export const recipes = ${e} as const;`,D=e=>`export const GlobalStyle = createGlobalStyle\`\n${e}\n\`;`,H=e=>(e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e))(e)?e:JSON.stringify(e),L=(e,t,n)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){const o=n();return Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0}),o}})},K=(o={})=>{var s,i,a;const c=null!==(s=o.language)&&void 0!==s?s:"ts",l=null!==(i=o.scheme)&&void 0!==i?i:"media",m=null!==(a=o.helpers)&&void 0!==a?a:[],h={name:"styled-components",version:1,allowedStates:r,bind(e,r){var s,i;const a=r.media,h=p(o.naming),f=((e,t)=>{var n,o,r,s,i,a,c,l,m,p;const h={},f={},v=[],y=new Set,$={},b=(e,n,o,r)=>{var s;const i=u(r,o,t);void 0!==i&&((null!==(s=h[e])&&void 0!==s?s:h[e]={})[n]=i,y.add(o))};for(const[h,y]of Object.entries(e.subsystems))for(const[e,g]of Object.entries(null!==(n=y.properties)&&void 0!==n?n:{})){b(h,d([e]),`${h}.${e}`,g.base);for(const[t,n]of Object.entries(null!==(o=g.extras)&&void 0!==o?o:{}))b(h,d([e,t]),`${h}.${e}.${t}`,n);for(const[t,n]of Object.entries(null!==(r=g.variants)&&void 0!==r?r:{})){b(h,d([e,t]),`${h}.${e}.${t}`,n.base);for(const[o,r]of Object.entries(null!==(s=n.extras)&&void 0!==s?s:{}))b(h,d([e,t,o]),`${h}.${e}.${t}.${o}`,r)}for(const n of null!==(i=g.modes)&&void 0!==i?i:[]){const o=n.mode;if(void 0===o)continue;const r=n.target,s=r?[e,r]:[e],i=r?`${h}.${e}.${r}`:`${h}.${e}`;for(const[r,y]of Object.entries(null!==(a=n.overrides)&&void 0!==a?a:{})){const n=u(y,`${h}.${e}`,t);if(void 0===n)continue;const a=d("base"===r?s:[...s,r]),b="base"===r?i:`${i}.${r}`;v.includes(o)||v.push(o),(null!==(l=(p=null!==(c=f[o])&&void 0!==c?c:f[o]={})[h])&&void 0!==l?l:p[h]={})[a]=n,(null!==(m=$[o])&&void 0!==m?m:$[o]=new Set).add(b)}}}return{tree:h,modes:f,modeNames:v,tokenPaths:y,modeOverridePaths:$}})(e,r.resolve),v={model:e,media:a,data:f,scheme:l,prefers:_},$=("media"===l||"both"===l)&&G(f.modeNames).length>0,b=(e,t,n)=>`${e}.${t}.${n}`,j=new Map,k=[];for(const[t,n]of Object.entries(e.subsystems))if("globals"!==t)for(const[e,o]of Object.entries(null!==(s=n.ruleSets)&&void 0!==s?s:{}))for(const[n,r]of Object.entries(o))j.set(b(t,e,n),x(r,v)),k.push({subsystem:t,group:e,variant:n});const O=(e,t,n,o)=>{const r=j.get(b(e,t,n));return r?R(r,o,v,O):""},S=(e,n,o)=>{var r;const s=null!==(r=j.get(b(e,n,o)))&&void 0!==r?r:[];return t`${({theme:e})=>R(s,e,v,O)}`},N=M(a),w=$?(e=>{const t={};for(const n of G(e)){const e=_[n];t[n]=Object.assign(C(e),{query:e})}return t})(f.modeNames):void 0,E={media:N};w&&(E.scheme=w);const B=((e,t)=>{const n={};for(const[t,o]of Object.entries(e.tree))n[t]={...o};if(e.modeNames.length){const t={};for(const n of e.modeNames){const o={};for(const[t,r]of Object.entries(e.modes[n]))o[t]={...r};t[n]=o}n.modes=t}return Object.assign(n,t),n})(f,E),J=()=>{var e,t;const n={};for(const{subsystem:o,group:r,variant:s}of k){const i=null!==(e=n[o])&&void 0!==e?e:n[o]={},a=null!==(t=i[r])&&void 0!==t?t:i[r]={};L(a,s,()=>S(o,r,s))}return n},T=((e,t)=>{var n;const o=[];for(const r of Object.values(null!=e?e:{}))for(const e of Object.values(r))if(e.selector)if("globals"===e.kind){const r=x(e,t);for(const[o,s]of Object.entries(null!==(n=e.variants)&&void 0!==n?n:{})){const n={kind:"globals",selector:e.selector,declarations:s.declarations,overrides:s.overrides},i=x(n,t);i.length&&r.push({type:"block",selector:`&.${o}`,children:i})}r.length&&o.push({type:"block",selector:e.selector,children:r})}else{const n=g(e.declarations,t.data);n.length&&o.push({type:"block",selector:e.selector,children:n})}return o})(null===(i=e.subsystems.globals)||void 0===i?void 0:i.ruleSets,v),A=T.length?n`${({theme:e})=>R(T,e,v,O)}`:void 0;return{recipeName:(e,t,n)=>h.recipeExportName(e,t,n),describePreview:()=>({stylesheets:[],unavailable:"This target emits JavaScript modules that render through React + styled-components, so there is no stylesheet a browser can load. Token values below are exact. For a live render, add a CSS target to the same config — it compiles the same recipes."}),describeUsage:()=>({format:"styled-components",summary:["This theme is emitted as TypeScript/JavaScript modules: a literal `theme` object plus tree-shakeable `css` recipe exports (and a `GlobalStyle` if the theme defines globals).",'Wrap your app once in styled-components\' `ThemeProvider` with the exported `theme`: `import { theme } from "./theme";` then `<ThemeProvider theme={theme}>`.',"Apply a recipe by spreading its `css` export into a styled component: ``styled.button`${componentsButtonsPrimary}` ``. Recipes read their values from `props.theme`, so there is no `var()` and no separate stylesheet.","If the theme defines globals, render `<GlobalStyle />` once inside the provider."],recipes:k.map(({subsystem:e,group:t,variant:n})=>({subsystem:e,group:t,variant:n,name:h.recipeExportName(e,t,n)}))}),renderRecipe:(n,o,r)=>((t,n,o)=>{var r,s,i;return null===(i=null===(s=null===(r=e.subsystems[t])||void 0===r?void 0:r.ruleSets)||void 0===s?void 0:s[n])||void 0===i?void 0:i[o]})(n,o,r)?S(n,o,r):t``,renderVariables:()=>t``,join:e=>e.flat(),extend(){const e={theme:B,recipes:J(),media:N};return w&&(e.scheme=w),A&&(e.GlobalStyle=A),e},emit:t=>{var n,o,r;const s=null!==(n=null==t?void 0:t.type)&&void 0!==n?n:"single";if("single"!==s&&"split"!==s)throw new Error(`styled-components adapter: emit mode '${s}' is not supported — the TS/JS target emits 'single' or 'split' (ES modules tree-shake per export; 'subsystem'/'components' are CSS-only concerns).`);const i=(e,t,n)=>h.recipeExportName(e,t,n),l=k.map(({subsystem:e,group:t,variant:n})=>{var o;return{exportName:h.recipeExportName(e,t,n),body:q(null!==(o=j.get(b(e,t,n)))&&void 0!==o?o:[],{spreadName:i})}}),d=["{"],p=new Map;for(const e of k)(null!==(o=p.get(e.subsystem))&&void 0!==o?o:p.set(e.subsystem,[]).get(e.subsystem)).push(e);for(const[e,t]of p){d.push(` ${e}: {`);const n=new Map;for(const{group:e,variant:o}of t)(null!==(r=n.get(e))&&void 0!==r?r:n.set(e,[]).get(e)).push(o);for(const[t,o]of n){d.push(` ${H(t)}: {`);for(const n of o)d.push(` ${H(n)}: ${h.recipeExportName(e,t,n)},`);d.push(" },")}d.push(" },")}d.push("}");const u=["media",...$?["scheme"]:[],...m.includes("color-math")?F:[]];var v;return(e=>{const t={},n={"media.ts":e.vendorMedia};e.vendorScheme&&(n["scheme.ts"]=e.vendorScheme);const o=e.recipes.length>0,r=void 0!==e.resetBody;if("single"===e.emitMode){const n=[];n.push([V(o,r),...W(e)].join("\n")),n.push(Z(e.themeObjectBody)),o&&(n.push(U(e.recipes)),n.push(X(e.recipesBarrelBody))),r&&n.push(D(e.resetBody)),t["theme.ts"]=n.join("\n\n")+"\n"}else t["theme.ts"]=[W(e).join("\n"),Z(e.themeObjectBody)].join("\n\n")+"\n",o&&(t["recipes.ts"]=[V(!0,!1),U(e.recipes),X(e.recipesBarrelBody)].join("\n\n")+"\n"),r&&(t["global.ts"]=[V(!1,!0),D(e.resetBody)].join("\n\n")+"\n");if("ts"===e.language&&(t["theme.d.ts"]='import "styled-components";\nimport type { theme } from "./theme";\n\ndeclare module "styled-components" {\n export interface DefaultTheme extends Readonly<typeof theme> {}\n}\n'),"js"===e.language){for(const e of Object.keys(t))e.endsWith(".ts")&&!e.endsWith(".d.ts")&&(t[e.replace(/\.ts$/,".js")]=t[e],delete t[e]);for(const e of Object.keys(n))n[e.replace(/\.ts$/,".js")]=n[e],delete n[e]}return{files:t,vendorHelpers:n}})({language:c,emitMode:s,helpers:m,usesScheme:$,themeObjectBody:y(f,u),recipes:l,recipesBarrelBody:d.join("\n"),resetBody:T.length?q(T,{spreadName:i}):void 0,vendorMedia:I(e.breakpoints,a),vendorScheme:$?(v=f.modeNames,`// Vendored, self-contained styled-components colour-scheme helper (generated by @theme-registry/refract).\n// Only dependency: styled-components. Realizes appearance modes as prefers-color-scheme media blocks.\nimport { css } from "styled-components";\n\nconst wrap = (query) => {\n const fn = (styles, ...interpolations) => css\`\${query} { \${css(styles, ...interpolations)} }\`;\n fn.query = query;\n return fn;\n};\n\nexport const scheme = {\n${G(v).map(e=>` ${JSON.stringify(e)}: wrap(${JSON.stringify(_[e])}),`).join("\n")}\n};\n\nexport default scheme;\n`):void 0})}}}};return e(h)};export{K as createStyledComponentsAdapter,M as wrapMediaDescriptor};
|
|
12
12
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/lowering.ts","../src/identifiers.ts","../src/theme-object.ts","../src/recipe.ts","../src/media.ts","../src/scheme.ts","../src/emit.ts","../src/index.ts"],"sourcesContent":["/**\n * Shared lowering helpers for the styled-components adapter — the format-neutral bits the recipe IR\n * builder ({@link ../recipe}) and both sinks (emit-source / runtime-live) lean on: the state-selector\n * table the adapter owns, canonical LVHA state ordering, and breakpoint → concrete `@media` string\n * resolution. It imports **only** core (Model + media types), so the adapter stays liftable to its own\n * package (Step 11).\n *\n * The SC target emits TS/JS modules (a literal theme object + `css` recipes), not a stylesheet, so\n * there is no CSS-variable / class-name lowering here — recipe values read straight from the theme\n * (`${({ theme }) => theme.…}`) and the theme object *is* the indirection.\n */\nimport type { MediaDescriptor, MediaVariant } from \"@theme-registry/refract\";\nimport type { Orientation, RuleSetOverride } from \"@theme-registry/refract\";\n\n// ---------------------------------------------------------------------------\n// State selector table (adapter-owned)\n// ---------------------------------------------------------------------------\n\nexport const SC_STATE_SELECTORS: Record<string, string> = {\n link: \":link\",\n visited: \":visited\",\n hover: \":hover\",\n focus: \":focus\",\n active: \":active\",\n disabled: \"[disabled]\",\n pressed: \"[aria-pressed]\",\n};\n\n/** The states the SC adapter can render (the validation set core threads into normalization). */\nexport const SC_KNOWN_STATES: ReadonlyArray<string> = Object.keys(SC_STATE_SELECTORS);\n\nconst STATE_ORDER: Record<string, number> = SC_KNOWN_STATES.reduce<Record<string, number>>(\n (acc, name, index) => {\n acc[name] = index;\n return acc;\n },\n {},\n);\n\n/** Order state overrides in canonical LVHA order (breakpoint-scoped ones after the base state). */\nexport const orderStateOverrides = (overrides: RuleSetOverride[]): RuleSetOverride[] =>\n overrides\n .map((override, index) => ({ override, index }))\n .sort((a, b) => {\n const oa = STATE_ORDER[a.override.state as string] ?? Number.MAX_SAFE_INTEGER;\n const ob = STATE_ORDER[b.override.state as string] ?? Number.MAX_SAFE_INTEGER;\n if (oa !== ob) return oa - ob;\n const bpa = a.override.breakpoint ? 1 : 0;\n const bpb = b.override.breakpoint ? 1 : 0;\n if (bpa !== bpb) return bpa - bpb;\n return a.index - b.index;\n })\n .map(({ override }) => override);\n\n// ---------------------------------------------------------------------------\n// Breakpoint → concrete @media query resolution\n// ---------------------------------------------------------------------------\n\nexport const DEFAULT_MEDIA_QUERY: MediaVariant = \"exact\";\n\n/** Resolve a breakpoint + query kind (+ orientation) to its concrete `@media (...)` string. */\nexport const resolveMediaQuery = <TBreakpoint extends string>(\n media: MediaDescriptor<TBreakpoint>,\n breakpoint: TBreakpoint,\n query: MediaVariant,\n orientation?: Orientation,\n): string => {\n if (!orientation) return media[breakpoint]?.[query] ?? \"\";\n const opts = { orientation };\n if (query === \"min\") return media.min(breakpoint, opts);\n if (query === \"max\") return media.max(breakpoint, opts);\n return media.exact(breakpoint, opts);\n};\n","/**\n * JS-identifier naming for the styled-components TS/JS emit (§8).\n *\n * The SC target emits a **literal theme object** and **flat `css` recipe consts**, so its names are\n * JavaScript identifiers, not CSS variables/classes. This module is the SC analogue of the shared\n * `../naming` namer: it reuses that module's `sanitizeSegment` + collision-guard discipline (§7B) but\n * produces a **camelCase identifier form** instead of a kebab class/var.\n *\n * theme key: `themeKey([\"primary\", \"text\"])` → `primaryText` (folds a variant/extra\n * into its group under `theme.<subsystem>`)\n * theme access: `themeAccess(\"colors.primary.text\")` → `{ subsystem: \"colors\", key: \"primaryText\" }`\n * recipe export: `recipeExportName(\"components\",\"buttons\",\"primary\")` → `componentsButtonsPrimary`\n *\n * Unlike the CSS/SC class names, SC identifiers carry **no prefix** (the artifact's `colorsSolidPrimary`,\n * not `dtColorsSolidPrimary`) — the literal theme object *is* the isolation boundary. The §7B\n * `naming.className` override still remaps a recipe's identity (its export name); `naming.variableName`\n * has no coherent target on a nested object and is accepted-but-structural (theme keys stay derived).\n */\nimport type { NamingOverrides } from \"@theme-registry/refract/adapter-kit\";\n\n/** Split an authored segment into alphanumeric words (`\"button-lg\"` → `[\"button\",\"lg\"]`). Interior\n * case is preserved so an already-camelCase property (`fontSize`) survives as one word. */\nconst splitWords = (segment: string): string[] => segment.split(/[^a-zA-Z0-9]+/).filter(Boolean);\n\nconst lowerFirst = (word: string): string => word.charAt(0).toLowerCase() + word.slice(1);\nconst upperFirst = (word: string): string => word.charAt(0).toUpperCase() + word.slice(1);\n\n/**\n * camelCase-join a list of address segments into one identifier: the first word lower-cased, every\n * later word upper-cased and concatenated. A leading digit (invalid identifier start) is prefixed `_`.\n */\nexport const camelJoin = (segments: string[]): string => {\n const words = segments.flatMap(splitWords);\n if (!words.length) return \"_\";\n const joined = words.map((w, i) => (i === 0 ? lowerFirst(w) : upperFirst(w))).join(\"\");\n return /^[0-9]/.test(joined) ? `_${joined}` : joined;\n};\n\n/** A token's key under `theme.<subsystem>` — the property + its variant/extra segments camel-folded. */\nexport const themeKey = (segmentsAfterSubsystem: string[]): string => camelJoin(segmentsAfterSubsystem);\n\n/** A dotted token path → its `theme.<subsystem>.<key>` address parts. `colors.primary.text` →\n * `{ subsystem: \"colors\", key: \"primaryText\" }`; `borders.radius` → `{ subsystem: \"borders\", key: \"radius\" }`. */\nexport const themeAccess = (path: string): { subsystem: string; key: string } => {\n const [subsystem, ...rest] = path.split(\".\");\n return { subsystem, key: themeKey(rest) };\n};\n\n/**\n * A bound identifier minter for one theme: the recipe-export namer with the §7B collision guard.\n * Distinct addresses producing the same identifier throw; the same address re-resolving is fine.\n */\nexport interface ScIdentifiers {\n /** The camelCase export name for a recipe (`components`,`buttons`,`primary` → `componentsButtonsPrimary`). */\n recipeExportName(subsystem: string, group: string, variant: string): string;\n}\n\nexport const createIdentifiers = (overrides?: NamingOverrides): ScIdentifiers => {\n const seen = new Map<string, string>(); // identifier → source address key\n\n const track = (name: string, key: string): void => {\n const prev = seen.get(name);\n if (prev !== undefined && prev !== key) {\n throw new Error(\n `styled-components emit: recipe identifier \"${name}\" is produced by both \"${prev}\" and ` +\n `\"${key}\" — the naming override must map distinct recipes to distinct identifiers`,\n );\n }\n seen.set(name, key);\n };\n\n return {\n recipeExportName(subsystem, group, variant) {\n const segments = [subsystem, group, variant];\n let name = camelJoin(segments);\n if (overrides?.className) {\n // Feed the override a PREFIX-FREE default (SC identifiers carry no prefix), so a no-op\n // decorator round-trips to the structural name and only a real remap changes identity.\n const fallback = segments.map(s => splitWords(s).join(\"-\")).join(\"-\");\n const out = overrides.className(\n { kind: \"recipe\", subsystem, group, variant },\n { classToken: \"\", name: fallback },\n );\n name = camelJoin(splitWords(out));\n if (!name || name === \"_\") {\n throw new Error(\n `styled-components emit: className override returned an empty/invalid identifier for ` +\n `\"${subsystem}.${group}.${variant}\"`,\n );\n }\n }\n track(name, `${subsystem}.${group}.${variant}`);\n return name;\n },\n };\n};\n","/**\n * The literal theme object (§8) — the SC target's replacement for CSS `:root` variables.\n *\n * `buildThemeData` walks the Model's property tokens into a nested `{ [subsystem]: { [camelKey]: literal } }`\n * tree (variants/extras fold into their group as camelCased keys — `primary` → `primaryText`), plus a\n * parallel `modes` tree (§10.3 appearance-mode overrides — only the fields a mode redefines). The object\n * **is** the indirection: values are resolved literals, no `var()`. The same data serves two sinks — a\n * live JS object for the runtime `theme` (recipes read it from styled-components context) and an\n * object-literal source string for `emit()`.\n *\n * Structured compound tokens (§15 shadow / transition `Ref.struct`) are **skipped** — the SC adapter's\n * structured composition is deferred, exactly as the prior stylesheet lane skipped their `:root` vars.\n */\nimport type { ThemeModel, Ref, Literal } from \"@theme-registry/refract\";\nimport { themeKey } from \"./identifiers\";\n\n/** A resolved literal in the theme object: a number stays a number (`fontWeight`), a length/colour is a string. */\nexport type ThemeLiteral = string | number;\ntype ThemeTree = Record<string, Record<string, ThemeLiteral>>;\ntype ModesTree = Record<string, ThemeTree>;\n\nexport interface ThemeData {\n /** `subsystem → key → literal` (no `modes` / helpers — those are attached by the caller). */\n readonly tree: ThemeTree;\n /** `mode → subsystem → key → literal` — only the fields each mode redefines. */\n readonly modes: ModesTree;\n /** The mode names present (`[\"dark\"]`), in first-seen order. */\n readonly modeNames: string[];\n /** Every dotted token path that made it into the tree (non-struct) — recipe refs check membership. */\n readonly tokenPaths: Set<string>;\n /** `mode → set of dotted token paths that carry an override` — the recipe scheme block reads this. */\n readonly modeOverridePaths: Record<string, Set<string>>;\n}\n\n/** Format one token `Ref` to its theme-object literal. Returns `undefined` for a structured token (skipped). */\nconst formatValue = (ref: Ref, path: string, resolve: (path: string) => Literal): ThemeLiteral | undefined => {\n if (ref.struct !== undefined) return undefined;\n if (ref.external !== undefined) return `var(${ref.external})`; // §W6b — the theme entry IS the parent var\n\n const raw: Literal = ref.value !== undefined ? ref.value : resolve(path);\n // §21: a length leaf carries its resolved unit — emit `value + unit` as a string. A unit-less number\n // (fontWeight / lineHeight / opacity) has no `unit` and stays a JS number, so the theme object types\n // it as `number`.\n if (ref.unit !== undefined) return `${raw}${ref.unit}`;\n return raw;\n};\n\n/** Walk the Model into the nested theme tree + modes tree. `resolve` fills in pure-alias tokens. */\nexport const buildThemeData = (model: ThemeModel, resolve: (path: string) => Literal): ThemeData => {\n const tree: ThemeTree = {};\n const modes: ModesTree = {};\n const modeNames: string[] = [];\n const tokenPaths = new Set<string>();\n const modeOverridePaths: Record<string, Set<string>> = {};\n\n const put = (subsystem: string, key: string, path: string, ref: Ref): void => {\n const value = formatValue(ref, path, resolve);\n if (value === undefined) return; // structured token — deferred\n (tree[subsystem] ??= {})[key] = value;\n tokenPaths.add(path);\n };\n\n for (const [subsystem, sub] of Object.entries(model.subsystems)) {\n for (const [property, pm] of Object.entries(sub.properties ?? {})) {\n put(subsystem, themeKey([property]), `${subsystem}.${property}`, pm.base);\n for (const [extra, ref] of Object.entries(pm.extras ?? {})) {\n put(subsystem, themeKey([property, extra]), `${subsystem}.${property}.${extra}`, ref);\n }\n for (const [variant, v] of Object.entries(pm.variants ?? {})) {\n put(subsystem, themeKey([property, variant]), `${subsystem}.${property}.${variant}`, v.base);\n // dec.3 — a variant's own extras map to `<property><Variant><Extra>` in the SC theme object.\n for (const [extra, ref] of Object.entries(v.extras ?? {})) {\n put(subsystem, themeKey([property, variant, extra]), `${subsystem}.${property}.${variant}.${extra}`, ref);\n }\n }\n // §10.3 appearance modes — a LIST of `{ mode, target?, overrides }`. Each field maps to the\n // property key (or a variant key when `target` scopes it); an extra field appends `<Extra>`.\n // The recipe scheme block re-reads exactly these paths.\n for (const entry of pm.modes ?? []) {\n const mode = entry.mode;\n if (mode === undefined) continue;\n const target = entry.target;\n const segments = target ? [property, target] : [property];\n const basePath = target ? `${subsystem}.${property}.${target}` : `${subsystem}.${property}`;\n for (const [field, ref] of Object.entries(entry.overrides ?? {})) {\n const value = formatValue(ref, `${subsystem}.${property}`, resolve);\n if (value === undefined) continue;\n const key = field === \"base\" ? themeKey(segments) : themeKey([...segments, field]);\n const path = field === \"base\" ? basePath : `${basePath}.${field}`;\n if (!modeNames.includes(mode)) modeNames.push(mode);\n (((modes[mode] ??= {})[subsystem] ??= {}))[key] = value;\n (modeOverridePaths[mode] ??= new Set()).add(path);\n }\n }\n }\n }\n\n return { tree, modes, modeNames, tokenPaths, modeOverridePaths };\n};\n\n// ---------------------------------------------------------------------------\n// Serialization to object-literal source (emit)\n// ---------------------------------------------------------------------------\n\nconst INDENT = \" \";\n\n/** A theme literal → its JS source (`600` stays a number literal; a string is JSON-quoted). */\nconst literalSource = (value: ThemeLiteral): string =>\n typeof value === \"number\" ? String(value) : JSON.stringify(value);\n\nconst serializeLeafMap = (map: Record<string, ThemeLiteral>, depth: number): string => {\n const pad = INDENT.repeat(depth);\n const inner = INDENT.repeat(depth + 1);\n const entries = Object.entries(map).map(([k, v]) => `${inner}${k}: ${literalSource(v)},`);\n return `{\\n${entries.join(\"\\n\")}\\n${pad}}`;\n};\n\nconst serializeTree = (tree: ThemeTree, depth: number): string[] =>\n Object.entries(tree).map(\n ([subsystem, map]) => `${INDENT.repeat(depth)}${subsystem}: ${serializeLeafMap(map, depth)},`,\n );\n\n/**\n * Serialize the theme object literal body (the `{ … }`), including the subsystem trees, the optional\n * `modes` tree, and any trailing bare-identifier refs (`media`, `scheme`, helper fns) the caller wires.\n */\nexport const serializeThemeObject = (data: ThemeData, trailingRefs: string[]): string => {\n const lines: string[] = [\"{\"];\n lines.push(...serializeTree(data.tree, 1));\n\n if (data.modeNames.length) {\n lines.push(`${INDENT}modes: {`);\n for (const mode of data.modeNames) {\n lines.push(`${INDENT.repeat(2)}${mode}: {`);\n lines.push(...serializeTree(data.modes[mode], 3));\n lines.push(`${INDENT.repeat(2)}},`);\n }\n lines.push(`${INDENT}},`);\n }\n\n for (const ref of trailingRefs) lines.push(`${INDENT}${ref},`);\n lines.push(\"}\");\n return lines.join(\"\\n\");\n};\n\n/**\n * Assemble the **live** runtime theme object: the token tree + `modes` + the wrapped `media` / `scheme`\n * tagged-template helpers + any opted-in color-math fns. This is what a consumer passes to\n * `<ThemeProvider>`; recipes read every value off it via styled-components context.\n */\nexport const buildRuntimeThemeObject = (\n data: ThemeData,\n attach: Record<string, unknown>,\n): Record<string, unknown> => {\n const obj: Record<string, unknown> = {};\n for (const [subsystem, map] of Object.entries(data.tree)) obj[subsystem] = { ...map };\n if (data.modeNames.length) {\n const modes: Record<string, unknown> = {};\n for (const mode of data.modeNames) {\n const bySub: Record<string, unknown> = {};\n for (const [subsystem, map] of Object.entries(data.modes[mode])) bySub[subsystem] = { ...map };\n modes[mode] = bySub;\n }\n obj.modes = modes;\n }\n Object.assign(obj, attach);\n return obj;\n};\n","/**\n * The shared recipe renderer (§8) — one lowering, two sinks.\n *\n * A recipe {@link RuleSet} lowers to a format-neutral node tree ({@link RecipeNode}) — base\n * declarations, composition spreads, state / breakpoint / colour-scheme conditional blocks — that\n * BOTH sinks walk:\n * - **`recipeSource`** serializes it to `css\\`…\\`` **source** (`${({ theme }) => theme.…}` value\n * reads, `${sibling}` composition spreads, `theme.media` / `theme.scheme` tagged-template blocks)\n * for `emit()`.\n * - **`recipePlainCss`** renders it to a **live CSS string** off a runtime theme object (values\n * resolved from `props.theme`, breakpoints as concrete `@media`, dark as `prefers-color-scheme` /\n * `[data-theme]`) — the body of a lazy `css` block for the runtime surface.\n *\n * Values read from the theme, never `var()`; dark mode lives *in the recipe block* (§10.3), so it\n * tree-shakes with the recipe and switches with a plain CSS recalc — no `:root`, no provider swap.\n */\nimport type { MediaDescriptor, MediaVariant } from \"@theme-registry/refract\";\nimport type { Ref, RuleSet, RuleSetGroup, ThemeModel } from \"@theme-registry/refract\";\nimport { SC_STATE_SELECTORS, orderStateOverrides, resolveMediaQuery, DEFAULT_MEDIA_QUERY } from \"./lowering\";\nimport { themeAccess } from \"./identifiers\";\nimport type { ThemeData } from \"./theme-object\";\n\n/** How `model.modes` are realized into a recipe (§8): OS media, a `[data-theme]` toggle, or both. */\nexport type SchemeOption = \"media\" | \"attribute\" | \"both\";\n\n// ---------------------------------------------------------------------------\n// Node tree (the shared lowering)\n// ---------------------------------------------------------------------------\n\n/** One fragment of a declaration value: literal text, a theme token read, or an appearance-mode read. */\ntype Fragment =\n | { lit: string }\n | { ref: string }\n | { modeRef: { mode: string; path: string } };\n\ntype RecipeNode =\n | { type: \"decl\"; property: string; value: Fragment[] }\n /** A nested selector block (`&:hover`, `[data-theme=\"dark\"] &`) — arrow-form value reads. */\n | { type: \"block\"; selector: string; children: RecipeNode[] }\n /** A breakpoint block realized via `theme.media.<bp>.<query>` (captured-form reads inside). */\n | { type: \"media\"; breakpoint: string; query: MediaVariant; orientation?: \"landscape\" | \"portrait\"; children: RecipeNode[] }\n /** A colour-scheme block realized via `theme.scheme.<mode>` (captured-form reads inside). */\n | { type: \"scheme\"; mode: string; children: RecipeNode[] }\n /** A composition spread of a sibling recipe (`${componentsButtonsPrimary}` / inline its CSS). */\n | { type: \"spread\"; subsystem: string; group: string; variant: string };\n\n/** Context threaded into the IR builder + both sinks. */\nexport interface RecipeContext {\n readonly model: ThemeModel;\n readonly media: MediaDescriptor<string>;\n readonly data: ThemeData;\n readonly scheme: SchemeOption;\n /** The concrete `@media (prefers-color-scheme: <mode>)` string per realizable mode. */\n readonly prefers: Record<string, string>;\n}\n\nconst str = (value: unknown): string => (value == null ? \"\" : String(value));\n\n/** A rule-set declaration `Ref` → its value fragments. Returns `undefined` to SKIP the declaration\n * (a structured token the theme object doesn't carry). A literal is emitted as-is; a token ref (with\n * optional adapter `wrap`, e.g. `blur(…)`) becomes a theme read. */\nconst refFragments = (ref: Ref, data: ThemeData): Fragment[] | undefined => {\n if (ref.ref === undefined) return [{ lit: str(ref.value) }];\n if (!data.tokenPaths.has(ref.ref)) return undefined; // structured / absent token — deferred\n const read: Fragment = { ref: ref.ref };\n return ref.wrap ? [{ lit: `${ref.wrap}(` }, read, { lit: \")\" }] : [read];\n};\n\nconst declNodes = (declarations: Record<string, Ref> | undefined, data: ThemeData): RecipeNode[] => {\n const nodes: RecipeNode[] = [];\n for (const [property, ref] of Object.entries(declarations ?? {})) {\n const value = refFragments(ref, data);\n if (value) nodes.push({ type: \"decl\", property, value });\n }\n return nodes;\n};\n\n/** Parse a component composition reference (`\"colors:solid.primary\"`) into its address. */\nconst parseReference = (\n reference: string,\n): { subsystem: string; group: string; variant: string } | undefined => {\n const [subsystem, rest] = reference.split(\":\");\n if (!subsystem || !rest) return undefined;\n const dot = rest.indexOf(\".\");\n if (dot < 0) return undefined;\n return { subsystem, group: rest.slice(0, dot), variant: rest.slice(dot + 1) };\n};\n\n/** Which realizations (media / attribute) a mode uses under the current `scheme` option. Only `dark`\n * / `light` can ride `prefers-color-scheme`; any other named mode falls back to `[data-theme]`. */\nconst schemeRealizations = (mode: string, scheme: SchemeOption): { media: boolean; attribute: boolean } => {\n const mediaEligible = mode === \"dark\" || mode === \"light\";\n const media = mediaEligible && (scheme === \"media\" || scheme === \"both\");\n const attribute =\n scheme === \"attribute\" || scheme === \"both\" || (scheme === \"media\" && !mediaEligible);\n return { media, attribute };\n};\n\n/** Mode-override declarations for a set of declarations, reading `theme.modes.<mode>.…`. */\nconst modeDeclNodes = (\n declarations: Record<string, Ref> | undefined,\n mode: string,\n data: ThemeData,\n): RecipeNode[] => {\n const overridden = data.modeOverridePaths[mode];\n if (!overridden) return [];\n const nodes: RecipeNode[] = [];\n for (const [property, ref] of Object.entries(declarations ?? {})) {\n if (ref.ref !== undefined && overridden.has(ref.ref)) {\n nodes.push({ type: \"decl\", property, value: [{ modeRef: { mode, path: ref.ref } }] });\n }\n }\n return nodes;\n};\n\n/**\n * Lower one recipe {@link RuleSet} (+ optional composition `references`) to the shared node tree:\n * spreads → base declarations → breakpoint blocks → state blocks → colour-scheme blocks.\n */\nexport const buildRecipeIR = (ruleSet: RuleSet, ctx: RecipeContext): RecipeNode[] => {\n const nodes: RecipeNode[] = [];\n\n // Composition (components): spread each referenced sibling recipe first.\n for (const reference of ruleSet.references ?? []) {\n const parsed = parseReference(reference);\n if (parsed) nodes.push({ type: \"spread\", ...parsed });\n }\n\n // Base declarations.\n nodes.push(...declNodes(ruleSet.declarations, ctx.data));\n\n // Breakpoint-only overrides → a media block.\n for (const override of ruleSet.overrides) {\n if (override.state !== undefined || !override.breakpoint) continue;\n const children = declNodes(override.declarations, ctx.data);\n if (children.length) {\n nodes.push({\n type: \"media\",\n breakpoint: override.breakpoint,\n query: (override.query ?? DEFAULT_MEDIA_QUERY) as MediaVariant,\n orientation: override.orientation,\n children,\n });\n }\n }\n\n // State (+ state×breakpoint) overrides → a `&:hover`-style block, canonical LVHA order.\n const stateOverrides = ruleSet.overrides.filter(o => o.state !== undefined);\n for (const override of orderStateOverrides(stateOverrides)) {\n const stateSelector = SC_STATE_SELECTORS[override.state as string];\n const children = declNodes(override.declarations, ctx.data);\n if (!stateSelector || !children.length) continue;\n const block: RecipeNode = { type: \"block\", selector: `&${stateSelector}`, children };\n if (override.breakpoint) {\n nodes.push({\n type: \"media\",\n breakpoint: override.breakpoint,\n query: (override.query ?? DEFAULT_MEDIA_QUERY) as MediaVariant,\n orientation: override.orientation,\n children: [block],\n });\n } else {\n nodes.push(block);\n }\n }\n\n // Colour-scheme blocks (§10.3) — one per mode whose fields this recipe reads.\n for (const mode of ctx.data.modeNames) {\n const baseMode = modeDeclNodes(ruleSet.declarations, mode, ctx.data);\n const stateModeBlocks: RecipeNode[] = [];\n for (const override of orderStateOverrides(stateOverrides)) {\n const stateSelector = SC_STATE_SELECTORS[override.state as string];\n if (!stateSelector) continue;\n const children = modeDeclNodes(override.declarations, mode, ctx.data);\n if (children.length) stateModeBlocks.push({ type: \"block\", selector: `&${stateSelector}`, children });\n }\n const children = [...baseMode, ...stateModeBlocks];\n if (!children.length) continue;\n\n const { media, attribute } = schemeRealizations(mode, ctx.scheme);\n if (media) nodes.push({ type: \"scheme\", mode, children });\n if (attribute) nodes.push({ type: \"block\", selector: `[data-theme=\"${mode}\"] &`, children });\n }\n\n return nodes;\n};\n\n/**\n * Lower the `globals` subsystem's rule-sets (§9) into `block` nodes for the `GlobalStyle` — one raw\n * `<selector> { … }` per rule-set. Two kinds:\n * - `kind:\"reset\"` (preset `static` / `defaults`) — declaration-only (literals as-is, token refs as\n * theme reads).\n * - `kind:\"globals\"` (themed `elements`) — the element's base declarations PLUS its state/breakpoint/\n * colour-scheme blocks (via {@link buildRecipeIR}) and each delta-only variant nested as a\n * `&.<variant>` block. Dark rides the referenced token's own modes — realized *inside* the element\n * block as a `theme.scheme.<mode>` / `[data-theme]` conditional (same as recipes), no `:root`.\n * Feeds the `GlobalStyle` emitter + the runtime `GlobalStyle`.\n */\nexport const buildGlobalsIR = (\n groups: Record<string, RuleSetGroup> | undefined,\n ctx: RecipeContext,\n): RecipeNode[] => {\n const nodes: RecipeNode[] = [];\n for (const group of Object.values(groups ?? {})) {\n for (const ruleSet of Object.values(group)) {\n if (!ruleSet.selector) continue;\n if (ruleSet.kind === \"globals\") {\n const children = buildRecipeIR(ruleSet, ctx);\n for (const [variantName, variant] of Object.entries(ruleSet.variants ?? {})) {\n const variantRuleSet: RuleSet = {\n kind: \"globals\",\n selector: ruleSet.selector,\n declarations: variant.declarations,\n overrides: variant.overrides,\n };\n const variantChildren = buildRecipeIR(variantRuleSet, ctx);\n if (variantChildren.length) {\n children.push({ type: \"block\", selector: `&.${variantName}`, children: variantChildren });\n }\n }\n if (children.length) nodes.push({ type: \"block\", selector: ruleSet.selector, children });\n } else {\n const children = declNodes(ruleSet.declarations, ctx.data);\n if (children.length) nodes.push({ type: \"block\", selector: ruleSet.selector, children });\n }\n }\n }\n return nodes;\n};\n\n// ---------------------------------------------------------------------------\n// Sink 1 — source serialization (emit)\n// ---------------------------------------------------------------------------\n\nconst INDENT = \" \";\n\n/** A theme read `theme.<subsystem>.<key>` (optionally under `modes.<mode>`). */\nconst accessExpr = (path: string, mode?: string): string => {\n const { subsystem, key } = themeAccess(path);\n return mode ? `theme.modes.${mode}.${subsystem}.${key}` : `theme.${subsystem}.${key}`;\n};\n\n/** Serialize one declaration's value fragments. `captured` = inside a media/scheme tagged template\n * (the outer arrow already bound `theme`, so reads are bare `${theme.…}` not `${({theme})=>…}`). */\nconst fragmentsSource = (fragments: Fragment[], captured: boolean): string =>\n fragments\n .map(fragment => {\n if (\"lit\" in fragment) return fragment.lit;\n const expr = \"ref\" in fragment ? accessExpr(fragment.ref) : accessExpr(fragment.modeRef.path, fragment.modeRef.mode);\n return captured ? `\\${${expr}}` : `\\${({ theme }) => ${expr}}`;\n })\n .join(\"\");\n\ninterface SourceOptions {\n /** The export identifier for a spread reference (`components`,`buttons`,`primary` → `componentsButtonsPrimary`). */\n spreadName(subsystem: string, group: string, variant: string): string;\n}\n\nconst nodeSource = (node: RecipeNode, indent: string, captured: boolean, opts: SourceOptions): string => {\n switch (node.type) {\n case \"decl\":\n return `${indent}${node.property}: ${fragmentsSource(node.value, captured)};`;\n case \"spread\":\n return `${indent}\\${${opts.spreadName(node.subsystem, node.group, node.variant)}}`;\n case \"block\": {\n const inner = node.children.map(c => nodeSource(c, indent + INDENT, captured, opts)).join(\"\\n\");\n return `${indent}${node.selector} {\\n${inner}\\n${indent}}`;\n }\n case \"media\": {\n const target = node.orientation\n ? `theme.media.${node.query}(${JSON.stringify(node.breakpoint)}, { orientation: ${JSON.stringify(node.orientation)} })`\n : `theme.media.${node.breakpoint}.${node.query}`;\n const inner = node.children.map(c => nodeSource(c, indent + INDENT, true, opts)).join(\"\\n\");\n return `${indent}\\${({ theme }) => ${target}\\`\\n${inner}\\n${indent}\\`}`;\n }\n case \"scheme\": {\n const inner = node.children.map(c => nodeSource(c, indent + INDENT, true, opts)).join(\"\\n\");\n return `${indent}\\${({ theme }) => theme.scheme.${node.mode}\\`\\n${inner}\\n${indent}\\`}`;\n }\n }\n};\n\n/** Serialize a recipe's node tree to the body of a `css\\`…\\`` template (2-space indented). */\nexport const recipeSource = (nodes: RecipeNode[], opts: SourceOptions): string =>\n nodes.map(node => nodeSource(node, INDENT, false, opts)).join(\"\\n\");\n\n// ---------------------------------------------------------------------------\n// Sink 2 — live plain-CSS rendering (runtime)\n// ---------------------------------------------------------------------------\n\n/** Read a value off the runtime theme object: `theme[subsystem][key]` (optionally under `modes.<mode>`). */\nconst readTheme = (theme: Record<string, any>, path: string, mode?: string): unknown => {\n const { subsystem, key } = themeAccess(path);\n const root = mode ? theme?.modes?.[mode] : theme;\n return root?.[subsystem]?.[key];\n};\n\nconst fragmentsValue = (fragments: Fragment[], theme: Record<string, any>): string =>\n fragments\n .map(fragment => {\n if (\"lit\" in fragment) return fragment.lit;\n if (\"ref\" in fragment) return str(readTheme(theme, fragment.ref));\n return str(readTheme(theme, fragment.modeRef.path, fragment.modeRef.mode));\n })\n .join(\"\");\n\n/** Resolve a sibling recipe's live CSS (composition) — injected by the adapter's lazy registry. */\nexport type SpreadRenderer = (\n subsystem: string,\n group: string,\n variant: string,\n theme: Record<string, any>,\n) => string;\n\nconst nodePlainCss = (\n node: RecipeNode,\n theme: Record<string, any>,\n ctx: RecipeContext,\n spread: SpreadRenderer,\n): string => {\n switch (node.type) {\n case \"decl\":\n return `${node.property}: ${fragmentsValue(node.value, theme)};`;\n case \"spread\":\n return spread(node.subsystem, node.group, node.variant, theme);\n case \"block\": {\n const inner = node.children.map(c => nodePlainCss(c, theme, ctx, spread)).join(\" \");\n return `${node.selector} { ${inner} }`;\n }\n case \"media\": {\n const query = resolveMediaQuery(ctx.media, node.breakpoint, node.query, node.orientation);\n const inner = node.children.map(c => nodePlainCss(c, theme, ctx, spread)).join(\" \");\n return query ? `${query} { ${inner} }` : inner;\n }\n case \"scheme\": {\n const query = ctx.prefers[node.mode] ?? \"\";\n const inner = node.children.map(c => nodePlainCss(c, theme, ctx, spread)).join(\" \");\n return query ? `${query} { ${inner} }` : inner;\n }\n }\n};\n\n/** Render a recipe's node tree to a live CSS string off a runtime theme object. */\nexport const recipePlainCss = (\n nodes: RecipeNode[],\n theme: Record<string, any>,\n ctx: RecipeContext,\n spread: SpreadRenderer,\n): string => nodes.map(node => nodePlainCss(node, theme, ctx, spread)).join(\"\\n\");\n","/**\n * SC-decorated media — the `wrapMedia` half of the adapter contract's media pattern.\n *\n * Core builds the plain {@link MediaDescriptor} (breakpoints → `@media (min-width:…)` strings);\n * this decorates it into styled-components **tagged-template** helpers so a consumer writes\n * `theme.media.md.min\\`color: red;\\`` (or `theme.media.min(\"md\")\\`…\\``) and gets an SC `css` block\n * scoped to that query. Re-ported from the dormant legacy SC adapter onto the clean-room\n * `core/media` (imports only core — self-contained for the Step 9 package extraction).\n */\nimport { css } from \"styled-components\";\nimport type { Interpolation, RuleSet } from \"styled-components\";\nimport type {\n MediaDescriptor,\n MediaGroupDescriptor,\n MediaQueryOptions,\n MediaVariant,\n} from \"@theme-registry/refract\";\n\ntype MediaTemplate = (\n styles: TemplateStringsArray,\n ...interpolations: Interpolation<object>[]\n) => RuleSet<object>;\n\n/** A media tagged-template that also carries the raw `@media` query string it wraps. */\nexport type MediaTemplateWithQuery = MediaTemplate & { readonly query: string };\n\nexport type WrappedMediaGroup = Record<MediaVariant, MediaTemplateWithQuery>;\n\n/** The SC-decorated media descriptor put on `theme.media` — tagged templates instead of strings. */\nexport type WrappedMediaDescriptor<TBreakpoint extends string> = {\n min: (key: TBreakpoint, options?: MediaOrientationOptions) => MediaTemplateWithQuery;\n max: (key: TBreakpoint, options?: MediaOrientationOptions) => MediaTemplateWithQuery;\n between: (\n from: TBreakpoint,\n to: TBreakpoint,\n options?: MediaOrientationOptions,\n ) => MediaTemplateWithQuery;\n} & Record<TBreakpoint, WrappedMediaGroup>;\n\ntype MediaOrientationOptions = Pick<MediaQueryOptions, \"orientation\">;\n\nconst RESERVED_DESCRIPTOR_KEYS = new Set([\"min\", \"max\", \"between\", \"exact\"]);\n\n/** Decorate a core {@link MediaDescriptor} into SC tagged-template helpers. */\nexport const wrapMediaDescriptor = <TBreakpoint extends string>(\n descriptor: MediaDescriptor<TBreakpoint>,\n): WrappedMediaDescriptor<TBreakpoint> => {\n const wrapped = {\n min: (key: TBreakpoint, options?: MediaOrientationOptions) =>\n wrapQuery(descriptor.min(key, options)),\n max: (key: TBreakpoint, options?: MediaOrientationOptions) =>\n wrapQuery(descriptor.max(key, options)),\n between: (from: TBreakpoint, to: TBreakpoint, options?: MediaOrientationOptions) =>\n wrapQuery(descriptor.between(from, to, options)),\n } as WrappedMediaDescriptor<TBreakpoint>;\n\n for (const key of Object.keys(descriptor) as TBreakpoint[]) {\n if (RESERVED_DESCRIPTOR_KEYS.has(key)) continue;\n (wrapped as Record<string, unknown>)[key] = wrapMediaGroup(\n descriptor[key] as MediaGroupDescriptor,\n );\n }\n\n return wrapped;\n};\n\nexport const wrapMediaGroup = (group: MediaGroupDescriptor): WrappedMediaGroup => {\n const wrapped = {} as WrappedMediaGroup;\n (Object.keys(group) as MediaVariant[]).forEach(variant => {\n wrapped[variant] = wrapQuery(group[variant]);\n });\n return wrapped;\n};\n\nconst wrapQuery = (query: string): MediaTemplateWithQuery =>\n Object.assign(buildTemplate(query), { query }) as MediaTemplateWithQuery;\n\nconst buildTemplate = (query: string): MediaTemplate => {\n if (!query) {\n return (styles, ...interpolations) => css`\n ${css(styles, ...interpolations)}\n `;\n }\n return (styles, ...interpolations) => css`\n ${query} {\n ${css(styles, ...interpolations)}\n }\n `;\n};\n","/**\n * SC colour-scheme tagged templates (§8) — the `theme.scheme.dark\\`…\\`` half of the appearance-mode\n * (§10.3) realization, parallel to `media.ts`. A recipe's dark block interpolates\n * `${({ theme }) => theme.scheme.dark\\`…\\`}`, which wraps its body in\n * `@media (prefers-color-scheme: dark) { … }`. Only `dark` / `light` ride `prefers-color-scheme`\n * (a `[data-theme]` toggle handles any other named mode — that path uses a plain nested selector,\n * not this helper).\n *\n * Two forms, like media: a **runtime** wrapper (`wrapSchemeHelper`) put on the live `theme.scheme`,\n * and a **vendored** self-contained module (`vendorSchemeHelper`) written by `emit()` so a downstream\n * app keeps `theme.scheme` after it drops refract (its only dependency is `styled-components`).\n */\nimport { css } from \"styled-components\";\nimport type { Interpolation, RuleSet } from \"styled-components\";\n\n/** The concrete `@media (prefers-color-scheme: …)` string for a realizable mode. */\nexport const PREFERS: Record<string, string> = {\n dark: \"@media (prefers-color-scheme: dark)\",\n light: \"@media (prefers-color-scheme: light)\",\n};\n\n/** Which authored modes ride `prefers-color-scheme` (the ones this helper realizes). */\nexport const mediaEligibleModes = (modeNames: readonly string[]): string[] =>\n modeNames.filter(mode => mode in PREFERS);\n\ntype SchemeTemplate = (\n styles: TemplateStringsArray,\n ...interpolations: Interpolation<object>[]\n) => RuleSet<object>;\n\n/** A scheme tagged-template that also carries the raw `@media (prefers-color-scheme: …)` it wraps. */\nexport type SchemeTemplateWithQuery = SchemeTemplate & { readonly query: string };\n\n/** The wrapped `theme.scheme` — one tagged template per realizable mode (`dark` / `light`). */\nexport type SchemeHelper = Record<string, SchemeTemplateWithQuery>;\n\nconst buildTemplate = (query: string): SchemeTemplate => (styles, ...interpolations) =>\n css`\n ${query} {\n ${css(styles, ...interpolations)}\n }\n `;\n\n/** Build the runtime `theme.scheme` for the given realizable modes. */\nexport const wrapSchemeHelper = (modeNames: readonly string[]): SchemeHelper => {\n const helper: SchemeHelper = {};\n for (const mode of mediaEligibleModes(modeNames)) {\n const query = PREFERS[mode];\n helper[mode] = Object.assign(buildTemplate(query), { query }) as SchemeTemplateWithQuery;\n }\n return helper;\n};\n\n/** Generate the self-contained vendored `scheme.ts` source for the given realizable modes. */\nexport const vendorSchemeHelper = (modeNames: readonly string[]): string => {\n const entries = mediaEligibleModes(modeNames)\n .map(mode => ` ${JSON.stringify(mode)}: wrap(${JSON.stringify(PREFERS[mode])}),`)\n .join(\"\\n\");\n\n return `// Vendored, self-contained styled-components colour-scheme helper (generated by @theme-registry/refract).\n// Only dependency: styled-components. Realizes appearance modes as prefers-color-scheme media blocks.\nimport { css } from \"styled-components\";\n\nconst wrap = (query) => {\n const fn = (styles, ...interpolations) => css\\`\\${query} { \\${css(styles, ...interpolations)} }\\`;\n fn.query = query;\n return fn;\n};\n\nexport const scheme = {\n${entries}\n};\n\nexport default scheme;\n`;\n};\n","/**\n * The styled-components `emit()` module assembler (§8) — writes **TS/JS modules**, not a stylesheet.\n *\n * What lands on disk (self-contained — a downstream app imports these and drops refract at runtime):\n * - **theme.ts** — the literal theme object (`export const theme = { … } as const`) + the flat, tree-\n * shakeable `css` recipe consts + a grouped `recipes` barrel + (if the raw defines `globals`) a\n * `GlobalStyle`. `emit: \"split\"` peels the recipes into `recipes.ts` and the `GlobalStyle` into\n * `global.ts`.\n * - **media.ts** (always) / **scheme.ts** (iff modes ride `prefers-color-scheme`) — vendored tagged\n * templates with this theme's concrete `@media` strings baked in.\n * - **theme.d.ts** (iff `language: \"ts\"`) — augments styled-components' `DefaultTheme` from `typeof theme`.\n * - **color-math.ts** is materialized by the shared build plumbing (`emitTheme` + `VENDOR_HELPERS`),\n * not here — this module only wires the `import`.\n */\nimport type { EmitOutput } from \"@theme-registry/refract\";\nimport type { MediaDescriptor, MediaVariant } from \"@theme-registry/refract\";\n\nconst VARIANTS: ReadonlyArray<MediaVariant> = [\"min\", \"max\", \"exact\"];\n\n/** color-math exports surfaced on `theme` when `helpers: [\"color-math\"]` is opted in. */\nexport const COLOR_MATH_ATTACH: ReadonlyArray<string> = [\"lighten\", \"darken\", \"alpha\"];\n\n/**\n * Generate a self-contained SC media-helper module (source text) for `breakpoints`, reading the\n * concrete `@media` query strings from the already-built core {@link MediaDescriptor}.\n */\nexport const vendorMediaHelper = <TBreakpoint extends string>(\n breakpoints: Record<TBreakpoint, number>,\n media: MediaDescriptor<TBreakpoint>,\n): string => {\n const keys = (Object.keys(breakpoints) as TBreakpoint[]).sort(\n (a, b) => breakpoints[a] - breakpoints[b],\n );\n\n const groups = keys\n .map(key => {\n const group = media[key];\n const variants = VARIANTS.map(\n variant => ` ${variant}: wrap(${JSON.stringify(group?.[variant] ?? \"\")}),`,\n ).join(\"\\n\");\n return ` ${JSON.stringify(key)}: {\\n${variants}\\n },`;\n })\n .join(\"\\n\");\n\n return `// Vendored, self-contained styled-components media helper (generated by @theme-registry/refract).\n// Only dependency: styled-components. Concrete @media strings are baked in for this theme's breakpoints.\nimport { css } from \"styled-components\";\n\nconst wrap = (query) => {\n const fn = query\n ? (styles, ...interpolations) => css\\`\\${query} { \\${css(styles, ...interpolations)} }\\`\n : (styles, ...interpolations) => css\\`\\${css(styles, ...interpolations)}\\`;\n fn.query = query;\n return fn;\n};\n\nexport const media = {\n${groups}\n};\n\nexport default media;\n`;\n};\n\n// ---------------------------------------------------------------------------\n// Module assembly\n// ---------------------------------------------------------------------------\n\n/** One recipe ready to serialize: its export identifier + its `css\\`…\\`` body source. */\nexport interface RecipeEmit {\n readonly exportName: string;\n readonly body: string;\n}\n\n/** Everything the assembler needs, prepared by the adapter's bind. */\nexport interface ScEmitInputs {\n readonly language: \"ts\" | \"js\";\n readonly emitMode: \"single\" | \"split\";\n readonly helpers: readonly string[];\n readonly usesScheme: boolean;\n /** The `export const theme = <this> as const` body (subsystems + modes + trailing refs). */\n readonly themeObjectBody: string;\n /** Recipes in dependency-safe order (a composed recipe's references precede it). */\n readonly recipes: readonly RecipeEmit[];\n /** The grouped `export const recipes = { … } as const` barrel body. */\n readonly recipesBarrelBody: string;\n /** The `createGlobalStyle\\`…\\`` body, if the raw defines `globals`. */\n readonly resetBody?: string;\n readonly vendorMedia: string;\n readonly vendorScheme?: string;\n}\n\nconst usesColorMath = (helpers: readonly string[]): boolean => helpers.includes(\"color-math\");\n\n/** The `import … from \"styled-components\"` line for the file that carries recipes / GlobalStyle. */\nconst scImport = (needsCss: boolean, needsGlobal: boolean): string => {\n const names = [needsCss ? \"css\" : \"\", needsGlobal ? \"createGlobalStyle\" : \"\"].filter(Boolean);\n return `import { ${names.join(\", \")} } from \"styled-components\";`;\n};\n\n/** The imports the theme object needs (`media`, optional `scheme`, optional color-math helpers). */\nconst themeImports = (inputs: ScEmitInputs): string[] => {\n const lines = [`import { media } from \"./media\";`];\n if (inputs.usesScheme) lines.push(`import { scheme } from \"./scheme\";`);\n if (usesColorMath(inputs.helpers)) {\n lines.push(`import { ${COLOR_MATH_ATTACH.join(\", \")} } from \"./color-math\";`);\n }\n return lines;\n};\n\nconst themeConst = (body: string): string => `export const theme = ${body} as const;`;\n\nconst recipeConsts = (recipes: readonly RecipeEmit[]): string =>\n recipes.map(r => `export const ${r.exportName} = css\\`\\n${r.body}\\n\\`;`).join(\"\\n\\n\");\n\nconst recipesBarrel = (body: string): string => `export const recipes = ${body} as const;`;\n\nconst globalStyle = (body: string): string => `export const GlobalStyle = createGlobalStyle\\`\\n${body}\\n\\`;`;\n\nconst themeDts = (): string =>\n `import \"styled-components\";\nimport type { theme } from \"./theme\";\n\ndeclare module \"styled-components\" {\n export interface DefaultTheme extends Readonly<typeof theme> {}\n}\n`;\n\n/** Assemble the SC emit output (files + vendored helpers) from the prepared inputs. */\nexport const buildScEmit = (inputs: ScEmitInputs): EmitOutput => {\n const files: Record<string, string> = {};\n const vendorHelpers: Record<string, string> = { \"media.ts\": inputs.vendorMedia };\n if (inputs.vendorScheme) vendorHelpers[\"scheme.ts\"] = inputs.vendorScheme;\n\n const hasRecipes = inputs.recipes.length > 0;\n const hasReset = inputs.resetBody !== undefined;\n\n if (inputs.emitMode === \"single\") {\n const parts: string[] = [];\n parts.push([scImport(hasRecipes, hasReset), ...themeImports(inputs)].join(\"\\n\"));\n parts.push(themeConst(inputs.themeObjectBody));\n if (hasRecipes) {\n parts.push(recipeConsts(inputs.recipes));\n parts.push(recipesBarrel(inputs.recipesBarrelBody));\n }\n if (hasReset) parts.push(globalStyle(inputs.resetBody!));\n files[\"theme.ts\"] = parts.join(\"\\n\\n\") + \"\\n\";\n } else {\n // split — theme / recipes / global in separate files.\n files[\"theme.ts\"] = [themeImports(inputs).join(\"\\n\"), themeConst(inputs.themeObjectBody)].join(\"\\n\\n\") + \"\\n\";\n if (hasRecipes) {\n files[\"recipes.ts\"] =\n [scImport(true, false), recipeConsts(inputs.recipes), recipesBarrel(inputs.recipesBarrelBody)].join(\"\\n\\n\") + \"\\n\";\n }\n if (hasReset) {\n files[\"global.ts\"] = [scImport(false, true), globalStyle(inputs.resetBody!)].join(\"\\n\\n\") + \"\\n\";\n }\n }\n\n if (inputs.language === \"ts\") files[\"theme.d.ts\"] = themeDts();\n\n // A `js` emit writes `.js` module names (the source is plain JS — no annotations are generated).\n if (inputs.language === \"js\") {\n for (const name of Object.keys(files)) {\n if (name.endsWith(\".ts\") && !name.endsWith(\".d.ts\")) {\n files[name.replace(/\\.ts$/, \".js\")] = files[name];\n delete files[name];\n }\n }\n for (const name of Object.keys(vendorHelpers)) {\n vendorHelpers[name.replace(/\\.ts$/, \".js\")] = vendorHelpers[name];\n delete vendorHelpers[name];\n }\n }\n\n return { files, vendorHelpers };\n};\n","/**\n * The styled-components adapter (§8) — lowers the format-neutral {@link ThemeModel} to **TS/JS\n * modules**, not a stylesheet. Worked reference: `src/adapters/css/`; imports only core (+ the\n * `styled-components` peer) so it can be lifted to its own package (Step 11).\n *\n * One renderer, two sinks (see `./recipe`): the same recipe lowering feeds `emit()` (serialize to\n * `css\\`…\\`` source on disk) and the runtime surface (`createTheme(raw, { adapter })` → a live `css`\n * block per recipe, lowered on first access and cached). Both project the SAME shapes:\n *\n * - **theme** — a literal object (`theme.colors.primary`, `theme.modes.dark.…`, `theme.media`,\n * `theme.scheme`, opted-in color-math fns). No `var()`; the object IS the indirection. This is\n * what a consumer passes to `<ThemeProvider>`.\n * - **recipes** — flat, tree-shakeable `css` blocks reading values off the theme (`${({ theme }) =>\n * theme.…}`); composition = a `css` spread of the referenced siblings. Grouped `recipes` barrel too.\n * - **GlobalStyle** — the globals subsystem as a `createGlobalStyle` (present iff the raw defines `globals`).\n * - **media** / **scheme** — SC tagged templates (breakpoints / `prefers-color-scheme`).\n */\nimport type { RuleSet as ModelRuleSet, ThemeModel } from \"@theme-registry/refract\";\nimport type { AdapterSpec, RenderContext, ThemeAdapter, NormalizedEmit, EmitOutput } from \"@theme-registry/refract\";\nimport type { UsageDescriptor } from \"@theme-registry/refract\";\nimport type { MediaDescriptor } from \"@theme-registry/refract\";\nimport { defineAdapter } from \"@theme-registry/refract\";\nimport { css, createGlobalStyle } from \"styled-components\";\nimport type { RuleSet } from \"styled-components\";\nimport type { NamingOverrides } from \"@theme-registry/refract/adapter-kit\";\nimport { SC_KNOWN_STATES } from \"./lowering\";\nimport { createIdentifiers } from \"./identifiers\";\nimport { buildThemeData, buildRuntimeThemeObject, serializeThemeObject } from \"./theme-object\";\nimport {\n buildRecipeIR,\n buildGlobalsIR,\n recipeSource,\n recipePlainCss,\n type RecipeContext,\n type SchemeOption,\n type SpreadRenderer,\n} from \"./recipe\";\nimport { wrapMediaDescriptor } from \"./media\";\nimport { wrapSchemeHelper, vendorSchemeHelper, mediaEligibleModes, PREFERS } from \"./scheme\";\nimport { vendorMediaHelper, buildScEmit, COLOR_MATH_ATTACH, type RecipeEmit, type ScEmitInputs } from \"./emit\";\n\n/** The output unit for this adapter — the return of the styled-components `css` tagged template. */\nexport type StyledComponentsUnit = RuleSet<object>;\n\n/** styled-components adapter options (§8). */\nexport type StyledComponentsAdapterOptions = {\n /**\n * Emit `.ts` (default) or `.js` modules. `ts` additionally emits `theme.d.ts` augmenting\n * styled-components' `DefaultTheme` from `typeof theme`, so `props.theme.…` is typed.\n */\n language?: \"ts\" | \"js\";\n /**\n * How appearance modes (§10.3) are realized in recipes: `\"media\"` (default) →\n * `@media (prefers-color-scheme: dark)` (follows the OS); `\"attribute\"` → `[data-theme=\"dark\"] &`\n * (a manual toggle overrides the OS); `\"both\"` → both blocks.\n */\n scheme?: SchemeOption;\n /**\n * Shared vendorable helpers surfaced on `theme` — `[\"color-math\"]` wires the `lighten`/`darken`/`alpha`\n * import (the module itself is materialized by the build plumbing, `emitTheme` + `VENDOR_HELPERS`).\n */\n helpers?: readonly string[];\n /** Accepted for parity with the CSS adapter's namer. SC identifiers carry no prefix (the literal\n * theme object is the isolation boundary), so these do not alter identifiers in v1. */\n prefix?: string;\n classPrefix?: string;\n /**\n * §7B — swap how names are generated (shared type with the CSS adapter). `className` remaps a\n * recipe's export identity (camelCased); `variableName` has no coherent target on the nested theme\n * object and is accepted-but-structural (theme keys stay derived from the token address).\n */\n naming?: NamingOverrides;\n};\n\nconst isValidIdentifier = (name: string): boolean => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);\nconst objectKey = (name: string): string => (isValidIdentifier(name) ? name : JSON.stringify(name));\n\n/** Memoize an object property: build the value on first access, then replace the getter with it. */\nconst lazy = (obj: Record<string, unknown>, key: string, compute: () => unknown): void => {\n Object.defineProperty(obj, key, {\n configurable: true,\n enumerable: true,\n get() {\n const value = compute();\n Object.defineProperty(obj, key, { value, enumerable: true, configurable: true });\n return value;\n },\n });\n};\n\nexport const createStyledComponentsAdapter = (\n options: StyledComponentsAdapterOptions = {},\n): ThemeAdapter<StyledComponentsUnit> => {\n const language = options.language ?? \"ts\";\n const scheme: SchemeOption = options.scheme ?? \"media\";\n const helpers = options.helpers ?? [];\n\n const spec: AdapterSpec<StyledComponentsUnit> = {\n name: \"styled-components\",\n version: 1,\n allowedStates: SC_KNOWN_STATES,\n bind(model: ThemeModel, ctx: RenderContext) {\n const media = ctx.media as MediaDescriptor<string>;\n const ids = createIdentifiers(options.naming);\n\n // The literal theme object data (tokens + modes) — the shared source for both sinks.\n const data = buildThemeData(model, ctx.resolve);\n const recipeCtx: RecipeContext = { model, media, data, scheme, prefers: PREFERS };\n\n // Do any recipes reference `theme.scheme`? (Only dark/light under media/both do.)\n const usesScheme = (scheme === \"media\" || scheme === \"both\") && mediaEligibleModes(data.modeNames).length > 0;\n\n // ── Recipe IR registry (every rule-set except globals), addressed by \"subsystem.group.variant\". ──\n const addressKey = (subsystem: string, group: string, variant: string): string =>\n `${subsystem}.${group}.${variant}`;\n const registry = new Map<string, ReturnType<typeof buildRecipeIR>>();\n const recipeAddresses: Array<{ subsystem: string; group: string; variant: string }> = [];\n for (const [subsystem, sub] of Object.entries(model.subsystems)) {\n if (subsystem === \"globals\") continue;\n for (const [group, ruleSetGroup] of Object.entries(sub.ruleSets ?? {})) {\n for (const [variant, ruleSet] of Object.entries(ruleSetGroup)) {\n registry.set(addressKey(subsystem, group, variant), buildRecipeIR(ruleSet, recipeCtx));\n recipeAddresses.push({ subsystem, group, variant });\n }\n }\n }\n\n const ruleSetOf = (subsystem: string, group: string, variant: string): ModelRuleSet | undefined =>\n model.subsystems[subsystem]?.ruleSets?.[group]?.[variant];\n\n // ── Runtime sinks ──\n // Composition spreads inline the referenced recipe's live CSS (recursively).\n const spreadRenderer: SpreadRenderer = (subsystem, group, variant, theme) => {\n const nodes = registry.get(addressKey(subsystem, group, variant));\n return nodes ? recipePlainCss(nodes, theme, recipeCtx, spreadRenderer) : \"\";\n };\n\n const buildLiveRecipe = (subsystem: string, group: string, variant: string): RuleSet<object> => {\n const nodes = registry.get(addressKey(subsystem, group, variant)) ?? [];\n return css`${({ theme }: { theme: Record<string, any> }) => recipePlainCss(nodes, theme, recipeCtx, spreadRenderer)}`;\n };\n\n const wrappedMedia = wrapMediaDescriptor(media);\n const wrappedScheme = usesScheme ? wrapSchemeHelper(data.modeNames) : undefined;\n\n // The live theme object put on `theme` (recipes read it from styled-components context).\n const attach: Record<string, unknown> = { media: wrappedMedia };\n if (wrappedScheme) attach.scheme = wrappedScheme;\n const runtimeTheme = buildRuntimeThemeObject(data, attach);\n\n // Lazy + cached `recipes.<subsystem>.<group>.<variant>` — each lowered on first access.\n const buildRecipesTree = (): Record<string, unknown> => {\n const tree: Record<string, unknown> = {};\n for (const { subsystem, group, variant } of recipeAddresses) {\n const groups = (tree[subsystem] ??= {}) as Record<string, Record<string, unknown>>;\n const variants = (groups[group] ??= {});\n lazy(variants, variant, () => buildLiveRecipe(subsystem, group, variant));\n }\n return tree;\n };\n\n // Globals → a live GlobalStyle (present iff the raw defines the globals subsystem).\n const resetNodes = buildGlobalsIR(model.subsystems.globals?.ruleSets, recipeCtx);\n const GlobalStyle = resetNodes.length\n ? createGlobalStyle`${({ theme }: { theme: Record<string, any> }) => recipePlainCss(resetNodes, theme, recipeCtx, spreadRenderer)}`\n : undefined;\n\n // ── Emit sink ──\n const emit = (plan?: NormalizedEmit): EmitOutput => {\n const type = plan?.type ?? \"single\";\n if (type !== \"single\" && type !== \"split\") {\n throw new Error(\n `styled-components adapter: emit mode '${type}' is not supported — the TS/JS target ` +\n `emits 'single' or 'split' (ES modules tree-shake per export; 'subsystem'/'components' ` +\n `are CSS-only concerns).`,\n );\n }\n\n const spreadName = (subsystem: string, group: string, variant: string): string =>\n ids.recipeExportName(subsystem, group, variant);\n\n // Recipes in dependency-safe order (a composed component's references precede it in the list).\n const recipes: RecipeEmit[] = recipeAddresses.map(({ subsystem, group, variant }) => ({\n exportName: ids.recipeExportName(subsystem, group, variant),\n body: recipeSource(registry.get(addressKey(subsystem, group, variant)) ?? [], { spreadName }),\n }));\n\n // Grouped barrel referencing the flat consts.\n const barrelLines: string[] = [\"{\"];\n const bySubsystem = new Map<string, Array<{ group: string; variant: string }>>();\n for (const addr of recipeAddresses) {\n (bySubsystem.get(addr.subsystem) ?? bySubsystem.set(addr.subsystem, []).get(addr.subsystem)!).push(addr);\n }\n for (const [subsystem, addrs] of bySubsystem) {\n barrelLines.push(` ${subsystem}: {`);\n const byGroup = new Map<string, string[]>();\n for (const { group, variant } of addrs) {\n (byGroup.get(group) ?? byGroup.set(group, []).get(group)!).push(variant);\n }\n for (const [group, variants] of byGroup) {\n barrelLines.push(` ${objectKey(group)}: {`);\n for (const variant of variants) {\n barrelLines.push(` ${objectKey(variant)}: ${ids.recipeExportName(subsystem, group, variant)},`);\n }\n barrelLines.push(` },`);\n }\n barrelLines.push(` },`);\n }\n barrelLines.push(\"}\");\n\n const trailingRefs = [\n \"media\",\n ...(usesScheme ? [\"scheme\"] : []),\n ...(helpers.includes(\"color-math\") ? COLOR_MATH_ATTACH : []),\n ];\n\n const inputs: ScEmitInputs = {\n language,\n emitMode: type,\n helpers,\n usesScheme,\n themeObjectBody: serializeThemeObject(data, trailingRefs),\n recipes,\n recipesBarrelBody: barrelLines.join(\"\\n\"),\n resetBody: resetNodes.length ? recipeSource(resetNodes, { spreadName }) : undefined,\n vendorMedia: vendorMediaHelper(model.breakpoints, media),\n vendorScheme: usesScheme ? vendorSchemeHelper(data.modeNames) : undefined,\n };\n return buildScEmit(inputs);\n };\n\n return {\n recipeName(subsystem, group, variant) {\n return ids.recipeExportName(subsystem, group, variant);\n },\n\n // Self-documentation: the REAL export identifiers (the tree-shakeable `css` consts) plus\n // SC-specific wiring prose for the emitted guide (llms.txt).\n describeUsage(): UsageDescriptor {\n return {\n format: \"styled-components\",\n summary: [\n \"This theme is emitted as TypeScript/JavaScript modules: a literal `theme` object plus tree-shakeable `css` recipe exports (and a `GlobalStyle` if the theme defines globals).\",\n 'Wrap your app once in styled-components\\' `ThemeProvider` with the exported `theme`: `import { theme } from \"./theme\";` then `<ThemeProvider theme={theme}>`.',\n \"Apply a recipe by spreading its `css` export into a styled component: ``styled.button`${componentsButtonsPrimary}` ``. Recipes read their values from `props.theme`, so there is no `var()` and no separate stylesheet.\",\n \"If the theme defines globals, render `<GlobalStyle />` once inside the provider.\",\n ],\n recipes: recipeAddresses.map(({ subsystem, group, variant }) => ({\n subsystem,\n group,\n variant,\n name: ids.recipeExportName(subsystem, group, variant),\n })),\n };\n },\n renderRecipe(subsystem, group, variant) {\n return ruleSetOf(subsystem, group, variant)\n ? buildLiveRecipe(subsystem, group, variant)\n : css``;\n },\n // The SC target has no CSS variables (the theme object is the indirection).\n renderVariables() {\n return css``;\n },\n join(parts) {\n return parts.flat() as RuleSet<object>;\n },\n\n // The runtime surface: the literal theme object + lazy recipes + GlobalStyle + media/scheme.\n extend() {\n const surface: Record<string, unknown> = {\n theme: runtimeTheme,\n recipes: buildRecipesTree(),\n media: wrappedMedia,\n };\n if (wrappedScheme) surface.scheme = wrappedScheme;\n if (GlobalStyle) surface.GlobalStyle = GlobalStyle;\n return surface;\n },\n\n emit,\n };\n },\n };\n return defineAdapter(spec);\n};\n\n// Public glue re-exports.\nexport { wrapMediaDescriptor } from \"./media\";\nexport type {\n WrappedMediaDescriptor,\n WrappedMediaGroup,\n MediaTemplateWithQuery,\n} from \"./media\";\nexport type { SchemeHelper, SchemeTemplateWithQuery } from \"./scheme\";\n"],"names":["SC_STATE_SELECTORS","link","visited","hover","focus","active","disabled","pressed","SC_KNOWN_STATES","Object","keys","STATE_ORDER","reduce","acc","name","index","orderStateOverrides","overrides","map","override","sort","a","b","oa","_a","state","Number","MAX_SAFE_INTEGER","ob","_b","bpa","breakpoint","bpb","DEFAULT_MEDIA_QUERY","splitWords","segment","split","filter","Boolean","camelJoin","segments","words","flatMap","length","joined","w","i","word","charAt","toLowerCase","slice","toUpperCase","upperFirst","join","test","themeKey","segmentsAfterSubsystem","themeAccess","path","subsystem","rest","key","createIdentifiers","seen","Map","recipeExportName","group","variant","className","fallback","s","out","kind","classToken","Error","prev","get","undefined","set","track","formatValue","ref","resolve","struct","external","raw","value","unit","INDENT","serializeLeafMap","depth","pad","repeat","inner","entries","k","v","String","JSON","stringify","serializeTree","tree","serializeThemeObject","data","trailingRefs","lines","push","modeNames","mode","modes","str","refFragments","lit","tokenPaths","has","read","wrap","declNodes","declarations","nodes","property","type","parseReference","reference","dot","indexOf","schemeRealizations","scheme","mediaEligible","media","attribute","modeDeclNodes","overridden","modeOverridePaths","modeRef","buildRecipeIR","ruleSet","ctx","references","parsed","children","query","orientation","stateOverrides","o","stateSelector","block","selector","_c","baseMode","stateModeBlocks","accessExpr","nodeSource","node","indent","captured","opts","fragments","fragment","expr","fragmentsSource","spreadName","c","target","recipeSource","readTheme","theme","root","nodePlainCss","spread","fragmentsValue","min","max","exact","resolveMediaQuery","prefers","recipePlainCss","RESERVED_DESCRIPTOR_KEYS","Set","wrapMediaDescriptor","descriptor","wrapped","options","wrapQuery","between","from","to","wrapMediaGroup","forEach","assign","buildTemplate","styles","interpolations","css","PREFERS","dark","light","mediaEligibleModes","VARIANTS","COLOR_MATH_ATTACH","vendorMediaHelper","breakpoints","variants","scImport","needsCss","needsGlobal","themeImports","inputs","usesScheme","helpers","includes","themeConst","body","recipeConsts","recipes","r","exportName","recipesBarrel","globalStyle","objectKey","isValidIdentifier","lazy","obj","compute","defineProperty","configurable","enumerable","createStyledComponentsAdapter","language","spec","version","allowedStates","bind","model","ids","naming","put","add","sub","subsystems","pm","properties","base","extra","extras","_d","entry","_e","basePath","field","_f","_h","_k","_g","_j","buildThemeData","recipeCtx","addressKey","registry","recipeAddresses","ruleSetGroup","ruleSets","spreadRenderer","buildLiveRecipe","wrappedMedia","wrappedScheme","helper","wrapSchemeHelper","attach","runtimeTheme","bySub","buildRuntimeThemeObject","buildRecipesTree","groups","resetNodes","values","variantName","variantRuleSet","variantChildren","buildGlobalsIR","globals","GlobalStyle","createGlobalStyle","recipeName","describeUsage","format","summary","renderRecipe","ruleSetOf","renderVariables","parts","flat","extend","surface","emit","plan","barrelLines","bySubsystem","addr","addrs","byGroup","files","vendorHelpers","vendorMedia","vendorScheme","hasRecipes","hasReset","resetBody","emitMode","themeObjectBody","recipesBarrelBody","endsWith","replace","buildScEmit","defineAdapter"],"mappings":"uHAkBO,MAAMA,EAA6C,CACxDC,KAAM,QACNC,QAAS,WACTC,MAAO,SACPC,MAAO,SACPC,OAAQ,UACRC,SAAU,aACVC,QAAS,kBAIEC,EAAyCC,OAAOC,KAAKV,GAE5DW,EAAsCH,EAAgBI,OAC1D,CAACC,EAAKC,EAAMC,KACVF,EAAIC,GAAQC,EACLF,GAET,CAAE,GAISG,EAAuBC,GAClCA,EACGC,IAAI,CAACC,EAAUJ,KAAW,CAAEI,WAAUJ,WACtCK,KAAK,CAACC,EAAGC,aACR,MAAMC,EAA4C,QAAvCC,EAAAb,EAAYU,EAA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ACrDgS,EAAchS,EAExB,CAED,MAAO,CAAE+R,QAAOC,kBCqDHW,CAZsB,CAC3BrF,WACAgF,SAAU3L,EACVwF,UACAD,aACAqG,gBAAiB/M,EAAqBC,EAAMC,GAC5C8G,UACAgG,kBAAmBd,EAAYnP,KAAK,MACpC8P,UAAWjC,EAAWvO,OAASyH,EAAa8G,EAAY,CAAEjH,oBAAgBpF,EAC1EkO,YAAavG,EAAkBiC,EAAMhC,YAAaxE,GAClD+K,aAAchG,GF5KWrG,EE4KqBJ,EAAKI,UFvKpD,scAJS0F,EAAmB1F,GAChCzF,IAAI0F,GAAQ,KAAKV,KAAKC,UAAUS,YAAeV,KAAKC,UAAU+F,EAAQtF,SACtEvD,KAAK,8CEyKgEwB,KAwDrE,GAEH,OAAO6O,EAAcrF"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/lowering.ts","../src/identifiers.ts","../src/theme-object.ts","../src/recipe.ts","../src/media.ts","../src/scheme.ts","../src/emit.ts","../src/index.ts"],"sourcesContent":["/**\n * Shared lowering helpers for the styled-components adapter — the format-neutral bits the recipe IR\n * builder ({@link ../recipe}) and both sinks (emit-source / runtime-live) lean on: the state-selector\n * table the adapter owns, canonical LVHA state ordering, and breakpoint → concrete `@media` string\n * resolution. It imports **only** core (Model + media types), so the adapter stays liftable to its own\n * package (Step 11).\n *\n * The SC target emits TS/JS modules (a literal theme object + `css` recipes), not a stylesheet, so\n * there is no CSS-variable / class-name lowering here — recipe values read straight from the theme\n * (`${({ theme }) => theme.…}`) and the theme object *is* the indirection.\n */\nimport type { MediaDescriptor, MediaVariant } from \"@theme-registry/refract\";\nimport type { Orientation, RuleSetOverride } from \"@theme-registry/refract\";\n\n// ---------------------------------------------------------------------------\n// State selector table (adapter-owned)\n// ---------------------------------------------------------------------------\n\nexport const SC_STATE_SELECTORS: Record<string, string> = {\n link: \":link\",\n visited: \":visited\",\n hover: \":hover\",\n focus: \":focus\",\n active: \":active\",\n disabled: \"[disabled]\",\n pressed: \"[aria-pressed]\",\n};\n\n/** The states the SC adapter can render (the validation set core threads into normalization). */\nexport const SC_KNOWN_STATES: ReadonlyArray<string> = Object.keys(SC_STATE_SELECTORS);\n\nconst STATE_ORDER: Record<string, number> = SC_KNOWN_STATES.reduce<Record<string, number>>(\n (acc, name, index) => {\n acc[name] = index;\n return acc;\n },\n {},\n);\n\n/** Order state overrides in canonical LVHA order (breakpoint-scoped ones after the base state). */\nexport const orderStateOverrides = (overrides: RuleSetOverride[]): RuleSetOverride[] =>\n overrides\n .map((override, index) => ({ override, index }))\n .sort((a, b) => {\n const oa = STATE_ORDER[a.override.state as string] ?? Number.MAX_SAFE_INTEGER;\n const ob = STATE_ORDER[b.override.state as string] ?? Number.MAX_SAFE_INTEGER;\n if (oa !== ob) return oa - ob;\n const bpa = a.override.breakpoint ? 1 : 0;\n const bpb = b.override.breakpoint ? 1 : 0;\n if (bpa !== bpb) return bpa - bpb;\n return a.index - b.index;\n })\n .map(({ override }) => override);\n\n// ---------------------------------------------------------------------------\n// Breakpoint → concrete @media query resolution\n// ---------------------------------------------------------------------------\n\nexport const DEFAULT_MEDIA_QUERY: MediaVariant = \"exact\";\n\n/** Resolve a breakpoint + query kind (+ orientation) to its concrete `@media (...)` string. */\nexport const resolveMediaQuery = <TBreakpoint extends string>(\n media: MediaDescriptor<TBreakpoint>,\n breakpoint: TBreakpoint,\n query: MediaVariant,\n orientation?: Orientation,\n): string => {\n if (!orientation) return media[breakpoint]?.[query] ?? \"\";\n const opts = { orientation };\n if (query === \"min\") return media.min(breakpoint, opts);\n if (query === \"max\") return media.max(breakpoint, opts);\n return media.exact(breakpoint, opts);\n};\n","/**\n * JS-identifier naming for the styled-components TS/JS emit (§8).\n *\n * The SC target emits a **literal theme object** and **flat `css` recipe consts**, so its names are\n * JavaScript identifiers, not CSS variables/classes. This module is the SC analogue of the shared\n * `../naming` namer: it reuses that module's `sanitizeSegment` + collision-guard discipline (§7B) but\n * produces a **camelCase identifier form** instead of a kebab class/var.\n *\n * theme key: `themeKey([\"primary\", \"text\"])` → `primaryText` (folds a variant/extra\n * into its group under `theme.<subsystem>`)\n * theme access: `themeAccess(\"colors.primary.text\")` → `{ subsystem: \"colors\", key: \"primaryText\" }`\n * recipe export: `recipeExportName(\"components\",\"buttons\",\"primary\")` → `componentsButtonsPrimary`\n *\n * Unlike the CSS/SC class names, SC identifiers carry **no prefix** (the artifact's `colorsSolidPrimary`,\n * not `dtColorsSolidPrimary`) — the literal theme object *is* the isolation boundary. The §7B\n * `naming.className` override still remaps a recipe's identity (its export name); `naming.variableName`\n * has no coherent target on a nested object and is accepted-but-structural (theme keys stay derived).\n */\nimport type { NamingOverrides } from \"@theme-registry/refract/adapter-kit\";\n\n/** Split an authored segment into alphanumeric words (`\"button-lg\"` → `[\"button\",\"lg\"]`). Interior\n * case is preserved so an already-camelCase property (`fontSize`) survives as one word. */\nconst splitWords = (segment: string): string[] => segment.split(/[^a-zA-Z0-9]+/).filter(Boolean);\n\nconst lowerFirst = (word: string): string => word.charAt(0).toLowerCase() + word.slice(1);\nconst upperFirst = (word: string): string => word.charAt(0).toUpperCase() + word.slice(1);\n\n/**\n * camelCase-join a list of address segments into one identifier: the first word lower-cased, every\n * later word upper-cased and concatenated. A leading digit (invalid identifier start) is prefixed `_`.\n */\nexport const camelJoin = (segments: string[]): string => {\n const words = segments.flatMap(splitWords);\n if (!words.length) return \"_\";\n const joined = words.map((w, i) => (i === 0 ? lowerFirst(w) : upperFirst(w))).join(\"\");\n return /^[0-9]/.test(joined) ? `_${joined}` : joined;\n};\n\n/** A token's key under `theme.<subsystem>` — the property + its variant/extra segments camel-folded. */\nexport const themeKey = (segmentsAfterSubsystem: string[]): string => camelJoin(segmentsAfterSubsystem);\n\n/** A dotted token path → its `theme.<subsystem>.<key>` address parts. `colors.primary.text` →\n * `{ subsystem: \"colors\", key: \"primaryText\" }`; `borders.radius` → `{ subsystem: \"borders\", key: \"radius\" }`. */\nexport const themeAccess = (path: string): { subsystem: string; key: string } => {\n const [subsystem, ...rest] = path.split(\".\");\n return { subsystem, key: themeKey(rest) };\n};\n\n/**\n * A bound identifier minter for one theme: the recipe-export namer with the §7B collision guard.\n * Distinct addresses producing the same identifier throw; the same address re-resolving is fine.\n */\nexport interface ScIdentifiers {\n /** The camelCase export name for a recipe (`components`,`buttons`,`primary` → `componentsButtonsPrimary`). */\n recipeExportName(subsystem: string, group: string, variant: string): string;\n}\n\nexport const createIdentifiers = (overrides?: NamingOverrides): ScIdentifiers => {\n const seen = new Map<string, string>(); // identifier → source address key\n\n const track = (name: string, key: string): void => {\n const prev = seen.get(name);\n if (prev !== undefined && prev !== key) {\n throw new Error(\n `styled-components emit: recipe identifier \"${name}\" is produced by both \"${prev}\" and ` +\n `\"${key}\" — the naming override must map distinct recipes to distinct identifiers`,\n );\n }\n seen.set(name, key);\n };\n\n return {\n recipeExportName(subsystem, group, variant) {\n const segments = [subsystem, group, variant];\n let name = camelJoin(segments);\n if (overrides?.className) {\n // Feed the override a PREFIX-FREE default (SC identifiers carry no prefix), so a no-op\n // decorator round-trips to the structural name and only a real remap changes identity.\n const fallback = segments.map(s => splitWords(s).join(\"-\")).join(\"-\");\n const out = overrides.className(\n { kind: \"recipe\", subsystem, group, variant },\n { classToken: \"\", name: fallback },\n );\n name = camelJoin(splitWords(out));\n if (!name || name === \"_\") {\n throw new Error(\n `styled-components emit: className override returned an empty/invalid identifier for ` +\n `\"${subsystem}.${group}.${variant}\"`,\n );\n }\n }\n track(name, `${subsystem}.${group}.${variant}`);\n return name;\n },\n };\n};\n","/**\n * The literal theme object (§8) — the SC target's replacement for CSS `:root` variables.\n *\n * `buildThemeData` walks the Model's property tokens into a nested `{ [subsystem]: { [camelKey]: literal } }`\n * tree (variants/extras fold into their group as camelCased keys — `primary` → `primaryText`), plus a\n * parallel `modes` tree (§10.3 appearance-mode overrides — only the fields a mode redefines). The object\n * **is** the indirection: values are resolved literals, no `var()`. The same data serves two sinks — a\n * live JS object for the runtime `theme` (recipes read it from styled-components context) and an\n * object-literal source string for `emit()`.\n *\n * Structured compound tokens (§15 shadow / transition `Ref.struct`) are **skipped** — the SC adapter's\n * structured composition is deferred, exactly as the prior stylesheet lane skipped their `:root` vars.\n */\nimport type { ThemeModel, Ref, Literal } from \"@theme-registry/refract\";\nimport { themeKey } from \"./identifiers\";\n\n/** A resolved literal in the theme object: a number stays a number (`fontWeight`), a length/colour is a string. */\nexport type ThemeLiteral = string | number;\ntype ThemeTree = Record<string, Record<string, ThemeLiteral>>;\ntype ModesTree = Record<string, ThemeTree>;\n\nexport interface ThemeData {\n /** `subsystem → key → literal` (no `modes` / helpers — those are attached by the caller). */\n readonly tree: ThemeTree;\n /** `mode → subsystem → key → literal` — only the fields each mode redefines. */\n readonly modes: ModesTree;\n /** The mode names present (`[\"dark\"]`), in first-seen order. */\n readonly modeNames: string[];\n /** Every dotted token path that made it into the tree (non-struct) — recipe refs check membership. */\n readonly tokenPaths: Set<string>;\n /** `mode → set of dotted token paths that carry an override` — the recipe scheme block reads this. */\n readonly modeOverridePaths: Record<string, Set<string>>;\n}\n\n/** Format one token `Ref` to its theme-object literal. Returns `undefined` for a structured token (skipped). */\nconst formatValue = (ref: Ref, path: string, resolve: (path: string) => Literal): ThemeLiteral | undefined => {\n if (ref.struct !== undefined) return undefined;\n if (ref.external !== undefined) return `var(${ref.external})`; // §W6b — the theme entry IS the parent var\n\n const raw: Literal = ref.value !== undefined ? ref.value : resolve(path);\n // §21: a length leaf carries its resolved unit — emit `value + unit` as a string. A unit-less number\n // (fontWeight / lineHeight / opacity) has no `unit` and stays a JS number, so the theme object types\n // it as `number`.\n if (ref.unit !== undefined) return `${raw}${ref.unit}`;\n return raw;\n};\n\n/** Walk the Model into the nested theme tree + modes tree. `resolve` fills in pure-alias tokens. */\nexport const buildThemeData = (model: ThemeModel, resolve: (path: string) => Literal): ThemeData => {\n const tree: ThemeTree = {};\n const modes: ModesTree = {};\n const modeNames: string[] = [];\n const tokenPaths = new Set<string>();\n const modeOverridePaths: Record<string, Set<string>> = {};\n\n const put = (subsystem: string, key: string, path: string, ref: Ref): void => {\n const value = formatValue(ref, path, resolve);\n if (value === undefined) return; // structured token — deferred\n (tree[subsystem] ??= {})[key] = value;\n tokenPaths.add(path);\n };\n\n for (const [subsystem, sub] of Object.entries(model.subsystems)) {\n for (const [property, pm] of Object.entries(sub.properties ?? {})) {\n put(subsystem, themeKey([property]), `${subsystem}.${property}`, pm.base);\n for (const [extra, ref] of Object.entries(pm.extras ?? {})) {\n put(subsystem, themeKey([property, extra]), `${subsystem}.${property}.${extra}`, ref);\n }\n for (const [variant, v] of Object.entries(pm.variants ?? {})) {\n put(subsystem, themeKey([property, variant]), `${subsystem}.${property}.${variant}`, v.base);\n // dec.3 — a variant's own extras map to `<property><Variant><Extra>` in the SC theme object.\n for (const [extra, ref] of Object.entries(v.extras ?? {})) {\n put(subsystem, themeKey([property, variant, extra]), `${subsystem}.${property}.${variant}.${extra}`, ref);\n }\n }\n // §10.3 appearance modes — a LIST of `{ mode, target?, overrides }`. Each field maps to the\n // property key (or a variant key when `target` scopes it); an extra field appends `<Extra>`.\n // The recipe scheme block re-reads exactly these paths.\n for (const entry of pm.modes ?? []) {\n const mode = entry.mode;\n if (mode === undefined) continue;\n const target = entry.target;\n const segments = target ? [property, target] : [property];\n const basePath = target ? `${subsystem}.${property}.${target}` : `${subsystem}.${property}`;\n for (const [field, ref] of Object.entries(entry.overrides ?? {})) {\n const value = formatValue(ref, `${subsystem}.${property}`, resolve);\n if (value === undefined) continue;\n const key = field === \"base\" ? themeKey(segments) : themeKey([...segments, field]);\n const path = field === \"base\" ? basePath : `${basePath}.${field}`;\n if (!modeNames.includes(mode)) modeNames.push(mode);\n (((modes[mode] ??= {})[subsystem] ??= {}))[key] = value;\n (modeOverridePaths[mode] ??= new Set()).add(path);\n }\n }\n }\n }\n\n return { tree, modes, modeNames, tokenPaths, modeOverridePaths };\n};\n\n// ---------------------------------------------------------------------------\n// Serialization to object-literal source (emit)\n// ---------------------------------------------------------------------------\n\nconst INDENT = \" \";\n\n/** A theme literal → its JS source (`600` stays a number literal; a string is JSON-quoted). */\nconst literalSource = (value: ThemeLiteral): string =>\n typeof value === \"number\" ? String(value) : JSON.stringify(value);\n\nconst serializeLeafMap = (map: Record<string, ThemeLiteral>, depth: number): string => {\n const pad = INDENT.repeat(depth);\n const inner = INDENT.repeat(depth + 1);\n const entries = Object.entries(map).map(([k, v]) => `${inner}${k}: ${literalSource(v)},`);\n return `{\\n${entries.join(\"\\n\")}\\n${pad}}`;\n};\n\nconst serializeTree = (tree: ThemeTree, depth: number): string[] =>\n Object.entries(tree).map(\n ([subsystem, map]) => `${INDENT.repeat(depth)}${subsystem}: ${serializeLeafMap(map, depth)},`,\n );\n\n/**\n * Serialize the theme object literal body (the `{ … }`), including the subsystem trees, the optional\n * `modes` tree, and any trailing bare-identifier refs (`media`, `scheme`, helper fns) the caller wires.\n */\nexport const serializeThemeObject = (data: ThemeData, trailingRefs: string[]): string => {\n const lines: string[] = [\"{\"];\n lines.push(...serializeTree(data.tree, 1));\n\n if (data.modeNames.length) {\n lines.push(`${INDENT}modes: {`);\n for (const mode of data.modeNames) {\n lines.push(`${INDENT.repeat(2)}${mode}: {`);\n lines.push(...serializeTree(data.modes[mode], 3));\n lines.push(`${INDENT.repeat(2)}},`);\n }\n lines.push(`${INDENT}},`);\n }\n\n for (const ref of trailingRefs) lines.push(`${INDENT}${ref},`);\n lines.push(\"}\");\n return lines.join(\"\\n\");\n};\n\n/**\n * Assemble the **live** runtime theme object: the token tree + `modes` + the wrapped `media` / `scheme`\n * tagged-template helpers + any opted-in color-math fns. This is what a consumer passes to\n * `<ThemeProvider>`; recipes read every value off it via styled-components context.\n */\nexport const buildRuntimeThemeObject = (\n data: ThemeData,\n attach: Record<string, unknown>,\n): Record<string, unknown> => {\n const obj: Record<string, unknown> = {};\n for (const [subsystem, map] of Object.entries(data.tree)) obj[subsystem] = { ...map };\n if (data.modeNames.length) {\n const modes: Record<string, unknown> = {};\n for (const mode of data.modeNames) {\n const bySub: Record<string, unknown> = {};\n for (const [subsystem, map] of Object.entries(data.modes[mode])) bySub[subsystem] = { ...map };\n modes[mode] = bySub;\n }\n obj.modes = modes;\n }\n Object.assign(obj, attach);\n return obj;\n};\n","/**\n * The shared recipe renderer (§8) — one lowering, two sinks.\n *\n * A recipe {@link RuleSet} lowers to a format-neutral node tree ({@link RecipeNode}) — base\n * declarations, composition spreads, state / breakpoint / colour-scheme conditional blocks — that\n * BOTH sinks walk:\n * - **`recipeSource`** serializes it to `css\\`…\\`` **source** (`${({ theme }) => theme.…}` value\n * reads, `${sibling}` composition spreads, `theme.media` / `theme.scheme` tagged-template blocks)\n * for `emit()`.\n * - **`recipePlainCss`** renders it to a **live CSS string** off a runtime theme object (values\n * resolved from `props.theme`, breakpoints as concrete `@media`, dark as `prefers-color-scheme` /\n * `[data-theme]`) — the body of a lazy `css` block for the runtime surface.\n *\n * Values read from the theme, never `var()`; dark mode lives *in the recipe block* (§10.3), so it\n * tree-shakes with the recipe and switches with a plain CSS recalc — no `:root`, no provider swap.\n */\nimport type { MediaDescriptor, MediaVariant } from \"@theme-registry/refract\";\nimport type { Ref, RuleSet, RuleSetGroup, ThemeModel } from \"@theme-registry/refract\";\nimport { SC_STATE_SELECTORS, orderStateOverrides, resolveMediaQuery, DEFAULT_MEDIA_QUERY } from \"./lowering\";\nimport { themeAccess } from \"./identifiers\";\nimport type { ThemeData } from \"./theme-object\";\n\n/** How `model.modes` are realized into a recipe (§8): OS media, a `[data-theme]` toggle, or both. */\nexport type SchemeOption = \"media\" | \"attribute\" | \"both\";\n\n// ---------------------------------------------------------------------------\n// Node tree (the shared lowering)\n// ---------------------------------------------------------------------------\n\n/** One fragment of a declaration value: literal text, a theme token read, or an appearance-mode read. */\ntype Fragment =\n | { lit: string }\n | { ref: string }\n | { modeRef: { mode: string; path: string } };\n\ntype RecipeNode =\n | { type: \"decl\"; property: string; value: Fragment[] }\n /** A nested selector block (`&:hover`, `[data-theme=\"dark\"] &`) — arrow-form value reads. */\n | { type: \"block\"; selector: string; children: RecipeNode[] }\n /** A breakpoint block realized via `theme.media.<bp>.<query>` (captured-form reads inside). */\n | { type: \"media\"; breakpoint: string; query: MediaVariant; orientation?: \"landscape\" | \"portrait\"; children: RecipeNode[] }\n /** A colour-scheme block realized via `theme.scheme.<mode>` (captured-form reads inside). */\n | { type: \"scheme\"; mode: string; children: RecipeNode[] }\n /** A composition spread of a sibling recipe (`${componentsButtonsPrimary}` / inline its CSS). */\n | { type: \"spread\"; subsystem: string; group: string; variant: string };\n\n/** Context threaded into the IR builder + both sinks. */\nexport interface RecipeContext {\n readonly model: ThemeModel;\n readonly media: MediaDescriptor<string>;\n readonly data: ThemeData;\n readonly scheme: SchemeOption;\n /** The concrete `@media (prefers-color-scheme: <mode>)` string per realizable mode. */\n readonly prefers: Record<string, string>;\n}\n\nconst str = (value: unknown): string => (value == null ? \"\" : String(value));\n\n/** A rule-set declaration `Ref` → its value fragments. Returns `undefined` to SKIP the declaration\n * (a structured token the theme object doesn't carry). A literal is emitted as-is; a token ref (with\n * optional adapter `wrap`, e.g. `blur(…)`) becomes a theme read. */\nconst refFragments = (ref: Ref, data: ThemeData): Fragment[] | undefined => {\n if (ref.ref === undefined) return [{ lit: str(ref.value) }];\n if (!data.tokenPaths.has(ref.ref)) return undefined; // structured / absent token — deferred\n const read: Fragment = { ref: ref.ref };\n return ref.wrap ? [{ lit: `${ref.wrap}(` }, read, { lit: \")\" }] : [read];\n};\n\nconst declNodes = (declarations: Record<string, Ref> | undefined, data: ThemeData): RecipeNode[] => {\n const nodes: RecipeNode[] = [];\n for (const [property, ref] of Object.entries(declarations ?? {})) {\n const value = refFragments(ref, data);\n if (value) nodes.push({ type: \"decl\", property, value });\n }\n return nodes;\n};\n\n/** Parse a component composition reference (`\"colors:solid.primary\"`) into its address. */\nconst parseReference = (\n reference: string,\n): { subsystem: string; group: string; variant: string } | undefined => {\n const [subsystem, rest] = reference.split(\":\");\n if (!subsystem || !rest) return undefined;\n const dot = rest.indexOf(\".\");\n if (dot < 0) return undefined;\n return { subsystem, group: rest.slice(0, dot), variant: rest.slice(dot + 1) };\n};\n\n/** Which realizations (media / attribute) a mode uses under the current `scheme` option. Only `dark`\n * / `light` can ride `prefers-color-scheme`; any other named mode falls back to `[data-theme]`. */\nconst schemeRealizations = (mode: string, scheme: SchemeOption): { media: boolean; attribute: boolean } => {\n const mediaEligible = mode === \"dark\" || mode === \"light\";\n const media = mediaEligible && (scheme === \"media\" || scheme === \"both\");\n const attribute =\n scheme === \"attribute\" || scheme === \"both\" || (scheme === \"media\" && !mediaEligible);\n return { media, attribute };\n};\n\n/** Mode-override declarations for a set of declarations, reading `theme.modes.<mode>.…`. */\nconst modeDeclNodes = (\n declarations: Record<string, Ref> | undefined,\n mode: string,\n data: ThemeData,\n): RecipeNode[] => {\n const overridden = data.modeOverridePaths[mode];\n if (!overridden) return [];\n const nodes: RecipeNode[] = [];\n for (const [property, ref] of Object.entries(declarations ?? {})) {\n if (ref.ref !== undefined && overridden.has(ref.ref)) {\n nodes.push({ type: \"decl\", property, value: [{ modeRef: { mode, path: ref.ref } }] });\n }\n }\n return nodes;\n};\n\n/**\n * Lower one recipe {@link RuleSet} (+ optional composition `references`) to the shared node tree:\n * spreads → base declarations → breakpoint blocks → state blocks → colour-scheme blocks.\n */\nexport const buildRecipeIR = (ruleSet: RuleSet, ctx: RecipeContext): RecipeNode[] => {\n const nodes: RecipeNode[] = [];\n\n // Composition (components): spread each referenced sibling recipe first.\n for (const reference of ruleSet.references ?? []) {\n const parsed = parseReference(reference);\n if (parsed) nodes.push({ type: \"spread\", ...parsed });\n }\n\n // Base declarations.\n nodes.push(...declNodes(ruleSet.declarations, ctx.data));\n\n // Breakpoint-only overrides → a media block.\n for (const override of ruleSet.overrides) {\n if (override.state !== undefined || !override.breakpoint) continue;\n const children = declNodes(override.declarations, ctx.data);\n if (children.length) {\n nodes.push({\n type: \"media\",\n breakpoint: override.breakpoint,\n query: (override.query ?? DEFAULT_MEDIA_QUERY) as MediaVariant,\n orientation: override.orientation,\n children,\n });\n }\n }\n\n // State (+ state×breakpoint) overrides → a `&:hover`-style block, canonical LVHA order.\n const stateOverrides = ruleSet.overrides.filter(o => o.state !== undefined);\n for (const override of orderStateOverrides(stateOverrides)) {\n const stateSelector = SC_STATE_SELECTORS[override.state as string];\n const children = declNodes(override.declarations, ctx.data);\n if (!stateSelector || !children.length) continue;\n const block: RecipeNode = { type: \"block\", selector: `&${stateSelector}`, children };\n if (override.breakpoint) {\n nodes.push({\n type: \"media\",\n breakpoint: override.breakpoint,\n query: (override.query ?? DEFAULT_MEDIA_QUERY) as MediaVariant,\n orientation: override.orientation,\n children: [block],\n });\n } else {\n nodes.push(block);\n }\n }\n\n // Colour-scheme blocks (§10.3) — one per mode whose fields this recipe reads.\n for (const mode of ctx.data.modeNames) {\n const baseMode = modeDeclNodes(ruleSet.declarations, mode, ctx.data);\n const stateModeBlocks: RecipeNode[] = [];\n for (const override of orderStateOverrides(stateOverrides)) {\n const stateSelector = SC_STATE_SELECTORS[override.state as string];\n if (!stateSelector) continue;\n const children = modeDeclNodes(override.declarations, mode, ctx.data);\n if (children.length) stateModeBlocks.push({ type: \"block\", selector: `&${stateSelector}`, children });\n }\n const children = [...baseMode, ...stateModeBlocks];\n if (!children.length) continue;\n\n const { media, attribute } = schemeRealizations(mode, ctx.scheme);\n if (media) nodes.push({ type: \"scheme\", mode, children });\n if (attribute) nodes.push({ type: \"block\", selector: `[data-theme=\"${mode}\"] &`, children });\n }\n\n return nodes;\n};\n\n/**\n * Lower the `globals` subsystem's rule-sets (§9) into `block` nodes for the `GlobalStyle` — one raw\n * `<selector> { … }` per rule-set. Two kinds:\n * - `kind:\"reset\"` (preset `static` / `defaults`) — declaration-only (literals as-is, token refs as\n * theme reads).\n * - `kind:\"globals\"` (themed `elements`) — the element's base declarations PLUS its state/breakpoint/\n * colour-scheme blocks (via {@link buildRecipeIR}) and each delta-only variant nested as a\n * `&.<variant>` block. Dark rides the referenced token's own modes — realized *inside* the element\n * block as a `theme.scheme.<mode>` / `[data-theme]` conditional (same as recipes), no `:root`.\n * Feeds the `GlobalStyle` emitter + the runtime `GlobalStyle`.\n */\nexport const buildGlobalsIR = (\n groups: Record<string, RuleSetGroup> | undefined,\n ctx: RecipeContext,\n): RecipeNode[] => {\n const nodes: RecipeNode[] = [];\n for (const group of Object.values(groups ?? {})) {\n for (const ruleSet of Object.values(group)) {\n if (!ruleSet.selector) continue;\n if (ruleSet.kind === \"globals\") {\n const children = buildRecipeIR(ruleSet, ctx);\n for (const [variantName, variant] of Object.entries(ruleSet.variants ?? {})) {\n const variantRuleSet: RuleSet = {\n kind: \"globals\",\n selector: ruleSet.selector,\n declarations: variant.declarations,\n overrides: variant.overrides,\n };\n const variantChildren = buildRecipeIR(variantRuleSet, ctx);\n if (variantChildren.length) {\n children.push({ type: \"block\", selector: `&.${variantName}`, children: variantChildren });\n }\n }\n if (children.length) nodes.push({ type: \"block\", selector: ruleSet.selector, children });\n } else {\n const children = declNodes(ruleSet.declarations, ctx.data);\n if (children.length) nodes.push({ type: \"block\", selector: ruleSet.selector, children });\n }\n }\n }\n return nodes;\n};\n\n// ---------------------------------------------------------------------------\n// Sink 1 — source serialization (emit)\n// ---------------------------------------------------------------------------\n\nconst INDENT = \" \";\n\n/** A theme read `theme.<subsystem>.<key>` (optionally under `modes.<mode>`). */\nconst accessExpr = (path: string, mode?: string): string => {\n const { subsystem, key } = themeAccess(path);\n return mode ? `theme.modes.${mode}.${subsystem}.${key}` : `theme.${subsystem}.${key}`;\n};\n\n/** Serialize one declaration's value fragments. `captured` = inside a media/scheme tagged template\n * (the outer arrow already bound `theme`, so reads are bare `${theme.…}` not `${({theme})=>…}`). */\nconst fragmentsSource = (fragments: Fragment[], captured: boolean): string =>\n fragments\n .map(fragment => {\n if (\"lit\" in fragment) return fragment.lit;\n const expr = \"ref\" in fragment ? accessExpr(fragment.ref) : accessExpr(fragment.modeRef.path, fragment.modeRef.mode);\n return captured ? `\\${${expr}}` : `\\${({ theme }) => ${expr}}`;\n })\n .join(\"\");\n\ninterface SourceOptions {\n /** The export identifier for a spread reference (`components`,`buttons`,`primary` → `componentsButtonsPrimary`). */\n spreadName(subsystem: string, group: string, variant: string): string;\n}\n\nconst nodeSource = (node: RecipeNode, indent: string, captured: boolean, opts: SourceOptions): string => {\n switch (node.type) {\n case \"decl\":\n return `${indent}${node.property}: ${fragmentsSource(node.value, captured)};`;\n case \"spread\":\n return `${indent}\\${${opts.spreadName(node.subsystem, node.group, node.variant)}}`;\n case \"block\": {\n const inner = node.children.map(c => nodeSource(c, indent + INDENT, captured, opts)).join(\"\\n\");\n return `${indent}${node.selector} {\\n${inner}\\n${indent}}`;\n }\n case \"media\": {\n const target = node.orientation\n ? `theme.media.${node.query}(${JSON.stringify(node.breakpoint)}, { orientation: ${JSON.stringify(node.orientation)} })`\n : `theme.media.${node.breakpoint}.${node.query}`;\n const inner = node.children.map(c => nodeSource(c, indent + INDENT, true, opts)).join(\"\\n\");\n return `${indent}\\${({ theme }) => ${target}\\`\\n${inner}\\n${indent}\\`}`;\n }\n case \"scheme\": {\n const inner = node.children.map(c => nodeSource(c, indent + INDENT, true, opts)).join(\"\\n\");\n return `${indent}\\${({ theme }) => theme.scheme.${node.mode}\\`\\n${inner}\\n${indent}\\`}`;\n }\n }\n};\n\n/** Serialize a recipe's node tree to the body of a `css\\`…\\`` template (2-space indented). */\nexport const recipeSource = (nodes: RecipeNode[], opts: SourceOptions): string =>\n nodes.map(node => nodeSource(node, INDENT, false, opts)).join(\"\\n\");\n\n// ---------------------------------------------------------------------------\n// Sink 2 — live plain-CSS rendering (runtime)\n// ---------------------------------------------------------------------------\n\n/** Read a value off the runtime theme object: `theme[subsystem][key]` (optionally under `modes.<mode>`). */\nconst readTheme = (theme: Record<string, any>, path: string, mode?: string): unknown => {\n const { subsystem, key } = themeAccess(path);\n const root = mode ? theme?.modes?.[mode] : theme;\n return root?.[subsystem]?.[key];\n};\n\nconst fragmentsValue = (fragments: Fragment[], theme: Record<string, any>): string =>\n fragments\n .map(fragment => {\n if (\"lit\" in fragment) return fragment.lit;\n if (\"ref\" in fragment) return str(readTheme(theme, fragment.ref));\n return str(readTheme(theme, fragment.modeRef.path, fragment.modeRef.mode));\n })\n .join(\"\");\n\n/** Resolve a sibling recipe's live CSS (composition) — injected by the adapter's lazy registry. */\nexport type SpreadRenderer = (\n subsystem: string,\n group: string,\n variant: string,\n theme: Record<string, any>,\n) => string;\n\nconst nodePlainCss = (\n node: RecipeNode,\n theme: Record<string, any>,\n ctx: RecipeContext,\n spread: SpreadRenderer,\n): string => {\n switch (node.type) {\n case \"decl\":\n return `${node.property}: ${fragmentsValue(node.value, theme)};`;\n case \"spread\":\n return spread(node.subsystem, node.group, node.variant, theme);\n case \"block\": {\n const inner = node.children.map(c => nodePlainCss(c, theme, ctx, spread)).join(\" \");\n return `${node.selector} { ${inner} }`;\n }\n case \"media\": {\n const query = resolveMediaQuery(ctx.media, node.breakpoint, node.query, node.orientation);\n const inner = node.children.map(c => nodePlainCss(c, theme, ctx, spread)).join(\" \");\n return query ? `${query} { ${inner} }` : inner;\n }\n case \"scheme\": {\n const query = ctx.prefers[node.mode] ?? \"\";\n const inner = node.children.map(c => nodePlainCss(c, theme, ctx, spread)).join(\" \");\n return query ? `${query} { ${inner} }` : inner;\n }\n }\n};\n\n/** Render a recipe's node tree to a live CSS string off a runtime theme object. */\nexport const recipePlainCss = (\n nodes: RecipeNode[],\n theme: Record<string, any>,\n ctx: RecipeContext,\n spread: SpreadRenderer,\n): string => nodes.map(node => nodePlainCss(node, theme, ctx, spread)).join(\"\\n\");\n","/**\n * SC-decorated media — the `wrapMedia` half of the adapter contract's media pattern.\n *\n * Core builds the plain {@link MediaDescriptor} (breakpoints → `@media (min-width:…)` strings);\n * this decorates it into styled-components **tagged-template** helpers so a consumer writes\n * `theme.media.md.min\\`color: red;\\`` (or `theme.media.min(\"md\")\\`…\\``) and gets an SC `css` block\n * scoped to that query. Re-ported from the dormant legacy SC adapter onto the clean-room\n * `core/media` (imports only core — self-contained for the Step 9 package extraction).\n */\nimport { css } from \"styled-components\";\nimport type { Interpolation, RuleSet } from \"styled-components\";\nimport type {\n MediaDescriptor,\n MediaGroupDescriptor,\n MediaQueryOptions,\n MediaVariant,\n} from \"@theme-registry/refract\";\n\ntype MediaTemplate = (\n styles: TemplateStringsArray,\n ...interpolations: Interpolation<object>[]\n) => RuleSet<object>;\n\n/** A media tagged-template that also carries the raw `@media` query string it wraps. */\nexport type MediaTemplateWithQuery = MediaTemplate & { readonly query: string };\n\nexport type WrappedMediaGroup = Record<MediaVariant, MediaTemplateWithQuery>;\n\n/** The SC-decorated media descriptor put on `theme.media` — tagged templates instead of strings. */\nexport type WrappedMediaDescriptor<TBreakpoint extends string> = {\n min: (key: TBreakpoint, options?: MediaOrientationOptions) => MediaTemplateWithQuery;\n max: (key: TBreakpoint, options?: MediaOrientationOptions) => MediaTemplateWithQuery;\n between: (\n from: TBreakpoint,\n to: TBreakpoint,\n options?: MediaOrientationOptions,\n ) => MediaTemplateWithQuery;\n} & Record<TBreakpoint, WrappedMediaGroup>;\n\ntype MediaOrientationOptions = Pick<MediaQueryOptions, \"orientation\">;\n\nconst RESERVED_DESCRIPTOR_KEYS = new Set([\"min\", \"max\", \"between\", \"exact\"]);\n\n/** Decorate a core {@link MediaDescriptor} into SC tagged-template helpers. */\nexport const wrapMediaDescriptor = <TBreakpoint extends string>(\n descriptor: MediaDescriptor<TBreakpoint>,\n): WrappedMediaDescriptor<TBreakpoint> => {\n const wrapped = {\n min: (key: TBreakpoint, options?: MediaOrientationOptions) =>\n wrapQuery(descriptor.min(key, options)),\n max: (key: TBreakpoint, options?: MediaOrientationOptions) =>\n wrapQuery(descriptor.max(key, options)),\n between: (from: TBreakpoint, to: TBreakpoint, options?: MediaOrientationOptions) =>\n wrapQuery(descriptor.between(from, to, options)),\n } as WrappedMediaDescriptor<TBreakpoint>;\n\n for (const key of Object.keys(descriptor) as TBreakpoint[]) {\n if (RESERVED_DESCRIPTOR_KEYS.has(key)) continue;\n (wrapped as Record<string, unknown>)[key] = wrapMediaGroup(\n descriptor[key] as MediaGroupDescriptor,\n );\n }\n\n return wrapped;\n};\n\nexport const wrapMediaGroup = (group: MediaGroupDescriptor): WrappedMediaGroup => {\n const wrapped = {} as WrappedMediaGroup;\n (Object.keys(group) as MediaVariant[]).forEach(variant => {\n wrapped[variant] = wrapQuery(group[variant]);\n });\n return wrapped;\n};\n\nconst wrapQuery = (query: string): MediaTemplateWithQuery =>\n Object.assign(buildTemplate(query), { query }) as MediaTemplateWithQuery;\n\nconst buildTemplate = (query: string): MediaTemplate => {\n if (!query) {\n return (styles, ...interpolations) => css`\n ${css(styles, ...interpolations)}\n `;\n }\n return (styles, ...interpolations) => css`\n ${query} {\n ${css(styles, ...interpolations)}\n }\n `;\n};\n","/**\n * SC colour-scheme tagged templates (§8) — the `theme.scheme.dark\\`…\\`` half of the appearance-mode\n * (§10.3) realization, parallel to `media.ts`. A recipe's dark block interpolates\n * `${({ theme }) => theme.scheme.dark\\`…\\`}`, which wraps its body in\n * `@media (prefers-color-scheme: dark) { … }`. Only `dark` / `light` ride `prefers-color-scheme`\n * (a `[data-theme]` toggle handles any other named mode — that path uses a plain nested selector,\n * not this helper).\n *\n * Two forms, like media: a **runtime** wrapper (`wrapSchemeHelper`) put on the live `theme.scheme`,\n * and a **vendored** self-contained module (`vendorSchemeHelper`) written by `emit()` so a downstream\n * app keeps `theme.scheme` after it drops refract (its only dependency is `styled-components`).\n */\nimport { css } from \"styled-components\";\nimport type { Interpolation, RuleSet } from \"styled-components\";\n\n/** The concrete `@media (prefers-color-scheme: …)` string for a realizable mode. */\nexport const PREFERS: Record<string, string> = {\n dark: \"@media (prefers-color-scheme: dark)\",\n light: \"@media (prefers-color-scheme: light)\",\n};\n\n/** Which authored modes ride `prefers-color-scheme` (the ones this helper realizes). */\nexport const mediaEligibleModes = (modeNames: readonly string[]): string[] =>\n modeNames.filter(mode => mode in PREFERS);\n\ntype SchemeTemplate = (\n styles: TemplateStringsArray,\n ...interpolations: Interpolation<object>[]\n) => RuleSet<object>;\n\n/** A scheme tagged-template that also carries the raw `@media (prefers-color-scheme: …)` it wraps. */\nexport type SchemeTemplateWithQuery = SchemeTemplate & { readonly query: string };\n\n/** The wrapped `theme.scheme` — one tagged template per realizable mode (`dark` / `light`). */\nexport type SchemeHelper = Record<string, SchemeTemplateWithQuery>;\n\nconst buildTemplate = (query: string): SchemeTemplate => (styles, ...interpolations) =>\n css`\n ${query} {\n ${css(styles, ...interpolations)}\n }\n `;\n\n/** Build the runtime `theme.scheme` for the given realizable modes. */\nexport const wrapSchemeHelper = (modeNames: readonly string[]): SchemeHelper => {\n const helper: SchemeHelper = {};\n for (const mode of mediaEligibleModes(modeNames)) {\n const query = PREFERS[mode];\n helper[mode] = Object.assign(buildTemplate(query), { query }) as SchemeTemplateWithQuery;\n }\n return helper;\n};\n\n/** Generate the self-contained vendored `scheme.ts` source for the given realizable modes. */\nexport const vendorSchemeHelper = (modeNames: readonly string[]): string => {\n const entries = mediaEligibleModes(modeNames)\n .map(mode => ` ${JSON.stringify(mode)}: wrap(${JSON.stringify(PREFERS[mode])}),`)\n .join(\"\\n\");\n\n return `// Vendored, self-contained styled-components colour-scheme helper (generated by @theme-registry/refract).\n// Only dependency: styled-components. Realizes appearance modes as prefers-color-scheme media blocks.\nimport { css } from \"styled-components\";\n\nconst wrap = (query) => {\n const fn = (styles, ...interpolations) => css\\`\\${query} { \\${css(styles, ...interpolations)} }\\`;\n fn.query = query;\n return fn;\n};\n\nexport const scheme = {\n${entries}\n};\n\nexport default scheme;\n`;\n};\n","/**\n * The styled-components `emit()` module assembler (§8) — writes **TS/JS modules**, not a stylesheet.\n *\n * What lands on disk (self-contained — a downstream app imports these and drops refract at runtime):\n * - **theme.ts** — the literal theme object (`export const theme = { … } as const`) + the flat, tree-\n * shakeable `css` recipe consts + a grouped `recipes` barrel + (if the raw defines `globals`) a\n * `GlobalStyle`. `emit: \"split\"` peels the recipes into `recipes.ts` and the `GlobalStyle` into\n * `global.ts`.\n * - **media.ts** (always) / **scheme.ts** (iff modes ride `prefers-color-scheme`) — vendored tagged\n * templates with this theme's concrete `@media` strings baked in.\n * - **theme.d.ts** (iff `language: \"ts\"`) — augments styled-components' `DefaultTheme` from `typeof theme`.\n * - **color-math.ts** is materialized by the shared build plumbing (`emitTheme` + `VENDOR_HELPERS`),\n * not here — this module only wires the `import`.\n */\nimport type { EmitOutput } from \"@theme-registry/refract\";\nimport type { MediaDescriptor, MediaVariant } from \"@theme-registry/refract\";\n\nconst VARIANTS: ReadonlyArray<MediaVariant> = [\"min\", \"max\", \"exact\"];\n\n/** color-math exports surfaced on `theme` when `helpers: [\"color-math\"]` is opted in. */\nexport const COLOR_MATH_ATTACH: ReadonlyArray<string> = [\"lighten\", \"darken\", \"alpha\"];\n\n/**\n * Generate a self-contained SC media-helper module (source text) for `breakpoints`, reading the\n * concrete `@media` query strings from the already-built core {@link MediaDescriptor}.\n */\nexport const vendorMediaHelper = <TBreakpoint extends string>(\n breakpoints: Record<TBreakpoint, number>,\n media: MediaDescriptor<TBreakpoint>,\n): string => {\n const keys = (Object.keys(breakpoints) as TBreakpoint[]).sort(\n (a, b) => breakpoints[a] - breakpoints[b],\n );\n\n const groups = keys\n .map(key => {\n const group = media[key];\n const variants = VARIANTS.map(\n variant => ` ${variant}: wrap(${JSON.stringify(group?.[variant] ?? \"\")}),`,\n ).join(\"\\n\");\n return ` ${JSON.stringify(key)}: {\\n${variants}\\n },`;\n })\n .join(\"\\n\");\n\n return `// Vendored, self-contained styled-components media helper (generated by @theme-registry/refract).\n// Only dependency: styled-components. Concrete @media strings are baked in for this theme's breakpoints.\nimport { css } from \"styled-components\";\n\nconst wrap = (query) => {\n const fn = query\n ? (styles, ...interpolations) => css\\`\\${query} { \\${css(styles, ...interpolations)} }\\`\n : (styles, ...interpolations) => css\\`\\${css(styles, ...interpolations)}\\`;\n fn.query = query;\n return fn;\n};\n\nexport const media = {\n${groups}\n};\n\nexport default media;\n`;\n};\n\n// ---------------------------------------------------------------------------\n// Module assembly\n// ---------------------------------------------------------------------------\n\n/** One recipe ready to serialize: its export identifier + its `css\\`…\\`` body source. */\nexport interface RecipeEmit {\n readonly exportName: string;\n readonly body: string;\n}\n\n/** Everything the assembler needs, prepared by the adapter's bind. */\nexport interface ScEmitInputs {\n readonly language: \"ts\" | \"js\";\n readonly emitMode: \"single\" | \"split\";\n readonly helpers: readonly string[];\n readonly usesScheme: boolean;\n /** The `export const theme = <this> as const` body (subsystems + modes + trailing refs). */\n readonly themeObjectBody: string;\n /** Recipes in dependency-safe order (a composed recipe's references precede it). */\n readonly recipes: readonly RecipeEmit[];\n /** The grouped `export const recipes = { … } as const` barrel body. */\n readonly recipesBarrelBody: string;\n /** The `createGlobalStyle\\`…\\`` body, if the raw defines `globals`. */\n readonly resetBody?: string;\n readonly vendorMedia: string;\n readonly vendorScheme?: string;\n}\n\nconst usesColorMath = (helpers: readonly string[]): boolean => helpers.includes(\"color-math\");\n\n/** The `import … from \"styled-components\"` line for the file that carries recipes / GlobalStyle. */\nconst scImport = (needsCss: boolean, needsGlobal: boolean): string => {\n const names = [needsCss ? \"css\" : \"\", needsGlobal ? \"createGlobalStyle\" : \"\"].filter(Boolean);\n return `import { ${names.join(\", \")} } from \"styled-components\";`;\n};\n\n/** The imports the theme object needs (`media`, optional `scheme`, optional color-math helpers). */\nconst themeImports = (inputs: ScEmitInputs): string[] => {\n const lines = [`import { media } from \"./media\";`];\n if (inputs.usesScheme) lines.push(`import { scheme } from \"./scheme\";`);\n if (usesColorMath(inputs.helpers)) {\n lines.push(`import { ${COLOR_MATH_ATTACH.join(\", \")} } from \"./color-math\";`);\n }\n return lines;\n};\n\nconst themeConst = (body: string): string => `export const theme = ${body} as const;`;\n\nconst recipeConsts = (recipes: readonly RecipeEmit[]): string =>\n recipes.map(r => `export const ${r.exportName} = css\\`\\n${r.body}\\n\\`;`).join(\"\\n\\n\");\n\nconst recipesBarrel = (body: string): string => `export const recipes = ${body} as const;`;\n\nconst globalStyle = (body: string): string => `export const GlobalStyle = createGlobalStyle\\`\\n${body}\\n\\`;`;\n\nconst themeDts = (): string =>\n `import \"styled-components\";\nimport type { theme } from \"./theme\";\n\ndeclare module \"styled-components\" {\n export interface DefaultTheme extends Readonly<typeof theme> {}\n}\n`;\n\n/** Assemble the SC emit output (files + vendored helpers) from the prepared inputs. */\nexport const buildScEmit = (inputs: ScEmitInputs): EmitOutput => {\n const files: Record<string, string> = {};\n const vendorHelpers: Record<string, string> = { \"media.ts\": inputs.vendorMedia };\n if (inputs.vendorScheme) vendorHelpers[\"scheme.ts\"] = inputs.vendorScheme;\n\n const hasRecipes = inputs.recipes.length > 0;\n const hasReset = inputs.resetBody !== undefined;\n\n if (inputs.emitMode === \"single\") {\n const parts: string[] = [];\n parts.push([scImport(hasRecipes, hasReset), ...themeImports(inputs)].join(\"\\n\"));\n parts.push(themeConst(inputs.themeObjectBody));\n if (hasRecipes) {\n parts.push(recipeConsts(inputs.recipes));\n parts.push(recipesBarrel(inputs.recipesBarrelBody));\n }\n if (hasReset) parts.push(globalStyle(inputs.resetBody!));\n files[\"theme.ts\"] = parts.join(\"\\n\\n\") + \"\\n\";\n } else {\n // split — theme / recipes / global in separate files.\n files[\"theme.ts\"] = [themeImports(inputs).join(\"\\n\"), themeConst(inputs.themeObjectBody)].join(\"\\n\\n\") + \"\\n\";\n if (hasRecipes) {\n files[\"recipes.ts\"] =\n [scImport(true, false), recipeConsts(inputs.recipes), recipesBarrel(inputs.recipesBarrelBody)].join(\"\\n\\n\") + \"\\n\";\n }\n if (hasReset) {\n files[\"global.ts\"] = [scImport(false, true), globalStyle(inputs.resetBody!)].join(\"\\n\\n\") + \"\\n\";\n }\n }\n\n if (inputs.language === \"ts\") files[\"theme.d.ts\"] = themeDts();\n\n // A `js` emit writes `.js` module names (the source is plain JS — no annotations are generated).\n if (inputs.language === \"js\") {\n for (const name of Object.keys(files)) {\n if (name.endsWith(\".ts\") && !name.endsWith(\".d.ts\")) {\n files[name.replace(/\\.ts$/, \".js\")] = files[name];\n delete files[name];\n }\n }\n for (const name of Object.keys(vendorHelpers)) {\n vendorHelpers[name.replace(/\\.ts$/, \".js\")] = vendorHelpers[name];\n delete vendorHelpers[name];\n }\n }\n\n return { files, vendorHelpers };\n};\n","/**\n * The styled-components adapter (§8) — lowers the format-neutral {@link ThemeModel} to **TS/JS\n * modules**, not a stylesheet. Worked reference: `src/adapters/css/`; imports only core (+ the\n * `styled-components` peer) so it can be lifted to its own package (Step 11).\n *\n * One renderer, two sinks (see `./recipe`): the same recipe lowering feeds `emit()` (serialize to\n * `css\\`…\\`` source on disk) and the runtime surface (`createTheme(raw, { adapter })` → a live `css`\n * block per recipe, lowered on first access and cached). Both project the SAME shapes:\n *\n * - **theme** — a literal object (`theme.colors.primary`, `theme.modes.dark.…`, `theme.media`,\n * `theme.scheme`, opted-in color-math fns). No `var()`; the object IS the indirection. This is\n * what a consumer passes to `<ThemeProvider>`.\n * - **recipes** — flat, tree-shakeable `css` blocks reading values off the theme (`${({ theme }) =>\n * theme.…}`); composition = a `css` spread of the referenced siblings. Grouped `recipes` barrel too.\n * - **GlobalStyle** — the globals subsystem as a `createGlobalStyle` (present iff the raw defines `globals`).\n * - **media** / **scheme** — SC tagged templates (breakpoints / `prefers-color-scheme`).\n */\nimport type { RuleSet as ModelRuleSet, ThemeModel } from \"@theme-registry/refract\";\nimport type { AdapterSpec, RenderContext, ThemeAdapter, NormalizedEmit, EmitOutput } from \"@theme-registry/refract\";\nimport type { PreviewDescriptor, UsageDescriptor } from \"@theme-registry/refract\";\nimport type { MediaDescriptor } from \"@theme-registry/refract\";\nimport { defineAdapter } from \"@theme-registry/refract\";\nimport { css, createGlobalStyle } from \"styled-components\";\nimport type { RuleSet } from \"styled-components\";\nimport type { NamingOverrides } from \"@theme-registry/refract/adapter-kit\";\nimport { SC_KNOWN_STATES } from \"./lowering\";\nimport { createIdentifiers } from \"./identifiers\";\nimport { buildThemeData, buildRuntimeThemeObject, serializeThemeObject } from \"./theme-object\";\nimport {\n buildRecipeIR,\n buildGlobalsIR,\n recipeSource,\n recipePlainCss,\n type RecipeContext,\n type SchemeOption,\n type SpreadRenderer,\n} from \"./recipe\";\nimport { wrapMediaDescriptor } from \"./media\";\nimport { wrapSchemeHelper, vendorSchemeHelper, mediaEligibleModes, PREFERS } from \"./scheme\";\nimport { vendorMediaHelper, buildScEmit, COLOR_MATH_ATTACH, type RecipeEmit, type ScEmitInputs } from \"./emit\";\n\n/** The output unit for this adapter — the return of the styled-components `css` tagged template. */\nexport type StyledComponentsUnit = RuleSet<object>;\n\n/** styled-components adapter options (§8). */\nexport type StyledComponentsAdapterOptions = {\n /**\n * Emit `.ts` (default) or `.js` modules. `ts` additionally emits `theme.d.ts` augmenting\n * styled-components' `DefaultTheme` from `typeof theme`, so `props.theme.…` is typed.\n */\n language?: \"ts\" | \"js\";\n /**\n * How appearance modes (§10.3) are realized in recipes: `\"media\"` (default) →\n * `@media (prefers-color-scheme: dark)` (follows the OS); `\"attribute\"` → `[data-theme=\"dark\"] &`\n * (a manual toggle overrides the OS); `\"both\"` → both blocks.\n */\n scheme?: SchemeOption;\n /**\n * Shared vendorable helpers surfaced on `theme` — `[\"color-math\"]` wires the `lighten`/`darken`/`alpha`\n * import (the module itself is materialized by the build plumbing, `emitTheme` + `VENDOR_HELPERS`).\n */\n helpers?: readonly string[];\n /** Accepted for parity with the CSS adapter's namer. SC identifiers carry no prefix (the literal\n * theme object is the isolation boundary), so these do not alter identifiers in v1. */\n prefix?: string;\n classPrefix?: string;\n /**\n * §7B — swap how names are generated (shared type with the CSS adapter). `className` remaps a\n * recipe's export identity (camelCased); `variableName` has no coherent target on the nested theme\n * object and is accepted-but-structural (theme keys stay derived from the token address).\n */\n naming?: NamingOverrides;\n};\n\nconst isValidIdentifier = (name: string): boolean => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name);\nconst objectKey = (name: string): string => (isValidIdentifier(name) ? name : JSON.stringify(name));\n\n/** Memoize an object property: build the value on first access, then replace the getter with it. */\nconst lazy = (obj: Record<string, unknown>, key: string, compute: () => unknown): void => {\n Object.defineProperty(obj, key, {\n configurable: true,\n enumerable: true,\n get() {\n const value = compute();\n Object.defineProperty(obj, key, { value, enumerable: true, configurable: true });\n return value;\n },\n });\n};\n\nexport const createStyledComponentsAdapter = (\n options: StyledComponentsAdapterOptions = {},\n): ThemeAdapter<StyledComponentsUnit> => {\n const language = options.language ?? \"ts\";\n const scheme: SchemeOption = options.scheme ?? \"media\";\n const helpers = options.helpers ?? [];\n\n const spec: AdapterSpec<StyledComponentsUnit> = {\n name: \"styled-components\",\n version: 1,\n allowedStates: SC_KNOWN_STATES,\n bind(model: ThemeModel, ctx: RenderContext) {\n const media = ctx.media as MediaDescriptor<string>;\n const ids = createIdentifiers(options.naming);\n\n // The literal theme object data (tokens + modes) — the shared source for both sinks.\n const data = buildThemeData(model, ctx.resolve);\n const recipeCtx: RecipeContext = { model, media, data, scheme, prefers: PREFERS };\n\n // Do any recipes reference `theme.scheme`? (Only dark/light under media/both do.)\n const usesScheme = (scheme === \"media\" || scheme === \"both\") && mediaEligibleModes(data.modeNames).length > 0;\n\n // ── Recipe IR registry (every rule-set except globals), addressed by \"subsystem.group.variant\". ──\n const addressKey = (subsystem: string, group: string, variant: string): string =>\n `${subsystem}.${group}.${variant}`;\n const registry = new Map<string, ReturnType<typeof buildRecipeIR>>();\n const recipeAddresses: Array<{ subsystem: string; group: string; variant: string }> = [];\n for (const [subsystem, sub] of Object.entries(model.subsystems)) {\n if (subsystem === \"globals\") continue;\n for (const [group, ruleSetGroup] of Object.entries(sub.ruleSets ?? {})) {\n for (const [variant, ruleSet] of Object.entries(ruleSetGroup)) {\n registry.set(addressKey(subsystem, group, variant), buildRecipeIR(ruleSet, recipeCtx));\n recipeAddresses.push({ subsystem, group, variant });\n }\n }\n }\n\n const ruleSetOf = (subsystem: string, group: string, variant: string): ModelRuleSet | undefined =>\n model.subsystems[subsystem]?.ruleSets?.[group]?.[variant];\n\n // ── Runtime sinks ──\n // Composition spreads inline the referenced recipe's live CSS (recursively).\n const spreadRenderer: SpreadRenderer = (subsystem, group, variant, theme) => {\n const nodes = registry.get(addressKey(subsystem, group, variant));\n return nodes ? recipePlainCss(nodes, theme, recipeCtx, spreadRenderer) : \"\";\n };\n\n const buildLiveRecipe = (subsystem: string, group: string, variant: string): RuleSet<object> => {\n const nodes = registry.get(addressKey(subsystem, group, variant)) ?? [];\n return css`${({ theme }: { theme: Record<string, any> }) => recipePlainCss(nodes, theme, recipeCtx, spreadRenderer)}`;\n };\n\n const wrappedMedia = wrapMediaDescriptor(media);\n const wrappedScheme = usesScheme ? wrapSchemeHelper(data.modeNames) : undefined;\n\n // The live theme object put on `theme` (recipes read it from styled-components context).\n const attach: Record<string, unknown> = { media: wrappedMedia };\n if (wrappedScheme) attach.scheme = wrappedScheme;\n const runtimeTheme = buildRuntimeThemeObject(data, attach);\n\n // Lazy + cached `recipes.<subsystem>.<group>.<variant>` — each lowered on first access.\n const buildRecipesTree = (): Record<string, unknown> => {\n const tree: Record<string, unknown> = {};\n for (const { subsystem, group, variant } of recipeAddresses) {\n const groups = (tree[subsystem] ??= {}) as Record<string, Record<string, unknown>>;\n const variants = (groups[group] ??= {});\n lazy(variants, variant, () => buildLiveRecipe(subsystem, group, variant));\n }\n return tree;\n };\n\n // Globals → a live GlobalStyle (present iff the raw defines the globals subsystem).\n const resetNodes = buildGlobalsIR(model.subsystems.globals?.ruleSets, recipeCtx);\n const GlobalStyle = resetNodes.length\n ? createGlobalStyle`${({ theme }: { theme: Record<string, any> }) => recipePlainCss(resetNodes, theme, recipeCtx, spreadRenderer)}`\n : undefined;\n\n // ── Emit sink ──\n const emit = (plan?: NormalizedEmit): EmitOutput => {\n const type = plan?.type ?? \"single\";\n if (type !== \"single\" && type !== \"split\") {\n throw new Error(\n `styled-components adapter: emit mode '${type}' is not supported — the TS/JS target ` +\n `emits 'single' or 'split' (ES modules tree-shake per export; 'subsystem'/'components' ` +\n `are CSS-only concerns).`,\n );\n }\n\n const spreadName = (subsystem: string, group: string, variant: string): string =>\n ids.recipeExportName(subsystem, group, variant);\n\n // Recipes in dependency-safe order (a composed component's references precede it in the list).\n const recipes: RecipeEmit[] = recipeAddresses.map(({ subsystem, group, variant }) => ({\n exportName: ids.recipeExportName(subsystem, group, variant),\n body: recipeSource(registry.get(addressKey(subsystem, group, variant)) ?? [], { spreadName }),\n }));\n\n // Grouped barrel referencing the flat consts.\n const barrelLines: string[] = [\"{\"];\n const bySubsystem = new Map<string, Array<{ group: string; variant: string }>>();\n for (const addr of recipeAddresses) {\n (bySubsystem.get(addr.subsystem) ?? bySubsystem.set(addr.subsystem, []).get(addr.subsystem)!).push(addr);\n }\n for (const [subsystem, addrs] of bySubsystem) {\n barrelLines.push(` ${subsystem}: {`);\n const byGroup = new Map<string, string[]>();\n for (const { group, variant } of addrs) {\n (byGroup.get(group) ?? byGroup.set(group, []).get(group)!).push(variant);\n }\n for (const [group, variants] of byGroup) {\n barrelLines.push(` ${objectKey(group)}: {`);\n for (const variant of variants) {\n barrelLines.push(` ${objectKey(variant)}: ${ids.recipeExportName(subsystem, group, variant)},`);\n }\n barrelLines.push(` },`);\n }\n barrelLines.push(` },`);\n }\n barrelLines.push(\"}\");\n\n const trailingRefs = [\n \"media\",\n ...(usesScheme ? [\"scheme\"] : []),\n ...(helpers.includes(\"color-math\") ? COLOR_MATH_ATTACH : []),\n ];\n\n const inputs: ScEmitInputs = {\n language,\n emitMode: type,\n helpers,\n usesScheme,\n themeObjectBody: serializeThemeObject(data, trailingRefs),\n recipes,\n recipesBarrelBody: barrelLines.join(\"\\n\"),\n resetBody: resetNodes.length ? recipeSource(resetNodes, { spreadName }) : undefined,\n vendorMedia: vendorMediaHelper(model.breakpoints, media),\n vendorScheme: usesScheme ? vendorSchemeHelper(data.modeNames) : undefined,\n };\n return buildScEmit(inputs);\n };\n\n return {\n recipeName(subsystem, group, variant) {\n return ids.recipeExportName(subsystem, group, variant);\n },\n\n // Preview (§20): the output is JS modules that need React + styled-components to render, so\n // there is no stylesheet to load. Token plates still work; for a live design-review page add a\n // CSS target to the same config — same recipes through the same core IR, so it's faithful.\n describePreview(): PreviewDescriptor {\n return {\n stylesheets: [],\n unavailable:\n \"This target emits JavaScript modules that render through React + styled-components, \" +\n \"so there is no stylesheet a browser can load. Token values below are exact. For a live \" +\n \"render, add a CSS target to the same config — it compiles the same recipes.\",\n };\n },\n\n // Self-documentation: the REAL export identifiers (the tree-shakeable `css` consts) plus\n // SC-specific wiring prose for the emitted guide (llms.txt).\n describeUsage(): UsageDescriptor {\n return {\n format: \"styled-components\",\n summary: [\n \"This theme is emitted as TypeScript/JavaScript modules: a literal `theme` object plus tree-shakeable `css` recipe exports (and a `GlobalStyle` if the theme defines globals).\",\n 'Wrap your app once in styled-components\\' `ThemeProvider` with the exported `theme`: `import { theme } from \"./theme\";` then `<ThemeProvider theme={theme}>`.',\n \"Apply a recipe by spreading its `css` export into a styled component: ``styled.button`${componentsButtonsPrimary}` ``. Recipes read their values from `props.theme`, so there is no `var()` and no separate stylesheet.\",\n \"If the theme defines globals, render `<GlobalStyle />` once inside the provider.\",\n ],\n recipes: recipeAddresses.map(({ subsystem, group, variant }) => ({\n subsystem,\n group,\n variant,\n name: ids.recipeExportName(subsystem, group, variant),\n })),\n };\n },\n renderRecipe(subsystem, group, variant) {\n return ruleSetOf(subsystem, group, variant)\n ? buildLiveRecipe(subsystem, group, variant)\n : css``;\n },\n // The SC target has no CSS variables (the theme object is the indirection).\n renderVariables() {\n return css``;\n },\n join(parts) {\n return parts.flat() as RuleSet<object>;\n },\n\n // The runtime surface: the literal theme object + lazy recipes + GlobalStyle + media/scheme.\n extend() {\n const surface: Record<string, unknown> = {\n theme: runtimeTheme,\n recipes: buildRecipesTree(),\n media: wrappedMedia,\n };\n if (wrappedScheme) surface.scheme = wrappedScheme;\n if (GlobalStyle) surface.GlobalStyle = GlobalStyle;\n return surface;\n },\n\n emit,\n };\n },\n };\n return defineAdapter(spec);\n};\n\n// Public glue re-exports.\nexport { wrapMediaDescriptor } from \"./media\";\nexport type {\n WrappedMediaDescriptor,\n WrappedMediaGroup,\n MediaTemplateWithQuery,\n} from \"./media\";\nexport type { SchemeHelper, SchemeTemplateWithQuery } from \"./scheme\";\n"],"names":["SC_STATE_SELECTORS","link","visited","hover","focus","active","disabled","pressed","SC_KNOWN_STATES","Object","keys","STATE_ORDER","reduce","acc","name","index","orderStateOverrides","overrides","map","override","sort","a","b","oa","_a","state","Number","MAX_SAFE_INTEGER","ob","_b","bpa","breakpoint","bpb","DEFAULT_MEDIA_QUERY","splitWords","segment","split","filter","Boolean","camelJoin","segments","words","flatMap","length","joined","w","i","word","charAt","toLowerCase","slice","toUpperCase","upperFirst","join","test","themeKey","segmentsAfterSubsystem","themeAccess","path","subsystem","rest","key","createIdentifiers","seen","Map","recipeExportName","group","variant","className","fallback","s","out","kind","classToken","Error","prev","get","undefined","set","track","formatValue","ref","resolve","struct","external","raw","value","unit","INDENT","serializeLeafMap","depth","pad","repeat","inner","entries","k","v","String","JSON","stringify","serializeTree","tree","serializeThemeObject","data","trailingRefs","lines","push","modeNames","mode","modes","str","refFragments","lit","tokenPaths","has","read","wrap","declNodes","declarations","nodes","property","type","parseReference","reference","dot","indexOf","schemeRealizations","scheme","mediaEligible","media","attribute","modeDeclNodes","overridden","modeOverridePaths","modeRef","buildRecipeIR","ruleSet","ctx","references","parsed","children","query","orientation","stateOverrides","o","stateSelector","block","selector","_c","baseMode","stateModeBlocks","accessExpr","nodeSource","node","indent","captured","opts","fragments","fragment","expr","fragmentsSource","spreadName","c","target","recipeSource","readTheme","theme","root","nodePlainCss","spread","fragmentsValue","min","max","exact","resolveMediaQuery","prefers","recipePlainCss","RESERVED_DESCRIPTOR_KEYS","Set","wrapMediaDescriptor","descriptor","wrapped","options","wrapQuery","between","from","to","wrapMediaGroup","forEach","assign","buildTemplate","styles","interpolations","css","PREFERS","dark","light","mediaEligibleModes","VARIANTS","COLOR_MATH_ATTACH","vendorMediaHelper","breakpoints","variants","scImport","needsCss","needsGlobal","themeImports","inputs","usesScheme","helpers","includes","themeConst","body","recipeConsts","recipes","r","exportName","recipesBarrel","globalStyle","objectKey","isValidIdentifier","lazy","obj","compute","defineProperty","configurable","enumerable","createStyledComponentsAdapter","language","spec","version","allowedStates","bind","model","ids","naming","put","add","sub","subsystems","pm","properties","base","extra","extras","_d","entry","_e","basePath","field","_f","_h","_k","_g","_j","buildThemeData","recipeCtx","addressKey","registry","recipeAddresses","ruleSetGroup","ruleSets","spreadRenderer","buildLiveRecipe","wrappedMedia","wrappedScheme","helper","wrapSchemeHelper","attach","runtimeTheme","bySub","buildRuntimeThemeObject","buildRecipesTree","groups","resetNodes","values","variantName","variantRuleSet","variantChildren","buildGlobalsIR","globals","GlobalStyle","createGlobalStyle","recipeName","describePreview","stylesheets","unavailable","describeUsage","format","summary","renderRecipe","ruleSetOf","renderVariables","parts","flat","extend","surface","emit","plan","barrelLines","bySubsystem","addr","addrs","byGroup","files","vendorHelpers","vendorMedia","vendorScheme","hasRecipes","hasReset","resetBody","emitMode","themeObjectBody","recipesBarrelBody","endsWith","replace","buildScEmit","defineAdapter"],"mappings":"uHAkBO,MAAMA,EAA6C,CACxDC,KAAM,QACNC,QAAS,WACTC,MAAO,SACPC,MAAO,SACPC,OAAQ,UACRC,SAAU,aACVC,QAAS,kBAIEC,EAAyCC,OAAOC,KAAKV,GAE5DW,EAAsCH,EAAgBI,OAC1D,CAACC,EAAKC,EAAMC,KACVF,EAAIC,GAAQC,EACLF,GAET,CAAE,GAISG,EAAuBC,GAClCA,EACGC,IAAI,CAACC,EAAUJ,KAAW,CAAEI,WAAUJ,WACtCK,KAAK,CAACC,EAAGC,aACR,MAAMC,EAA4C,QAAvCC,EAAAb,EAAYU,EAAEF,SAASM,cAAgB,IAAAD,EAAAA,EAAIE,OAAOC,iBACvDC,EAA4C,QAAvCC,EAAAlB,EAAYW,EAAEH,SAASM,cAAgB,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AC3BxF,WACAmF,SAAU9L,EACVwF,UACAD,aACAwG,gBAAiBlN,EAAqBC,EAAMC,GAC5C8G,UACAmG,kBAAmBd,EAAYtP,KAAK,MACpCiQ,UAAWpC,EAAWvO,OAASyH,EAAa8G,EAAY,CAAEjH,oBAAgBpF,EAC1EqO,YAAa1G,EAAkBiC,EAAMhC,YAAaxE,GAClDkL,aAAcnG,GF5KWrG,EE4KqBJ,EAAKI,UFvKpD,scAJS0F,EAAmB1F,GAChCzF,IAAI0F,GAAQ,KAAKV,KAAKC,UAAUS,YAAeV,KAAKC,UAAU+F,EAAQtF,SACtEvD,KAAK,8CEyKgEwB,KAqErE,GAEH,OAAOgP,EAAcxF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theme-registry/refract-styled-components",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"description": "The styled-components output adapter for @theme-registry/refract — emits TS/JS theme modules (literal theme object + tree-shakeable css recipes + GlobalStyle).",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Petyo Stoyanov",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"styled-components": "^6.0.0",
|
|
36
|
-
"@theme-registry/refract": "^0.1.
|
|
36
|
+
"@theme-registry/refract": "^0.1.8"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"styled-components": {
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"styled-components": "^6.4.0",
|
|
50
50
|
"typescript": "^5.4.2",
|
|
51
51
|
"vitest": "^4.1.10",
|
|
52
|
-
"@theme-registry/
|
|
53
|
-
"@theme-registry/
|
|
52
|
+
"@theme-registry/theme-fixtures": "^0.0.0",
|
|
53
|
+
"@theme-registry/refract": "^0.1.8"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"build": "rollup -c",
|