@theme-registry/refract 0.1.2 → 0.1.4
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/README.md +17 -1
- package/dist/build/createCommand.d.ts +47 -0
- package/dist/build/createInterview.d.ts +56 -0
- package/dist/build/index.d.ts +4 -0
- package/dist/build/init.d.ts +42 -0
- package/dist/build/prompt.d.ts +76 -0
- package/dist/build/scaffold.d.ts +146 -0
- package/dist/build.cjs.js +1 -1
- package/dist/build.cjs.js.map +1 -1
- package/dist/build.esm.js +1 -1
- package/dist/build.esm.js.map +1 -1
- package/dist/cli.js +1139 -14
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
- package/skills/theme-authoring/SKILL.md +3 -0
- package/skills/theme-scaffold/SKILL.md +130 -0
package/dist/build.esm.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{existsSync as e,readFileSync as t,writeFileSync as r,rmSync as n,mkdirSync as o,readdirSync as i}from"node:fs";import{join as s,dirname as a,resolve as l,basename as c,extname as u,isAbsolute as d}from"node:path";import{pathToFileURL as f}from"node:url";import{homedir as p}from"node:os";import{createInterface as m}from"node:readline/promises";import{parseArgs as g}from"node:util";const h=[{id:"color-math",outfile:"color-math.js",source:"src/subsystems/colors/utils.ts",exports:["lighten","darken","alpha","setL","rotateHue","complement","adjust","rgbToOklch","oklchToRgb","toHexColor","toOklchColor","convertHexToRGB","convertRgbToHex"],description:"Pure OKLCH colour math — the exact lighten/darken/setL/rotateHue/complement/adjust (+ OKLCH and hex converters) refract synthesizes palette steps/variants with, so a value computed live in the consumer matches the emitted CSS variables."}],b=e=>h.find(t=>t.id===e),v=(t=__dirname)=>{let r=t;for(;;){if(e(s(r,"package.json")))return r;const n=a(r);if(n===r)throw new Error(`No package.json found walking up from "${t}".`);r=n}},y=r=>{const n=s(v(),r);if(!e(n))throw new Error(`Vendor helper source "${r}" not found at "${n}". Ensure it is listed in package.json "files" so it ships with the package.`);return t(n,"utf8")};async function w(){var e;try{const t=await import("typescript");return null!==(e=t.default)&&void 0!==e?e:t}catch{throw new Error('refract: the optional peer dependency "typescript" is required to transpile a `.ts` theme.config or vendor a shared helper module, but it could not be resolved. Install it (`npm i -D typescript`), or use a `.mjs`/`.js` config and avoid the `helpers` opt-in.')}}const k=async e=>{const t=await w();return t.transpileModule(e,{compilerOptions:{module:t.ModuleKind.ESNext,target:t.ScriptTarget.ES2020}}).outputText};let $=0;const x=e=>l(e).replace(/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs)$/,""),j=async t=>{const o=await w(),i={module:o.ModuleKind.ESNext,target:o.ScriptTarget.ES2020,moduleResolution:o.ModuleResolutionKind.Bundler,resolveJsonModule:!0,allowJs:!1,noLib:!0,skipLibCheck:!0,noEmitOnError:!1,declaration:!1,sourceMap:!1,types:[]},u=o.createCompilerHost(i),d=o.createProgram([t],i,u),f=new Map,p=e=>!e.isDeclarationFile&&!e.fileName.includes("/node_modules/")&&/\.(ts|tsx|mts|cts)$/.test(e.fileName);for(const e of d.getSourceFiles()){if(!p(e))continue;const t=l(e.fileName),r=c(t).replace(/\.(ts|tsx|mts|cts)$/,"");f.set(x(t),s(a(t),`.${r}.${process.pid}-${$++}.mjs`))}const m=e=>t=>{const r=l(t.fileName),n=e.factory,s=e=>{const t=((e,t)=>{var r;if(!e.startsWith("."))return;const n=null===(r=o.resolveModuleName(e,t,i,u).resolvedModule)||void 0===r?void 0:r.resolvedFileName;return n?f.get(x(n)):void 0})(e,r);return t?n.createStringLiteral(`./${c(t)}`):void 0},a=t=>{if(o.isImportDeclaration(t)&&o.isStringLiteral(t.moduleSpecifier)){const e=s(t.moduleSpecifier.text);if(e)return n.updateImportDeclaration(t,t.modifiers,t.importClause,e,t.attributes)}else if(o.isExportDeclaration(t)&&t.moduleSpecifier&&o.isStringLiteral(t.moduleSpecifier)){const e=s(t.moduleSpecifier.text);if(e)return n.updateExportDeclaration(t,t.modifiers,t.isTypeOnly,t.exportClause,e,t.attributes)}else if(o.isCallExpression(t)&&t.expression.kind===o.SyntaxKind.ImportKeyword&&t.arguments.length&&o.isStringLiteral(t.arguments[0])){const e=s(t.arguments[0].text);if(e)return n.updateCallExpression(t,t.expression,t.typeArguments,[e,...t.arguments.slice(1)])}return o.visitEachChild(t,a,e)};return o.visitNode(t,a)},g=[],h=(e,t)=>{const n=f.get(x(e));n&&(r(n,t,"utf8"),g.push(n))},b=()=>{for(const e of g)n(e,{force:!0})};try{d.emit(void 0,h,void 0,!1,{before:[m]})}catch(e){throw b(),e}const v=f.get(x(t));if(!v||!e(v))throw b(),new Error(`refract: failed to compile the \`.ts\` config graph for "${t}".`);return{entry:v,cleanup:b}},A=e=>e.replace(/\|/g,"\\|");function E(e,t,r){var n;const o=[];if(o.push(`# Theme consumption guide (${e.format})`),o.push(""),o.push("This folder is a self-contained theme built with refract. You do NOT need refract to use it —","everything below refers to files in THIS folder (relative paths), so it works whether the theme","was installed as a package, unzipped from an artifact, or vendored into a repo."),o.push(""),t.files.length>0){o.push("## Files"),o.push("");for(const e of t.files)o.push(`- \`./${e}\``);o.push("")}o.push("## How to use"),o.push("");for(const t of e.summary)o.push(t);t.packageName&&(o.push(""),o.push(`If this theme is installed as the \`${t.packageName}\` package, you may import the same`,`files by specifier (e.g. \`${t.packageName}/${null!==(n=t.files[0])&&void 0!==n?n:"theme.css"}\`) instead of by relative path.`)),o.push("");const{recipes:i}=e;if(i.length>0){o.push("## Recipes — real names"),o.push(""),o.push("Use these exact identities; do not invent names."),o.push(""),o.push("| Recipe | Identity |"),o.push("| --- | --- |");const e=i.slice(0,60);for(const t of e)o.push(`| \`${A(`${t.subsystem}.${t.group}.${t.variant}`)}\` | \`${A(t.name)}\` |`);if(i.length>e.length){const t=i.length-e.length;o.push(""),o.push(`_(+${t} more recipe(s) — the complete list is in ${r?`\`./${r}\``:"the manifest"}.)_`)}o.push("")}return r&&(o.push("## Machine-readable index"),o.push(""),o.push(`See \`./${r}\` for the full recipe index and the theme's tokens (DTCG format).`),o.push("")),o.join("\n")}function R(e,t,r){var n;const o=null!==(n=r.llmsFile)&&void 0!==n?n:"llms.txt",i=void 0===r.manifestFile?"manifest.json":r.manifestFile,s={[o]:E(e,r,i)};if(i){const n={schema:1,format:e.format,files:r.files,packageName:r.packageName,recipes:e.recipes,tokens:t};s[i]=`${JSON.stringify(n,null,2)}\n`}return{files:s}}class S extends Error{constructor(e,t,r){super(t),this.name="RefractError",this.code=e,r&&(this.failures=r),Object.setPrototypeOf(this,S.prototype)}}const O=e=>"string"==typeof e||"number"==typeof e,C=e=>Array.isArray(e),T=e=>({value:e}),F=(e,t)=>{if(!t)return T(e);const r={ref:t.ref};return void 0!==t.fn&&(r.fn=t.fn),void 0!==t.arg&&(r.arg=t.arg),void 0!==t.modifiers&&(r.modifiers=t.modifiers),void 0!==e&&(r.value=e),r},_=new Set(["mode","target","base","derive"]),N=(e,t,r)=>{const n={},o=e.derive,i=e.base;if(o){if(void 0===o.ref)throw new S("REFRACT_E_REFERENCE",`Derived appearance mode "${t}.modes.${r}" was not baked — derived modes require a subsystem that resolves them (colors). Use a literal value instead.`);n.base=F(O(i)?i:void 0,o)}else O(i)?n.base=T(i):C(i)&&(n.base={struct:i});for(const[t,r]of Object.entries(e))_.has(t)||O(r)&&(n[t]=T(r));return n},P=(e,t)=>{const r={};for(const[n,o]of Object.entries(e))t.has(n)||O(o)&&(r[n]=T(o));return r},z=new Set(["base","derive"]),q=new Set(["base","responsive","variants","modes","external"]),M=new Set(["breakpoint","query","state","orientation","ref","modifiers","mode","variant","target","derive","ratio","step","steps"]),I=(e,t="property")=>{var r;const n={base:void 0!==e.external?{value:`var(${e.external})`,external:e.external}:(o=e.base,C(o)?{struct:o}:T(o))};var o;const i=P(e,q);if(Object.keys(i).length&&(n.extras=i),e.variants&&Object.keys(e.variants).length){const t={};for(const[r,n]of Object.entries(e.variants)){let e;const o=n.derive;if(O(n.base)?e=F(n.base,o):C(n.base)?e={struct:n.base}:void 0!==(null==o?void 0:o.ref)&&(e=F(void 0,o)),!e)continue;const i=P(n,z);t[r]=Object.keys(i).length?{base:e,extras:i}:{base:e}}Object.keys(t).length&&(n.variants=t)}const s=e.modes;if(s&&s.length){const e=[];for(const r of s){const n=r.mode,o=N(r,t,n);if(!Object.keys(o).length)continue;const i={mode:n,overrides:o};"string"==typeof r.target&&(i.target=r.target),e.push(i)}e.length&&(n.modes=e)}if(null===(r=e.responsive)||void 0===r?void 0:r.length){const t=e.responsive.map(e=>{const t=e,r={breakpoint:t.breakpoint};"string"==typeof t.query&&(r.query=t.query),"string"==typeof t.orientation&&(r.orientation=t.orientation),"string"==typeof t.ref&&(r.ref=t.ref),"string"==typeof t.mode&&(r.mode=t.mode),"string"==typeof t.target&&(r.target=t.target);const n=((e,t)=>{const r={};for(const[n,o]of Object.entries(e))t.has(n)||(O(o)?r[n]=T(o):C(o)&&(r[n]={struct:o}));return r})(t,M),o=t.derive;return o&&n.base&&void 0!==n.base.value&&(n.base=F(n.base.value,o)),Object.keys(n).length&&(r.overrides=n),r});n.responsive=t}return n},L=e=>({kind:"recipe",declarations:{...e.base},overrides:e.responsive.map(e=>{const t={};return void 0!==e.state&&(t.state=e.state),void 0!==e.breakpoint&&(t.breakpoint=e.breakpoint),void 0!==e.query&&(t.query=e.query),void 0!==e.orientation&&(t.orientation=e.orientation),void 0!==e.container&&(t.container=e.container),void 0!==e.size&&(t.size=e.size),void 0!==e.variant&&(t.variant=e.variant),void 0!==e.target&&(t.target=e.target),Object.keys(e.declarations).length&&(t.declarations={...e.declarations}),t})}),B=(e,t)=>{const r=L(e);return r.kind="recipe",t.length&&(r.references=t),r},U=new Set(["colors","typography","layout","effects","borders"]),V=e=>!!e&&Object.keys(e).length>0,D=e=>{var t;if(!e)return;const r={};return e.properties&&Object.keys(e.properties).length&&(r.properties=(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]=I(n,r);return t})(e.properties)),e.extraProperties&&Object.keys(e.extraProperties).length&&(r.properties={...null!==(t=r.properties)&&void 0!==t?t:{},...e.extraProperties}),V(e.ruleSetGroups)&&(r.ruleSets=e.ruleSetGroups),V(e.keyframes)&&(r.keyframes=e.keyframes),Object.keys(r).length?r:void 0},W=e=>{var t,r,n,o;const i={};for(const[s,a]of Object.entries(e.subsystems))for(const[e,l]of Object.entries(null!==(t=a.properties)&&void 0!==t?t:{})){const t=`${s}.${e}`;i[t]=l.base;for(const[e,o]of Object.entries(null!==(r=l.variants)&&void 0!==r?r:{})){i[`${t}.${e}`]=o.base;for(const[r,s]of Object.entries(null!==(n=o.extras)&&void 0!==n?n:{}))i[`${t}.${e}.${r}`]=s}for(const[e,r]of Object.entries(null!==(o=l.extras)&&void 0!==o?o:{}))i[`${t}.${e}`]=r}return i},H=new Set(["px","cm","mm","q","in","pc","pt","rem","em","ex","cap","ch","ic","lh","rlh","%","vw","vh","vi","vb","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh","cqw","cqh","cqi","cqb","cqmin","cqmax"]),G=/^-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?$/i,Y=/^(-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?)([a-z%]+)$/i,J=e=>{if("number"==typeof e)return{value:e};const t=e.trim();if(G.test(t))return{value:Number(t)};const r=Y.exec(t);if(r){const t=r[2].toLowerCase();if(H.has(t))return{value:Number(r[1]),unit:t};throw new S("REFRACT_E_UNITS",`Unknown length unit "${r[2]}" in "${e}". Use a CSS unit, or wrap functions/keywords (calc(), clamp(), var(), a keyword) — those pass through as raw strings.`)}return{raw:e}},K={"typography.lineHeight":"none","typography.letterSpacing":"em"},X=(e,t)=>{var r,n,o,i;const s=e.slice(0,e.indexOf("."));return null!==(i=null!==(o=null!==(n=null!==(r=null==t?void 0:t[e])&&void 0!==r?r:K[e])&&void 0!==n?n:null==t?void 0:t[s])&&void 0!==o?o:null==t?void 0:t.default)&&void 0!==i?i:"px"},Z=(e,t)=>Number((e/t).toFixed(4)),Q=(e,t,r)=>"none"===t?{value:e}:"rem"===t?{value:Z(e,r),unit:"rem"}:{value:e,unit:t},ee=(e,t,r)=>{if("number"==typeof e){const{value:n,unit:o}=Q(e,t,r);return void 0===o?e:{value:n,unit:o}}return e},te={typography:{fontSize:"length",letterSpacing:"length",lineHeight:"length"},layout:{spacing:"length",gutters:"length",sizes:"length"},borders:{width:"length",offset:"length",radius:"length"},effects:{blur:"length",shadow:"shadow"}},re=(e,t)=>{let r=!1;const n={};for(const[o,i]of Object.entries(e)){const e=t(i);e!==i&&(r=!0),n[o]=e}return r?n:e},ne=(e,t,r)=>{const n=t(e.base),o=e.variants?((e,t)=>{let r=!1;const n={};for(const[o,i]of Object.entries(e)){const e=t(i.base),s=i.extras?re(i.extras,t):void 0;e===i.base&&s===i.extras||(r=!0),n[o]=s?{base:e,extras:s}:{base:e}}return r?n:e})(e.variants,t):void 0,i=r&&e.extras?re(e.extras,t):e.extras,s=e.modes?((e,t)=>{let r=!1;const n=e.map(e=>{if(!e.overrides)return e;const n=re(e.overrides,t);return n===e.overrides?e:(r=!0,{...e,overrides:n})});return r?n:e})(e.modes,t):void 0,a=((e,t)=>{if(!e.responsive)return;let r=!1;const n=e.responsive.map(e=>{if(!e.overrides)return e;const n=re(e.overrides,t);return n===e.overrides?e:(r=!0,{...e,overrides:n})});return r?n:e.responsive})(e,t);if(n===e.base&&o===e.variants&&i===e.extras&&s===e.modes&&a===e.responsive)return e;const l={...e,base:n};return void 0!==o&&(l.variants=o),void 0!==i&&(l.extras=i),void 0!==s&&(l.modes=s),void 0!==a&&(l.responsive=a),l},oe=(e,t,r,n)=>{const o="shadow"===t?e=>{if(!e.struct)return e;const t=e.struct;let o=!1;const i=t.map(e=>{const t=((e,t,r)=>{const n={...e};let o=!1;for(const i of["offsetX","offsetY","blur","spread"]){const s=e[i];if(void 0===s)continue;const a=ee(s,t,r);a!==s&&(n[i]=a,o=!0)}return o?n:e})(e,r,n);return t!==e&&(o=!0),t});return o?{...e,struct:i}:e}:e=>((e,t,r)=>{if(void 0!==e.unit)return e;if(void 0!==e.ref&&void 0===e.value)return e;const n=e.value;if("number"==typeof n){const{value:o,unit:i}=Q(n,t,r);return void 0===i?e:{...e,value:o,unit:i}}if("string"==typeof n){const o=J(n);if("raw"in o)return e;if(void 0!==o.unit)return{...e,value:o.value,unit:o.unit};const{value:i,unit:s}=Q(o.value,t,r);return void 0===s?{...e,value:i}:{...e,value:i,unit:s}}return e})(e,r,n);return ne(e,o,!1)},ie=(e,t={})=>{var r;const n=null!==(r=t.baseFontSize)&&void 0!==r?r:16;let o=!1;const i={};for(const[r,s]of Object.entries(e.subsystems)){const e=te[r];if(!e||!s.properties){i[r]=s;continue}let a=!1;const l={};for(const[o,i]of Object.entries(s.properties)){const s=e[o];if(!s){l[o]=i;continue}const c=X(`${r}.${o}`,t.units),u=oe(i,s,c,n);u!==i&&(a=!0),l[o]=u}a?(i[r]={...s,properties:l},o=!0):i[r]=s}return o?{...e,subsystems:i}:e},se=e=>(null==e?void 0:e.propertyPath)?` for "${e.propertyPath}"`:"",ae=(e,t)=>!t||(Array.isArray(t)?t.includes(e):t.has(e));function le(e,t){const r=e.variants?Object.keys(e.variants):[];if(!r.length)return;const n=new Set(r),o=(null==t?void 0:t.propertyPath)?` for "${t.propertyPath}"`:"";for(const t of e.responsive){if(t.ref&&!n.has(t.ref))throw new S("REFRACT_E_RESPONSIVE",`Responsive entry${o} references unknown variant "${t.ref}" (ref).`);if(t.target&&!n.has(t.target))throw new S("REFRACT_E_RESPONSIVE",`Responsive entry${o} references unknown target "${t.target}".`)}}const ce=e=>"object"==typeof e&&null!==e&&Array.isArray(e.modifiers),ue=(e,t)=>{if(!Array.isArray(e)||0===e.length)throw new S("REFRACT_E_VARIANT",`Derivation "${t}" needs a non-empty "modifiers" array.`);return e.map((e,r)=>{if("object"!=typeof e||null===e||Array.isArray(e))throw new S("REFRACT_E_VARIANT",`Modifier ${r} of "${t}" must be a single-key object like { darken: 10 }.`);const n=Object.keys(e);if(1!==n.length)throw new S("REFRACT_E_VARIANT",`Modifier ${r} of "${t}" must have exactly one fn key; got [${n.join(", ")}].`);return{fn:n[0],arg:e[n[0]]}})},de=new Set(["breakpoint","query","ref","modifiers","mode","target","orientation"]),fe=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),pe=(e,t,r)=>{var n;const o=null!==(n=null!=e?e:t)&&void 0!==n?n:r.fallbackBase;if(void 0===o)throw new S("REFRACT_E_PROPERTY",`Unable to resolve base value${i=r.propertyPath,i?` for "${i}"`:""}.`);var i;return r.coerceValue?r.coerceValue(o):o},me=(e,t)=>{const r=new Set(t),n={},o={};let i=!1;for(const[t,s]of Object.entries(e))r.has(t)?(n[t]=s,i=!0):o[t]=s;return{base:i?n:void 0,extra:o}},ge=(e,t,r,n)=>{var o;if(void 0===e&&(null===(o=n.leafFields)||void 0===o?void 0:o.length)){const e=me(t,n.leafFields);if(void 0!==e.base){const t=e.base;return{base:n.coerceValue?n.coerceValue(t):t,extra:e.extra}}}return{base:pe(e,r,n),extra:t}},he=(e,t,r,n)=>{const o=r.propertyPath?`${r.propertyPath}.variants.${e}`:`variants.${e}`,i=fe(t)?t:{base:t},{base:s,...a}=i,{base:l,extra:c}=ge(s,a,n,{...r,propertyPath:o});return{...c,base:l}},be=(e,t={})=>{var r;const n=fe(e)?e:{base:e},{base:o,responsive:i,variants:s,modes:a,...l}=n,{base:c,extra:u}=ge(o,l,t.fallbackBase,t),d=s?Object.fromEntries(Object.entries(s).map(([e,r])=>[e,he(e,r,t,c)])):void 0,f=a?a.map(e=>((e,t)=>{const{mode:r,target:n,...o}=e,i=t.propertyPath?`${t.propertyPath}.modes.${r}`:`modes.${r}`;return{mode:r,...void 0!==n?{target:n}:{},...(()=>{var e;if((null===(e=t.leafFields)||void 0===e?void 0:e.length)&&!("base"in o)&&!ce(o)){const{base:e,extra:r}=me(o,t.leafFields);if(void 0!==e){const n={...r};return n.base=t.coerceValue?t.coerceValue(e):e,n}}if(ce(o)){const{ref:e,modifiers:t,...r}=o,n={...r};return n.derive={...void 0!==e?{ref:e}:{},modifiers:ue(t,i)},n}const{base:r,...n}=o,s={...n};if(void 0!==r&&(s.base=Array.isArray(r)||!t.coerceValue?r:t.coerceValue(r)),void 0===s.base&&!s.derive&&!Object.keys(n).length)throw new S("REFRACT_E_MODE",`Appearance mode "${i}" overrides nothing.`);return s})()}})(e,t)):void 0,p={propertyPath:t.propertyPath,allowedBreakpoints:t.allowedBreakpoints},m=(h=p,(null==(g=i)?void 0:g.length)?g.map(e=>{if(!e.breakpoint)throw new S("REFRACT_E_BREAKPOINT",`Responsive entry${se(h)} is missing a "breakpoint" value.`);if((null==h?void 0:h.allowedBreakpoints)&&!ae(e.breakpoint,h.allowedBreakpoints))throw new S("REFRACT_E_BREAKPOINT",`Responsive entry${se(h)} references unknown breakpoint "${e.breakpoint}".`);if(e.ref&&!ae(e.ref,null==h?void 0:h.allowedVariants))throw new S("REFRACT_E_RESPONSIVE",`Responsive entry${se(h)} references unknown variant "${e.ref}" (ref).`);if(e.target&&!ae(e.target,null==h?void 0:h.allowedTargets))throw new S("REFRACT_E_RESPONSIVE",`Responsive entry${se(h)} references unknown target "${e.target}".`);const{query:t,...r}=e;return{...r,query:null!=t?t:"exact"}}):[]);var g,h;const b=(null===(r=t.leafFields)||void 0===r?void 0:r.length)?m.map(e=>((e,t)=>{const r={},n={};let o;for(const[t,i]of Object.entries(e))de.has(t)?r[t]=i:"base"===t?o=i:n[t]=i;const i=t.leafFields.some(e=>e in n);if(void 0===o&&!i)return e;const{base:s,extra:a}=ge(o,n,void 0,t);return{...r,...a,base:s}})(e,t)):m;return{...u,base:c,responsive:b,variants:d,modes:f}},ve=["orientation","height","aspectRatio"],ye=(e,t)=>!t||(Array.isArray(t)?t.includes(e):t.has(e)),we=e=>e?` for "${e}"`:"",ke="responsive",$e="states",xe="css",je="variants",Ae=e=>Array.isArray(e)?e:e&&"object"==typeof e?Object.entries(e).map(([e,t])=>({state:e,...t})):[],Ee=e=>{var t;return`${e.state}\0${null!==(t=e.target)&&void 0!==t?t:""}`},Re=(e,t)=>{const r=Ae(e).map(e=>({...e})),n=new Map(r.map((e,t)=>[Ee(e),t]));for(const e of Ae(t)){const t=Ee(e),o=n.get(t);void 0!==o?r[o]={...r[o],...e}:(n.set(t,r.length),r.push({...e}))}return r},Se=(e,t)=>{var r,n;const o={...e};for(const[i,s]of Object.entries(t))null!==s?i===ke?o[ke]=[...null!==(r=e[ke])&&void 0!==r?r:[],...s]:i===$e?o[$e]=Re(e[$e],s):i===xe?o[xe]={...null!==(n=e[xe])&&void 0!==n?n:{},...s}:o[i]=s:delete o[i];return o},Oe=(e,t={})=>{const r=((e,t)=>{if(!Object.values(e).some(e=>null!=e&&"object"==typeof e&&null!=e[je]))return e;const r={},n=(e,n)=>{if(e in r)throw new S("REFRACT_E_VARIANT",`Recipe variant expansion${we(t)} produced a duplicate recipe name "${e}" — a desugared "<recipe>-<variant>" collides with an existing sibling recipe.`);r[e]=n};for(const[t,r]of Object.entries(e)){const{[je]:e,...o}=r;if(n(t,o),null!=e){const r=null!=o[$e]?{...o,[$e]:Ae(o[$e]).filter(e=>!e.target)}:o;for(const[o,i]of Object.entries(e))n(`${t}-${o}`,Se(r,i))}}return r})(e,t.propertyPath),n=Object.keys(r),o=n.length?new Set(n):void 0,i={};return n.forEach(e=>{var n;const s=r[e];i[e]=Ce(`${null!==(n=t.propertyPath)&&void 0!==n?n:"recipes"}.${e}`,s,{allowedBreakpoints:t.allowedBreakpoints,allowedStates:t.allowedStates,allowedTargets:o,allowedVariants:o,allowedContainers:t.allowedContainers,recipeName:e})}),i},Ce=(e,t,r)=>{const{responsive:n,states:o,...i}=t;return{base:i,responsive:[...Te(o,e,r),...Fe(n,e,r)]}},Te=(e,t,r)=>Ae(e).map(e=>{const{state:n,...o}=e;if(r.allowedStates&&!ye(n,r.allowedStates))throw new S("REFRACT_E_STATE",`Recipe state entry${we(t)} references unknown state "${n}".`);if(o.target&&r.allowedTargets){const e=r.recipeName?`${r.recipeName}-${o.target}`:o.target;if(!ye(e,r.allowedTargets))throw new S("REFRACT_E_RESPONSIVE",`Recipe state entry${we(t)} references unknown target "${o.target}".`)}return{...o,state:n}}),Fe=(e,t,r)=>(null==e?void 0:e.length)?e.map(e=>{var n;if(void 0!==e.variant&&void 0!==e.target)throw new S("REFRACT_E_RESPONSIVE",`Responsive entry${we(t)} cannot set both "variant" and "target".`);if(void 0!==e.container)return _e(e,t,r);if(!e.breakpoint)throw new S("REFRACT_E_BREAKPOINT",`Responsive recipe entry${we(t)} is missing a "breakpoint" value.`);if(r.allowedBreakpoints&&!ye(e.breakpoint,r.allowedBreakpoints))throw new S("REFRACT_E_BREAKPOINT",`Responsive recipe entry${we(t)} references unknown breakpoint "${e.breakpoint}".`);if(e.state&&r.allowedStates&&!ye(e.state,r.allowedStates))throw new S("REFRACT_E_STATE",`Responsive recipe entry${we(t)} references unknown state "${e.state}".`);if(e.variant&&!ye(e.variant,r.allowedVariants))throw new S("REFRACT_E_RESPONSIVE",`Responsive recipe entry${we(t)} references unknown variant "${e.variant}".`);if(e.target&&!ye(e.target,r.allowedTargets))throw new S("REFRACT_E_RESPONSIVE",`Responsive recipe entry${we(t)} references unknown target "${e.target}".`);return{...e,query:null!==(n=e.query)&&void 0!==n?n:"exact"}}):[],_e=(e,t,r)=>{var n,o;const i=e.container;for(const r of ve)if(void 0!==e[r])throw new S("REFRACT_E_CONTAINER",`Container recipe entry${we(t)} cannot use "${r}" — container queries respond to a container's inline size, not orientation/height/aspect-ratio.`);const s=null===(n=r.allowedContainers)||void 0===n?void 0:n.get(i);if(r.allowedContainers&&!s)throw new S("REFRACT_E_CONTAINER",`Container recipe entry${we(t)} references unknown container "${i}".`);if(void 0===e.size)throw new S("REFRACT_E_CONTAINER",`Container recipe entry${we(t)} for container "${i}" is missing a "size" value.`);if(s&&!s.has(e.size))throw new S("REFRACT_E_CONTAINER",`Container recipe entry${we(t)} references unknown size "${e.size}" on container "${i}".`);return{...e,query:null!==(o=e.query)&&void 0!==o?o:"min"}},Ne=(e,t,r={})=>{var n;const o=new Map,i=[],s=null!==(n=r.groupPath)&&void 0!==n?n:"recipes",a=r=>{if(o.has(r))return o.get(r);if(i.includes(r)){const e=[...i,r].join(" -> ");throw new S("REFRACT_E_CYCLE",`Cyclic recipe reference in "${s}": ${e}`)}const n=e[r];if(!n)throw new S("REFRACT_E_REFERENCE",`Recipe variant "${r}" is not defined in "${s}".`);i.push(r);try{const e=t(r,n,a);return o.set(r,e),e}finally{i.pop()}};return{resolve:a,resolveAll:()=>{const t={};for(const r of Object.keys(e))t[r]=a(r);return t}}},Pe=(e,t,r,n=new Map,o=new Set)=>{const i=n.get(r);if(void 0!==i)return i;const s=e[r];if(!s)throw new S("REFRACT_E_TOKEN_PATH",`Unknown token path "${r}".`);if(void 0!==s.external){const e=`var(${s.external})`;return n.set(r,e),e}if(void 0===s.ref){if(void 0===s.value)throw new S("REFRACT_E_TOKEN_PATH",`Token "${r}" has neither "ref" nor "value".`);return n.set(r,s.value),s.value}if(o.has(r))throw new S("REFRACT_E_CYCLE",`Cyclic token reference: ${[...o,r].join(" -> ")}`);o.add(r);const a=Pe(e,t,s.ref,n,o);let l;if(void 0!==s.modifiers)l=s.modifiers.reduce((e,n)=>{const o=t[n.fn];if(!o)throw new S("REFRACT_E_TOKEN_PATH",`Unknown derivation fn "${n.fn}" for token "${r}".`);return o(e,n.arg)},a);else if(void 0!==s.fn){const e=t[s.fn];if(!e)throw new S("REFRACT_E_TOKEN_PATH",`Unknown derivation fn "${s.fn}" for token "${r}".`);l=e(a,s.arg)}else l=a;return o.delete(r),n.set(r,l),l},ze=(e,t)=>!!(null==e?void 0:e.ref)&&((void 0!==e.modifiers||void 0!==e.fn)&&(e=>{const[t,r]=e.split(".");return`${t}.${r}`})(e.ref)!==t),qe=(e,t,r,n,o)=>{let i;try{i=Pe(t,r,e.ref,n)}catch{throw new S("REFRACT_E_VALIDATION",`${o}: cross-property derivation references unknown token '${e.ref}'.`)}const s=(e,t)=>{const n=r[e];if(!n)throw new S("REFRACT_E_VALIDATION",`${o}: unknown derivation fn '${e}'.`);return n(i,t)};if(void 0!==e.modifiers)for(const t of e.modifiers)i=s(t.fn,t.arg);else void 0!==e.fn&&(i=s(e.fn,e.arg));return{...e,value:i}},Me=(e,t,r,n,o,i)=>{let s;for(const[a,l]of Object.entries(e))ze(l,t)&&(s=null!=s?s:{...e},s[a]=qe(l,r,n,o,`${i}.${a}`));return s},Ie=(e,t,r,n,o)=>{const i=e.variants?((e,t,r,n,o)=>{let i;for(const[s,a]of Object.entries(e)){const l=`${t}.variants.${s}`,c=ze(a.base,t)?qe(a.base,r,n,o,l):a.base,u=a.extras?Me(a.extras,t,r,n,o,`${l} extra`):void 0;(c!==a.base||u)&&(i=null!=i?i:{...e},i[s]=u?{base:c,extras:u}:{...a,base:c})}return i})(e.variants,t,r,n,o):void 0;let s;if(e.modes)for(let i=0;i<e.modes.length;i++){const a=e.modes[i];if(!a.overrides)continue;const l=Me(a.overrides,t,r,n,o,`${t}.modes.${a.mode}`);l&&(s=null!=s?s:[...e.modes],s[i]={...a,overrides:l})}if(!i&&!s)return;const a={...e};return i&&(a.variants=i),s&&(a.modes=s),a},Le=(e,t)=>{var r;const n=W(e),o=new Map;let i=!1;const s={};for(const[a,l]of Object.entries(e.subsystems)){let e,c=!1;for(const[i,s]of Object.entries(null!==(r=l.properties)&&void 0!==r?r:{})){const r=Ie(s,`${a}.${i}`,n,t,o);r&&(e=null!=e?e:{...l.properties},e[i]=r,c=!0)}c?(s[a]={...l,properties:e},i=!0):s[a]=l}return i?{...e,subsystems:s}:e},Be=["min","max","exact","between"],Ue=e=>void 0===e?void 0:e-.02,Ve=(e,t)=>{const r=(e=>Object.keys(e).sort((t,r)=>e[t]-e[r]))(e);(e=>{const t=e.filter(e=>Be.includes(e));if(t.length)throw new S("REFRACT_E_BREAKPOINT",`Breakpoint names conflict with reserved keys: ${t.map(e=>`"${e}"`).join(", ")}. Reserved: ${Be.map(e=>`"${e}"`).join(", ")}.`)})(r);const n=e=>r[r.indexOf(e)+1],o=r.reduce((r,o)=>{const i=e[o],s=n(o),a=void 0!==s?e[s]:void 0;return r[o]=De({own:i,next:a},t),r},{}),i=e=>{const t=o[e];if(!t)throw new S("REFRACT_E_BREAKPOINT",`Breakpoint "${e}" is not defined.`);return t};return{...o,min:(r,n)=>{const o=i(r);return n?t({min:e[r],...n}):o.min},max:(r,o)=>{const s=i(r);if(!o)return s.max;const a=n(r),l=void 0!==a?e[a]:void 0;return t({max:Ue(l),...o})},exact:(r,o)=>{const s=i(r);if(!o)return s.exact;const a=n(r),l=void 0!==a?e[a]:void 0;return t({min:e[r],max:Ue(l),...o})},between:(r,n,o)=>{const i=e[r],s=e[n];if(void 0===i||void 0===s)throw new S("REFRACT_E_BREAKPOINT",`Cannot build media query between "${r}" and "${n}" breakpoints.`);return t({min:i,max:s-.02,...o})}}},De=({own:e,next:t},r)=>{const n=Ue(t);return{min:r({min:e}),max:void 0===n?"":r({max:n}),exact:r({min:e,max:n})}},We="px",He=16,Ge=e=>{var t;return{unit:null!==(t=null==e?void 0:e.unit)&&void 0!==t?t:We,baseFontSize:(null==e?void 0:e.baseFontSize)&&e.baseFontSize>0?e.baseFontSize:He}},Ye=(e,t)=>{if("px"===t.unit)return`${e}px`;const r=e/t.baseFontSize;return`${Number(r.toFixed(4))}${t.unit}`},Je=({min:e,max:t,orientation:r},n)=>{const o=[];if(void 0!==e&&void 0!==t&&e>t)throw new S("REFRACT_E_MEDIA","Invalid media query: `min` cannot be greater than `max`.");return void 0!==e&&o.push(`(min-width: ${Ye(e,n)})`),void 0!==t&&o.push(`(max-width: ${Ye(t,n)})`),r&&o.push(`(orientation: ${r})`),o.length?`@media ${o.join(" and ")}`:""},Ke=(e,{min:t,max:r},n)=>{const o=[];if(void 0!==t&&void 0!==r&&t>r)throw new S("REFRACT_E_MEDIA","Invalid container query: `min` cannot be greater than `max`.");return void 0!==t&&o.push(`(min-width: ${Ye(t,n)})`),void 0!==r&&o.push(`(max-width: ${Ye(r,n)})`),o.length?`@container ${e} ${o.join(" and ")}`:""},Xe={xs:0,sm:576,md:768,lg:992,xl:1280},Ze=(e,t)=>{const r=Ge(t),n={};for(const[t,o]of Object.entries(null!=e?e:{}))n[t]=Ve(o.sizes,e=>Ke(t,{min:e.min,max:e.max},r));return n},Qe=new Set([3,6]),et=(e,t,r)=>Math.min(r,Math.max(t,e)),tt=e=>et(e,0,255),rt=e=>Math.round(1e3*et(e,0,1))/1e3,nt=e=>{const t=e.replace(/^\s*#|\s*$/g,"");if(!Qe.has(t.length))throw new Error(`Unsupported hex length: "${t}". Use 3 or 6 digits.`);const r=3===t.length?t.replace(/(.)/g,"$1$1"):t;return[parseInt(r.substring(0,2),16),parseInt(r.substring(2,4),16),parseInt(r.substring(4,6),16)]},ot=/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+)\s*)?\)$/i,it=e=>{const t=e.trim(),r=ot.exec(t);return r?{rgb:[Number(r[1]),Number(r[2]),Number(r[3])],a:void 0===r[4]?1:rt(Number(r[4]))}:{rgb:nt(t),a:1}},st=(e,t=1)=>{const r=rt(t),[n,o,i]=e,s=tt(Math.round(n)),a=tt(Math.round(o)),l=tt(Math.round(i));return r>=1?`rgb(${s}, ${a}, ${l})`:`rgba(${s}, ${a}, ${l}, ${r})`},at=180/Math.PI,lt=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),ct=e=>e>=.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,ut=e=>{const[t,r,n]=e,o=((e,t,r)=>{const n=.4122214708*e+.5363325363*t+.0514459929*r,o=.2119034982*e+.6806995451*t+.1073969566*r,i=.0883024619*e+.2817188376*t+.6299787005*r,s=Math.cbrt(n),a=Math.cbrt(o),l=Math.cbrt(i);return{L:.2104542553*s+.793617785*a-.0040720468*l,a:1.9779984951*s-2.428592205*a+.4505937099*l,b:.0259040371*s+.7827717662*a-.808675766*l}})(lt(t/255),lt(r/255),lt(n/255)),i=Math.sqrt(o.a*o.a+o.b*o.b);let s=Math.atan2(o.b,o.a)*at;return s<0&&(s+=360),{L:100*o.L,C:i,h:s}},dt=e=>{const t=et(e.L,0,100)/100,r=e.h/at,n=Math.cos(r),o=Math.sin(r),i=e=>((e,t,r)=>{const n=e+.3963377774*t+.2158037573*r,o=e-.1055613458*t-.0638541728*r,i=e-.0894841775*t-1.291485548*r,s=n*n*n,a=o*o*o,l=i*i*i;return[4.0767416621*s-3.3077115913*a+.2309699292*l,-1.2684380046*s+2.6097574011*a-.3413193965*l,-.0041960863*s-.7034186147*a+1.707614701*l]})(t,e*n,e*o),s=e=>e.every(e=>e>=-1e-6&&e<=1.000001);let a=i(e.C);if(!s(a)){let t=0,r=e.C;for(let e=0;e<24;e++){const e=(t+r)/2;s(i(e))?t=e:r=e}a=i(t)}return[255*ct(et(a[0],0,1)),255*ct(et(a[1],0,1)),255*ct(et(a[2],0,1))]},ft=(e,t)=>{const{rgb:r,a:n}=it(e);return st(dt(t(ut(r))),n)},pt=(e,t)=>ft(e,e=>({...e,L:et(e.L+t,0,100)})),mt=(e,t)=>ft(e,e=>({...e,L:et(e.L-t,0,100)})),gt=(e,t)=>ft(e,e=>({...e,L:et(t,0,100)})),ht=(e,t)=>ft(e,e=>({...e,h:((e.h+t)%360+360)%360})),bt=(e,t)=>ft(e,e=>({L:void 0===t.l?e.L:et(t.l,0,100),C:void 0===t.c?e.C:Math.max(0,e.C*t.c),h:void 0===t.h?e.h:((e.h+t.h)%360+360)%360})),vt=e=>{const{rgb:t,a:r}=it(e),n=(e=>{if(3!==e.length)throw new Error(`Expected RGB tuple of length 3, received ${e.length}`);return`#${e.map(e=>{const t=tt(Math.round(e)).toString(16);return 1===t.length?`0${t}`:t}).join("")}`})(t);if(r>=1)return n;return`${n}${tt(Math.round(255*r)).toString(16).padStart(2,"0")}`},yt=(e,t)=>{const{rgb:r}=it(e);return st(r,(e=>et(e,0,100))(t)/100)},wt={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},kt=e=>Math.round(1e3*Math.min(1,Math.max(0,e)))/1e3,$t=(e,t,r)=>{const n=(e%360+360)%360/60,o=(1-Math.abs(2*Math.min(1,Math.max(0,r))-1))*Math.min(1,Math.max(0,t)),i=o*(1-Math.abs(n%2-1)),s=Math.min(1,Math.max(0,r))-o/2,[a,l,c]=n<1?[o,i,0]:n<2?[i,o,0]:n<3?[0,o,i]:n<4?[0,i,o]:n<5?[i,0,o]:[o,0,i];return[255*(a+s),255*(l+s),255*(c+s)]},xt=/^oklch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(?:deg)?\s*(?:\/\s*([\d.]+)(%?)\s*)?\)$/i,jt=/^hsla?\(\s*([\d.]+)(?:deg)?\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%\s*(?:[,/]\s*([\d.]+)(%?)\s*)?\)$/i,At=e=>{if("string"==typeof e){const t=(e=>{const t=e.trim(),r=xt.exec(t);if(r){const e="%"===r[2]?Number(r[1]):100*Number(r[1]),t=void 0===r[5]?1:kt("%"===r[6]?Number(r[5])/100:Number(r[5]));return{rgb:dt({L:e,C:Number(r[3]),h:Number(r[4])}),a:t}}const n=jt.exec(t);if(n){const e=void 0===n[4]?1:kt("%"===n[5]?Number(n[4])/100:Number(n[4]));return{rgb:$t(Number(n[1]),Number(n[2])/100,Number(n[3])/100),a:e}}const o=wt[t.toLowerCase()];if(o)return{rgb:nt(o),a:1};try{return it(t)}catch{return null}})(e);if(!t)throw new S("REFRACT_E_COLOR_INPUT",`Invalid colour "${e}". Author a colour as a hex string ("#4dabf7"), an [r, g, b] tuple, or a CSS colour — oklch(), hsl()/hsla(), rgb()/rgba(), or a named keyword (e.g. "rebeccapurple"). A var(--…) can't be tonally derived at build time.`);return st(t.rgb,t.a)}if(!Array.isArray(e)||3!==e.length||e.some(e=>"number"!=typeof e))throw new S("REFRACT_E_COLOR_TUPLE",`Invalid colour tuple ${JSON.stringify(e)}. Use an [r, g, b] tuple with 0–255 channels (alpha comes from an \`alpha\` variant, not the base).`);const[t,r,n]=e;return st([t,r,n])},Et={lighten:(e,t)=>pt(e,Number(t)),darken:(e,t)=>mt(e,Number(t)),alpha:(e,t)=>yt(e,Number(t)),setL:(e,t)=>gt(e,Number(t)),rotateHue:(e,t)=>ht(e,Number(t)),adjust:(e,t)=>bt(e,t)},Rt=["light","lighter"],St=["dark","darker"],Ot=(e,t)=>{if(!e||!e.includes("."))return!1;const[r,n]=e.split(".");return`${r}.${n}`!=`colors.${t}`},Ct=(e,t)=>{try{return At(e)}catch(e){throw new S("REFRACT_E_COLOR_INPUT",`colors.${t}.text — ${e.message}`)}},Tt=(e,t,r={})=>{var n;const o=((e,t)=>{let r=t;if(void 0!==t.text&&(r={...r,text:Ct(t.text,e)}),t.variants){let n=!1;const o={};for(const[r,i]of Object.entries(t.variants))void 0!==i.text?(o[r]={...i,text:Ct(i.text,`${e}.variants.${r}`)},n=!0):o[r]=i;n&&(r={...r,variants:o})}if(t.modes){let n=!1;const o=t.modes.map(t=>void 0!==t.text?(n=!0,{...t,text:Ct(t.text,`${e}.modes.${t.mode}`)}):t);n&&(r={...r,modes:o})}return r})(e,t),i=(e=>{try{return it(e),!0}catch{return!1}})(o.base),s=!(!o.steps||!o.steps.length),a=Object.keys(r).length>0,l=void 0!==o.harmony;if((s||a||l)&&!i)throw new S("REFRACT_E_STEPS",`colors.${e} declares derived steps/variants but its base "${o.base}" is not a hex or [r,g,b] colour.`);const c=i?Nt(o,e):{},u=i?zt(o,e):{},d=null!==(n=o.variants)&&void 0!==n?n:{},f={...c,...u,...d},p=Ut(e,o.base,f,r),m={...c,...u,...d,...p},g=_t(o,e,m),h=Ft(o,e,m);return Object.keys(m).length||g||h?{...o,...Object.keys(m).length?{variants:m}:{},...g?{modes:g}:{},...h?{responsive:h}:{}}:o},Ft=(e,t,r)=>{const n=e.responsive;if(!n||!n.length)return;let o=!1;const i=n.map((e,n)=>{const i=e.ref,s=e.modifiers;if(!i||!Array.isArray(s)||!s.length){let t;for(const r of["base","text"]){const n=e[r];if("string"==typeof n||Array.isArray(n)){const o=At(n);o!==n&&(t=null!=t?t:{...e},t[r]=o)}}return t&&(o=!0),null!=t?t:e}const a=r[i];if(!a)throw new S("REFRACT_E_VARIANT_REF",`colors.${t}.responsive[${n}] references unknown variant "${i}".`);if(void 0===a.base)throw new S("REFRACT_E_VARIANT_REF",`colors.${t}.responsive[${n}] references "${i}", a cross-property derivation — not supported.`);const l=Bt({modifiers:s},t,`responsive[${n}]`);let c=a.base;for(const e of l)c=Et[e.fn](c,e.arg);o=!0;const{ref:u,modifiers:d,...f}=e;return{...f,base:c,derive:{ref:`colors.${t}.${i}`,modifiers:l}}});return o?i:n},_t=(e,t,r)=>{const n=e.modes;if(!n||!n.length)return;return n.map(n=>{var o;const i=n.mode,s=n.derive;if(!s)return n;const a=null!==(o=s.modifiers)&&void 0!==o?o:s.fn?[{fn:s.fn,arg:s.arg}]:[];if(Ot(s.ref,t)){const{base:e,derive:t,...r}=n;return{...r,derive:{ref:s.ref,modifiers:a}}}const l=((n,o)=>{if(!n||n===`colors.${t}`)return{value:e.base,path:`colors.${t}`};const i=n.includes(".")?n.slice(`colors.${t}.`.length):n,s=r[i];if(!s||void 0===s.base)throw new S("REFRACT_E_VARIANT_REF",`colors.${t}.modes.${o} references unknown variant "${n}".`);return{value:s.base,path:`colors.${t}.${i}`}})(s.ref,i);let c=l.value;for(const e of a){const r=Et[e.fn];if(!r)throw new S("REFRACT_E_VARIANT_REF",`Unknown derivation fn "${e.fn}" for appearance mode "colors.${t}.modes.${i}".`);c=r(c,e.arg)}return{...n,base:c,derive:{ref:l.path,modifiers:a}}})},Nt=(e,t)=>e.steps&&e.steps.length?Lt(e,t):Mt(e,t),Pt={complement:[{name:"complement",deg:180}],analogous:[{name:"analogous1",deg:-30},{name:"analogous2",deg:30}],"split-complement":[{name:"split1",deg:150},{name:"split2",deg:210}],triadic:[{name:"triadic1",deg:120},{name:"triadic2",deg:240}],tetradic:[{name:"tetradic1",deg:90},{name:"complement",deg:180},{name:"tetradic2",deg:270}]},zt=(e,t)=>{const r=e.harmony;if(void 0===r)return{};let n,o;if("string"==typeof r)n=r;else{if("object"!=typeof r||null===r||Array.isArray(r))throw new S("REFRACT_E_HARMONY",`colors.${t}.harmony must be a scheme name or a { scheme: [names] } object.`);{const e=Object.keys(r);if(1!==e.length)throw new S("REFRACT_E_HARMONY",`colors.${t}.harmony object form must name exactly one scheme; got [${e.join(", ")}].`);n=e[0],o=r[n]}}const i=Pt[n];if(!i)throw new S("REFRACT_E_HARMONY",`colors.${t}.harmony: unknown scheme "${n}". Use one of ${Object.keys(Pt).join(", ")}.`);const s={};return i.forEach((r,n)=>{var i;const a=null!==(i=null==o?void 0:o[n])&&void 0!==i?i:r.name;s[a]={base:ht(e.base,r.deg),derive:{ref:`colors.${t}`,fn:"rotateHue",arg:r.deg}}}),s},qt=(e,t,r,n,o,i,s,a)=>{var l;const c=e=>e?`colors.${r}.${e}`:`colors.${r}`;let u,d=t.base;for(const t of o){if(void 0!==(null===(l=n[t])||void 0===l?void 0:l.base)){d=n[t].base,u=t;continue}const r=i(d,a);e[t]={base:r,derive:{ref:c(u),fn:s,arg:a}},d=r,u=t}},Mt=(e,t)=>{var r,n,o;const i=null!==(r=e.variants)&&void 0!==r?r:{},s={},a=null!==(n=e.lightenBy)&&void 0!==n?n:10,l=null!==(o=e.darkenBy)&&void 0!==o?o:10;return qt(s,e,t,i,Rt,pt,"lighten",a),qt(s,e,t,i,St,mt,"darken",l),s},It=e=>e<=0?100:e>=1e3?0:Math.min(98,Math.max(5,(1e3-e)/10)),Lt=(e,t)=>{var r,n;const o=null!==(r=e.steps)&&void 0!==r?r:[],i=o.find(e=>"number"!=typeof e||isNaN(e)||e<0||e>1e3);if(void 0!==i)throw new S("REFRACT_E_STEPS",`colors.${t}.steps must be numbers in 0–1000 (e.g. [50, …, 950]); got ${JSON.stringify(i)}.`);const s=null!==(n=e.variants)&&void 0!==n?n:{},a={};for(const r of o){const n=r.toString();if(s[n])continue;const o=It(r);a[n]={base:gt(e.base,o),derive:{ref:`colors.${t}`,fn:"setL",arg:o}}}return a},Bt=(e,t,r)=>{const n=`colors.${t}.variants.${r}`,o=e.modifiers;if(!Array.isArray(o)||0===o.length)throw new S("REFRACT_E_VARIANT",`${n} needs a non-empty "modifiers" array (e.g. [{ darken: 10 }]).`);return o.map((e,o)=>{if("object"!=typeof e||null===e||Array.isArray(e))throw new S("REFRACT_E_VARIANT",`${n}.modifiers[${o}] must be a single-key object like { darken: 10 }.`);const i=Object.keys(e);if(1!==i.length)throw new S("REFRACT_E_VARIANT",`${n}.modifiers[${o}] must have exactly one fn key; got [${i.join(", ")}].`);const s=i[0];if(!Et[s])throw new S("REFRACT_E_VARIANT",`${n}.modifiers[${o}] unknown fn "${s}"; use ${Object.keys(Et).join(" / ")}.`);const a=e[s],l="adjust"===s?((e,t,r)=>{const n=`colors.${t}.variants.${r}.adjust`;if("object"!=typeof e||null===e||Array.isArray(e))throw new S("REFRACT_E_ADJUST",`${n} must be an object with numeric l / c / h dials.`);const{l:o,c:i,h:s}=e,a={};if(void 0!==o){if("number"!=typeof o||isNaN(o)||o<0||o>100)throw new S("REFRACT_E_ADJUST",`${n}.l must be an absolute OKLCH lightness in 0–100; got ${JSON.stringify(o)}.`);a.l=o}if(void 0!==i){if("number"!=typeof i||isNaN(i)||i<0)throw new S("REFRACT_E_ADJUST",`${n}.c must be a non-negative chroma multiplier (1 keeps, 0 greys); got ${JSON.stringify(i)}.`);a.c=i}if(void 0!==s){if("number"!=typeof s||isNaN(s))throw new S("REFRACT_E_ADJUST",`${n}.h must be a numeric hue rotation in degrees; got ${JSON.stringify(s)}.`);a.h=s}return a})(a,t,r):Number(a);return{fn:s,arg:l}})},Ut=(e,t,r,n)=>{const o={},i=new Set,s=(t,r)=>{if(void 0===t.base)throw new S("REFRACT_E_VARIANT_REF",`colors.${e} variant chains off "${r}", which is a cross-property derivation — not supported.`);return t.base};function a(l,c){if(o[l])return;if(i.has(l))throw new S("REFRACT_E_CYCLE",`Cyclic colour variant derivation at colors.${e}.${l}.`);i.add(l);const u=Bt(c,e,l);if(Ot(c.ref,e))return o[l]={derive:{ref:c.ref,modifiers:u}},void i.delete(l);const d=(i=>{if(!i)return{value:t,path:`colors.${e}`};if(o[i])return{value:s(o[i],i),path:`colors.${e}.${i}`};if(r[i])return{value:s(r[i],i),path:`colors.${e}.${i}`};if(n[i])return a(i,n[i]),{value:s(o[i],i),path:`colors.${e}.${i}`};throw new S("REFRACT_E_VARIANT_REF",`colors.${e} variant references unknown source "${i}".`)})(c.ref);let f=d.value;for(const e of u)f=Et[e.fn](f,e.arg);o[l]={base:f,derive:{ref:d.path,modifiers:u}},i.delete(l)}for(const[e,t]of Object.entries(n))a(e,t);return o},Vt=new Set("display position top right bottom left inset inset-block inset-block-start inset-block-end inset-inline inset-inline-start inset-inline-end float clear z-index visibility overflow overflow-x overflow-y overflow-block overflow-inline overflow-clip-margin overflow-anchor box-sizing width height min-width min-height max-width max-height block-size inline-size min-block-size min-inline-size max-block-size max-inline-size aspect-ratio margin margin-top margin-right margin-bottom margin-left margin-block margin-block-start margin-block-end margin-inline margin-inline-start margin-inline-end margin-trim padding padding-top padding-right padding-bottom padding-left padding-block padding-block-start padding-block-end padding-inline padding-inline-start padding-inline-end flex flex-grow flex-shrink flex-basis flex-direction flex-flow flex-wrap order justify-content justify-items justify-self align-content align-items align-self place-content place-items place-self gap row-gap column-gap grid grid-area grid-template grid-template-areas grid-template-columns grid-template-rows grid-auto-columns grid-auto-rows grid-auto-flow grid-column grid-column-start grid-column-end grid-row grid-row-start grid-row-end columns column-count column-width column-gap column-rule column-rule-color column-rule-style column-rule-width column-span column-fill color opacity accent-color caret-color color-scheme forced-color-adjust print-color-adjust background background-color background-image background-position background-position-x background-position-y background-size background-repeat background-origin background-clip background-attachment background-blend-mode mix-blend-mode isolation border border-width border-style border-color border-top border-top-width border-top-style border-top-color border-right border-right-width border-right-style border-right-color border-bottom border-bottom-width border-bottom-style border-bottom-color border-left border-left-width border-left-style border-left-color border-block border-block-width border-block-style border-block-color border-block-start border-block-start-width border-block-start-style border-block-start-color border-block-end border-block-end-width border-block-end-style border-block-end-color border-inline border-inline-width border-inline-style border-inline-color border-inline-start border-inline-start-width border-inline-start-style border-inline-start-color border-inline-end border-inline-end-width border-inline-end-style border-inline-end-color border-radius border-top-left-radius border-top-right-radius border-bottom-right-radius border-bottom-left-radius border-start-start-radius border-start-end-radius border-end-start-radius border-end-end-radius border-image border-image-source border-image-slice border-image-width border-image-outset border-image-repeat border-collapse border-spacing outline outline-width outline-style outline-color outline-offset box-shadow filter backdrop-filter clip-path mask mask-image mask-mode mask-repeat mask-position mask-clip mask-origin mask-size mask-composite mask-type opacity transform transform-origin transform-box transform-style perspective perspective-origin backface-visibility rotate scale translate transition transition-property transition-duration transition-timing-function transition-delay transition-behavior animation animation-name animation-duration animation-timing-function animation-delay animation-iteration-count animation-direction animation-fill-mode animation-play-state animation-composition animation-timeline will-change font font-family font-size font-size-adjust font-weight font-style font-variant font-variant-caps font-variant-numeric font-variant-ligatures font-variant-east-asian font-variant-alternates font-variant-position font-feature-settings font-variation-settings font-kerning font-stretch font-optical-sizing font-synthesis font-display line-height letter-spacing word-spacing text-align text-align-last text-decoration text-decoration-line text-decoration-color text-decoration-style text-decoration-thickness text-decoration-skip-ink text-underline-offset text-underline-position text-transform text-indent text-overflow text-shadow text-rendering text-wrap text-wrap-mode text-wrap-style text-emphasis text-emphasis-color text-emphasis-style text-emphasis-position text-orientation text-combine-upright text-justify white-space white-space-collapse word-break word-wrap overflow-wrap hyphens hyphenate-character line-break tab-size vertical-align writing-mode direction unicode-bidi quotes content list-style list-style-type list-style-position list-style-image counter-reset counter-increment counter-set cursor pointer-events user-select touch-action resize appearance caret scroll-behavior scroll-margin scroll-margin-top scroll-margin-right scroll-margin-bottom scroll-margin-left scroll-padding scroll-padding-top scroll-padding-right scroll-padding-bottom scroll-padding-left scroll-snap-type scroll-snap-align scroll-snap-stop overscroll-behavior overscroll-behavior-x overscroll-behavior-y scrollbar-width scrollbar-color scrollbar-gutter table-layout caption-side empty-cells vertical-align object-fit object-position image-rendering fill fill-opacity fill-rule stroke stroke-width stroke-opacity stroke-linecap stroke-linejoin stroke-dasharray stroke-dashoffset stroke-miterlimit paint-order shape-rendering stop-color flood-color lighting-color container container-type container-name contain content-visibility break-before break-after break-inside page-break-before page-break-after page-break-inside orphans widows all cx cy r rx ry d".split(" ")),Dt=/^-(webkit|moz|ms|o)-/,Wt=e=>{if(e.startsWith("--"))return!0;const t=e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();return!!Dt.test(t)||Vt.has(t)},Ht=new Set(["breakpoint","query","state","variant","target","orientation"]),Gt=(e,t,r)=>{const n={};if(!e)return n;for(const[o,i]of Object.entries(e)){if(void 0===i||Ht.has(o))continue;if(!Wt(o))throw new S("REFRACT_E_RECIPE_PROPERTY",`Unknown recipe property "${o}" in ${r} — expected a CSS property or a reserved key (variant, target, state, breakpoint, query, orientation, container, size).`);const e=Yt(i,t,r,o);void 0!==e&&(n[Jt(o)]=e)}return n},Yt=(e,t,r,n)=>{var o;if("number"==typeof e)return{value:e};const i=e.trim();if(!i)return;const s=i.split("."),a=s[0],l=t.properties[a];if(!l)return{value:i};const c=s.length>1?s.slice(1).join("."):void 0;if(!c)return{ref:`colors.${a}`};if("text"===c)return{ref:`colors.${a}.text`};if(!(null===(o=l.variants)||void 0===o?void 0:o[c]))throw new S("REFRACT_E_VARIANT_REF",`Unknown palette variant reference "${a}.${c}" in ${r}.${n}.`);return{ref:`colors.${a}.${c}`}},Jt=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Kt=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),Xt=([e,t,r])=>.2126*Kt(e/255)+.7152*Kt(t/255)+.0722*Kt(r/255),Zt={fail:0,"AA-large":1,AA:2,AAA:3},Qt=2.4,er=.2126729,tr=.7151522,rr=.072175,nr=.56,or=.57,ir=.62,sr=.65,ar=.022,lr=1.414,cr=1.14,ur=.027,dr=1.14,fr=.027,pr=5e-4,mr=.1,gr=([e,t,r])=>er*Math.pow(e/255,Qt)+tr*Math.pow(t/255,Qt)+rr*Math.pow(r/255,Qt),hr=(e,t)=>{const r=e=>e>ar?e:e+Math.pow(ar-e,lr),n=r(gr(e)),o=r(gr(t));if(Math.abs(o-n)<pr)return 0;let i;if(o>n){const e=(Math.pow(o,nr)-Math.pow(n,or))*cr;i=e<mr?0:e-ur}else{const e=(Math.pow(o,sr)-Math.pow(n,ir))*dr;i=e>-mr?0:e+fr}return 100*i},br=(e,t)=>{const r=10**t;return Math.round(e*r)/r},vr=(e,t)=>{if(void 0!==t.ref)try{return String(e.resolveToken(t.ref))}catch{return}if("string"==typeof t.value)return t.value},yr="color",wr=["background-color","background"],kr=e=>{if(e)for(const t of wr)if(e[t])return e[t]},$r=(e,t,r,n,o)=>{let i,s;try{void 0!==r&&(i=it(r).rgb)}catch{}try{void 0!==n&&(s=it(n).rgb)}catch{}if(!i||!s)return{kind:e,label:t,fg:r,bg:n,skipped:i||s?i?"bg not a colour":"fg not a colour":"no derivable fg/bg"};const a=((e,t)=>{const r=Xt(e),n=Xt(t);return(Math.max(r,n)+.05)/(Math.min(r,n)+.05)})(i,s),l=((e,t)=>t?e>=4.5?"AAA":e>=3?"AA":"fail":e>=7?"AAA":e>=4.5?"AA":e>=3?"AA-large":"fail")(a,o.largeText),c=Zt[l]>=Zt[o.minWcag];return{kind:e,label:t,fg:r,bg:n,wcagRatio:br(a,2),wcagLevel:l,apcaLc:br(hr(i,s),1),pass:c}},xr=(e,t={})=>{var r,n,o,i,s,a,l,c,u,d,f;const p={largeText:null!==(r=t.largeText)&&void 0!==r&&r,minWcag:null!==(n=t.minWcag)&&void 0!==n?n:"AA"},m=null===(o=t.includeRecipes)||void 0===o||o,g=[];if(null===(i=t.includePalettes)||void 0===i||i)for(const t of Object.keys(e.tokens)){const r=/^colors\.([^.]+)\.text$/.exec(t);if(!r)continue;const n=`colors.${r[1]}`;let o,i;try{o=String(e.resolveToken(t))}catch{}try{i=String(e.resolveToken(n))}catch{}g.push($r("palette",n,o,i,p))}if(m)for(const[t,r]of Object.entries(e.model.subsystems))if(r.ruleSets)for(const[n,o]of Object.entries(r.ruleSets))for(const[r,i]of Object.entries(o)){const o=i.declarations[yr],m=kr(i.declarations),h=`${t}.${n}.${r}`;o&&m&&g.push($r("recipe",h,vr(e,o),vr(e,m),p));for(const t of null!==(s=i.overrides)&&void 0!==s?s:[]){const r=null!==(l=null===(a=t.declarations)||void 0===a?void 0:a[yr])&&void 0!==l?l:o,n=null!==(c=kr(t.declarations))&&void 0!==c?c:m;if(!t.declarations||!t.declarations[yr]&&!kr(t.declarations))continue;if(!r||!n)continue;const i=null!==(f=null!==(d=null!==(u=t.state)&&void 0!==u?u:t.breakpoint)&&void 0!==d?d:t.query)&&void 0!==f?f:"override";g.push($r("recipe",`${h} (${i})`,vr(e,r),vr(e,n),p))}}const h=g.filter(e=>!e.skipped),b=h.filter(e=>!1===e.pass),v=h.reduce((e,t)=>{var r,n;return void 0===e||(null!==(r=t.wcagRatio)&&void 0!==r?r:1/0)<(null!==(n=e.wcagRatio)&&void 0!==n?n:1/0)?t:e},void 0),y={pairings:g,summary:{total:h.length,passed:h.length-b.length,failed:b.length,skipped:g.length-h.length,worst:v},ok:0===b.length};if(t.strict&&b.length>0){const e=b.map(e=>`${e.label} (${e.wcagRatio}:1, ${e.wcagLevel})`).join(", ");throw new S("REFRACT_E_AUDIT",`refract audit: ${b.length} pairing(s) fail WCAG ${p.minWcag} — ${e}. Adjust the colour(s), lower --min-wcag, or drop --strict to report without failing.`,b.map(e=>`${e.label} (${e.wcagRatio}:1, ${e.wcagLevel})`))}return y},jr=new Set(["recipes"]),Ar=e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&!("base"in e)&&Array.isArray(e.modifiers),Er=e=>{if("object"!=typeof e||null===e||Array.isArray(e)||!e.variants)return{value:e,specs:{}};const t=e.variants,r={},n={};for(const[e,o]of Object.entries(t))Ar(o)?r[e]=o:n[e]=o;if(!Object.keys(r).length)return{value:e,specs:r};const o=Object.keys(n).length?n:void 0;return{value:{...e,variants:o},specs:r}},Rr={key:"colors",derivations:{lighten:(e,t)=>pt(String(e),Number(t)),darken:(e,t)=>mt(String(e),Number(t)),alpha:(e,t)=>yt(String(e),Number(t)),setL:(e,t)=>gt(String(e),Number(t)),rotateHue:(e,t)=>ht(String(e),Number(t)),adjust:(e,t)=>bt(String(e),t)},normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(jr.has(n))continue;const{value:e,specs:i}=Er(o),s=be(e,{propertyPath:`colors.${n}`,allowedBreakpoints:t.allowedBreakpoints,coerceValue:At}),a=Tt(n,s,i);le(a,{propertyPath:`colors.${n}`}),r[n]=a}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>{const n=`${r.groupPath}.${e}`;return{base:Gt(t.base,r,n),responsive:t.responsive.map(e=>{const{breakpoint:t,query:o,state:i,variant:s,target:a,orientation:l,container:c,size:u,...d}=e,f={declarations:{...s?{...r.resolveRecipeVariant(s).base}:{},...Gt(d,r,`${n}.responsive`)}};return t&&(f.breakpoint=t,f.query=null!=o?o:"exact"),c&&(f.container=c,u&&(f.size=u),f.query=null!=o?o:"min"),i&&(f.state=i),l&&(f.orientation=l),a&&(f.target=a),f})}})(e,t,r)},Sr={"minor-second":1.067,"major-second":1.125,"minor-third":1.2,"major-third":1.25,"perfect-fourth":1.333,"augmented-fourth":1.414,"perfect-fifth":1.5,golden:1.618},Or={xs:-2,sm:-1,md:0,lg:1,xl:2,"2xl":3,"3xl":4,"4xl":5},Cr=(e,t)=>"fontSize"!==e?t:Tr(t),Tr=e=>{var t,r,n,o;const i=e.ratio;if(!i)return e;const s=Sr[i];if(!s)return e;const a=null!==(t=e.baseFontSize)&&void 0!==t?t:e.base,l=null!==(r=e.precision)&&void 0!==r?r:4,c=e.algorithm,u=null!==(n=e.variants)&&void 0!==n?n:{},d={};let f=null;for(const[e,t]of Object.entries(Or)){if(u[e]){f=null!==(o=u[e].base)&&void 0!==o?o:null;continue}let r;r=c?c(a,e,t,f):a*Math.pow(s,t);const n=Number(r.toFixed(l));f=n,d[e]={base:n}}return{...e,variants:{...d,...u}}},Fr=new Set(["breakpoint","query","state","variant","target","orientation"]),_r={fontFamily:"font-family",fontSize:"font-size",fontWeight:"font-weight",lineHeight:"line-height",letterSpacing:"letter-spacing",fontStyle:"font-style",textTransform:"text-transform",textDecoration:"text-decoration",textAlign:"text-align"},Nr=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(!n||Fr.has(r))continue;const e=_r[r];e&&(t[e]={ref:Pr(r,n)})}return t},Pr=(e,t)=>"base"===t?`typography.${e}`:`typography.${e}.${t}`,zr=new Set(["recipes"]),qr={key:"typography",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(zr.has(n))continue;const e=be(o,{propertyPath:`typography.${n}`,allowedBreakpoints:t.allowedBreakpoints}),i=Cr(n,e);le(i,{propertyPath:`typography.${n}`}),r[n]=i}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:Nr(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:i,target:s,orientation:a,container:l,size:c,...u}=e,d={declarations:{...i?{...r.resolveRecipeVariant(i).base}:{},...Nr(u)}};return t&&(d.breakpoint=t,d.query=null!=n?n:"exact"),l&&(d.container=l,c&&(d.size=c),d.query=null!=n?n:"min"),o&&(d.state=o),s&&(d.target=s),a&&(d.orientation=a),d})}))(0,t,r)},Mr=["spacing","gutters","aspectRatio","sizes"],Ir=new Set(["spacing","gutters","sizes"]),Lr=new Set(["spacing","gutters"]),Br=["xs","sm","md","lg","xl","2xl","3xl","4xl"],Ur=e=>Number(e.toFixed(4)),Vr=(e,t)=>{var r;if(!Ir.has(e))return t;const n=((e,t)=>{const r=t,n=void 0!==r.ratio,o=void 0!==r.step;if(!n&&!o)return;if(n&&o)throw new S("REFRACT_E_LAYOUT",`layout.${e}: declare only one of "ratio" (geometric) or "step" (linear) scale, not both.`);const i=r.steps;if(n){let t;if(void 0===i)t=Br;else{if(!Array.isArray(i))throw new S("REFRACT_E_LAYOUT",`layout.${e}: a geometric scale ("ratio") needs "steps" as an ordered name array, e.g. ["sm","md","lg"].`);t=i.map(String)}const n=t.map((e,t)=>({name:e,exp:t}));return{curve:"geometric",ratio:Number(r.ratio),specs:n}}let s;if(void 0===i)s=Br.map((e,t)=>({name:e,exp:t,mult:t+1}));else{if(Array.isArray(i)||"object"!=typeof i||null===i)throw new S("REFRACT_E_LAYOUT",`layout.${e}: a linear scale ("step") needs "steps" as a name→multiplier map, e.g. { sm:1, md:2, lg:3 }.`);s=Object.entries(i).map(([e,t],r)=>({name:e,exp:r,mult:Number(t)}))}return{curve:"linear",step:Number(r.step),specs:s}})(e,t);if(!n)return Lr.has(e)?Dr(t):t;const o=((e,t,r)=>{const n=`layout.${e}`,o={};for(const e of r.specs)if("geometric"===r.curve){const i=Ur(Number(t)*Math.pow(r.ratio,e.exp));o[e.name]={base:i,derive:{ref:n,fn:"scaleStep",arg:{curve:"geometric",ratio:r.ratio,exp:e.exp}}}}else{const t=Ur(r.step*e.mult);o[e.name]={base:t,derive:{ref:n,fn:"scaleStep",arg:{curve:"linear",step:r.step,mult:e.mult}}}}return o})(e,t.base,n);let i={...o,...null!==(r=t.variants)&&void 0!==r?r:{}};Lr.has(e)&&(i={...i,none:{base:0}});const s=((e,t,r,n)=>{if(!(null==r?void 0:r.length))return r;const o=`layout.${e}`,i=[];let s=!1;for(const a of r){const r=a;if(void 0===r.ratio&&void 0===r.step){i.push(r);continue}if(s=!0,void 0!==r.ratio&&void 0!==r.step)throw new S("REFRACT_E_LAYOUT",`layout.${e}: a responsive ramp entry may set only "ratio" or "step", not both.`);if(!n)throw new S("REFRACT_E_LAYOUT",`layout.${e}: a responsive ramp entry needs a base scale — declare a top-level "ratio"/"step" (+ "steps") first.`);const{breakpoint:l,query:c,orientation:u}=r,d=void 0!==r.ratio;for(const s of n.specs){let n,a;if(d){const e=Number(r.ratio),o=void 0!==r.base,i=Number(o?r.base:t);n=Ur(i*Math.pow(e,s.exp)),a={curve:"geometric",ratio:e,exp:s.exp,...o?{base:i}:{}}}else{if(void 0===s.mult)throw new S("REFRACT_E_LAYOUT",`layout.${e}: a linear responsive ramp ("step") requires a linear base scale (a name→multiplier "steps").`);const t=Number(r.step);n=Ur(t*s.mult),a={curve:"linear",step:t,mult:s.mult}}const f={breakpoint:l,query:c,target:s.name,base:n,derive:{ref:o,fn:"scaleStep",arg:a}};void 0!==u&&(f.orientation=u),i.push(f)}}return s?i:r})(e,t.base,t.responsive,n);return(e=>{const{ratio:t,step:r,steps:n,...o}=e;return o})({...t,variants:i,responsive:s})},Dr=e=>{var t;const r=null!==(t=e.variants)&&void 0!==t?t:{};return{...e,variants:{...r,none:{base:0}}}},Wr=new Set(["breakpoint","query","state","variant","target","orientation"]),Hr={paddingY:["padding-top","padding-bottom"],paddingX:["padding-left","padding-right"],marginY:["margin-top","margin-bottom"],marginX:["margin-left","margin-right"],gap:["gap"],background:["background"],width:["width"],minWidth:["min-width"],maxWidth:["max-width"],height:["height"],minHeight:["min-height"],maxHeight:["max-height"]},Gr={paddingY:"spacing",paddingX:"spacing",marginY:"spacing",marginX:"spacing",gap:"spacing",width:"sizes",minWidth:"sizes",maxWidth:"sizes",height:"sizes",minHeight:"sizes",maxHeight:"sizes",background:"literal"},Yr=(e,t)=>"base"===t?`layout.${e}`:`layout.${e}.${t}`,Jr=(e,t)=>{const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Wr.has(n))continue;if(!o)continue;const e=Hr[n];if(!e)throw new S("REFRACT_E_LAYOUT",`Unknown layout recipe property "${n}" in ${t}. Known verbs: ${Object.keys(Hr).join(", ")}. For arbitrary CSS use a component \`css\` delta.`);const i=Gr[n];for(const t of e)r[t]="literal"===i?{value:o}:{ref:Yr(i,o)}}return r},Kr=e=>({ref:"base"===e?"layout.spacing":`layout.spacing.${e}`}),Xr=e=>({ref:"base"===e?"layout.gutters":`layout.gutters.${e}`}),Zr=e=>({ref:`layout.${e}`}),Qr=e=>({value:e}),en=e=>Object.keys(e).sort((t,r)=>e[t]-e[r]),tn=[["templateColumns","grid-template-columns"],["templateRows","grid-template-rows"],["autoRows","grid-auto-rows"],["autoColumns","grid-auto-columns"],["justifyItems","justify-items"],["alignItems","align-items"],["justifyContent","justify-content"],["alignContent","align-content"]],rn=(e,t)=>{const r={};t&&(r.display=Qr("grid"));for(const[t,n]of tn){const o=e[t];o&&(r[n]=Qr(o))}return e.gap&&(r.gap=Kr(e.gap)),r},nn=e=>{var t,r;if(!e||"string"==typeof e)return{mode:null!==(t=e)&&void 0!==t?t:"fixed"};const n=e;return{mode:null!==(r=n.base)&&void 0!==r?r:"fixed",inset:n.inset,gutter:n.gutter,direction:n.direction,align:n.align,justify:n.justify,maxWidth:n.maxWidth}},on=(e,t,r=new Set,n)=>{var o,i,s,a;const l=Ge(n),c=e=>Ye(e,l),u={},d={},f=en(t),p=e&&"object"==typeof e?e:void 0,m=p?{mode:null!==(o=p.base)&&void 0!==o?o:"fixed",inset:p.inset,gutter:p.gutter,direction:p.direction,align:p.align,justify:p.justify,maxWidth:p.maxWidth}:nn(null!=e?e:"fixed"),g=null!==(i=null==p?void 0:p.variants)&&void 0!==i?i:{},h=null!==(s=null==p?void 0:p.responsive)&&void 0!==s?s:[],b=e=>e?`container-${e}`:"container",v=(e,n)=>{var o,i,s,a,l,p,g,h,v;const y=e?`--${e}`:"",w=`container${y}--inset`,k=`container${y}--gutter`,$=null!==(i=null!==(o=n.inset)&&void 0!==o?o:m.inset)&&void 0!==i?i:"base",x=null!==(s=n.gutter)&&void 0!==s?s:m.gutter,j=null!==(l=null!==(a=n.mode)&&void 0!==a?a:m.mode)&&void 0!==l?l:"fixed",A=null!==(p=n.direction)&&void 0!==p?p:m.direction,E=null!==(g=n.align)&&void 0!==g?g:m.align,R=null!==(h=n.justify)&&void 0!==h?h:m.justify,S=null!==(v=n.maxWidth)&&void 0!==v?v:e?m.maxWidth:void 0;u[w]={base:Kr($)},x&&(u[k]={base:Xr(x)});const O={"box-sizing":Qr("border-box"),width:Qr("100%"),"margin-left":Qr("auto"),"margin-right":Qr("auto"),"padding-left":Zr(w),"padding-right":Zr(w)};x&&(O.gap=Zr(k)),A&&(O.display=Qr("flex"),O["flex-direction"]=Qr(A)),E&&(O["align-items"]=Qr(E)),R&&(O["justify-content"]=Qr(R));const C=[];if("fixed"===j){const e="string"==typeof S&&void 0!==t[S]?S:void 0,r=e?f.indexOf(e):-1;for(let n=0;n<f.length;n++){const o=f[n],i=t[r>=0&&n>r?e:o];0!==i?0===n?O["max-width"]=Qr(c(i)):C.push({breakpoint:o,query:"min",declarations:{"max-width":Qr(c(i))}}):0===n&&(O["max-width"]=Qr("none"))}}else"fluid"===j?void 0!==S&&(O["max-width"]=((e,t,r)=>{return"number"==typeof e?Qr(`${e}px`):t.has(e)?{ref:"base"===(n=e)?"layout.sizes":`layout.sizes.${n}`}:void 0!==r[e]?Qr(`${r[e]}px`):Qr(e);var n})(S,r,t)):O["max-width"]=Qr("number"==typeof j?`${j}px`:j);d[b(e)]={kind:"recipe",declarations:O,overrides:C}};v(null,m);for(const[e,t]of Object.entries(g))v(e,nn(t));for(const e of h){const t=e.target,r=b(null!=t?t:null),n=d[r];if(!n)continue;const o={};if(e.direction&&(o["flex-direction"]=Qr(e.direction)),e.align&&(o["align-items"]=Qr(e.align)),e.justify&&(o["justify-content"]=Qr(e.justify)),e.inset){const e=t?`container--${t}--inset`:"container--inset";o["padding-left"]=Zr(e),o["padding-right"]=Zr(e)}if(e.gutter){const e=t?`container--${t}--gutter`:"container--gutter";o.gap=Zr(e)}Object.keys(o).length&&n.overrides.push({breakpoint:e.breakpoint,query:null!==(a=e.query)&&void 0!==a?a:"exact",declarations:o})}return{ruleSetGroups:{container:d},configProperties:u}},sn=(e,t,r)=>{const n={},o={},i=e=>{e&&(Object.assign(n,e.ruleSetGroups),Object.assign(o,e.configProperties))};return i(((e,t)=>{var r,n;if(!e)return;const o="number"==typeof e?{size:e}:e,i=o.size,s=null!==(r=o.gutter)&&void 0!==r?r:"base",a=null!==(n=o.inset)&&void 0!==n?n:"none",l={"columns--size":{base:Qr(String(i))},"columns--gutter":{base:Xr(s)},"columns--inset":{base:Kr(a)}},c={},u=Array.from({length:i},(e,t)=>t+1);for(const e of en(t))for(const r of u){const n=`col-${e}-${r}`,o=`offset-${e}-${r}`,i={"grid-column-end":Qr(`span ${r}`)},s={"grid-column-start":Qr(String(r+1))};0===t[e]?(c[n]={kind:"utility",declarations:i,overrides:[]},c[o]={kind:"utility",declarations:s,overrides:[]}):(c[n]={kind:"utility",declarations:{},overrides:[{breakpoint:e,query:"min",declarations:i}]},c[o]={kind:"utility",declarations:{},overrides:[{breakpoint:e,query:"min",declarations:s}]})}return{ruleSetGroups:{columns:c},configProperties:l}})(e.columns,t)),i((e=>{var t,r;if(!e||!Object.keys(e).length)return;const n={};for(const[o,i]of Object.entries(e)){const e=rn(i,!0),s=[];for(const e of null!==(t=i.responsive)&&void 0!==t?t:[]){const t=rn(e,!1);Object.keys(t).length&&s.push({breakpoint:e.breakpoint,query:null!==(r=e.query)&&void 0!==r?r:"exact",declarations:t})}n[`grid-${o}`]={kind:"recipe",declarations:e,overrides:s}}return{ruleSetGroups:{grids:n},configProperties:{}}})(e.grids)),i((e=>{var t,r,n;if(!e||!Object.keys(e).length)return;const o={};for(const[i,s]of Object.entries(e)){const e={display:Qr(s.inline?"inline-flex":"flex"),"flex-direction":Qr(null!==(t=s.direction)&&void 0!==t?t:"column")};s.align&&(e["align-items"]=Qr(s.align)),s.justify&&(e["justify-content"]=Qr(s.justify)),s.wrap&&(e["flex-wrap"]=Qr(s.wrap)),s.gap&&(e.gap=Kr(s.gap));const a=[];for(const e of null!==(r=s.responsive)&&void 0!==r?r:[]){const t={};void 0!==e.inline&&(t.display=Qr(e.inline?"inline-flex":"flex")),e.direction&&(t["flex-direction"]=Qr(e.direction)),e.align&&(t["align-items"]=Qr(e.align)),e.justify&&(t["justify-content"]=Qr(e.justify)),e.wrap&&(t["flex-wrap"]=Qr(e.wrap)),Object.keys(t).length&&a.push({breakpoint:e.breakpoint,query:null!==(n=e.query)&&void 0!==n?n:"exact",declarations:t})}o[`stack-${i}`]={kind:"recipe",declarations:e,overrides:a}}return{ruleSetGroups:{stacks:o},configProperties:{}}})(e.stacks)),i(on(e.container,t,(e=>{const t=new Set;if(e&&"object"==typeof e&&!Array.isArray(e)){const r=e;"base"in r&&t.add("base");const n=r.variants;if(n&&"object"==typeof n)for(const e of Object.keys(n))t.add(e)}return t})(e.sizes),r)),{ruleSetGroups:n,configProperties:o}},an=new Set(Mr),ln={key:"layout",derivations:{scaleStep:(e,t)=>((e,t)=>{const r=null!=t?t:{};if("linear"===r.curve)return Ur(Number(r.step)*Number(r.mult));const n=void 0!==r.base?Number(r.base):Number(e);return Ur(n*Math.pow(Number(r.ratio),Number(r.exp)))})(e,t)},normalizeProperties(e,t){const r={};if(!e)return r;for(const n of Mr){const o=e[n];if(void 0===o||!an.has(n))continue;const i=be(o,{propertyPath:`layout.${n}`,allowedBreakpoints:t.allowedBreakpoints}),s=Vr(n,i);le(s,{propertyPath:`layout.${n}`}),r[n]=s}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>{var n;const o=`${null!==(n=r.groupPath)&&void 0!==n?n:"layout.recipes"}.${e}`;return{base:Jr(t.base,o),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:i,variant:s,target:a,orientation:l,container:c,size:u,...d}=e,f={declarations:{...s?{...r.resolveRecipeVariant(s).base}:{},...Jr(d,o)}};return t&&(f.breakpoint=t,f.query=null!=n?n:"exact"),c&&(f.container=c,u&&(f.size=u),f.query=null!=n?n:"min"),i&&(f.state=i),a&&(f.target=a),l&&(f.orientation=l),f})}})(e,t,r),buildStructural:(e,t)=>sn(e,t.breakpoints,t.mediaConfig)},cn=new Set(["breakpoint","query","state","variant","target","orientation"]),un={boxShadow:"box-shadow",opacity:"opacity",blur:"filter",transition:"transition",zIndex:"z-index"},dn={boxShadow:"shadow",opacity:"opacity",blur:"blur",transition:"transitions",zIndex:"zIndex"},fn=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(!n||cn.has(r))continue;const e=un[r],o=dn[r];if(!e||!o)continue;const i={ref:pn(o,n)};"blur"===r&&(i.wrap="blur"),t[e]=i}return t},pn=(e,t)=>"base"===t?`effects.${e}`:`effects.${e}.${t}`,mn=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),gn=(e,t)=>{if(void 0!==e){if("number"!=typeof e||Number.isNaN(e))throw new S("REFRACT_E_EFFECTS",`${t} must be a number, received ${JSON.stringify(e)}.`);return e}},hn=(e,t)=>{if(void 0!==e){if("number"==typeof e){if(Number.isNaN(e))throw new S("REFRACT_E_EFFECTS",`${t} must be a number or length string, received ${JSON.stringify(e)}.`);return e}if("string"==typeof e){const r=J(e);if("raw"in r)throw new S("REFRACT_E_EFFECTS",`${t} must be a number or a <number><unit> length (received ${JSON.stringify(e)}).`);return void 0===r.unit?r.value:{value:r.value,unit:r.unit}}throw new S("REFRACT_E_EFFECTS",`${t} must be a number or length string, received ${JSON.stringify(e)}.`)}},bn=new Set(["offsetX","offsetY","blur","spread","color","inset"]),vn=(e,t)=>{if(!mn(e))throw new S("REFRACT_E_EFFECTS",`${t} must be a shadow-layer object, received ${JSON.stringify(e)}.`);for(const r of Object.keys(e))if(!bn.has(r))throw new S("REFRACT_E_EFFECTS",`${t} has unknown shadow field "${r}" (allowed: ${[...bn].join(", ")}).`);const r={},n=hn(e.offsetX,`${t}.offsetX`),o=hn(e.offsetY,`${t}.offsetY`),i=hn(e.blur,`${t}.blur`),s=hn(e.spread,`${t}.spread`);if(void 0!==n&&(r.offsetX=n),void 0!==o&&(r.offsetY=o),void 0!==i&&(r.blur=i),void 0!==s&&(r.spread=s),void 0!==e.color){if("string"!=typeof e.color||!e.color)throw new S("REFRACT_E_EFFECTS",`${t}.color must be a "colors.*" token-path string.`);r.color=e.color}if(void 0!==e.inset){if("boolean"!=typeof e.inset)throw new S("REFRACT_E_EFFECTS",`${t}.inset must be a boolean.`);e.inset&&(r.inset=!0)}return r},yn=new Set(["property","duration","timingFunction","delay"]),wn=(e,t)=>{if(!mn(e))throw new S("REFRACT_E_EFFECTS",`${t} must be a transition-part object, received ${JSON.stringify(e)}.`);for(const r of Object.keys(e))if(!yn.has(r))throw new S("REFRACT_E_EFFECTS",`${t} has unknown transition field "${r}" (allowed: ${[...yn].join(", ")}).`);if("string"!=typeof e.property||!e.property)throw new S("REFRACT_E_EFFECTS",`${t}.property is required (the CSS property to transition).`);const r={property:e.property},n=gn(e.duration,`${t}.duration`),o=gn(e.delay,`${t}.delay`);if(void 0!==n&&(r.duration=n),void 0!==e.timingFunction){if("string"!=typeof e.timingFunction||!e.timingFunction)throw new S("REFRACT_E_EFFECTS",`${t}.timingFunction must be a keyword or cubic-bezier(...) string.`);r.timingFunction=e.timingFunction}return void 0!==o&&(r.delay=o),r},kn=new Set(["recipes"]),$n={shadow:["offsetX","offsetY","blur","spread","color","inset"],transitions:["property","duration","timingFunction","delay"]},xn=e=>"shadow"===e?t=>((e,t="effects.shadow")=>{if("string"==typeof e){if("none"===e)return"none";throw new S("REFRACT_E_EFFECTS",`${t} must be structured shadow layer(s) or "none" — raw CSS strings are not accepted (received ${JSON.stringify(e)}).`)}if(Array.isArray(e)){if(!e.length)throw new S("REFRACT_E_EFFECTS",`${t} is an empty shadow-layer array.`);return e.map((e,r)=>vn(e,`${t}[${r}]`))}return[vn(e,t)]})(t,`effects.${e}`):"transitions"===e?t=>((e,t="effects.transitions")=>{if("string"==typeof e){if("none"===e)return"none";throw new S("REFRACT_E_EFFECTS",`${t} must be structured transition part(s) or "none" — raw CSS strings are not accepted (received ${JSON.stringify(e)}).`)}if(Array.isArray(e)){if(!e.length)throw new S("REFRACT_E_EFFECTS",`${t} is an empty transition-part array.`);return e.map((e,r)=>wn(e,`${t}[${r}]`))}return[wn(e,t)]})(t,`effects.${e}`):void 0,jn={key:"effects",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(kn.has(n))continue;const e=$n[n],i=xn(n),s=be(o,{propertyPath:`effects.${n}`,allowedBreakpoints:t.allowedBreakpoints,...e?{leafFields:e}:{},...i?{coerceValue:i}:{},...e?{fallbackBase:"none"}:{}});le(s,{propertyPath:`effects.${n}`}),r[n]=s}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:fn(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:i,target:s,orientation:a,container:l,size:c,...u}=e,d={declarations:{...i?{...r.resolveRecipeVariant(i).base}:{},...fn(u)}};return t&&(d.breakpoint=t,d.query=null!=n?n:"exact"),l&&(d.container=l,c&&(d.size=c),d.query=null!=n?n:"min"),o&&(d.state=o),s&&(d.target=s),a&&(d.orientation=a),d})}))(0,t,r)},An=new Set(["breakpoint","query","state","variant","target","orientation","container","size"]),En=new Set(["as","side"]),Rn=new Set(["width","style","offset","radius","color"]),Sn=(e,t,r)=>"radius"===r?"border-radius":"offset"===r?"outline-offset":"outline"===e?`outline-${r}`:t?`border-${t}-${r}`:`border-${r}`,On=(e,t)=>"color"===e?{ref:t}:{ref:"base"===t?`borders.${e}`:`borders.${e}.${t}`},Cn=(e,t,r)=>{const n={};if(!e)return n;for(const[o,i]of Object.entries(e))i&&!An.has(o)&&!En.has(o)&&Rn.has(o)&&(n[Sn(t,r,o)]=On(o,i));return n},Tn=new Set(["recipes"]),Fn={key:"borders",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Tn.has(n))continue;const e=be(o,{propertyPath:`borders.${n}`,allowedBreakpoints:t.allowedBreakpoints});le(e,{propertyPath:`borders.${n}`}),r[n]=e}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>{var n;const o=null!==(n=t.base.as)&&void 0!==n?n:"border",i=t.base.side,s=Cn(t.base,o,i),a=t.responsive.map(e=>{var t,n;const{breakpoint:s,query:a,state:l,variant:c,target:u,orientation:d,container:f,size:p,as:m,side:g,...h}=e,b=null!==(t=m)&&void 0!==t?t:o,v=null!==(n=g)&&void 0!==n?n:i,y={declarations:{...c?{...r.resolveRecipeVariant(c).base}:{},...Cn(h,b,v)}};return s&&(y.breakpoint=s,y.query=null!=a?a:"exact"),f&&(y.container=f,p&&(y.size=p),y.query=null!=a?a:"min"),l&&(y.state=l),d&&(y.orientation=d),u&&(y.target=u),y});return{base:s,responsive:a}})(0,t,r)},_n=new Set(["breakpoint","query","state","variant","target","orientation"]),Nn={keyframes:"animation-name",duration:"animation-duration",easing:"animation-timing-function",delay:"animation-delay",iterationCount:"animation-iteration-count",direction:"animation-direction",fillMode:"animation-fill-mode",playState:"animation-play-state"},Pn={duration:"duration",easing:"easing",delay:"delay"},zn=(e,t)=>"base"===t?`animation.${e}`:`animation.${e}.${t}`,qn=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(void 0===n||""===n||_n.has(r))continue;const e=Nn[r];e&&(t[e]="keyframes"===r?{ref:`animation.keyframes.${n}`}:Pn[r]?{ref:zn(Pn[r],String(n))}:{value:n})}return t},Mn=new Set(["keyframes","recipes"]),In=e=>e&&"object"==typeof e&&"ref"in e?{ref:String(e.ref)}:"string"==typeof e||"number"==typeof e?{value:e}:void 0,Ln=e=>{const t={};for(const[r,n]of Object.entries(e)){const e=In(n);e&&(t[r]=e)}return t},Bn=e=>{const t=[];for(const[r,n]of Object.entries(e))t.push({stop:r,declarations:Ln(n)});return{steps:t}},Un=e=>{if(!e||"object"!=typeof e)return{};const t={};for(const[r,n]of Object.entries(e))n&&"object"==typeof n&&(t[r]=Bn(n));return t},Vn={key:"animation",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Mn.has(n))continue;const e=be(o,{propertyPath:`animation.${n}`,allowedBreakpoints:t.allowedBreakpoints});le(e,{propertyPath:`animation.${n}`}),r[n]=e}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:qn(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:i,target:s,orientation:a,container:l,size:c,...u}=e,d={declarations:{...i?{...r.resolveRecipeVariant(i).base}:{},...qn(u)}};return t&&(d.breakpoint=t,d.query=null!=n?n:"exact"),l&&(d.container=l,c&&(d.size=c),d.query=null!=n?n:"min"),o&&(d.state=o),s&&(d.target=s),a&&(d.orientation=a),d})}))(0,t,r),buildStructural:e=>({ruleSetGroups:{},configProperties:{},keyframes:Un(e.keyframes)})},Dn=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e))t[Hn(r)]=Wn(n);return t},Wn=e=>"object"==typeof e?{ref:e.ref}:{value:e},Hn=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Gn={key:"components",normalizeProperties:()=>({}),interpretRecipe:(e,t,r)=>((e,t)=>({base:Dn(t.base.css),responsive:t.responsive.map(e=>{var t,r;const n=e,o={declarations:Dn(n.css)};return n.breakpoint&&(o.breakpoint=n.breakpoint,o.query=null!==(t=n.query)&&void 0!==t?t:"exact"),n.container&&(o.container=n.container,n.size&&(o.size=n.size),o.query=null!==(r=n.query)&&void 0!==r?r:"min"),n.state&&(o.state=n.state),n.orientation&&(o.orientation=n.orientation),n.target&&(o.target=n.target),o})}))(0,t),extractReferences:e=>(e=>{const t=[];for(const[r,n]of Object.entries(e))U.has(r)&&"string"==typeof n&&n.includes(".")&&t.push(`${r}:${n}`);return t})(e)},Yn=e=>({value:e}),Jn=e=>({ref:e}),Kn=(e,t)=>({kind:"reset",selector:e,declarations:t,overrides:[]}),Xn=e=>{const t={};for(const[r,n,o]of e){const e={};for(const[t,r]of Object.entries(o))e[t]=Yn(r);t[r]=Kn(n,e)}return t},Zn=[["h1","4xl"],["h2","3xl"],["h3","2xl"],["h4","xl"],["h5","lg"],["h6","md"]],Qn={preflight:{static:[["box","*,::before,::after",{"box-sizing":"border-box","border-width":"0","border-style":"solid"}],["body","body",{margin:"0","line-height":"inherit"}],["headings","h1,h2,h3,h4,h5,h6",{"font-size":"inherit","font-weight":"inherit",margin:"0"}],["blocks","p,figure,blockquote,dl,dd",{margin:"0"}],["lists","ul,ol",{"list-style":"none",margin:"0",padding:"0"}],["media","img,picture,video,canvas,svg",{display:"block","max-width":"100%"}],["forms","button,input,select,textarea",{font:"inherit",color:"inherit"}],["anchors","a",{color:"inherit","text-decoration":"inherit"}]],headings:!0},normalize:{static:[["box","*,::before,::after",{"box-sizing":"border-box"}],["body","body",{margin:"0"}],["media","img,picture,video,canvas,svg",{"max-width":"100%"}]],headings:!1},reset:{static:[["box","*,::before,::after",{"box-sizing":"border-box"}],["all","*",{margin:"0",padding:"0",border:"0",font:"inherit","vertical-align":"baseline"}],["headings","h1,h2,h3,h4,h5,h6",{"font-size":"inherit","font-weight":"inherit"}],["lists","ul,ol",{"list-style":"none"}],["media","img,picture,video,canvas,svg",{display:"block","max-width":"100%"}]],headings:!0}},eo=Object.keys(Qn),to=e=>{if(!1===e)return{};const t=Qn[e];if(!t)throw new S("REFRACT_E_PRESET",`globals: unknown preset "${e}" — expected one of ${eo.join(", ")} or false`);const r={static:Xn(t.static)};return t.headings&&(r.defaults=(()=>{const e={};for(const[t,r]of Zn)e[t]=Kn(t,{"font-size":Jn(`typography.fontSize.${r}`)});return e})()),r},ro=new Set(["state","breakpoint","query","orientation","container","size","variant","target"]),no=e=>null!==e&&"object"==typeof e?{ref:e.ref}:{value:e},oo=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),io=e=>{const t={};for(const[r,n]of Object.entries(e))null==n||ro.has(r)||(t[oo(r)]=no(n));return t},so=e=>{const t={declarations:io(e)},r=e;for(const e of ro)void 0!==r[e]&&(t[e]=r[e]);return t},ao=(e,t,r)=>(e=>({declarations:io(e.base),overrides:e.responsive.map(so)}))(Oe({[e]:t},r)[e]),lo=(e,t)=>{const r=null!=e?e:{},n={};if(void 0!==r.preset){const e=to(r.preset);e.static&&(n.static=e.static),e.defaults&&(n.defaults=e.defaults)}const o=((e,t)=>{if(!e||!Object.keys(e).length)return;const r=Object.keys(t.breakpoints),n={};for(const[o,i]of Object.entries(e)){if(!i||"object"!=typeof i)continue;const e={propertyPath:`globals.elements.${o}`,allowedBreakpoints:r,allowedStates:t.allowedStates,allowedContainers:t.allowedContainers},{variants:s,...a}=i,l=ao(o,a,e),c={kind:"globals",selector:o,declarations:l.declarations,overrides:l.overrides};if(s&&"object"==typeof s&&Object.keys(s).length){const t={};for(const[r,n]of Object.entries(s))n&&"object"==typeof n&&(t[r]=ao(r,n,{...e,propertyPath:`${e.propertyPath}.variants.${r}`}));Object.keys(t).length&&(c.variants=t)}n[o]=c}return Object.keys(n).length?n:void 0})(r.elements,t);return o&&(n.elements=o),n},co=[Rr,qr,ln,jn,Fn,Vn,Gn,{key:"globals",normalizeProperties:()=>({}),buildStructural:(e,t)=>({ruleSetGroups:lo(e,t),configProperties:{}})}];const uo=(e,t)=>Ve(e,e=>Je(e,Ge(t))),fo=e=>{var t;if(!e||"object"!=typeof e)return;const r={};for(const[n,o]of Object.entries(e))o&&"object"==typeof o&&o.sizes&&Object.keys(o.sizes).length&&(r[n]={type:null!==(t=o.type)&&void 0!==t?t:"inline-size",sizes:{...o.sizes}});return Object.keys(r).length?r:void 0},po=e=>{if(!e)return;const t=new Map;for(const[r,n]of Object.entries(e))t.set(r,new Set(Object.keys(n.sizes)));return t},mo=(e,t)=>{if(e.startsWith("--"))return e;const r=e.split(".").join("-").toLowerCase();return t?`--${t}-${r}`:`--${r}`};function go(e,t,r){const{clean:n,externals:o}=((e,t)=>{if(!e)return{clean:e,externals:{}};const r={},n={};for(const[o,i]of Object.entries(e))if(null===i||"object"!=typeof i||Array.isArray(i)||"string"!=typeof i.external)r[o]=i;else{const e=mo(i.external,t);n[o]={base:`var(${e})`,external:e,responsive:[]}}return{clean:r,externals:n}})(t,r.extendsPrefix),i=e.normalizeProperties(n,{allowedBreakpoints:r.allowedBreakpoints});Object.assign(i,o);const s=r.inheritedProperties?{...r.inheritedProperties,...i}:i,a=function(e,t,r){var n,o;if(!e.interpretRecipe||!t||!Object.keys(t).length)return{};const i={};for(const[s,a]of Object.entries(t)){const t=`${e.key}.recipes.${s}`,l=Oe(a,{propertyPath:t,allowedBreakpoints:r.allowedBreakpoints,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers}),c=Ne(l,(n,o,i)=>e.interpretRecipe(n,o,{breakpoints:r.breakpoints,media:r.media,properties:r.properties,resolveRecipeVariant:i,groupPath:t}),{groupPath:t}),u=c.resolveAll(),d={};for(const[t,r]of Object.entries(u))if(e.extractReferences){const i=e.extractReferences(null!==(o=null===(n=l[t])||void 0===n?void 0:n.base)&&void 0!==o?o:{});d[t]=B(r,i)}else d[t]=L(r);i[s]=d}return i}(e,null==t?void 0:t.recipes,{breakpoints:r.breakpoints,media:r.media,properties:s,allowedBreakpoints:r.allowedBreakpoints,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers});let l,c,u=a;if(e.buildStructural&&t){const n=e.buildStructural(t,{breakpoints:r.breakpoints,media:r.media,mediaConfig:r.mediaConfig,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers});u={...n.ruleSetGroups,...a},Object.keys(n.configProperties).length&&(l=n.configProperties),n.keyframes&&Object.keys(n.keyframes).length&&(c=n.keyframes)}const d={};return Object.keys(i).length&&(d.properties=i),Object.keys(u).length&&(d.ruleSetGroups=u),l&&(d.extraProperties=l),c&&(d.keyframes=c),d}function ho(e){const t={};if(!(null==e?void 0:e.properties))return t;for(const[r,n]of Object.entries(e.properties)){const e={base:n.base.value};if(n.variants&&Object.keys(n.variants).length){const t={};for(const[e,r]of Object.entries(n.variants)){const n={base:r.base.value};if(r.extras)for(const[e,t]of Object.entries(r.extras))n[e]=t.value;t[e]=n}e.variants=t}if(n.extras)for(const[t,r]of Object.entries(n.extras))e[t]=r.value;t[r]=e}return t}function bo(e,t){var r,n,o,i,s;if(!e)return t;const a={...e};if(t.properties&&(a.properties={...null!==(r=e.properties)&&void 0!==r?r:{},...t.properties}),t.ruleSets){const r={...null!==(n=e.ruleSets)&&void 0!==n?n:{}};for(const[n,s]of Object.entries(t.ruleSets))r[n]={...null!==(i=null===(o=e.ruleSets)||void 0===o?void 0:o[n])&&void 0!==i?i:{},...s};a.ruleSets=r}return t.keyframes&&(a.keyframes={...null!==(s=e.keyframes)&&void 0!==s?s:{},...t.keyframes}),a}function vo(e,t){var r,n,o,i;const{adapter:s}=t,a=e,l=null!==(r=a.breakpoints)&&void 0!==r?r:Xe,c=Object.keys(l),u=null!==(o=null===(n=a.extends)||void 0===n?void 0:n.prefix)&&void 0!==o?o:"dt",d=s.allowedStates,f=new Set(null!==(i=a.modes)&&void 0!==i?i:["dark","light"]),p=t.media,m=uo(l,p),g=fo(a.containers),h=po(g),b={};for(const e of co){const t=go(e,a[e.key],{breakpoints:l,extendsPrefix:u,media:m,mediaConfig:p,allowedBreakpoints:c,allowedStates:d,allowedContainers:h});Object.keys(t).length&&(b[e.key]=t)}const v=(e=>{var t;const r={},n=D(e.colors);n&&(r.colors=n);const o=D(e.typography);o&&(r.typography=o);const i=D(e.layout);i&&(r.layout=i);const s=D(e.effects);s&&(r.effects=s);const a=D(e.borders);a&&(r.borders=a);const l=D(e.animation);l&&(r.animation=l),V(null===(t=e.components)||void 0===t?void 0:t.ruleSetGroups)&&(r.components={ruleSets:e.components.ruleSetGroups});const c=D(e.globals);c&&(r.globals=c);const u={breakpoints:e.breakpoints,subsystems:r};return e.containers&&Object.keys(e.containers).length&&(u.containers=e.containers),u})({breakpoints:l,containers:g,...b}),y={units:t.units,baseFontSize:t.baseFontSize},w=function(e,t){var r;const{propertiesOverlay:n,ruleSetsOverlay:o,keyframesOverlay:i,containersOverlay:s}=t;if(!(n||o||i||s))return e;const a={...e.subsystems},l=new Set([...Object.keys(null!=n?n:{}),...Object.keys(null!=o?o:{}),...Object.keys(null!=i?i:{})]);for(const e of l)a[e]=bo(a[e],{properties:null==n?void 0:n[e],ruleSets:null==o?void 0:o[e],keyframes:null==i?void 0:i[e]});const c={...e,subsystems:a};return s&&(c.containers={...null!==(r=e.containers)&&void 0!==r?r:{},...s}),c}(ie(v,y),t),k=(e=>{const t={};for(const r of e)for(const[e,n]of Object.entries(r)){if(e in t)throw new S("REFRACT_E_TOKEN_PATH",`Duplicate derivation fn "${e}" registered by two subsystems.`);t[e]=n}return t})(co.flatMap(e=>e.derivations?[e.derivations]:[])),$=Le(w,k),x=[...wo($),...ko($),...$o($),...yo($,f)];if(x.length>0){const e=x.map(e=>` - ${e}`).join("\n");throw new S("REFRACT_E_VALIDATION",`refract: ${x.length} validation error(s):\n${e}`,x)}return xo($,{adapter:s,derivationRegistry:k,allowedStates:d,mediaConfig:p,unitConfig:y})}function yo(e,t){var r,n,o;const i=[],s=(e,r,n,o)=>{t.has(n)||i.push(`${e}.${r}${o}: unknown appearance mode '${n}' — declare it in the top-level 'modes' registry (known: ${[...t].join(", ")})`)};for(const[t,i]of Object.entries(e.subsystems))for(const[e,a]of Object.entries(null!==(r=i.properties)&&void 0!==r?r:{})){for(const r of null!==(n=a.modes)&&void 0!==n?n:[])r.mode&&s(t,e,r.mode,"");for(const r of null!==(o=a.responsive)&&void 0!==o?o:[])r.mode&&s(t,e,r.mode," (responsive)")}return i}function wo(e){var t,r,n,o,i;const s=null===(t=e.subsystems.components)||void 0===t?void 0:t.ruleSets;if(!s)return[];const a=[];for(const[t,l]of Object.entries(s))for(const[s,c]of Object.entries(l))for(const l of null!==(r=c.references)&&void 0!==r?r:[]){const[r,c=""]=l.split(":"),u=c.indexOf("."),d=u>=0?c.slice(0,u):c,f=u>=0?c.slice(u+1):"";(null===(i=null===(o=null===(n=e.subsystems[r])||void 0===n?void 0:n.ruleSets)||void 0===o?void 0:o[d])||void 0===i?void 0:i[f])||a.push(`components.${t}.${s}: Recipe variant "${f}" is not defined in "${r}:${d}". Check the subsystem:group.variant reference against what the subsystem declares.`)}return a}function ko(e){var t,r;const n=null===(t=e.subsystems.components)||void 0===t?void 0:t.ruleSets;if(!n)return[];const o=W(e),i=[],s=(e,t,r,n)=>{for(const[s,a]of Object.entries(null!=e?e:{}))void 0===a.ref||a.ref in o||i.push(`components.${t}.${r}: css '${s}'${n} references unknown token '${a.ref}' — check the token path, or use a bare string / number for a raw CSS value`)};for(const[e,t]of Object.entries(n))for(const[n,o]of Object.entries(t)){s(o.declarations,e,n,"");for(const t of null!==(r=o.overrides)&&void 0!==r?r:[])s(t.declarations,e,n," (override)")}return i}function $o(e){var t,r,n,o,i;const s=null===(t=e.subsystems.globals)||void 0===t?void 0:t.ruleSets;if(!s)return[];const a=W(e),l=[],c=(e,t,r)=>{for(const[n,o]of Object.entries(null!=e?e:{}))void 0===o.ref||o.ref in a||l.push(`globals element '${t}'${r}: '${n}' references unknown token '${o.ref}' — check the token path, or use a bare string / number for a raw CSS value`)};for(const e of Object.values(s))for(const t of Object.values(e)){if("globals"!==t.kind)continue;const e=null!==(r=t.selector)&&void 0!==r?r:"";c(t.declarations,e,"");for(const r of null!==(n=t.overrides)&&void 0!==n?n:[])c(r.declarations,e," (override)");for(const[r,n]of Object.entries(null!==(o=t.variants)&&void 0!==o?o:{})){const t=` (variant '${r}')`;c(n.declarations,e,t);for(const r of null!==(i=n.overrides)&&void 0!==i?i:[])c(r.declarations,e,`${t} (override)`)}}return l}function xo(e,t){var r;const n=uo(e.breakpoints,t.mediaConfig),o=Ze(e.containers,t.mediaConfig),i=new WeakMap,s=()=>{let t=i.get(e);return t||(t=W(e),i.set(e,t)),t},a=e=>Pe(s(),t.derivationRegistry,e),l={media:n,containers:o,resolve:a},c=t.adapter.bind(e,l),u={model:e,get tokens(){return s()},resolveToken:a,override:r=>function(e,t,r){var n,o,i;const s=t.breakpoints,a=s?{...e.breakpoints,...s}:e.breakpoints,l=Object.keys(a),c=uo(a,r.mediaConfig),u=fo(t.containers),d=u?{...null!==(n=e.containers)&&void 0!==n?n:{},...u}:e.containers,f=po(d),p={...e.subsystems};for(const n of co){const s=t[n.key];if(void 0===s)continue;const u=ho(e.subsystems[n.key]),d=go(n,s,{breakpoints:a,extendsPrefix:null!==(i=null===(o=t.extends)||void 0===o?void 0:o.prefix)&&void 0!==i?i:"dt",media:c,mediaConfig:r.mediaConfig,allowedBreakpoints:l,allowedStates:r.allowedStates,allowedContainers:f,inheritedProperties:u}),m=D(d);m&&(p[n.key]=bo(e.subsystems[n.key],m))}const m={breakpoints:a,subsystems:p};d&&Object.keys(d).length&&(m.containers=d);const g=ie(m,r.unitConfig),h=Le(g,r.derivationRegistry);return xo(h,r)}(e,r,t)},d=null===(r=c.extend)||void 0===r?void 0:r.call(c,u);return d&&Object.defineProperties(u,Object.getOwnPropertyDescriptors(d)),u}const jo="theme.css",Ao="styles.css",Eo="variables.css",Ro=(e,t)=>"variables"===t?`${e}.variables.css`:`${e}.css`,So=e=>`${e.group}-${e.variant}.css`,Oo="variables.css";function Co(e){var t,r,n,o,i,s,a,l;if(void 0===e)return{type:"single",file:jo};if("string"==typeof e)switch(e){case"single":return{type:"single",file:jo};case"split":return{type:"split",file:Ao,variables:Eo};case"subsystem":return{type:"subsystem",filename:Ro};case"components":return{type:"components",inline:!0,filename:So,variables:Oo}}switch(null!==(t=e.type)&&void 0!==t?t:"variables"in e?"split":"single"){case"single":return{type:"single",file:null!==(r=e.file)&&void 0!==r?r:jo};case"split":{const t=e;return{type:"split",file:null!==(n=t.file)&&void 0!==n?n:Ao,variables:null!==(o=t.variables)&&void 0!==o?o:Eo}}case"subsystem":return{type:"subsystem",filename:null!==(i=e.filename)&&void 0!==i?i:Ro};case"components":{const t=e;return{type:"components",inline:null===(s=t.inline)||void 0===s||s,filename:null!==(a=t.filename)&&void 0!==a?a:So,variables:null!==(l=t.variables)&&void 0!==l?l:Oo}}}throw new Error("resolveEmitPlan: unrecognized emit directive.")}const To="com.theme-registry.refract",Fo=e=>"object"==typeof e&&null!==e&&"$value"in e,_o=/^\{([^}]+)\}$/,No=(e,t,r=new Set)=>{if("string"==typeof e){const n=e.match(_o);if(n){const o=n[1];if(r.has(o))throw new S("REFRACT_E_CYCLE",`Circular token reference: ${o}`);const i=t.get(o);return i?(r.add(o),No(i.value,t,r)):e}return e}if(Array.isArray(e))return e.map(e=>No(e,t,new Set(r)));if("object"==typeof e&&null!==e){const n={};for(const[o,i]of Object.entries(e))n[o]=No(i,t,new Set(r));return n}return e};function Po(e){var t;const r=[];for(const[n,o]of Object.entries(e.subsystems))for(const[e,i]of Object.entries(null!==(t=o.ruleSets)&&void 0!==t?t:{}))for(const t of Object.keys(i))r.push({subsystem:n,group:e,variant:t});return r}function zo(){return{name:(e={name:"noop",version:1,bind:()=>({recipeName:()=>"",renderRecipe:()=>"",renderVariables:()=>"",join:e=>e.join(""),emit:()=>({files:{}})})}).name,version:e.version,allowedStates:e.allowedStates,bind(t,r){var n,o,i,s;const a=e.bind(t,r),l=null!==(n=a.renderAllRecipes)&&void 0!==n?n:()=>a.join(Po(t).map(({subsystem:e,group:t,variant:r})=>a.renderRecipe(e,t,r))),c=null!==(o=a.renderAllVariables)&&void 0!==o?o:()=>a.join(Object.keys(t.subsystems).map(e=>a.renderVariables(e))),u=null!==(i=a.renderAll)&&void 0!==i?i:()=>a.join([c(),l()]),d=null!==(s=a.describeUsage)&&void 0!==s?s:()=>({format:e.name,summary:[`This theme was built with the "${e.name}" refract adapter.`],recipes:Po(t).map(({subsystem:e,group:t,variant:r})=>({subsystem:e,group:t,variant:r,name:a.recipeName(e,t,r)}))});return{...a,renderAllRecipes:l,renderAllVariables:c,renderAll:u,describeUsage:d}}};var e}const qo=(e,t)=>{var r,n,o;const i=(e=>{const t=[],r=new Map,n=(e,o,i)=>{var s,a,l;const c=null!==(s=e.$type)&&void 0!==s?s:i;for(const[i,s]of Object.entries(e)){if(i.startsWith("$"))continue;if("object"!=typeof s||null===s)continue;const e=[...o,i];if(Fo(s)){const n=s,o={path:e,type:null!==(l=null!==(a=n.$type)&&void 0!==a?a:c)&&void 0!==l?l:"color",value:n.$value,description:n.$description,extensions:n.$extensions};t.push(o),r.set(e.join("."),o)}else n(s,e,c)}};n(e,[]);for(const e of t)e.value=No(e.value,r);return t})(e),s=null!==(r=null==t?void 0:t.groupMapping)&&void 0!==r?r:{},a={},l={},c={},u={},d={};let f=null!==(n=null==t?void 0:t.breakpoints)&&void 0!==n?n:{};const p=new Map;for(const e of i){const t=e.path[0];p.has(t)||p.set(t,[]),p.get(t).push(e)}const m=null==t?void 0:t.breakpointGroup;if(m&&p.has(m)){f={};for(const e of p.get(m)){f[e.path[e.path.length-1]]=Qo(e.value)}p.delete(m)}for(const[e,t]of p){const r=null!==(o=s[e])&&void 0!==o?o:Mo(e,t);if("ignore"!==r)switch(r){case"colors":Bo(t,e,a);break;case"typography":Vo(t,e,l);break;case"effects":Ho(t,e,c);break;case"borders":Yo(t,e,u);break;case"layout":Ko(t,e,d)}}const g={};return Object.keys(f).length&&(g.breakpoints=f),Object.keys(a).length&&(g.colors=a),Object.keys(l).length&&(g.typography=l),Object.keys(c).length&&(g.effects=c),Object.keys(u).length&&(g.borders=u),Object.keys(d).length&&(g.layout=d),g},Mo=(e,t)=>{var r;const n=null===(r=t[0])||void 0===r?void 0:r.type;if("color"===n)return"colors";if("typography"===n)return"typography";if("shadow"===n)return"effects";if("border"===n)return"borders";if("strokeStyle"===n)return"borders";if("transition"===n)return"effects";const o=e.toLowerCase();if(o.includes("color")||o.includes("palette"))return"colors";if(o.includes("font")||o.includes("typo")||o.includes("text"))return"typography";if(o.includes("spacing")||o.includes("space")||o.includes("gutter"))return"layout";if(o.includes("radius")||o.includes("border")||o.includes("outline"))return"borders";if(o.includes("shadow")||o.includes("blur")||o.includes("opacity")||o.includes("z-index")||o.includes("zindex")||o.includes("transition")||o.includes("effect"))return"effects";if("dimension"===n){if(o.includes("spacing")||o.includes("gap"))return"layout";if(o.includes("radius")||o.includes("border"))return"borders";if(o.includes("font")||o.includes("size"))return"typography"}return"ignore"},Io=/^\{([^}]+)\}$/,Lo=e=>{if("string"!=typeof e)return;const t=e.match(Io);if(!t)return;const r=t[1],n=r.indexOf("."),o=n<0?r:r.slice(0,n),i=n<0?"":r.slice(n+1),s="color"===o?"colors":o;return i?`${s}.${i}`:s},Bo=(e,t,r)=>{var n;const o=new Map,i=[];for(const t of e)if(t.path.length<=2)i.push(t);else{const e=t.path[1];o.has(e)||o.set(e,[]),o.get(e).push(t)}for(const e of i){const t=e.path[e.path.length-1];if(!r[t]){const n=Lo(e.value);r[t]=n?{external:n}:{base:String(e.value)}}}for(const[e,t]of o)if(1===t.length){const n=t[0],o=n.path[n.path.length-1];o===e?r[e]={base:String(n.value)}:(r[e]||(r[e]={base:String(t[0].value)}),r[e].variants={[o]:String(n.value)})}else{const o=null!==(n=t.find(e=>{const t=e.path[e.path.length-1];return"base"===t||"default"===t||"500"===t}))&&void 0!==n?n:t[0],i={};for(const e of t){if(e===o)continue;i[e.path.slice(2).join("-")]=String(e.value)}r[e]={base:String(o.value),...Object.keys(i).length?{variants:i}:{}}}},Uo={fontfamily:"fontFamily",fontsize:"fontSize",fontweight:"fontWeight",lineheight:"lineHeight",letterspacing:"letterSpacing",fontstyle:"fontStyle",texttransform:"textTransform",textdecoration:"textDecoration",textalign:"textAlign"},Vo=(e,t,r)=>{for(const n of e)if("typography"===n.type){const e=n.value,t=n.path.slice(1).join("-")||n.path[n.path.length-1];e.fontFamily&&Do(r,"fontFamily",Array.isArray(e.fontFamily)?e.fontFamily.join(", "):e.fontFamily,t),e.fontSize&&Do(r,"fontSize",ei(e.fontSize),t),void 0!==e.fontWeight&&Do(r,"fontWeight",e.fontWeight,t),void 0!==e.lineHeight&&Do(r,"lineHeight",e.lineHeight,t),e.letterSpacing&&Do(r,"letterSpacing",e.letterSpacing,t)}else{const e=Wo(n,t);if(!e)continue;const o=n.path[n.path.length-1],i="fontFamily"===n.type&&Array.isArray(n.value)?n.value.join(", "):"dimension"===n.type?ei(n.value):n.value;Do(r,e,i,o)}},Do=(e,t,r,n)=>{if(!e[t])return void(e[t]={base:r,variants:{}});const o=e[t];"base"===n||"default"===n||"md"===n?o.base=r:o.variants[n]=r},Wo=(e,t)=>{if("fontFamily"===e.type)return"fontFamily";if("fontWeight"===e.type)return"fontWeight";const r=e.path.join(".").toLowerCase();for(const[e,t]of Object.entries(Uo))if(r.includes(e))return t;const n=t.toLowerCase();for(const[e,t]of Object.entries(Uo))if(n.includes(e))return t;return null},Ho=(e,t,r)=>{for(const t of e){const e=t.path[t.path.length-1];switch(t.type){case"shadow":{const n=Xo(t.value);Go(r,"shadow",n,e);break}case"transition":{const n=t.value,o=n.timingFunction?`cubic-bezier(${n.timingFunction.join(", ")})`:"ease",i=`all ${n.duration} ${o}`;Go(r,"transitions",i,e);break}case"dimension":t.path.join(".").toLowerCase().includes("blur")&&Go(r,"blur",ei(t.value),e);break;case"number":{const n=t.path.join(".").toLowerCase();n.includes("opacity")?Go(r,"opacity",t.value,e):(n.includes("z-index")||n.includes("zindex"))&&Go(r,"zIndex",t.value,e);break}}}},Go=(e,t,r,n)=>{if(!e[t])return void(e[t]={base:r,variants:{}});const o=e[t];"base"===n||"default"===n||"md"===n?o.base=r:o.variants[n]=r},Yo=(e,t,r)=>{for(const t of e){const e=t.path[t.path.length-1];switch(t.type){case"border":{const n=t.value;Jo(r,"width",ei(n.width),e),n.style&&Jo(r,"style",n.style,e);break}case"strokeStyle":Jo(r,"style",String(t.value),e);break;case"dimension":{const n=t.path.join(".").toLowerCase();n.includes("radius")?Jo(r,"radius",ei(t.value),e):n.includes("offset")?Jo(r,"offset",ei(t.value),e):n.includes("width")&&Jo(r,"width",ei(t.value),e);break}}}},Jo=(e,t,r,n)=>{if(!e[t])return void(e[t]={base:r,variants:{}});const o=e[t];"base"===n||"default"===n||"md"===n?o.base=r:o.variants[n]=r},Ko=(e,t,r)=>{for(const t of e){if("dimension"!==t.type)continue;const e=t.path[t.path.length-1],n=Qo(t.value);r.spacing||(r.spacing={base:n,variants:{}});const o=r.spacing;"base"===e||"default"===e||"4"===e?o.base=n:o.variants[e]=n}},Xo=e=>Array.isArray(e)?e.map(e=>Zo(e)).join(", "):Zo(e),Zo=e=>{const t=[];return e.inset&&t.push("inset"),t.push(e.offsetX,e.offsetY,e.blur,e.spread,e.color),t.join(" ")},Qo=e=>{if("number"==typeof e)return e;const t=parseFloat(e);return isNaN(t)?0:e.endsWith("rem")?Math.round(16*t):t},ei=e=>{if("number"==typeof e)return e;const t=parseFloat(e);return isNaN(t)?e:e.endsWith("px")?t:e},ti=(e,t)=>{var r;const n={};(null==t?void 0:t.name)&&(n.$name=t.name);const o=e.model.breakpoints;if(!1!==(null==t?void 0:t.includeBreakpoints)&&o&&Object.keys(o).length){const e={$type:"dimension"};for(const[t,r]of Object.entries(o))e[t]={$value:`${r}px`};n.breakpoint=e}const i=ni(e),s=t=>{try{return String(e.resolveToken(t))}catch{return t}},a=i.get("colors");if(a){const e={$type:"color"};for(const[t,r]of a){const n={};void 0!==r.base&&(n.base={$value:vt(String(r.base))});for(const[e,t]of Object.entries(r.members))n[e]={$value:vt(String(t))};e[t]=n}n.color=e}const l=i.get("typography");if(l){const e={};for(const[t,r]of l){const n={$type:oi(t)};void 0!==r.base&&(n.base={$value:ii(r.base,r.baseUnit)});for(const[e,t]of Object.entries(r.members))n[e]={$value:ii(t,r.memberUnits[e])};e[t]=n}n.typography=e}const c=i.get("effects");if(c)for(const[e,t]of c){const{groupName:r,type:o}=si(e);n[r]||(n[r]={$type:o});const i=n[r];void 0!==t.base&&(i.base={$value:ai(e,t.base,s,t.baseUnit)});for(const[r,n]of Object.entries(t.members))i[r]={$value:ai(e,n,s,t.memberUnits[r])}}const u=i.get("borders");if(u)for(const[e,t]of u){const{groupName:r,type:o}=li(e);n[r]||(n[r]={$type:o});const i=n[r];void 0!==t.base&&(i.base={$value:ci(t.base,t.baseUnit)});for(const[e,r]of Object.entries(t.members))i[e]={$value:ci(r,t.memberUnits[e])}}const d=i.get("layout");if(d)for(const[e,t]of d){if(e.includes("--"))continue;const r=e;n[r]||(n[r]={$type:"dimension"});const o=n[r];void 0!==t.base&&(o.base={$value:ui(t.base,t.baseUnit)});for(const[e,r]of Object.entries(t.members))o[e]={$value:ui(r,t.memberUnits[e])}}if(null==t?void 0:t.includeRecipes){const t=(e=>{const t={},r={},n={};for(const[o,i]of Object.entries(e.subsystems))i.properties&&Object.keys(i.properties).length&&(t[o]=i.properties),i.ruleSets&&Object.keys(i.ruleSets).length&&(r[o]=i.ruleSets),i.keyframes&&Object.keys(i.keyframes).length&&(n[o]=i.keyframes);const o=Object.keys(t).length>0,i=Object.keys(r).length>0,s=Object.keys(n).length>0,a=!!e.containers&&Object.keys(e.containers).length>0;if(o||i||s||a)return{version:1,...o?{properties:t}:{},...i?{ruleSets:r}:{},...s?{keyframes:n}:{},...a?{containers:e.containers}:{}}})(e.model);t&&(n.$extensions={...null!==(r=n.$extensions)&&void 0!==r?r:{},[To]:t})}return n},ri=(e,t)=>void 0!==t?`${e}${t}`:e,ni=e=>{const t=new Map;for(const r of Object.keys(e.tokens)){const n=r.indexOf(".");if(n<0)continue;const o=r.slice(0,n),i=r.slice(n+1),s=i.indexOf("."),a=s<0?i:i.slice(0,s),l=s<0?void 0:i.slice(s+1),c=e.tokens[r];if(void 0!==(null==c?void 0:c.external))continue;let u;if(void 0!==(null==c?void 0:c.struct))u=c.struct;else try{u=e.resolveToken(r)}catch{continue}const d=null==c?void 0:c.unit;let f=t.get(o);f||(f=new Map,t.set(o,f));let p=f.get(a);p||(p={members:{},memberUnits:{}},f.set(a,p)),void 0===l?(p.base=u,void 0!==d&&(p.baseUnit=d)):(p.members[l]=u,void 0!==d&&(p.memberUnits[l]=d))}return t},oi=e=>{switch(e){case"fontFamily":return"fontFamily";case"fontWeight":return"fontWeight";case"fontSize":case"letterSpacing":return"dimension";default:return"number"}},ii=(e,t)=>ri(e,t),si=e=>{switch(e){case"shadow":return{groupName:"shadow",type:"shadow"};case"transitions":return{groupName:"transition",type:"transition"};case"blur":default:return{groupName:e,type:"dimension"};case"opacity":case"zIndex":return{groupName:e,type:"number"}}},ai=(e,t,r,n)=>Array.isArray(t)?"transitions"===e?t.map(e=>{var t;const r=[e.property];return null==e.duration&&null==e.delay||r.push(`${null!==(t=e.duration)&&void 0!==t?t:0}ms`),e.timingFunction&&r.push(e.timingFunction),null!=e.delay&&r.push(`${e.delay}ms`),r.join(" ")}).join(", "):((e,t)=>e.map(e=>{const r=`0${(e=>{for(const t of[e.offsetX,e.offsetY,e.blur,e.spread])if(void 0!==t&&"number"!=typeof t)return t.unit;return"px"})(e)}`,n=e=>void 0===e?r:(e=>"number"==typeof e?`${e}px`:`${e.value}${e.unit}`)(e),o=[];return e.inset&&o.push("inset"),o.push(n(e.offsetX),n(e.offsetY)),null!=e.spread?o.push(n(e.blur),n(e.spread)):null!=e.blur&&o.push(n(e.blur)),e.color&&o.push(t(e.color)),o.join(" ")}).join(", "))(t,r):ri(t,n),li=e=>{switch(e){case"radius":return{groupName:"radius",type:"dimension"};case"width":return{groupName:"borderWidth",type:"dimension"};case"offset":return{groupName:"outlineOffset",type:"dimension"};case"style":return{groupName:"borderStyle",type:"strokeStyle"};default:return{groupName:e,type:"dimension"}}},ci=(e,t)=>ri(e,t),ui=(e,t)=>ri(e,t);async function di(e){var t;const{raw:n,adapter:i,outDir:l,helpers:c=[],emit:u,media:d,units:f,baseFontSize:p,guide:m}=e,g=vo(n,{adapter:i,media:d,units:f,baseFontSize:p}),v=Ve(g.model.breakpoints,e=>Je(e,Ge(d))),w=Ze(g.model.containers,d),$=i.bind(g.model,{media:v,containers:w,resolve:g.resolveToken});if(!$.emit)throw new Error(`Adapter "${i.name}" does not implement emit(); it cannot build to disk.`);const x=$.emit(Co(u)),j=[];o(l,{recursive:!0});const A=(e,t)=>{const n=s(l,e);o(a(n),{recursive:!0}),r(n,t,"utf8"),j.push(n)};for(const[e,t]of Object.entries(x.files))A(e,t);for(const[e,r]of Object.entries(null!==(t=x.vendorHelpers)&&void 0!==t?t:{}))A(e,r);for(const e of c){const t=b(e);if(!t)throw new Error(`Unknown vendor helper "${e}". Known: ${h.map(e=>e.id).join(", ")}.`);A(t.outfile,await k(y(t.source)))}if(m){const e=!0===m?{}:m,t=R($.describeUsage(),ti(g),{files:Object.keys(x.files),packageName:e.packageName,llmsFile:e.llmsFile,manifestFile:e.manifestFile});for(const[e,r]of Object.entries(t.files))A(e,r)}return{outDir:l,files:j}}const fi=e=>e,pi="theme.config",mi=[".ts",".mjs",".js"],gi=(t=process.cwd())=>{for(const r of mi){const n=s(t,`${pi}${r}`);if(e(n))return n}};let hi=0;async function bi(t={}){var r,n,o;const i=null!==(r=t.cwd)&&void 0!==r?r:process.cwd(),s=t.configPath?l(i,t.configPath):gi(i);if(!s||!e(s)){const e=t.configPath?`"${t.configPath}"`:`${pi}.(ts|mjs|js) in "${i}"`;throw new Error(`No theme config found at ${e}.`)}const a=await async function(e){if(".ts"!==u(e)){const t=`${f(e).href}?v=${++hi}`;return await import(t)}const{entry:t,cleanup:r}=await j(e);try{return await import(f(t).href)}finally{r()}}(s),c=null!==(o=null!==(n=a.default)&&void 0!==n?n:a.config)&&void 0!==o?o:a;if(!c||"object"!=typeof c||!Array.isArray(c.targets))throw new Error(`"${s}" must export (default) a defineConfig({ raw, targets }) object.`);return{config:c,path:s}}const vi="@theme-registry/refract-css";function yi(){var e;const r=s(v(),"package.json");return null!==(e=JSON.parse(t(r,"utf8")).name)&&void 0!==e?e:"@theme-registry/refract"}function wi(e){return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${vi}";\n\n// refract build config. \`refract build\` reads this file, builds the theme once, and writes\n// each target's emitted files into that target's \`outDir\`. The config is your code: it \`import\`s\n// the adapters it wants and passes their options at construction (not via CLI flags).\nexport default defineConfig({\n // The raw theme — authored in refract's nested slices. Extend with typography/effects/layout.\n raw: {\n breakpoints: { sm: 576, md: 768, lg: 1024, xl: 1280 },\n colors: {\n // Starter palette passes its own contrast audit (WCAG AA): white text clears 4.5:1 on both\n // bases. Keep that when you retune — the auditor is a shipped feature; the default should model it.\n primary: { base: "#1864ab", text: "#fff", variants: { dark: "#0b4a86", light: "#a5d8ff" } },\n neutral: { base: "#495057", text: "#fff", variants: { light: "#f1f3f5", dark: "#212529" } },\n recipes: {\n solid: {\n primary: { background: "primary", color: "primary.text" },\n neutral: { background: "neutral.light", color: "neutral.dark" },\n },\n },\n },\n },\n targets: [\n // The CSS adapter (from @theme-registry/refract-css). Pass its options here, at construction.\n { adapter: createCssAdapter(/* { colors: { prefix: "app" } } */), outDir: "dist/theme" },\n\n // Add another adapter target once its package is installed, e.g.:\n // import { createStyledComponentsAdapter } from "@theme-registry/refract-styled-components";\n // { adapter: createStyledComponentsAdapter(), outDir: "dist/theme-sc" },\n ],\n});\n`}function ki(t={}){var n,o,i;const a=null!==(n=t.cwd)&&void 0!==n?n:process.cwd(),l=null!==(o=t.variant)&&void 0!==o?o:"ts",c=null!==(i=t.packageName)&&void 0!==i?i:yi(),u=s(a,`theme.config.${l}`);if(e(u)&&!t.force)throw new Error(`theme.config.${l} already exists at "${u}". Pass --force to overwrite it.`);return r(u,wi(c),"utf8"),{path:u,variant:l,packageName:c}}const $i="theme.config.ts";function xi(e){const t={};for(const r of e.split(",")){const[e,n]=r.split(":"),o=null==e?void 0:e.trim(),i=Number.parseFloat((null!=n?n:"").trim());o&&Number.isFinite(i)&&(t[o]=i)}return t}function ji(e,t,r){return`// Generated by \`refract import\` from ${r}.\n// DTCG carries property tokens ONLY — recipes, components, composition, and states are not imported.\n// The mapping is heuristic (subsystem inferred from \`$type\`/name; \`border\` composite colors dropped;\n// rem rounded to px). Review the seeded tokens, then hand-author the rest of your theme below.\nimport type { RawTheme } from "${e}/build";\n\nexport const raw: RawTheme = ${JSON.stringify(t,null,2)};\n`}function Ai(e,t){return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${vi}";\nimport { raw } from "${t}";\n\n// Generated by \`refract import\`. This is your build config — edit it freely. Add adapter options at\n// construction (\`createCssAdapter({ … })\`) and extra targets (SC/JSON/…) as their packages install.\nexport default defineConfig({\n raw,\n targets: [\n { adapter: createCssAdapter(), outDir: "dist/theme" },\n ],\n});\n`}function Ei(e){const t={};for(const[r,n]of Object.entries(e))"breakpoints"!==r&&(t[r]=n&&"object"==typeof n?Object.keys(n).length:0);return t}function Ri(n){var i,s;const u=null!==(i=n.cwd)&&void 0!==i?i:process.cwd(),f=null!==(s=n.packageName)&&void 0!==s?s:yi(),p=d(n.input)?n.input:l(u,n.input);if(!e(p))throw new Error(`No DTCG document found at "${n.input}" (resolved to "${p}").`);let m;try{m=JSON.parse(t(p,"utf8"))}catch(e){throw new Error(`"${p}" is not valid JSON: ${e.message}`)}const g={};n.breakpointGroup&&(g.breakpointGroup=n.breakpointGroup),n.breakpoints&&Object.keys(n.breakpoints).length&&(g.breakpoints=n.breakpoints);const h=qo(m,g),b=n.out?d(n.out)?n.out:l(u,n.out):l(u,"theme.raw.ts");if(e(b)&&!n.force)throw new Error(`${c(b)} already exists at "${b}". Pass --force to overwrite it.`);let v;if(o(a(b),{recursive:!0}),r(b,ji(f,h,JSON.stringify(c(p))),"utf8"),!n.rawOnly){if(v=l(a(b),$i),e(v)&&!n.force)throw new Error(`${$i} already exists at "${v}". Pass --force to overwrite it, or --raw-only to skip writing a config.`);const t=`./${c(b).replace(/\.(ts|mts|cts|tsx)$/,"")}`;r(v,Ai(f,t),"utf8")}return{inputFile:p,rawFile:b,configFile:v,sections:Object.keys(h),counts:Ei(h)}}async function Si(e={}){var t;const r=null!==(t=e.cwd)&&void 0!==t?t:process.cwd(),{config:n,path:o}=await bi({cwd:r,configPath:e.configPath});if(!n.targets.length)throw new Error(`"${o}" has no targets to build.`);const i=function(e,t){if(void 0===t)return[...e];const r=e.filter(e=>e.name===t);if(r.length)return r;if(/^\d+$/.test(t)){const r=Number(t);if(r>=0&&r<e.length)return[e[r]]}const n=e.filter(e=>e.outDir===t);if(n.length)return n;throw new Error(`No target matched "${t}". Config has ${e.length} target(s): `+e.map((e,t)=>{var r;return null!==(r=e.name)&&void 0!==r?r:`#${t} (${e.outDir})`}).join(", ")+".")}(n.targets,e.target);if(void 0!==e.out&&i.length>1)throw new Error(`--out is ambiguous across ${i.length} targets; pass --target to pick one first.`);const s=a(o),c=[];for(const t of i){const o=void 0!==e.out?d(e.out)?e.out:l(r,e.out):d(t.outDir)?t.outDir:l(s,t.outDir),i=await di({raw:n.raw,adapter:t.adapter,outDir:o,helpers:t.helpers,emit:t.emit,media:n.media,units:n.units,baseFontSize:n.baseFontSize,guide:t.guide});c.push({name:t.name,adapter:t.adapter.name,outDir:i.outDir,files:i.files})}return{configPath:o,targets:c}}async function Oi(e={}){var t;const n=null!==(t=e.cwd)&&void 0!==t?t:process.cwd(),{config:i,path:s}=await bi({cwd:n,configPath:e.configPath}),c=vo(i.raw,{adapter:zo()}),u=ti(c),f=e.out?d(e.out)?e.out:l(n,e.out):l(n,"tokens.json");o(a(f),{recursive:!0}),r(f,`${JSON.stringify(u,null,2)}\n`,"utf8");return{configPath:s,outFile:f,groupCount:Object.keys(u).filter(e=>!e.startsWith("$")).length}}async function Ci(e={}){var t;const r=null!==(t=e.cwd)&&void 0!==t?t:process.cwd(),{config:n,path:o}=await bi({cwd:r,configPath:e.configPath}),i=vo(n.raw,{adapter:zo()});return{configPath:o,result:xr(i,{strict:e.strict,minWcag:e.minWcag,largeText:e.largeText})}}const Ti=(e,t)=>{try{return String(e.resolveToken(t))}catch{return null}},Fi=e=>{var t;const r=[];for(const[n,o]of Object.entries(e.model.subsystems))for(const[e,i]of Object.entries(null!==(t=o.ruleSets)&&void 0!==t?t:{}))for(const t of Object.keys(i))r.push({subsystem:n,group:e,variant:t});return r},_i=(e,t,r,n)=>{var o,i,s;return Boolean(null===(s=null===(i=null===(o=e.model.subsystems[t])||void 0===o?void 0:o.ruleSets)||void 0===i?void 0:i[r])||void 0===s?void 0:s[n])};function Ni(e,t){const r=((e,t)=>{const r=new Set([...Object.keys(e.tokens),...Object.keys(t.tokens)]),n=[];for(const o of r){const r=o in e.tokens,i=o in t.tokens,s=r?Ti(e,o):null,a=i?Ti(t,o):null;r&&!i?n.push({path:o,before:s,after:null,kind:"removed"}):!r&&i?n.push({path:o,before:null,after:a,kind:"added"}):s!==a&&n.push({path:o,before:s,after:a,kind:"changed"})}return n.sort((e,t)=>e.path.localeCompare(t.path))})(e,t),n=((e,t)=>{var r,n,o,i,s,a,l,c;const u=e,d=t;if(!u.renderRecipe&&!d.renderRecipe)return[];const f=new Set,p=[...Fi(e),...Fi(t)].filter(e=>{const t=`${e.subsystem}.${e.group}.${e.variant}`;return!f.has(t)&&(f.add(t),!0)}),m=[];for(const{subsystem:f,group:g,variant:h}of p){const p=_i(e,f,g,h),b=_i(t,f,g,h),v=null!==(i=null!==(n=null===(r=d.getClass)||void 0===r?void 0:r.call(d,f,g,h))&&void 0!==n?n:null===(o=u.getClass)||void 0===o?void 0:o.call(u,f,g,h))&&void 0!==i?i:`${f}.${g}.${h}`;p&&!b?m.push({name:v,kind:"removed"}):!p&&b?m.push({name:v,kind:"added"}):(null!==(a=null===(s=u.renderRecipe)||void 0===s?void 0:s.call(u,f,g,h))&&void 0!==a?a:"")!==(null!==(c=null===(l=d.renderRecipe)||void 0===l?void 0:l.call(d,f,g,h))&&void 0!==c?c:"")&&m.push({name:v,kind:"changed"})}return m.sort((e,t)=>e.name.localeCompare(t.name))})(e,t),o=((e,t)=>{var r,n,o,i;const s=e=>e?{ratio:e.wcagRatio,level:e.wcagLevel,pass:e.pass}:null,a=e=>new Map(e.map(e=>[e.label,e])),l=a(xr(e).pairings),c=a(xr(t).pairings),u=new Set([...l.keys(),...c.keys()]),d=[];for(const e of u){const t=l.get(e),a=c.get(e),u=s(t),f=s(a);if((null==u?void 0:u.ratio)===(null==f?void 0:f.ratio)&&(null==u?void 0:u.level)===(null==f?void 0:f.level)&&Boolean(t)===Boolean(a))continue;const p=(null!==(r=null==t?void 0:t.pass)&&void 0!==r?r:null)!==(null!==(n=null==a?void 0:a.pass)&&void 0!==n?n:null)||(null!==(o=null==t?void 0:t.wcagLevel)&&void 0!==o?o:null)!==(null!==(i=null==a?void 0:a.wcagLevel)&&void 0!==i?i:null);d.push({label:e,before:u,after:f,crossed:p})}return d.sort((e,t)=>e.label.localeCompare(t.label))})(e,t);return{tokens:r,classes:n,contrast:o,summary:{tokensChanged:r.length,classesChanged:n.length,pairingsCrossed:o.filter(e=>e.crossed).length}}}const Pi={fail:0,"AA-large":1,AA:2,AAA:3};let zi=0;async function qi(r){var n,o,i,s;if(!e(r))throw new Error(`candidate theme not found at "${r}".`);let a;if(".json"===u(r))a=JSON.parse(t(r,"utf8"));else if(".ts"===u(r)){const{entry:e,cleanup:t}=await j(r);try{const t=await import(f(e).href);a=null!==(o=null!==(n=t.default)&&void 0!==n?n:t.raw)&&void 0!==o?o:t}finally{t()}}else{const e=await import(`${f(r).href}?v=${++zi}`);a=null!==(s=null!==(i=e.default)&&void 0!==i?i:e.raw)&&void 0!==s?s:e}return function(e,t){const r=t?` (${t})`:"";if(null===e||"object"!=typeof e||Array.isArray(e)){const t=Array.isArray(e)?"an array":null===e?"null":typeof e;throw new S("REFRACT_E_RAW_SHAPE",`Expected a RawTheme object${r}, got ${t}. Pass the raw theme (a module's default export, or a .json raw theme).`)}if(Array.isArray(e.targets))throw new S("REFRACT_E_RAW_SHAPE",`Expected a RawTheme object${r}, but got what looks like a defineConfig({ raw, targets }). Pass its \`raw\` (or a module that default-exports the raw theme), not the whole config.`)}(a,r),a}async function Mi(e){var t,r,n,o,i,s,a,c;const u=null!==(t=e.cwd)&&void 0!==t?t:process.cwd(),{config:d,path:f}=await bi({cwd:u,configPath:e.configPath}),p=l(u,e.candidatePath),m=await qi(p),g={units:d.units,baseFontSize:d.baseFontSize,media:d.media},h=d.targets.map((e,t)=>{var r,n;return{name:null!==(n=null!==(r=e.name)&&void 0!==r?r:e.outDir)&&void 0!==n?n:`target-${t}`,adapter:e.adapter}}),b=h.map(({name:e,adapter:t})=>{var r;try{return vo(m,{adapter:t,...g}),{name:e,ok:!0,errors:[]}}catch(t){const n=t;return{name:e,ok:!1,errors:n.failures?[...n.failures]:[null!==(r=n.message)&&void 0!==r?r:String(t)]}}}),v=null!==(n=null!==(r=h.find(({adapter:e})=>"function"==typeof vo(d.raw,{adapter:e,...g}).renderRecipe))&&void 0!==r?r:h[0])&&void 0!==n?n:{name:"noop",adapter:zo()},y=vo(d.raw,{adapter:v.adapter,...g});let w={tokens:[],classes:[],contrast:[],summary:{tokensChanged:0,classesChanged:0,pairingsCrossed:0}};try{w=Ni(y,vo(m,{adapter:v.adapter,...g}))}catch{}const k=[];if(void 0!==e.maxClassChanges&&w.summary.classesChanged>e.maxClassChanges&&k.push(`${w.summary.classesChanged} classes changed (max ${e.maxClassChanges})`),void 0!==e.maxTokenChanges&&w.summary.tokensChanged>e.maxTokenChanges&&k.push(`${w.summary.tokensChanged} tokens changed (max ${e.maxTokenChanges})`),e.failBelow){const t=null!==(o=Pi[e.failBelow])&&void 0!==o?o:0;for(const r of w.contrast){const n=(null===(i=r.after)||void 0===i?void 0:i.level)&&null!==(s=Pi[r.after.level])&&void 0!==s?s:0,o=(null===(a=r.before)||void 0===a?void 0:a.level)&&null!==(c=Pi[r.before.level])&&void 0!==c?c:0;r.after&&n<t&&n<o&&k.push(`${r.label} drops to ${r.after.level} (below ${e.failBelow})`)}}const $=b.filter(e=>!e.ok).map(e=>e.name);return $.length&&k.push(`candidate no longer builds for: ${$.join(", ")}`),{configPath:f,candidatePath:p,diff:w,targets:b,ok:0===k.length,violations:k}}const Ii=["claude","codex","opencode","github-copilot","cursor","generic"],Li={claude:{kind:"claude",routerFile:".claude/skills"},codex:{kind:"agents-md",routerFile:"AGENTS.md"},opencode:{kind:"agents-md",routerFile:"AGENTS.md"},"github-copilot":{kind:"agents-md",routerFile:".github/copilot-instructions.md"},cursor:{kind:"agents-md",routerFile:".cursor/rules/refract-skills.mdc"},generic:{kind:"agents-md",routerFile:"AGENTS.md"}},Bi="\x3c!-- refract-skills:start --\x3e",Ui="\x3c!-- refract-skills:end --\x3e",Vi=s(".refract","skills.lock"),Di=s(".refract","skills");function Wi(e){return null!=e?e:s(v(),"skills")}function Hi(r){const n=Wi(r);if(!e(n))throw new Error(`Skills catalog not found at "${n}". Reinstall @theme-registry/refract.`);return i(n,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>s(n,e.name,"SKILL.md")).filter(e).map(e=>function(e,t){var r,n,o;const i=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(e),s=i?i[1]:"",l=i?e.slice(i[0].length).replace(/^\s+/,""):e,c=e=>{const t=new RegExp(`^${e}:\\s*(.*)$`,"m").exec(s);return t?t[1].trim():void 0},u=null!==(n=null!==(r=c("name"))&&void 0!==r?r:a(t).split(/[\\/]/).pop())&&void 0!==n?n:"unnamed",d="optional"===c("tier")?"optional":"core";return{name:u,description:null!==(o=c("description"))&&void 0!==o?o:"",tier:d,raw:e,body:l,sourcePath:t}}(t(e,"utf8"),e)).sort((e,t)=>e.name.localeCompare(t.name))}function Gi(e){const t=e.map(e=>`| [${e.name}](${Di}/${e.name}.md) | ${function(e){const t=e.description.split(/\s*Triggers:/)[0].trim();return(t.split(/\.\s/)[0].trim()||t).replace(/\|/g,"\\|")}(e)} |`).join("\n");return[Bi,"","## refract theme skills","","These skills document the [refract](https://github.com/theme-registry/refract) theme toolkit.","When a task matches a row below, read the linked file before working.","","| Skill | Use it for |","| --- | --- |",t,"",Ui].join("\n")}function Yi(e,t){const r=e.indexOf(Bi),n=e.indexOf(Ui);if(-1!==r&&-1!==n&&n>r)return e.slice(0,r)+t+e.slice(n+Ui.length);const o=e.replace(/\s+$/,"");return o?`${o}\n\n${t}\n`:`${t}\n`}function Ji(e,t){o(a(e),{recursive:!0}),r(e,t,"utf8")}function Ki(r){var n,o,i;const a=null!==(n=r.scope)&&void 0!==n?n:"local",l="global"===a?null!==(o=r.home)&&void 0!==o?o:p():null!==(i=r.cwd)&&void 0!==i?i:process.cwd(),c=function(e,t){if(t.skills&&t.skills.length>0){const r=new Map(e.map(e=>[e.name,e])),n=[];for(const o of t.skills){const t=r.get(o);if(!t)throw new Error(`Unknown skill "${o}". Available: ${e.map(e=>e.name).join(", ")}.`);n.push(t)}return n}return e.filter(e=>"core"===e.tier||t.includeOptional)}(Hi(r.catalogDir),r);if(0===r.agents.length)throw new Error("Pick at least one agent target.");const u=new Set;if(r.agents.some(e=>"agents-md"===Li[e].kind))for(const e of c){const t=s(l,Di,`${e.name}.md`);Ji(t,e.body),u.add(t)}for(const n of r.agents){const r=Li[n];if("claude"===r.kind)for(const e of c){const t=s(l,r.routerFile,e.name,"SKILL.md");Ji(t,e.raw),u.add(t)}else{const n=s(l,r.routerFile);Ji(n,Yi(e(n)?t(n,"utf8"):"",Gi(c))),u.add(n)}}const{name:d,version:f}=function(){var e,r;const n=JSON.parse(t(s(v(),"package.json"),"utf8"));return{name:null!==(e=n.name)&&void 0!==e?e:"@theme-registry/refract",version:null!==(r=n.version)&&void 0!==r?r:"0.0.0"}}(),m={schema:1,packageName:d,refractVersion:f,scope:a,agents:[...r.agents],skills:c.map(e=>e.name)},g=s(l,Vi);return Ji(g,`${JSON.stringify(m,null,2)}\n`),{scope:a,agents:[...r.agents],skills:c.map(e=>e.name),files:[...u].sort(),manifestPath:g}}function Xi(r={}){var n,o,i;const a=null!==(n=r.scope)&&void 0!==n?n:"local",l="global"===a?null!==(o=r.home)&&void 0!==o?o:p():null!==(i=r.cwd)&&void 0!==i?i:process.cwd(),c=s(l,Vi);if(!e(c))throw new Error(`No skills manifest at "${c}". Run \`refract skills install\` first.`);const u=JSON.parse(t(c,"utf8"));return Ki({agents:u.agents,scope:a,skills:u.skills,cwd:r.cwd,home:r.home,catalogDir:r.catalogDir})}const Zi="refract — build a refract theme to disk.\n\nUsage:\n refract init [--js | --mjs] [--force]\n refract import <tokens.json> [--out <file>] [--raw-only] [--force]\n [--breakpoint-group <name>] [--breakpoints <n:px,…>]\n refract build [--config <path>] [--target <name|index>] [--out <dir>]\n refract tokens [--config <path>] [--out <file>]\n refract diff <candidate> [--config <path>] [--max-class-changes <n>]\n [--max-token-changes <n>] [--fail-below <AA|AAA|AA-large>]\n refract audit [--config <path>] [--strict] [--min-wcag <AA|AAA|AA-large>] [--large]\n refract skills <install|list|update> [--agent <a,b|all>] [--global|--local]\n [--only <names>] [--optional]\n refract help\n\nCommands:\n init Scaffold a runnable theme.config.(ts|js|mjs) in the current directory.\n import Seed a theme.raw.ts (+ theme.config.ts) from a DTCG tokens.json (one-shot).\n build Load the config and emit every target's files to its outDir.\n tokens Export the theme's tokens as a DTCG tokens.json (adapter-free).\n diff Show a candidate theme's blast radius vs the config (tokens/classes/contrast); thresholds gate CI.\n audit Score colour pairings for WCAG-2 contrast (+ advisory APCA). Reports; --strict fails.\n skills Install the bundled AI skills into your agent CLI(s) (claude/codex/…).\n";function Qi(e,t){var r;const n=t,o="string"==typeof n.code&&n.code.startsWith("REFRACT_E_")?`[${n.code}] `:"";if(process.stderr.write(`refract ${e}: ${o}${null!==(r=n.message)&&void 0!==r?r:String(t)}\n`),n.failures)for(const e of n.failures)process.stderr.write(` - ${e}\n`);return 1}const es=new Set(["AAA","AA","AA-large"]);async function ts(e){const[t,...r]=e;if("list"===t)try{for(const e of Hi())process.stdout.write(` ${e.name.padEnd(26)} [${e.tier}] ${e.description.split(/\s*Triggers:/)[0].trim().slice(0,80)}\n`);return 0}catch(e){return Qi("skills list",e)}const{values:n}=g({args:r,options:{agent:{type:"string"},global:{type:"boolean",default:!1},local:{type:"boolean",default:!1},only:{type:"string"},optional:{type:"boolean",default:!1}},allowPositionals:!1});if(n.global&&n.local)return process.stderr.write("refract skills: pass at most one of --global / --local.\n"),1;const o=n.global?"global":"local";try{if("update"===t){const e=Xi({scope:o});return process.stdout.write(`Updated ${e.skills.length} skill(s) for ${e.agents.join(", ")} (${e.scope}).\n`),0}if("install"===t||void 0===t){let e,t=Boolean(n.optional),r=o;if(n.agent)e=function(e){if("all"===e.trim())return[...Ii];const t=e.split(",").map(e=>e.trim()).filter(Boolean),r=t.filter(e=>!Ii.includes(e));if(r.length>0)throw new Error(`unknown agent(s) ${r.map(e=>`"${e}"`).join(", ")}. Known: ${Ii.join(", ")}.`);return t}(n.agent);else{if(!process.stdin.isTTY)return process.stderr.write("refract skills install: pass --agent <a,b|all> (no TTY for prompts).\n"),1;{const o=await async function(){const e=m({input:process.stdin,output:process.stdout});try{process.stdout.write("Install refract skills for which agent(s)?\n"),Ii.forEach((e,t)=>process.stdout.write(` ${t+1}) ${e}\n`));const t=await e.question("Enter numbers (comma-separated), or 'all': "),r="all"===t.trim()||""===t.trim()?[...Ii]:t.split(",").map(e=>Ii[Number(e.trim())-1]).filter(e=>Boolean(e));if(0===r.length)throw new Error("no agents selected.");return{agents:r,scope:(await e.question("Scope — [l]ocal (project) or [g]lobal (home)? [l]: ")).trim().toLowerCase().startsWith("g")?"global":"local",includeOptional:(await e.question("Include optional skills (adapter-scaffold, troubleshooting)? [y/N]: ")).trim().toLowerCase().startsWith("y")}}finally{e.close()}}();e=o.agents,t=o.includeOptional,n.global||n.local||(r=o.scope)}}const i=Ki({agents:e,scope:r,skills:n.only?n.only.split(",").map(e=>e.trim()).filter(Boolean):void 0,includeOptional:t});process.stdout.write(`Installed ${i.skills.length} skill(s) for ${i.agents.join(", ")} (${i.scope}):\n`);for(const e of i.files)process.stdout.write(` ${e}\n`);return process.stdout.write(` manifest → ${i.manifestPath}\n`),0}return process.stderr.write(`refract skills: unknown subcommand "${t}". Use install | list | update.\n`),1}catch(e){return Qi("skills",e)}}async function rs(e){const[t,...r]=e;switch(t){case"init":return async function(e){const{values:t}=g({args:e,options:{js:{type:"boolean",default:!1},mjs:{type:"boolean",default:!1},force:{type:"boolean",default:!1}},allowPositionals:!1});if(t.js&&t.mjs)return process.stderr.write("refract init: pass at most one of --js / --mjs.\n"),1;const r=t.mjs?"mjs":t.js?"js":"ts";try{const e=ki({variant:r,force:Boolean(t.force)});return process.stdout.write(`Created ${e.path}\n`),process.stdout.write("Next: edit the raw theme, then run `refract build`.\n"),0}catch(e){return Qi("init",e)}}(r);case"import":return async function(e){const{values:t,positionals:r}=g({args:e,options:{out:{type:"string"},"raw-only":{type:"boolean",default:!1},force:{type:"boolean",default:!1},"breakpoint-group":{type:"string"},breakpoints:{type:"string"}},allowPositionals:!0}),n=r[0];if(!n)return process.stderr.write("refract import: pass the DTCG document to import, e.g. `refract import tokens.json`.\n"),1;if(r.length>1)return process.stderr.write(`refract import: unexpected extra argument "${r[1]}".\n`),1;try{const e=Ri({input:n,out:t.out,rawOnly:Boolean(t["raw-only"]),force:Boolean(t.force),breakpointGroup:t["breakpoint-group"],breakpoints:t.breakpoints?xi(t.breakpoints):void 0});process.stdout.write(`Imported ${e.inputFile}\n`),process.stdout.write(` raw → ${e.rawFile}\n`),e.configFile&&process.stdout.write(` config → ${e.configFile}\n`);const r=Object.entries(e.counts).map(([e,t])=>`${e} (${t})`).join(", ");return r&&process.stdout.write(` seeded: ${r}\n`),process.stdout.write("Next: review the inferred tokens, then add recipes/components and run `refract build`.\n"),0}catch(e){return Qi("import",e)}}(r);case"build":return async function(e){const{values:t}=g({args:e,options:{config:{type:"string"},target:{type:"string"},out:{type:"string"}},allowPositionals:!1});try{const e=await Si({configPath:t.config,target:t.target,out:t.out});process.stdout.write(`Built from ${e.configPath}\n`);for(const t of e.targets){const e=t.name?`${t.name} [${t.adapter}]`:t.adapter;process.stdout.write(` ${e} → ${t.outDir} (${t.files.length} file(s))\n`);for(const e of t.files)process.stdout.write(` ${e}\n`)}return 0}catch(e){return Qi("build",e)}}(r);case"tokens":return async function(e){const{values:t}=g({args:e,options:{config:{type:"string"},out:{type:"string"}},allowPositionals:!1});try{const e=await Oi({configPath:t.config,out:t.out});return process.stdout.write(`Exported tokens from ${e.configPath}\n`),process.stdout.write(` ${e.groupCount} group(s) → ${e.outFile}\n`),0}catch(e){return Qi("tokens",e)}}(r);case"diff":return async function(e){var t,r,n,o;const{values:i,positionals:s}=g({args:e,options:{config:{type:"string"},"max-class-changes":{type:"string"},"max-token-changes":{type:"string"},"fail-below":{type:"string"}},allowPositionals:!0}),a=s[0];if(!a)return process.stderr.write("refract diff: pass the candidate theme, e.g. `refract diff candidate.ts`.\n"),1;const l=i["fail-below"];if(void 0!==l&&!es.has(l))return process.stderr.write(`refract diff: --fail-below must be one of AAA | AA | AA-large (got "${l}").\n`),1;try{const e=await Mi({configPath:i.config,candidatePath:a,maxClassChanges:void 0!==i["max-class-changes"]?Number(i["max-class-changes"]):void 0,maxTokenChanges:void 0!==i["max-token-changes"]?Number(i["max-token-changes"]):void 0,failBelow:l}),{diff:s}=e;process.stdout.write(`Diffed ${e.candidatePath}\n vs ${e.configPath}\n`),process.stdout.write(` ${s.summary.tokensChanged} token(s), ${s.summary.classesChanged} class(es), ${s.summary.pairingsCrossed} pairing(s) crossed a threshold\n`);for(const e of s.tokens.slice(0,20)){const t="changed"===e.kind?`${e.before} → ${e.after}`:"added"===e.kind?`+ ${e.after}`:`- ${e.before}`;process.stdout.write(` token ${e.path}: ${t}\n`)}s.tokens.length>20&&process.stdout.write(` … +${s.tokens.length-20} more token(s)\n`);for(const e of s.classes)process.stdout.write(` class ${e.kind.padEnd(7)} ${e.name}\n`);for(const e of s.contrast.filter(e=>e.crossed))process.stdout.write(` contrast ${e.label}: ${null!==(r=null===(t=e.before)||void 0===t?void 0:t.level)&&void 0!==r?r:"—"} → ${null!==(o=null===(n=e.after)||void 0===n?void 0:n.level)&&void 0!==o?o:"—"}\n`);if(e.violations.length){process.stderr.write("✗ diff gate failed:\n");for(const t of e.violations)process.stderr.write(` ${t}\n`);return 1}return 0}catch(e){return Qi("diff",e)}}(r);case"audit":return async function(e){const{values:t}=g({args:e,options:{config:{type:"string"},strict:{type:"boolean",default:!1},"min-wcag":{type:"string"},large:{type:"boolean",default:!1}},allowPositionals:!1}),r=t["min-wcag"];if(void 0!==r&&!es.has(r))return process.stderr.write(`refract audit: --min-wcag must be one of AAA | AA | AA-large (got "${r}").\n`),1;try{const{configPath:e,result:n}=await Ci({configPath:t.config,strict:t.strict,minWcag:r,largeText:t.large});process.stdout.write(`Audited ${e}\n`);for(const e of n.pairings)if(e.skipped)process.stdout.write(` ~ ${e.label} — skipped (${e.skipped})\n`);else{const t=e.pass?"✓":"✗";process.stdout.write(` ${t} ${e.label} — ${e.wcagRatio}:1 ${e.wcagLevel} · APCA Lc ${e.apcaLc}\n`)}const o=n.summary;return process.stdout.write(`${o.passed}/${o.total} pass, ${o.failed} fail, ${o.skipped} skipped\n`),0}catch(e){return Qi("audit",e)}}(r);case"skills":return ts(r);case void 0:case"help":case"--help":case"-h":return process.stdout.write(Zi),0;default:return process.stderr.write(`refract: unknown command "${t}".\n\n${Zi}`),1}}"undefined"!=typeof require&&"undefined"!=typeof module&&require.main===module&&rs(process.argv.slice(2)).then(e=>process.exit(e),e=>{var t;process.stderr.write(`refract: ${null!==(t=e.stack)&&void 0!==t?t:e}\n`),process.exit(1)});export{Ii as AGENT_TARGETS,vi as CSS_ADAPTER_PACKAGE,h as VENDOR_HELPERS,R as buildGuide,j as compileTsConfigGraph,fi as defineConfig,Ni as diffThemes,di as emitTheme,gi as findConfigFile,v as findPackageRoot,b as findVendorHelper,Hi as listSkills,bi as loadConfig,rs as main,xi as parseBreakpointsFlag,yi as readOwnPackageName,y as readVendorSource,Co as resolveEmitPlan,Ci as runAudit,Si as runBuild,Mi as runDiff,Ri as runImport,ki as runInit,Ki as runSkillsInstall,Xi as runSkillsUpdate,Oi as runTokens,wi as scaffoldConfig,Ai as scaffoldImportConfig,ji as scaffoldRaw,Wi as skillsCatalogDir,k as transpileToEsm};
|
|
1
|
+
import{existsSync as e,readFileSync as t,writeFileSync as r,rmSync as n,mkdirSync as o,readdirSync as s}from"node:fs";import{join as i,dirname as a,resolve as l,basename as c,extname as u,isAbsolute as d}from"node:path";import{pathToFileURL as f}from"node:url";import{createInterface as p}from"node:readline";import{homedir as m}from"node:os";import{createInterface as h}from"node:readline/promises";import{parseArgs as g}from"node:util";const b=[{id:"color-math",outfile:"color-math.js",source:"src/subsystems/colors/utils.ts",exports:["lighten","darken","alpha","setL","rotateHue","complement","adjust","rgbToOklch","oklchToRgb","toHexColor","toOklchColor","convertHexToRGB","convertRgbToHex"],description:"Pure OKLCH colour math — the exact lighten/darken/setL/rotateHue/complement/adjust (+ OKLCH and hex converters) refract synthesizes palette steps/variants with, so a value computed live in the consumer matches the emitted CSS variables."}],v=e=>b.find(t=>t.id===e),y=(t=__dirname)=>{let r=t;for(;;){if(e(i(r,"package.json")))return r;const n=a(r);if(n===r)throw new Error(`No package.json found walking up from "${t}".`);r=n}},w=r=>{const n=i(y(),r);if(!e(n))throw new Error(`Vendor helper source "${r}" not found at "${n}". Ensure it is listed in package.json "files" so it ships with the package.`);return t(n,"utf8")};async function $(){var e;try{const t=await import("typescript");return null!==(e=t.default)&&void 0!==e?e:t}catch{throw new Error('refract: the optional peer dependency "typescript" is required to transpile a `.ts` theme.config or vendor a shared helper module, but it could not be resolved. Install it (`npm i -D typescript`), or use a `.mjs`/`.js` config and avoid the `helpers` opt-in.')}}const k=async e=>{const t=await $();return t.transpileModule(e,{compilerOptions:{module:t.ModuleKind.ESNext,target:t.ScriptTarget.ES2020}}).outputText};let x=0;const j=e=>l(e).replace(/\.(ts|tsx|mts|cts|js|jsx|mjs|cjs)$/,""),A=async t=>{const o=await $(),s={module:o.ModuleKind.ESNext,target:o.ScriptTarget.ES2020,moduleResolution:o.ModuleResolutionKind.Bundler,resolveJsonModule:!0,allowJs:!1,noLib:!0,skipLibCheck:!0,noEmitOnError:!1,declaration:!1,sourceMap:!1,types:[]},u=o.createCompilerHost(s),d=o.createProgram([t],s,u),f=new Map,p=e=>!e.isDeclarationFile&&!e.fileName.includes("/node_modules/")&&/\.(ts|tsx|mts|cts)$/.test(e.fileName);for(const e of d.getSourceFiles()){if(!p(e))continue;const t=l(e.fileName),r=c(t).replace(/\.(ts|tsx|mts|cts)$/,"");f.set(j(t),i(a(t),`.${r}.${process.pid}-${x++}.mjs`))}const m=e=>t=>{const r=l(t.fileName),n=e.factory,i=e=>{const t=((e,t)=>{var r;if(!e.startsWith("."))return;const n=null===(r=o.resolveModuleName(e,t,s,u).resolvedModule)||void 0===r?void 0:r.resolvedFileName;return n?f.get(j(n)):void 0})(e,r);return t?n.createStringLiteral(`./${c(t)}`):void 0},a=t=>{if(o.isImportDeclaration(t)&&o.isStringLiteral(t.moduleSpecifier)){const e=i(t.moduleSpecifier.text);if(e)return n.updateImportDeclaration(t,t.modifiers,t.importClause,e,t.attributes)}else if(o.isExportDeclaration(t)&&t.moduleSpecifier&&o.isStringLiteral(t.moduleSpecifier)){const e=i(t.moduleSpecifier.text);if(e)return n.updateExportDeclaration(t,t.modifiers,t.isTypeOnly,t.exportClause,e,t.attributes)}else if(o.isCallExpression(t)&&t.expression.kind===o.SyntaxKind.ImportKeyword&&t.arguments.length&&o.isStringLiteral(t.arguments[0])){const e=i(t.arguments[0].text);if(e)return n.updateCallExpression(t,t.expression,t.typeArguments,[e,...t.arguments.slice(1)])}return o.visitEachChild(t,a,e)};return o.visitNode(t,a)},h=[],g=(e,t)=>{const n=f.get(j(e));n&&(r(n,t,"utf8"),h.push(n))},b=()=>{for(const e of h)n(e,{force:!0})};try{d.emit(void 0,g,void 0,!1,{before:[m]})}catch(e){throw b(),e}const v=f.get(j(t));if(!v||!e(v))throw b(),new Error(`refract: failed to compile the \`.ts\` config graph for "${t}".`);return{entry:v,cleanup:b}},E=e=>e.replace(/\|/g,"\\|");function S(e,t,r){var n;const o=[];if(o.push(`# Theme consumption guide (${e.format})`),o.push(""),o.push("This folder is a self-contained theme built with refract. You do NOT need refract to use it —","everything below refers to files in THIS folder (relative paths), so it works whether the theme","was installed as a package, unzipped from an artifact, or vendored into a repo."),o.push(""),t.files.length>0){o.push("## Files"),o.push("");for(const e of t.files)o.push(`- \`./${e}\``);o.push("")}o.push("## How to use"),o.push("");for(const t of e.summary)o.push(t);t.packageName&&(o.push(""),o.push(`If this theme is installed as the \`${t.packageName}\` package, you may import the same`,`files by specifier (e.g. \`${t.packageName}/${null!==(n=t.files[0])&&void 0!==n?n:"theme.css"}\`) instead of by relative path.`)),o.push("");const{recipes:s}=e;if(s.length>0){o.push("## Recipes — real names"),o.push(""),o.push("Use these exact identities; do not invent names."),o.push(""),o.push("| Recipe | Identity |"),o.push("| --- | --- |");const e=s.slice(0,60);for(const t of e)o.push(`| \`${E(`${t.subsystem}.${t.group}.${t.variant}`)}\` | \`${E(t.name)}\` |`);if(s.length>e.length){const t=s.length-e.length;o.push(""),o.push(`_(+${t} more recipe(s) — the complete list is in ${r?`\`./${r}\``:"the manifest"}.)_`)}o.push("")}return r&&(o.push("## Machine-readable index"),o.push(""),o.push(`See \`./${r}\` for the full recipe index and the theme's tokens (DTCG format).`),o.push("")),o.join("\n")}function R(e,t,r){var n;const o=null!==(n=r.llmsFile)&&void 0!==n?n:"llms.txt",s=void 0===r.manifestFile?"manifest.json":r.manifestFile,i={[o]:S(e,r,s)};if(s){const n={schema:1,format:e.format,files:r.files,packageName:r.packageName,recipes:e.recipes,tokens:t};i[s]=`${JSON.stringify(n,null,2)}\n`}return{files:i}}class O extends Error{constructor(e,t,r){super(t),this.name="RefractError",this.code=e,r&&(this.failures=r),Object.setPrototypeOf(this,O.prototype)}}const C=e=>"string"==typeof e||"number"==typeof e,T=e=>Array.isArray(e),F=e=>({value:e}),N=(e,t)=>{if(!t)return F(e);const r={ref:t.ref};return void 0!==t.fn&&(r.fn=t.fn),void 0!==t.arg&&(r.arg=t.arg),void 0!==t.modifiers&&(r.modifiers=t.modifiers),void 0!==e&&(r.value=e),r},_=new Set(["mode","target","base","derive"]),P=(e,t,r)=>{const n={},o=e.derive,s=e.base;if(o){if(void 0===o.ref)throw new O("REFRACT_E_REFERENCE",`Derived appearance mode "${t}.modes.${r}" was not baked — derived modes require a subsystem that resolves them (colors). Use a literal value instead.`);n.base=N(C(s)?s:void 0,o)}else C(s)?n.base=F(s):T(s)&&(n.base={struct:s});for(const[t,r]of Object.entries(e))_.has(t)||C(r)&&(n[t]=F(r));return n},z=(e,t)=>{const r={};for(const[n,o]of Object.entries(e))t.has(n)||C(o)&&(r[n]=F(o));return r},M=new Set(["base","derive"]),q=new Set(["base","responsive","variants","modes","external"]),L=new Set(["breakpoint","query","state","orientation","ref","modifiers","mode","variant","target","derive","ratio","step","steps"]),I=(e,t="property")=>{var r;const n={base:void 0!==e.external?{value:`var(${e.external})`,external:e.external}:(o=e.base,T(o)?{struct:o}:F(o))};var o;const s=z(e,q);if(Object.keys(s).length&&(n.extras=s),e.variants&&Object.keys(e.variants).length){const t={};for(const[r,n]of Object.entries(e.variants)){let e;const o=n.derive;if(C(n.base)?e=N(n.base,o):T(n.base)?e={struct:n.base}:void 0!==(null==o?void 0:o.ref)&&(e=N(void 0,o)),!e)continue;const s=z(n,M);t[r]=Object.keys(s).length?{base:e,extras:s}:{base:e}}Object.keys(t).length&&(n.variants=t)}const i=e.modes;if(i&&i.length){const e=[];for(const r of i){const n=r.mode,o=P(r,t,n);if(!Object.keys(o).length)continue;const s={mode:n,overrides:o};"string"==typeof r.target&&(s.target=r.target),e.push(s)}e.length&&(n.modes=e)}if(null===(r=e.responsive)||void 0===r?void 0:r.length){const t=e.responsive.map(e=>{const t=e,r={breakpoint:t.breakpoint};"string"==typeof t.query&&(r.query=t.query),"string"==typeof t.orientation&&(r.orientation=t.orientation),"string"==typeof t.ref&&(r.ref=t.ref),"string"==typeof t.mode&&(r.mode=t.mode),"string"==typeof t.target&&(r.target=t.target);const n=((e,t)=>{const r={};for(const[n,o]of Object.entries(e))t.has(n)||(C(o)?r[n]=F(o):T(o)&&(r[n]={struct:o}));return r})(t,L),o=t.derive;return o&&n.base&&void 0!==n.base.value&&(n.base=N(n.base.value,o)),Object.keys(n).length&&(r.overrides=n),r});n.responsive=t}return n},B=e=>({kind:"recipe",declarations:{...e.base},overrides:e.responsive.map(e=>{const t={};return void 0!==e.state&&(t.state=e.state),void 0!==e.breakpoint&&(t.breakpoint=e.breakpoint),void 0!==e.query&&(t.query=e.query),void 0!==e.orientation&&(t.orientation=e.orientation),void 0!==e.container&&(t.container=e.container),void 0!==e.size&&(t.size=e.size),void 0!==e.variant&&(t.variant=e.variant),void 0!==e.target&&(t.target=e.target),Object.keys(e.declarations).length&&(t.declarations={...e.declarations}),t})}),U=(e,t)=>{const r=B(e);return r.kind="recipe",t.length&&(r.references=t),r},D=new Set(["colors","typography","layout","effects","borders"]),V=e=>!!e&&Object.keys(e).length>0,W=e=>{var t;if(!e)return;const r={};return e.properties&&Object.keys(e.properties).length&&(r.properties=(e=>{const t={};for(const[r,n]of Object.entries(e))t[r]=I(n,r);return t})(e.properties)),e.extraProperties&&Object.keys(e.extraProperties).length&&(r.properties={...null!==(t=r.properties)&&void 0!==t?t:{},...e.extraProperties}),V(e.ruleSetGroups)&&(r.ruleSets=e.ruleSetGroups),V(e.keyframes)&&(r.keyframes=e.keyframes),Object.keys(r).length?r:void 0},Y=e=>{var t,r,n,o;const s={};for(const[i,a]of Object.entries(e.subsystems))for(const[e,l]of Object.entries(null!==(t=a.properties)&&void 0!==t?t:{})){const t=`${i}.${e}`;s[t]=l.base;for(const[e,o]of Object.entries(null!==(r=l.variants)&&void 0!==r?r:{})){s[`${t}.${e}`]=o.base;for(const[r,i]of Object.entries(null!==(n=o.extras)&&void 0!==n?n:{}))s[`${t}.${e}.${r}`]=i}for(const[e,r]of Object.entries(null!==(o=l.extras)&&void 0!==o?o:{}))s[`${t}.${e}`]=r}return s},H=new Set(["px","cm","mm","q","in","pc","pt","rem","em","ex","cap","ch","ic","lh","rlh","%","vw","vh","vi","vb","vmin","vmax","svw","svh","lvw","lvh","dvw","dvh","cqw","cqh","cqi","cqb","cqmin","cqmax"]),G=/^-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?$/i,J=/^(-?(?:\d+\.?\d*|\.\d+)(?:e-?\d+)?)([a-z%]+)$/i,K=e=>{if("number"==typeof e)return{value:e};const t=e.trim();if(G.test(t))return{value:Number(t)};const r=J.exec(t);if(r){const t=r[2].toLowerCase();if(H.has(t))return{value:Number(r[1]),unit:t};throw new O("REFRACT_E_UNITS",`Unknown length unit "${r[2]}" in "${e}". Use a CSS unit, or wrap functions/keywords (calc(), clamp(), var(), a keyword) — those pass through as raw strings.`)}return{raw:e}},X={"typography.lineHeight":"none","typography.letterSpacing":"em"},Z=(e,t)=>{var r,n,o,s;const i=e.slice(0,e.indexOf("."));return null!==(s=null!==(o=null!==(n=null!==(r=null==t?void 0:t[e])&&void 0!==r?r:X[e])&&void 0!==n?n:null==t?void 0:t[i])&&void 0!==o?o:null==t?void 0:t.default)&&void 0!==s?s:"px"},Q=(e,t)=>Number((e/t).toFixed(4)),ee=(e,t,r)=>"none"===t?{value:e}:"rem"===t?{value:Q(e,r),unit:"rem"}:{value:e,unit:t},te=(e,t,r)=>{if("number"==typeof e){const{value:n,unit:o}=ee(e,t,r);return void 0===o?e:{value:n,unit:o}}return e},re={typography:{fontSize:"length",letterSpacing:"length",lineHeight:"length"},layout:{spacing:"length",gutters:"length",sizes:"length"},borders:{width:"length",offset:"length",radius:"length"},effects:{blur:"length",shadow:"shadow"}},ne=(e,t)=>{let r=!1;const n={};for(const[o,s]of Object.entries(e)){const e=t(s);e!==s&&(r=!0),n[o]=e}return r?n:e},oe=(e,t,r)=>{const n=t(e.base),o=e.variants?((e,t)=>{let r=!1;const n={};for(const[o,s]of Object.entries(e)){const e=t(s.base),i=s.extras?ne(s.extras,t):void 0;e===s.base&&i===s.extras||(r=!0),n[o]=i?{base:e,extras:i}:{base:e}}return r?n:e})(e.variants,t):void 0,s=r&&e.extras?ne(e.extras,t):e.extras,i=e.modes?((e,t)=>{let r=!1;const n=e.map(e=>{if(!e.overrides)return e;const n=ne(e.overrides,t);return n===e.overrides?e:(r=!0,{...e,overrides:n})});return r?n:e})(e.modes,t):void 0,a=((e,t)=>{if(!e.responsive)return;let r=!1;const n=e.responsive.map(e=>{if(!e.overrides)return e;const n=ne(e.overrides,t);return n===e.overrides?e:(r=!0,{...e,overrides:n})});return r?n:e.responsive})(e,t);if(n===e.base&&o===e.variants&&s===e.extras&&i===e.modes&&a===e.responsive)return e;const l={...e,base:n};return void 0!==o&&(l.variants=o),void 0!==s&&(l.extras=s),void 0!==i&&(l.modes=i),void 0!==a&&(l.responsive=a),l},se=(e,t,r,n)=>{const o="shadow"===t?e=>{if(!e.struct)return e;const t=e.struct;let o=!1;const s=t.map(e=>{const t=((e,t,r)=>{const n={...e};let o=!1;for(const s of["offsetX","offsetY","blur","spread"]){const i=e[s];if(void 0===i)continue;const a=te(i,t,r);a!==i&&(n[s]=a,o=!0)}return o?n:e})(e,r,n);return t!==e&&(o=!0),t});return o?{...e,struct:s}:e}:e=>((e,t,r)=>{if(void 0!==e.unit)return e;if(void 0!==e.ref&&void 0===e.value)return e;const n=e.value;if("number"==typeof n){const{value:o,unit:s}=ee(n,t,r);return void 0===s?e:{...e,value:o,unit:s}}if("string"==typeof n){const o=K(n);if("raw"in o)return e;if(void 0!==o.unit)return{...e,value:o.value,unit:o.unit};const{value:s,unit:i}=ee(o.value,t,r);return void 0===i?{...e,value:s}:{...e,value:s,unit:i}}return e})(e,r,n);return oe(e,o,!1)},ie=(e,t={})=>{var r;const n=null!==(r=t.baseFontSize)&&void 0!==r?r:16;let o=!1;const s={};for(const[r,i]of Object.entries(e.subsystems)){const e=re[r];if(!e||!i.properties){s[r]=i;continue}let a=!1;const l={};for(const[o,s]of Object.entries(i.properties)){const i=e[o];if(!i){l[o]=s;continue}const c=Z(`${r}.${o}`,t.units),u=se(s,i,c,n);u!==s&&(a=!0),l[o]=u}a?(s[r]={...i,properties:l},o=!0):s[r]=i}return o?{...e,subsystems:s}:e},ae=e=>(null==e?void 0:e.propertyPath)?` for "${e.propertyPath}"`:"",le=(e,t)=>!t||(Array.isArray(t)?t.includes(e):t.has(e));function ce(e,t){const r=e.variants?Object.keys(e.variants):[];if(!r.length)return;const n=new Set(r),o=(null==t?void 0:t.propertyPath)?` for "${t.propertyPath}"`:"";for(const t of e.responsive){if(t.ref&&!n.has(t.ref))throw new O("REFRACT_E_RESPONSIVE",`Responsive entry${o} references unknown variant "${t.ref}" (ref).`);if(t.target&&!n.has(t.target))throw new O("REFRACT_E_RESPONSIVE",`Responsive entry${o} references unknown target "${t.target}".`)}}const ue=e=>"object"==typeof e&&null!==e&&Array.isArray(e.modifiers),de=(e,t)=>{if(!Array.isArray(e)||0===e.length)throw new O("REFRACT_E_VARIANT",`Derivation "${t}" needs a non-empty "modifiers" array.`);return e.map((e,r)=>{if("object"!=typeof e||null===e||Array.isArray(e))throw new O("REFRACT_E_VARIANT",`Modifier ${r} of "${t}" must be a single-key object like { darken: 10 }.`);const n=Object.keys(e);if(1!==n.length)throw new O("REFRACT_E_VARIANT",`Modifier ${r} of "${t}" must have exactly one fn key; got [${n.join(", ")}].`);return{fn:n[0],arg:e[n[0]]}})},fe=new Set(["breakpoint","query","ref","modifiers","mode","target","orientation"]),pe=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),me=(e,t,r)=>{var n;const o=null!==(n=null!=e?e:t)&&void 0!==n?n:r.fallbackBase;if(void 0===o)throw new O("REFRACT_E_PROPERTY",`Unable to resolve base value${s=r.propertyPath,s?` for "${s}"`:""}.`);var s;return r.coerceValue?r.coerceValue(o):o},he=(e,t)=>{const r=new Set(t),n={},o={};let s=!1;for(const[t,i]of Object.entries(e))r.has(t)?(n[t]=i,s=!0):o[t]=i;return{base:s?n:void 0,extra:o}},ge=(e,t,r,n)=>{var o;if(void 0===e&&(null===(o=n.leafFields)||void 0===o?void 0:o.length)){const e=he(t,n.leafFields);if(void 0!==e.base){const t=e.base;return{base:n.coerceValue?n.coerceValue(t):t,extra:e.extra}}}return{base:me(e,r,n),extra:t}},be=(e,t,r,n)=>{const o=r.propertyPath?`${r.propertyPath}.variants.${e}`:`variants.${e}`,s=pe(t)?t:{base:t},{base:i,...a}=s,{base:l,extra:c}=ge(i,a,n,{...r,propertyPath:o});return{...c,base:l}},ve=(e,t={})=>{var r;const n=pe(e)?e:{base:e},{base:o,responsive:s,variants:i,modes:a,...l}=n,{base:c,extra:u}=ge(o,l,t.fallbackBase,t),d=i?Object.fromEntries(Object.entries(i).map(([e,r])=>[e,be(e,r,t,c)])):void 0,f=a?a.map(e=>((e,t)=>{const{mode:r,target:n,...o}=e,s=t.propertyPath?`${t.propertyPath}.modes.${r}`:`modes.${r}`;return{mode:r,...void 0!==n?{target:n}:{},...(()=>{var e;if((null===(e=t.leafFields)||void 0===e?void 0:e.length)&&!("base"in o)&&!ue(o)){const{base:e,extra:r}=he(o,t.leafFields);if(void 0!==e){const n={...r};return n.base=t.coerceValue?t.coerceValue(e):e,n}}if(ue(o)){const{ref:e,modifiers:t,...r}=o,n={...r};return n.derive={...void 0!==e?{ref:e}:{},modifiers:de(t,s)},n}const{base:r,...n}=o,i={...n};if(void 0!==r&&(i.base=Array.isArray(r)||!t.coerceValue?r:t.coerceValue(r)),void 0===i.base&&!i.derive&&!Object.keys(n).length)throw new O("REFRACT_E_MODE",`Appearance mode "${s}" overrides nothing.`);return i})()}})(e,t)):void 0,p={propertyPath:t.propertyPath,allowedBreakpoints:t.allowedBreakpoints},m=(g=p,(null==(h=s)?void 0:h.length)?h.map(e=>{if(!e.breakpoint)throw new O("REFRACT_E_BREAKPOINT",`Responsive entry${ae(g)} is missing a "breakpoint" value.`);if((null==g?void 0:g.allowedBreakpoints)&&!le(e.breakpoint,g.allowedBreakpoints))throw new O("REFRACT_E_BREAKPOINT",`Responsive entry${ae(g)} references unknown breakpoint "${e.breakpoint}".`);if(e.ref&&!le(e.ref,null==g?void 0:g.allowedVariants))throw new O("REFRACT_E_RESPONSIVE",`Responsive entry${ae(g)} references unknown variant "${e.ref}" (ref).`);if(e.target&&!le(e.target,null==g?void 0:g.allowedTargets))throw new O("REFRACT_E_RESPONSIVE",`Responsive entry${ae(g)} references unknown target "${e.target}".`);const{query:t,...r}=e;return{...r,query:null!=t?t:"exact"}}):[]);var h,g;const b=(null===(r=t.leafFields)||void 0===r?void 0:r.length)?m.map(e=>((e,t)=>{const r={},n={};let o;for(const[t,s]of Object.entries(e))fe.has(t)?r[t]=s:"base"===t?o=s:n[t]=s;const s=t.leafFields.some(e=>e in n);if(void 0===o&&!s)return e;const{base:i,extra:a}=ge(o,n,void 0,t);return{...r,...a,base:i}})(e,t)):m;return{...u,base:c,responsive:b,variants:d,modes:f}},ye=["orientation","height","aspectRatio"],we=(e,t)=>!t||(Array.isArray(t)?t.includes(e):t.has(e)),$e=e=>e?` for "${e}"`:"",ke="responsive",xe="states",je="css",Ae="variants",Ee=e=>Array.isArray(e)?e:e&&"object"==typeof e?Object.entries(e).map(([e,t])=>({state:e,...t})):[],Se=e=>{var t;return`${e.state}\0${null!==(t=e.target)&&void 0!==t?t:""}`},Re=(e,t)=>{const r=Ee(e).map(e=>({...e})),n=new Map(r.map((e,t)=>[Se(e),t]));for(const e of Ee(t)){const t=Se(e),o=n.get(t);void 0!==o?r[o]={...r[o],...e}:(n.set(t,r.length),r.push({...e}))}return r},Oe=(e,t)=>{var r,n;const o={...e};for(const[s,i]of Object.entries(t))null!==i?s===ke?o[ke]=[...null!==(r=e[ke])&&void 0!==r?r:[],...i]:s===xe?o[xe]=Re(e[xe],i):s===je?o[je]={...null!==(n=e[je])&&void 0!==n?n:{},...i}:o[s]=i:delete o[s];return o},Ce=(e,t={})=>{const r=((e,t)=>{if(!Object.values(e).some(e=>null!=e&&"object"==typeof e&&null!=e[Ae]))return e;const r={},n=(e,n)=>{if(e in r)throw new O("REFRACT_E_VARIANT",`Recipe variant expansion${$e(t)} produced a duplicate recipe name "${e}" — a desugared "<recipe>-<variant>" collides with an existing sibling recipe.`);r[e]=n};for(const[t,r]of Object.entries(e)){const{[Ae]:e,...o}=r;if(n(t,o),null!=e){const r=null!=o[xe]?{...o,[xe]:Ee(o[xe]).filter(e=>!e.target)}:o;for(const[o,s]of Object.entries(e))n(`${t}-${o}`,Oe(r,s))}}return r})(e,t.propertyPath),n=Object.keys(r),o=n.length?new Set(n):void 0,s={};return n.forEach(e=>{var n;const i=r[e];s[e]=Te(`${null!==(n=t.propertyPath)&&void 0!==n?n:"recipes"}.${e}`,i,{allowedBreakpoints:t.allowedBreakpoints,allowedStates:t.allowedStates,allowedTargets:o,allowedVariants:o,allowedContainers:t.allowedContainers,recipeName:e})}),s},Te=(e,t,r)=>{const{responsive:n,states:o,...s}=t;return{base:s,responsive:[...Fe(o,e,r),...Ne(n,e,r)]}},Fe=(e,t,r)=>Ee(e).map(e=>{const{state:n,...o}=e;if(r.allowedStates&&!we(n,r.allowedStates))throw new O("REFRACT_E_STATE",`Recipe state entry${$e(t)} references unknown state "${n}".`);if(o.target&&r.allowedTargets){const e=r.recipeName?`${r.recipeName}-${o.target}`:o.target;if(!we(e,r.allowedTargets))throw new O("REFRACT_E_RESPONSIVE",`Recipe state entry${$e(t)} references unknown target "${o.target}".`)}return{...o,state:n}}),Ne=(e,t,r)=>(null==e?void 0:e.length)?e.map(e=>{var n;if(void 0!==e.variant&&void 0!==e.target)throw new O("REFRACT_E_RESPONSIVE",`Responsive entry${$e(t)} cannot set both "variant" and "target".`);if(void 0!==e.container)return _e(e,t,r);if(!e.breakpoint)throw new O("REFRACT_E_BREAKPOINT",`Responsive recipe entry${$e(t)} is missing a "breakpoint" value.`);if(r.allowedBreakpoints&&!we(e.breakpoint,r.allowedBreakpoints))throw new O("REFRACT_E_BREAKPOINT",`Responsive recipe entry${$e(t)} references unknown breakpoint "${e.breakpoint}".`);if(e.state&&r.allowedStates&&!we(e.state,r.allowedStates))throw new O("REFRACT_E_STATE",`Responsive recipe entry${$e(t)} references unknown state "${e.state}".`);if(e.variant&&!we(e.variant,r.allowedVariants))throw new O("REFRACT_E_RESPONSIVE",`Responsive recipe entry${$e(t)} references unknown variant "${e.variant}".`);if(e.target&&!we(e.target,r.allowedTargets))throw new O("REFRACT_E_RESPONSIVE",`Responsive recipe entry${$e(t)} references unknown target "${e.target}".`);return{...e,query:null!==(n=e.query)&&void 0!==n?n:"exact"}}):[],_e=(e,t,r)=>{var n,o;const s=e.container;for(const r of ye)if(void 0!==e[r])throw new O("REFRACT_E_CONTAINER",`Container recipe entry${$e(t)} cannot use "${r}" — container queries respond to a container's inline size, not orientation/height/aspect-ratio.`);const i=null===(n=r.allowedContainers)||void 0===n?void 0:n.get(s);if(r.allowedContainers&&!i)throw new O("REFRACT_E_CONTAINER",`Container recipe entry${$e(t)} references unknown container "${s}".`);if(void 0===e.size)throw new O("REFRACT_E_CONTAINER",`Container recipe entry${$e(t)} for container "${s}" is missing a "size" value.`);if(i&&!i.has(e.size))throw new O("REFRACT_E_CONTAINER",`Container recipe entry${$e(t)} references unknown size "${e.size}" on container "${s}".`);return{...e,query:null!==(o=e.query)&&void 0!==o?o:"min"}},Pe=(e,t,r={})=>{var n;const o=new Map,s=[],i=null!==(n=r.groupPath)&&void 0!==n?n:"recipes",a=r=>{if(o.has(r))return o.get(r);if(s.includes(r)){const e=[...s,r].join(" -> ");throw new O("REFRACT_E_CYCLE",`Cyclic recipe reference in "${i}": ${e}`)}const n=e[r];if(!n)throw new O("REFRACT_E_REFERENCE",`Recipe variant "${r}" is not defined in "${i}".`);s.push(r);try{const e=t(r,n,a);return o.set(r,e),e}finally{s.pop()}};return{resolve:a,resolveAll:()=>{const t={};for(const r of Object.keys(e))t[r]=a(r);return t}}},ze=(e,t,r,n=new Map,o=new Set)=>{const s=n.get(r);if(void 0!==s)return s;const i=e[r];if(!i)throw new O("REFRACT_E_TOKEN_PATH",`Unknown token path "${r}".`);if(void 0!==i.external){const e=`var(${i.external})`;return n.set(r,e),e}if(void 0===i.ref){if(void 0===i.value)throw new O("REFRACT_E_TOKEN_PATH",`Token "${r}" has neither "ref" nor "value".`);return n.set(r,i.value),i.value}if(o.has(r))throw new O("REFRACT_E_CYCLE",`Cyclic token reference: ${[...o,r].join(" -> ")}`);o.add(r);const a=ze(e,t,i.ref,n,o);let l;if(void 0!==i.modifiers)l=i.modifiers.reduce((e,n)=>{const o=t[n.fn];if(!o)throw new O("REFRACT_E_TOKEN_PATH",`Unknown derivation fn "${n.fn}" for token "${r}".`);return o(e,n.arg)},a);else if(void 0!==i.fn){const e=t[i.fn];if(!e)throw new O("REFRACT_E_TOKEN_PATH",`Unknown derivation fn "${i.fn}" for token "${r}".`);l=e(a,i.arg)}else l=a;return o.delete(r),n.set(r,l),l},Me=(e,t)=>!!(null==e?void 0:e.ref)&&((void 0!==e.modifiers||void 0!==e.fn)&&(e=>{const[t,r]=e.split(".");return`${t}.${r}`})(e.ref)!==t),qe=(e,t,r,n,o)=>{let s;try{s=ze(t,r,e.ref,n)}catch{throw new O("REFRACT_E_VALIDATION",`${o}: cross-property derivation references unknown token '${e.ref}'.`)}const i=(e,t)=>{const n=r[e];if(!n)throw new O("REFRACT_E_VALIDATION",`${o}: unknown derivation fn '${e}'.`);return n(s,t)};if(void 0!==e.modifiers)for(const t of e.modifiers)s=i(t.fn,t.arg);else void 0!==e.fn&&(s=i(e.fn,e.arg));return{...e,value:s}},Le=(e,t,r,n,o,s)=>{let i;for(const[a,l]of Object.entries(e))Me(l,t)&&(i=null!=i?i:{...e},i[a]=qe(l,r,n,o,`${s}.${a}`));return i},Ie=(e,t,r,n,o)=>{const s=e.variants?((e,t,r,n,o)=>{let s;for(const[i,a]of Object.entries(e)){const l=`${t}.variants.${i}`,c=Me(a.base,t)?qe(a.base,r,n,o,l):a.base,u=a.extras?Le(a.extras,t,r,n,o,`${l} extra`):void 0;(c!==a.base||u)&&(s=null!=s?s:{...e},s[i]=u?{base:c,extras:u}:{...a,base:c})}return s})(e.variants,t,r,n,o):void 0;let i;if(e.modes)for(let s=0;s<e.modes.length;s++){const a=e.modes[s];if(!a.overrides)continue;const l=Le(a.overrides,t,r,n,o,`${t}.modes.${a.mode}`);l&&(i=null!=i?i:[...e.modes],i[s]={...a,overrides:l})}if(!s&&!i)return;const a={...e};return s&&(a.variants=s),i&&(a.modes=i),a},Be=(e,t)=>{var r;const n=Y(e),o=new Map;let s=!1;const i={};for(const[a,l]of Object.entries(e.subsystems)){let e,c=!1;for(const[s,i]of Object.entries(null!==(r=l.properties)&&void 0!==r?r:{})){const r=Ie(i,`${a}.${s}`,n,t,o);r&&(e=null!=e?e:{...l.properties},e[s]=r,c=!0)}c?(i[a]={...l,properties:e},s=!0):i[a]=l}return s?{...e,subsystems:i}:e},Ue=["min","max","exact","between"],De=e=>void 0===e?void 0:e-.02,Ve=(e,t)=>{const r=(e=>Object.keys(e).sort((t,r)=>e[t]-e[r]))(e);(e=>{const t=e.filter(e=>Ue.includes(e));if(t.length)throw new O("REFRACT_E_BREAKPOINT",`Breakpoint names conflict with reserved keys: ${t.map(e=>`"${e}"`).join(", ")}. Reserved: ${Ue.map(e=>`"${e}"`).join(", ")}.`)})(r);const n=e=>r[r.indexOf(e)+1],o=r.reduce((r,o)=>{const s=e[o],i=n(o),a=void 0!==i?e[i]:void 0;return r[o]=We({own:s,next:a},t),r},{}),s=e=>{const t=o[e];if(!t)throw new O("REFRACT_E_BREAKPOINT",`Breakpoint "${e}" is not defined.`);return t};return{...o,min:(r,n)=>{const o=s(r);return n?t({min:e[r],...n}):o.min},max:(r,o)=>{const i=s(r);if(!o)return i.max;const a=n(r),l=void 0!==a?e[a]:void 0;return t({max:De(l),...o})},exact:(r,o)=>{const i=s(r);if(!o)return i.exact;const a=n(r),l=void 0!==a?e[a]:void 0;return t({min:e[r],max:De(l),...o})},between:(r,n,o)=>{const s=e[r],i=e[n];if(void 0===s||void 0===i)throw new O("REFRACT_E_BREAKPOINT",`Cannot build media query between "${r}" and "${n}" breakpoints.`);return t({min:s,max:i-.02,...o})}}},We=({own:e,next:t},r)=>{const n=De(t);return{min:r({min:e}),max:void 0===n?"":r({max:n}),exact:r({min:e,max:n})}},Ye="px",He=16,Ge=e=>{var t;return{unit:null!==(t=null==e?void 0:e.unit)&&void 0!==t?t:Ye,baseFontSize:(null==e?void 0:e.baseFontSize)&&e.baseFontSize>0?e.baseFontSize:He}},Je=(e,t)=>{if("px"===t.unit)return`${e}px`;const r=e/t.baseFontSize;return`${Number(r.toFixed(4))}${t.unit}`},Ke=({min:e,max:t,orientation:r},n)=>{const o=[];if(void 0!==e&&void 0!==t&&e>t)throw new O("REFRACT_E_MEDIA","Invalid media query: `min` cannot be greater than `max`.");return void 0!==e&&o.push(`(min-width: ${Je(e,n)})`),void 0!==t&&o.push(`(max-width: ${Je(t,n)})`),r&&o.push(`(orientation: ${r})`),o.length?`@media ${o.join(" and ")}`:""},Xe=(e,{min:t,max:r},n)=>{const o=[];if(void 0!==t&&void 0!==r&&t>r)throw new O("REFRACT_E_MEDIA","Invalid container query: `min` cannot be greater than `max`.");return void 0!==t&&o.push(`(min-width: ${Je(t,n)})`),void 0!==r&&o.push(`(max-width: ${Je(r,n)})`),o.length?`@container ${e} ${o.join(" and ")}`:""},Ze={xs:0,sm:576,md:768,lg:992,xl:1280},Qe=(e,t)=>{const r=Ge(t),n={};for(const[t,o]of Object.entries(null!=e?e:{}))n[t]=Ve(o.sizes,e=>Xe(t,{min:e.min,max:e.max},r));return n},et=new Set([3,6]),tt=(e,t,r)=>Math.min(r,Math.max(t,e)),rt=e=>tt(e,0,255),nt=e=>Math.round(1e3*tt(e,0,1))/1e3,ot=e=>{const t=e.replace(/^\s*#|\s*$/g,"");if(!et.has(t.length))throw new Error(`Unsupported hex length: "${t}". Use 3 or 6 digits.`);const r=3===t.length?t.replace(/(.)/g,"$1$1"):t;return[parseInt(r.substring(0,2),16),parseInt(r.substring(2,4),16),parseInt(r.substring(4,6),16)]},st=e=>{if(3!==e.length)throw new Error(`Expected RGB tuple of length 3, received ${e.length}`);return`#${e.map(e=>{const t=rt(Math.round(e)).toString(16);return 1===t.length?`0${t}`:t}).join("")}`},it=/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+)\s*)?\)$/i,at=e=>{const t=e.trim(),r=it.exec(t);return r?{rgb:[Number(r[1]),Number(r[2]),Number(r[3])],a:void 0===r[4]?1:nt(Number(r[4]))}:{rgb:ot(t),a:1}},lt=(e,t=1)=>{const r=nt(t),[n,o,s]=e,i=rt(Math.round(n)),a=rt(Math.round(o)),l=rt(Math.round(s));return r>=1?`rgb(${i}, ${a}, ${l})`:`rgba(${i}, ${a}, ${l}, ${r})`},ct=180/Math.PI,ut=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),dt=e=>e>=.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,ft=e=>{const[t,r,n]=e,o=((e,t,r)=>{const n=.4122214708*e+.5363325363*t+.0514459929*r,o=.2119034982*e+.6806995451*t+.1073969566*r,s=.0883024619*e+.2817188376*t+.6299787005*r,i=Math.cbrt(n),a=Math.cbrt(o),l=Math.cbrt(s);return{L:.2104542553*i+.793617785*a-.0040720468*l,a:1.9779984951*i-2.428592205*a+.4505937099*l,b:.0259040371*i+.7827717662*a-.808675766*l}})(ut(t/255),ut(r/255),ut(n/255)),s=Math.sqrt(o.a*o.a+o.b*o.b);let i=Math.atan2(o.b,o.a)*ct;return i<0&&(i+=360),{L:100*o.L,C:s,h:i}},pt=e=>{const t=tt(e.L,0,100)/100,r=e.h/ct,n=Math.cos(r),o=Math.sin(r),s=e=>((e,t,r)=>{const n=e+.3963377774*t+.2158037573*r,o=e-.1055613458*t-.0638541728*r,s=e-.0894841775*t-1.291485548*r,i=n*n*n,a=o*o*o,l=s*s*s;return[4.0767416621*i-3.3077115913*a+.2309699292*l,-1.2684380046*i+2.6097574011*a-.3413193965*l,-.0041960863*i-.7034186147*a+1.707614701*l]})(t,e*n,e*o),i=e=>e.every(e=>e>=-1e-6&&e<=1.000001);let a=s(e.C);if(!i(a)){let t=0,r=e.C;for(let e=0;e<24;e++){const e=(t+r)/2;i(s(e))?t=e:r=e}a=s(t)}return[255*dt(tt(a[0],0,1)),255*dt(tt(a[1],0,1)),255*dt(tt(a[2],0,1))]},mt=(e,t)=>{const{rgb:r,a:n}=at(e);return lt(pt(t(ft(r))),n)},ht=(e,t)=>mt(e,e=>({...e,L:tt(e.L+t,0,100)})),gt=(e,t)=>mt(e,e=>({...e,L:tt(e.L-t,0,100)})),bt=(e,t)=>mt(e,e=>({...e,L:tt(t,0,100)})),vt=(e,t)=>mt(e,e=>({...e,h:((e.h+t)%360+360)%360})),yt=(e,t)=>mt(e,e=>({L:void 0===t.l?e.L:tt(t.l,0,100),C:void 0===t.c?e.C:Math.max(0,e.C*t.c),h:void 0===t.h?e.h:((e.h+t.h)%360+360)%360})),wt=e=>{const{rgb:t,a:r}=at(e),n=st(t);if(r>=1)return n;return`${n}${rt(Math.round(255*r)).toString(16).padStart(2,"0")}`},$t=(e,t)=>{const{rgb:r}=at(e);return lt(r,(e=>tt(e,0,100))(t)/100)},kt={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},xt=e=>Math.round(1e3*Math.min(1,Math.max(0,e)))/1e3,jt=(e,t,r)=>{const n=(e%360+360)%360/60,o=(1-Math.abs(2*Math.min(1,Math.max(0,r))-1))*Math.min(1,Math.max(0,t)),s=o*(1-Math.abs(n%2-1)),i=Math.min(1,Math.max(0,r))-o/2,[a,l,c]=n<1?[o,s,0]:n<2?[s,o,0]:n<3?[0,o,s]:n<4?[0,s,o]:n<5?[s,0,o]:[o,0,s];return[255*(a+i),255*(l+i),255*(c+i)]},At=/^oklch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(?:deg)?\s*(?:\/\s*([\d.]+)(%?)\s*)?\)$/i,Et=/^hsla?\(\s*([\d.]+)(?:deg)?\s*[, ]\s*([\d.]+)%\s*[, ]\s*([\d.]+)%\s*(?:[,/]\s*([\d.]+)(%?)\s*)?\)$/i,St=e=>{if("string"==typeof e){const t=(e=>{const t=e.trim(),r=At.exec(t);if(r){const e="%"===r[2]?Number(r[1]):100*Number(r[1]),t=void 0===r[5]?1:xt("%"===r[6]?Number(r[5])/100:Number(r[5]));return{rgb:pt({L:e,C:Number(r[3]),h:Number(r[4])}),a:t}}const n=Et.exec(t);if(n){const e=void 0===n[4]?1:xt("%"===n[5]?Number(n[4])/100:Number(n[4]));return{rgb:jt(Number(n[1]),Number(n[2])/100,Number(n[3])/100),a:e}}const o=kt[t.toLowerCase()];if(o)return{rgb:ot(o),a:1};try{return at(t)}catch{return null}})(e);if(!t)throw new O("REFRACT_E_COLOR_INPUT",`Invalid colour "${e}". Author a colour as a hex string ("#4dabf7"), an [r, g, b] tuple, or a CSS colour — oklch(), hsl()/hsla(), rgb()/rgba(), or a named keyword (e.g. "rebeccapurple"). A var(--…) can't be tonally derived at build time.`);return lt(t.rgb,t.a)}if(!Array.isArray(e)||3!==e.length||e.some(e=>"number"!=typeof e))throw new O("REFRACT_E_COLOR_TUPLE",`Invalid colour tuple ${JSON.stringify(e)}. Use an [r, g, b] tuple with 0–255 channels (alpha comes from an \`alpha\` variant, not the base).`);const[t,r,n]=e;return lt([t,r,n])},Rt={lighten:(e,t)=>ht(e,Number(t)),darken:(e,t)=>gt(e,Number(t)),alpha:(e,t)=>$t(e,Number(t)),setL:(e,t)=>bt(e,Number(t)),rotateHue:(e,t)=>vt(e,Number(t)),adjust:(e,t)=>yt(e,t)},Ot=["light","lighter"],Ct=["dark","darker"],Tt=(e,t)=>{if(!e||!e.includes("."))return!1;const[r,n]=e.split(".");return`${r}.${n}`!=`colors.${t}`},Ft=(e,t)=>{try{return St(e)}catch(e){throw new O("REFRACT_E_COLOR_INPUT",`colors.${t}.text — ${e.message}`)}},Nt=(e,t,r={})=>{var n;const o=((e,t)=>{let r=t;if(void 0!==t.text&&(r={...r,text:Ft(t.text,e)}),t.variants){let n=!1;const o={};for(const[r,s]of Object.entries(t.variants))void 0!==s.text?(o[r]={...s,text:Ft(s.text,`${e}.variants.${r}`)},n=!0):o[r]=s;n&&(r={...r,variants:o})}if(t.modes){let n=!1;const o=t.modes.map(t=>void 0!==t.text?(n=!0,{...t,text:Ft(t.text,`${e}.modes.${t.mode}`)}):t);n&&(r={...r,modes:o})}return r})(e,t),s=(e=>{try{return at(e),!0}catch{return!1}})(o.base),i=!(!o.steps||!o.steps.length),a=Object.keys(r).length>0,l=void 0!==o.harmony;if((i||a||l)&&!s)throw new O("REFRACT_E_STEPS",`colors.${e} declares derived steps/variants but its base "${o.base}" is not a hex or [r,g,b] colour.`);const c=s?zt(o,e):{},u=s?qt(o,e):{},d=null!==(n=o.variants)&&void 0!==n?n:{},f={...c,...u,...d},p=Vt(e,o.base,f,r),m={...c,...u,...d,...p},h=Pt(o,e,m),g=_t(o,e,m);return Object.keys(m).length||h||g?{...o,...Object.keys(m).length?{variants:m}:{},...h?{modes:h}:{},...g?{responsive:g}:{}}:o},_t=(e,t,r)=>{const n=e.responsive;if(!n||!n.length)return;let o=!1;const s=n.map((e,n)=>{const s=e.ref,i=e.modifiers;if(!s||!Array.isArray(i)||!i.length){let t;for(const r of["base","text"]){const n=e[r];if("string"==typeof n||Array.isArray(n)){const o=St(n);o!==n&&(t=null!=t?t:{...e},t[r]=o)}}return t&&(o=!0),null!=t?t:e}const a=r[s];if(!a)throw new O("REFRACT_E_VARIANT_REF",`colors.${t}.responsive[${n}] references unknown variant "${s}".`);if(void 0===a.base)throw new O("REFRACT_E_VARIANT_REF",`colors.${t}.responsive[${n}] references "${s}", a cross-property derivation — not supported.`);const l=Dt({modifiers:i},t,`responsive[${n}]`);let c=a.base;for(const e of l)c=Rt[e.fn](c,e.arg);o=!0;const{ref:u,modifiers:d,...f}=e;return{...f,base:c,derive:{ref:`colors.${t}.${s}`,modifiers:l}}});return o?s:n},Pt=(e,t,r)=>{const n=e.modes;if(!n||!n.length)return;return n.map(n=>{var o;const s=n.mode,i=n.derive;if(!i)return n;const a=null!==(o=i.modifiers)&&void 0!==o?o:i.fn?[{fn:i.fn,arg:i.arg}]:[];if(Tt(i.ref,t)){const{base:e,derive:t,...r}=n;return{...r,derive:{ref:i.ref,modifiers:a}}}const l=((n,o)=>{if(!n||n===`colors.${t}`)return{value:e.base,path:`colors.${t}`};const s=n.includes(".")?n.slice(`colors.${t}.`.length):n,i=r[s];if(!i||void 0===i.base)throw new O("REFRACT_E_VARIANT_REF",`colors.${t}.modes.${o} references unknown variant "${n}".`);return{value:i.base,path:`colors.${t}.${s}`}})(i.ref,s);let c=l.value;for(const e of a){const r=Rt[e.fn];if(!r)throw new O("REFRACT_E_VARIANT_REF",`Unknown derivation fn "${e.fn}" for appearance mode "colors.${t}.modes.${s}".`);c=r(c,e.arg)}return{...n,base:c,derive:{ref:l.path,modifiers:a}}})},zt=(e,t)=>e.steps&&e.steps.length?Ut(e,t):It(e,t),Mt={complement:[{name:"complement",deg:180}],analogous:[{name:"analogous1",deg:-30},{name:"analogous2",deg:30}],"split-complement":[{name:"split1",deg:150},{name:"split2",deg:210}],triadic:[{name:"triadic1",deg:120},{name:"triadic2",deg:240}],tetradic:[{name:"tetradic1",deg:90},{name:"complement",deg:180},{name:"tetradic2",deg:270}]},qt=(e,t)=>{const r=e.harmony;if(void 0===r)return{};let n,o;if("string"==typeof r)n=r;else{if("object"!=typeof r||null===r||Array.isArray(r))throw new O("REFRACT_E_HARMONY",`colors.${t}.harmony must be a scheme name or a { scheme: [names] } object.`);{const e=Object.keys(r);if(1!==e.length)throw new O("REFRACT_E_HARMONY",`colors.${t}.harmony object form must name exactly one scheme; got [${e.join(", ")}].`);n=e[0],o=r[n]}}const s=Mt[n];if(!s)throw new O("REFRACT_E_HARMONY",`colors.${t}.harmony: unknown scheme "${n}". Use one of ${Object.keys(Mt).join(", ")}.`);const i={};return s.forEach((r,n)=>{var s;const a=null!==(s=null==o?void 0:o[n])&&void 0!==s?s:r.name;i[a]={base:vt(e.base,r.deg),derive:{ref:`colors.${t}`,fn:"rotateHue",arg:r.deg}}}),i},Lt=(e,t,r,n,o,s,i,a)=>{var l;const c=e=>e?`colors.${r}.${e}`:`colors.${r}`;let u,d=t.base;for(const t of o){if(void 0!==(null===(l=n[t])||void 0===l?void 0:l.base)){d=n[t].base,u=t;continue}const r=s(d,a);e[t]={base:r,derive:{ref:c(u),fn:i,arg:a}},d=r,u=t}},It=(e,t)=>{var r,n,o;const s=null!==(r=e.variants)&&void 0!==r?r:{},i={},a=null!==(n=e.lightenBy)&&void 0!==n?n:10,l=null!==(o=e.darkenBy)&&void 0!==o?o:10;return Lt(i,e,t,s,Ot,ht,"lighten",a),Lt(i,e,t,s,Ct,gt,"darken",l),i},Bt=e=>e<=0?100:e>=1e3?0:Math.min(98,Math.max(5,(1e3-e)/10)),Ut=(e,t)=>{var r,n;const o=null!==(r=e.steps)&&void 0!==r?r:[],s=o.find(e=>"number"!=typeof e||isNaN(e)||e<0||e>1e3);if(void 0!==s)throw new O("REFRACT_E_STEPS",`colors.${t}.steps must be numbers in 0–1000 (e.g. [50, …, 950]); got ${JSON.stringify(s)}.`);const i=null!==(n=e.variants)&&void 0!==n?n:{},a={};for(const r of o){const n=r.toString();if(i[n])continue;const o=Bt(r);a[n]={base:bt(e.base,o),derive:{ref:`colors.${t}`,fn:"setL",arg:o}}}return a},Dt=(e,t,r)=>{const n=`colors.${t}.variants.${r}`,o=e.modifiers;if(!Array.isArray(o)||0===o.length)throw new O("REFRACT_E_VARIANT",`${n} needs a non-empty "modifiers" array (e.g. [{ darken: 10 }]).`);return o.map((e,o)=>{if("object"!=typeof e||null===e||Array.isArray(e))throw new O("REFRACT_E_VARIANT",`${n}.modifiers[${o}] must be a single-key object like { darken: 10 }.`);const s=Object.keys(e);if(1!==s.length)throw new O("REFRACT_E_VARIANT",`${n}.modifiers[${o}] must have exactly one fn key; got [${s.join(", ")}].`);const i=s[0];if(!Rt[i])throw new O("REFRACT_E_VARIANT",`${n}.modifiers[${o}] unknown fn "${i}"; use ${Object.keys(Rt).join(" / ")}.`);const a=e[i],l="adjust"===i?((e,t,r)=>{const n=`colors.${t}.variants.${r}.adjust`;if("object"!=typeof e||null===e||Array.isArray(e))throw new O("REFRACT_E_ADJUST",`${n} must be an object with numeric l / c / h dials.`);const{l:o,c:s,h:i}=e,a={};if(void 0!==o){if("number"!=typeof o||isNaN(o)||o<0||o>100)throw new O("REFRACT_E_ADJUST",`${n}.l must be an absolute OKLCH lightness in 0–100; got ${JSON.stringify(o)}.`);a.l=o}if(void 0!==s){if("number"!=typeof s||isNaN(s)||s<0)throw new O("REFRACT_E_ADJUST",`${n}.c must be a non-negative chroma multiplier (1 keeps, 0 greys); got ${JSON.stringify(s)}.`);a.c=s}if(void 0!==i){if("number"!=typeof i||isNaN(i))throw new O("REFRACT_E_ADJUST",`${n}.h must be a numeric hue rotation in degrees; got ${JSON.stringify(i)}.`);a.h=i}return a})(a,t,r):Number(a);return{fn:i,arg:l}})},Vt=(e,t,r,n)=>{const o={},s=new Set,i=(t,r)=>{if(void 0===t.base)throw new O("REFRACT_E_VARIANT_REF",`colors.${e} variant chains off "${r}", which is a cross-property derivation — not supported.`);return t.base};function a(l,c){if(o[l])return;if(s.has(l))throw new O("REFRACT_E_CYCLE",`Cyclic colour variant derivation at colors.${e}.${l}.`);s.add(l);const u=Dt(c,e,l);if(Tt(c.ref,e))return o[l]={derive:{ref:c.ref,modifiers:u}},void s.delete(l);const d=(s=>{if(!s)return{value:t,path:`colors.${e}`};if(o[s])return{value:i(o[s],s),path:`colors.${e}.${s}`};if(r[s])return{value:i(r[s],s),path:`colors.${e}.${s}`};if(n[s])return a(s,n[s]),{value:i(o[s],s),path:`colors.${e}.${s}`};throw new O("REFRACT_E_VARIANT_REF",`colors.${e} variant references unknown source "${s}".`)})(c.ref);let f=d.value;for(const e of u)f=Rt[e.fn](f,e.arg);o[l]={base:f,derive:{ref:d.path,modifiers:u}},s.delete(l)}for(const[e,t]of Object.entries(n))a(e,t);return o},Wt=new Set("display position top right bottom left inset inset-block inset-block-start inset-block-end inset-inline inset-inline-start inset-inline-end float clear z-index visibility overflow overflow-x overflow-y overflow-block overflow-inline overflow-clip-margin overflow-anchor box-sizing width height min-width min-height max-width max-height block-size inline-size min-block-size min-inline-size max-block-size max-inline-size aspect-ratio margin margin-top margin-right margin-bottom margin-left margin-block margin-block-start margin-block-end margin-inline margin-inline-start margin-inline-end margin-trim padding padding-top padding-right padding-bottom padding-left padding-block padding-block-start padding-block-end padding-inline padding-inline-start padding-inline-end flex flex-grow flex-shrink flex-basis flex-direction flex-flow flex-wrap order justify-content justify-items justify-self align-content align-items align-self place-content place-items place-self gap row-gap column-gap grid grid-area grid-template grid-template-areas grid-template-columns grid-template-rows grid-auto-columns grid-auto-rows grid-auto-flow grid-column grid-column-start grid-column-end grid-row grid-row-start grid-row-end columns column-count column-width column-gap column-rule column-rule-color column-rule-style column-rule-width column-span column-fill color opacity accent-color caret-color color-scheme forced-color-adjust print-color-adjust background background-color background-image background-position background-position-x background-position-y background-size background-repeat background-origin background-clip background-attachment background-blend-mode mix-blend-mode isolation border border-width border-style border-color border-top border-top-width border-top-style border-top-color border-right border-right-width border-right-style border-right-color border-bottom border-bottom-width border-bottom-style border-bottom-color border-left border-left-width border-left-style border-left-color border-block border-block-width border-block-style border-block-color border-block-start border-block-start-width border-block-start-style border-block-start-color border-block-end border-block-end-width border-block-end-style border-block-end-color border-inline border-inline-width border-inline-style border-inline-color border-inline-start border-inline-start-width border-inline-start-style border-inline-start-color border-inline-end border-inline-end-width border-inline-end-style border-inline-end-color border-radius border-top-left-radius border-top-right-radius border-bottom-right-radius border-bottom-left-radius border-start-start-radius border-start-end-radius border-end-start-radius border-end-end-radius border-image border-image-source border-image-slice border-image-width border-image-outset border-image-repeat border-collapse border-spacing outline outline-width outline-style outline-color outline-offset box-shadow filter backdrop-filter clip-path mask mask-image mask-mode mask-repeat mask-position mask-clip mask-origin mask-size mask-composite mask-type opacity transform transform-origin transform-box transform-style perspective perspective-origin backface-visibility rotate scale translate transition transition-property transition-duration transition-timing-function transition-delay transition-behavior animation animation-name animation-duration animation-timing-function animation-delay animation-iteration-count animation-direction animation-fill-mode animation-play-state animation-composition animation-timeline will-change font font-family font-size font-size-adjust font-weight font-style font-variant font-variant-caps font-variant-numeric font-variant-ligatures font-variant-east-asian font-variant-alternates font-variant-position font-feature-settings font-variation-settings font-kerning font-stretch font-optical-sizing font-synthesis font-display line-height letter-spacing word-spacing text-align text-align-last text-decoration text-decoration-line text-decoration-color text-decoration-style text-decoration-thickness text-decoration-skip-ink text-underline-offset text-underline-position text-transform text-indent text-overflow text-shadow text-rendering text-wrap text-wrap-mode text-wrap-style text-emphasis text-emphasis-color text-emphasis-style text-emphasis-position text-orientation text-combine-upright text-justify white-space white-space-collapse word-break word-wrap overflow-wrap hyphens hyphenate-character line-break tab-size vertical-align writing-mode direction unicode-bidi quotes content list-style list-style-type list-style-position list-style-image counter-reset counter-increment counter-set cursor pointer-events user-select touch-action resize appearance caret scroll-behavior scroll-margin scroll-margin-top scroll-margin-right scroll-margin-bottom scroll-margin-left scroll-padding scroll-padding-top scroll-padding-right scroll-padding-bottom scroll-padding-left scroll-snap-type scroll-snap-align scroll-snap-stop overscroll-behavior overscroll-behavior-x overscroll-behavior-y scrollbar-width scrollbar-color scrollbar-gutter table-layout caption-side empty-cells vertical-align object-fit object-position image-rendering fill fill-opacity fill-rule stroke stroke-width stroke-opacity stroke-linecap stroke-linejoin stroke-dasharray stroke-dashoffset stroke-miterlimit paint-order shape-rendering stop-color flood-color lighting-color container container-type container-name contain content-visibility break-before break-after break-inside page-break-before page-break-after page-break-inside orphans widows all cx cy r rx ry d".split(" ")),Yt=/^-(webkit|moz|ms|o)-/,Ht=e=>{if(e.startsWith("--"))return!0;const t=e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();return!!Yt.test(t)||Wt.has(t)},Gt=new Set(["breakpoint","query","state","variant","target","orientation"]),Jt=(e,t,r)=>{const n={};if(!e)return n;for(const[o,s]of Object.entries(e)){if(void 0===s||Gt.has(o))continue;if(!Ht(o))throw new O("REFRACT_E_RECIPE_PROPERTY",`Unknown recipe property "${o}" in ${r} — expected a CSS property or a reserved key (variant, target, state, breakpoint, query, orientation, container, size).`);const e=Kt(s,t,r,o);void 0!==e&&(n[Xt(o)]=e)}return n},Kt=(e,t,r,n)=>{var o;if("number"==typeof e)return{value:e};const s=e.trim();if(!s)return;const i=s.split("."),a=i[0],l=t.properties[a];if(!l)return{value:s};const c=i.length>1?i.slice(1).join("."):void 0;if(!c)return{ref:`colors.${a}`};if("text"===c)return{ref:`colors.${a}.text`};if(!(null===(o=l.variants)||void 0===o?void 0:o[c]))throw new O("REFRACT_E_VARIANT_REF",`Unknown palette variant reference "${a}.${c}" in ${r}.${n}.`);return{ref:`colors.${a}.${c}`}},Xt=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Zt=e=>e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4),Qt=([e,t,r])=>.2126*Zt(e/255)+.7152*Zt(t/255)+.0722*Zt(r/255),er={fail:0,"AA-large":1,AA:2,AAA:3},tr=2.4,rr=.2126729,nr=.7151522,or=.072175,sr=.56,ir=.57,ar=.62,lr=.65,cr=.022,ur=1.414,dr=1.14,fr=.027,pr=1.14,mr=.027,hr=5e-4,gr=.1,br=([e,t,r])=>rr*Math.pow(e/255,tr)+nr*Math.pow(t/255,tr)+or*Math.pow(r/255,tr),vr=(e,t)=>{const r=e=>e>cr?e:e+Math.pow(cr-e,ur),n=r(br(e)),o=r(br(t));if(Math.abs(o-n)<hr)return 0;let s;if(o>n){const e=(Math.pow(o,sr)-Math.pow(n,ir))*dr;s=e<gr?0:e-fr}else{const e=(Math.pow(o,lr)-Math.pow(n,ar))*pr;s=e>-gr?0:e+mr}return 100*s},yr=(e,t)=>{const r=10**t;return Math.round(e*r)/r},wr=(e,t)=>{if(void 0!==t.ref)try{return String(e.resolveToken(t.ref))}catch{return}if("string"==typeof t.value)return t.value},$r="color",kr=["background-color","background"],xr=e=>{if(e)for(const t of kr)if(e[t])return e[t]},jr=(e,t,r,n,o)=>{let s,i;try{void 0!==r&&(s=at(r).rgb)}catch{}try{void 0!==n&&(i=at(n).rgb)}catch{}if(!s||!i)return{kind:e,label:t,fg:r,bg:n,skipped:s||i?s?"bg not a colour":"fg not a colour":"no derivable fg/bg"};const a=((e,t)=>{const r=Qt(e),n=Qt(t);return(Math.max(r,n)+.05)/(Math.min(r,n)+.05)})(s,i),l=((e,t)=>t?e>=4.5?"AAA":e>=3?"AA":"fail":e>=7?"AAA":e>=4.5?"AA":e>=3?"AA-large":"fail")(a,o.largeText),c=er[l]>=er[o.minWcag];return{kind:e,label:t,fg:r,bg:n,wcagRatio:yr(a,2),wcagLevel:l,apcaLc:yr(vr(s,i),1),pass:c}},Ar=(e,t={})=>{var r,n,o,s,i,a,l,c,u,d,f;const p={largeText:null!==(r=t.largeText)&&void 0!==r&&r,minWcag:null!==(n=t.minWcag)&&void 0!==n?n:"AA"},m=null===(o=t.includeRecipes)||void 0===o||o,h=[];if(null===(s=t.includePalettes)||void 0===s||s)for(const t of Object.keys(e.tokens)){const r=/^colors\.([^.]+)\.text$/.exec(t);if(!r)continue;const n=`colors.${r[1]}`;let o,s;try{o=String(e.resolveToken(t))}catch{}try{s=String(e.resolveToken(n))}catch{}h.push(jr("palette",n,o,s,p))}if(m)for(const[t,r]of Object.entries(e.model.subsystems))if(r.ruleSets)for(const[n,o]of Object.entries(r.ruleSets))for(const[r,s]of Object.entries(o)){const o=s.declarations[$r],m=xr(s.declarations),g=`${t}.${n}.${r}`;o&&m&&h.push(jr("recipe",g,wr(e,o),wr(e,m),p));for(const t of null!==(i=s.overrides)&&void 0!==i?i:[]){const r=null!==(l=null===(a=t.declarations)||void 0===a?void 0:a[$r])&&void 0!==l?l:o,n=null!==(c=xr(t.declarations))&&void 0!==c?c:m;if(!t.declarations||!t.declarations[$r]&&!xr(t.declarations))continue;if(!r||!n)continue;const s=null!==(f=null!==(d=null!==(u=t.state)&&void 0!==u?u:t.breakpoint)&&void 0!==d?d:t.query)&&void 0!==f?f:"override";h.push(jr("recipe",`${g} (${s})`,wr(e,r),wr(e,n),p))}}const g=h.filter(e=>!e.skipped),b=g.filter(e=>!1===e.pass),v=g.reduce((e,t)=>{var r,n;return void 0===e||(null!==(r=t.wcagRatio)&&void 0!==r?r:1/0)<(null!==(n=e.wcagRatio)&&void 0!==n?n:1/0)?t:e},void 0),y={pairings:h,summary:{total:g.length,passed:g.length-b.length,failed:b.length,skipped:h.length-g.length,worst:v},ok:0===b.length};if(t.strict&&b.length>0){const e=b.map(e=>`${e.label} (${e.wcagRatio}:1, ${e.wcagLevel})`).join(", ");throw new O("REFRACT_E_AUDIT",`refract audit: ${b.length} pairing(s) fail WCAG ${p.minWcag} — ${e}. Adjust the colour(s), lower --min-wcag, or drop --strict to report without failing.`,b.map(e=>`${e.label} (${e.wcagRatio}:1, ${e.wcagLevel})`))}return y},Er=new Set(["recipes"]),Sr=e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&!("base"in e)&&Array.isArray(e.modifiers),Rr=e=>{if("object"!=typeof e||null===e||Array.isArray(e)||!e.variants)return{value:e,specs:{}};const t=e.variants,r={},n={};for(const[e,o]of Object.entries(t))Sr(o)?r[e]=o:n[e]=o;if(!Object.keys(r).length)return{value:e,specs:r};const o=Object.keys(n).length?n:void 0;return{value:{...e,variants:o},specs:r}},Or={key:"colors",derivations:{lighten:(e,t)=>ht(String(e),Number(t)),darken:(e,t)=>gt(String(e),Number(t)),alpha:(e,t)=>$t(String(e),Number(t)),setL:(e,t)=>bt(String(e),Number(t)),rotateHue:(e,t)=>vt(String(e),Number(t)),adjust:(e,t)=>yt(String(e),t)},normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Er.has(n))continue;const{value:e,specs:s}=Rr(o),i=ve(e,{propertyPath:`colors.${n}`,allowedBreakpoints:t.allowedBreakpoints,coerceValue:St}),a=Nt(n,i,s);ce(a,{propertyPath:`colors.${n}`}),r[n]=a}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>{const n=`${r.groupPath}.${e}`;return{base:Jt(t.base,r,n),responsive:t.responsive.map(e=>{const{breakpoint:t,query:o,state:s,variant:i,target:a,orientation:l,container:c,size:u,...d}=e,f={declarations:{...i?{...r.resolveRecipeVariant(i).base}:{},...Jt(d,r,`${n}.responsive`)}};return t&&(f.breakpoint=t,f.query=null!=o?o:"exact"),c&&(f.container=c,u&&(f.size=u),f.query=null!=o?o:"min"),s&&(f.state=s),l&&(f.orientation=l),a&&(f.target=a),f})}})(e,t,r)},Cr={"minor-second":1.067,"major-second":1.125,"minor-third":1.2,"major-third":1.25,"perfect-fourth":1.333,"augmented-fourth":1.414,"perfect-fifth":1.5,golden:1.618},Tr={xs:-2,sm:-1,md:0,lg:1,xl:2,"2xl":3,"3xl":4,"4xl":5},Fr=(e,t)=>"fontSize"!==e?t:Nr(t),Nr=e=>{var t,r,n,o;const s=e.ratio;if(!s)return e;const i=Cr[s];if(!i)return e;const a=null!==(t=e.baseFontSize)&&void 0!==t?t:e.base,l=null!==(r=e.precision)&&void 0!==r?r:4,c=e.algorithm,u=null!==(n=e.variants)&&void 0!==n?n:{},d={};let f=null;for(const[e,t]of Object.entries(Tr)){if(u[e]){f=null!==(o=u[e].base)&&void 0!==o?o:null;continue}let r;r=c?c(a,e,t,f):a*Math.pow(i,t);const n=Number(r.toFixed(l));f=n,d[e]={base:n}}return{...e,variants:{...d,...u}}},_r=new Set(["breakpoint","query","state","variant","target","orientation"]),Pr={fontFamily:"font-family",fontSize:"font-size",fontWeight:"font-weight",lineHeight:"line-height",letterSpacing:"letter-spacing",fontStyle:"font-style",textTransform:"text-transform",textDecoration:"text-decoration",textAlign:"text-align"},zr=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(!n||_r.has(r))continue;const e=Pr[r];e&&(t[e]={ref:Mr(r,n)})}return t},Mr=(e,t)=>"base"===t?`typography.${e}`:`typography.${e}.${t}`,qr=new Set(["recipes"]),Lr={key:"typography",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(qr.has(n))continue;const e=ve(o,{propertyPath:`typography.${n}`,allowedBreakpoints:t.allowedBreakpoints}),s=Fr(n,e);ce(s,{propertyPath:`typography.${n}`}),r[n]=s}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:zr(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:s,target:i,orientation:a,container:l,size:c,...u}=e,d={declarations:{...s?{...r.resolveRecipeVariant(s).base}:{},...zr(u)}};return t&&(d.breakpoint=t,d.query=null!=n?n:"exact"),l&&(d.container=l,c&&(d.size=c),d.query=null!=n?n:"min"),o&&(d.state=o),i&&(d.target=i),a&&(d.orientation=a),d})}))(0,t,r)},Ir=["spacing","gutters","aspectRatio","sizes"],Br=new Set(["spacing","gutters","sizes"]),Ur=new Set(["spacing","gutters"]),Dr=["xs","sm","md","lg","xl","2xl","3xl","4xl"],Vr=e=>Number(e.toFixed(4)),Wr=(e,t)=>{var r;if(!Br.has(e))return t;const n=((e,t)=>{const r=t,n=void 0!==r.ratio,o=void 0!==r.step;if(!n&&!o)return;if(n&&o)throw new O("REFRACT_E_LAYOUT",`layout.${e}: declare only one of "ratio" (geometric) or "step" (linear) scale, not both.`);const s=r.steps;if(n){let t;if(void 0===s)t=Dr;else{if(!Array.isArray(s))throw new O("REFRACT_E_LAYOUT",`layout.${e}: a geometric scale ("ratio") needs "steps" as an ordered name array, e.g. ["sm","md","lg"].`);t=s.map(String)}const n=t.map((e,t)=>({name:e,exp:t}));return{curve:"geometric",ratio:Number(r.ratio),specs:n}}let i;if(void 0===s)i=Dr.map((e,t)=>({name:e,exp:t,mult:t+1}));else{if(Array.isArray(s)||"object"!=typeof s||null===s)throw new O("REFRACT_E_LAYOUT",`layout.${e}: a linear scale ("step") needs "steps" as a name→multiplier map, e.g. { sm:1, md:2, lg:3 }.`);i=Object.entries(s).map(([e,t],r)=>({name:e,exp:r,mult:Number(t)}))}return{curve:"linear",step:Number(r.step),specs:i}})(e,t);if(!n)return Ur.has(e)?Yr(t):t;const o=((e,t,r)=>{const n=`layout.${e}`,o={};for(const e of r.specs)if("geometric"===r.curve){const s=Vr(Number(t)*Math.pow(r.ratio,e.exp));o[e.name]={base:s,derive:{ref:n,fn:"scaleStep",arg:{curve:"geometric",ratio:r.ratio,exp:e.exp}}}}else{const t=Vr(r.step*e.mult);o[e.name]={base:t,derive:{ref:n,fn:"scaleStep",arg:{curve:"linear",step:r.step,mult:e.mult}}}}return o})(e,t.base,n);let s={...o,...null!==(r=t.variants)&&void 0!==r?r:{}};Ur.has(e)&&(s={...s,none:{base:0}});const i=((e,t,r,n)=>{if(!(null==r?void 0:r.length))return r;const o=`layout.${e}`,s=[];let i=!1;for(const a of r){const r=a;if(void 0===r.ratio&&void 0===r.step){s.push(r);continue}if(i=!0,void 0!==r.ratio&&void 0!==r.step)throw new O("REFRACT_E_LAYOUT",`layout.${e}: a responsive ramp entry may set only "ratio" or "step", not both.`);if(!n)throw new O("REFRACT_E_LAYOUT",`layout.${e}: a responsive ramp entry needs a base scale — declare a top-level "ratio"/"step" (+ "steps") first.`);const{breakpoint:l,query:c,orientation:u}=r,d=void 0!==r.ratio;for(const i of n.specs){let n,a;if(d){const e=Number(r.ratio),o=void 0!==r.base,s=Number(o?r.base:t);n=Vr(s*Math.pow(e,i.exp)),a={curve:"geometric",ratio:e,exp:i.exp,...o?{base:s}:{}}}else{if(void 0===i.mult)throw new O("REFRACT_E_LAYOUT",`layout.${e}: a linear responsive ramp ("step") requires a linear base scale (a name→multiplier "steps").`);const t=Number(r.step);n=Vr(t*i.mult),a={curve:"linear",step:t,mult:i.mult}}const f={breakpoint:l,query:c,target:i.name,base:n,derive:{ref:o,fn:"scaleStep",arg:a}};void 0!==u&&(f.orientation=u),s.push(f)}}return i?s:r})(e,t.base,t.responsive,n);return(e=>{const{ratio:t,step:r,steps:n,...o}=e;return o})({...t,variants:s,responsive:i})},Yr=e=>{var t;const r=null!==(t=e.variants)&&void 0!==t?t:{};return{...e,variants:{...r,none:{base:0}}}},Hr=new Set(["breakpoint","query","state","variant","target","orientation"]),Gr={paddingY:["padding-top","padding-bottom"],paddingX:["padding-left","padding-right"],marginY:["margin-top","margin-bottom"],marginX:["margin-left","margin-right"],gap:["gap"],background:["background"],width:["width"],minWidth:["min-width"],maxWidth:["max-width"],height:["height"],minHeight:["min-height"],maxHeight:["max-height"]},Jr={paddingY:"spacing",paddingX:"spacing",marginY:"spacing",marginX:"spacing",gap:"spacing",width:"sizes",minWidth:"sizes",maxWidth:"sizes",height:"sizes",minHeight:"sizes",maxHeight:"sizes",background:"literal"},Kr=(e,t)=>"base"===t?`layout.${e}`:`layout.${e}.${t}`,Xr=(e,t)=>{const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Hr.has(n))continue;if(!o)continue;const e=Gr[n];if(!e)throw new O("REFRACT_E_LAYOUT",`Unknown layout recipe property "${n}" in ${t}. Known verbs: ${Object.keys(Gr).join(", ")}. For arbitrary CSS use a component \`css\` delta.`);const s=Jr[n];for(const t of e)r[t]="literal"===s?{value:o}:{ref:Kr(s,o)}}return r},Zr=e=>({ref:"base"===e?"layout.spacing":`layout.spacing.${e}`}),Qr=e=>({ref:"base"===e?"layout.gutters":`layout.gutters.${e}`}),en=e=>({ref:`layout.${e}`}),tn=e=>({value:e}),rn=e=>Object.keys(e).sort((t,r)=>e[t]-e[r]),nn=[["templateColumns","grid-template-columns"],["templateRows","grid-template-rows"],["autoRows","grid-auto-rows"],["autoColumns","grid-auto-columns"],["justifyItems","justify-items"],["alignItems","align-items"],["justifyContent","justify-content"],["alignContent","align-content"]],on=(e,t)=>{const r={};t&&(r.display=tn("grid"));for(const[t,n]of nn){const o=e[t];o&&(r[n]=tn(o))}return e.gap&&(r.gap=Zr(e.gap)),r},sn=e=>{var t,r;if(!e||"string"==typeof e)return{mode:null!==(t=e)&&void 0!==t?t:"fixed"};const n=e;return{mode:null!==(r=n.base)&&void 0!==r?r:"fixed",inset:n.inset,gutter:n.gutter,direction:n.direction,align:n.align,justify:n.justify,maxWidth:n.maxWidth}},an=(e,t,r=new Set,n)=>{var o,s,i,a;const l=Ge(n),c=e=>Je(e,l),u={},d={},f=rn(t),p=e&&"object"==typeof e?e:void 0,m=p?{mode:null!==(o=p.base)&&void 0!==o?o:"fixed",inset:p.inset,gutter:p.gutter,direction:p.direction,align:p.align,justify:p.justify,maxWidth:p.maxWidth}:sn(null!=e?e:"fixed"),h=null!==(s=null==p?void 0:p.variants)&&void 0!==s?s:{},g=null!==(i=null==p?void 0:p.responsive)&&void 0!==i?i:[],b=e=>e?`container-${e}`:"container",v=(e,n)=>{var o,s,i,a,l,p,h,g,v;const y=e?`--${e}`:"",w=`container${y}--inset`,$=`container${y}--gutter`,k=null!==(s=null!==(o=n.inset)&&void 0!==o?o:m.inset)&&void 0!==s?s:"base",x=null!==(i=n.gutter)&&void 0!==i?i:m.gutter,j=null!==(l=null!==(a=n.mode)&&void 0!==a?a:m.mode)&&void 0!==l?l:"fixed",A=null!==(p=n.direction)&&void 0!==p?p:m.direction,E=null!==(h=n.align)&&void 0!==h?h:m.align,S=null!==(g=n.justify)&&void 0!==g?g:m.justify,R=null!==(v=n.maxWidth)&&void 0!==v?v:e?m.maxWidth:void 0;u[w]={base:Zr(k)},x&&(u[$]={base:Qr(x)});const O={"box-sizing":tn("border-box"),width:tn("100%"),"margin-left":tn("auto"),"margin-right":tn("auto"),"padding-left":en(w),"padding-right":en(w)};x&&(O.gap=en($)),A&&(O.display=tn("flex"),O["flex-direction"]=tn(A)),E&&(O["align-items"]=tn(E)),S&&(O["justify-content"]=tn(S));const C=[];if("fixed"===j){const e="string"==typeof R&&void 0!==t[R]?R:void 0,r=e?f.indexOf(e):-1;for(let n=0;n<f.length;n++){const o=f[n],s=t[r>=0&&n>r?e:o];0!==s?0===n?O["max-width"]=tn(c(s)):C.push({breakpoint:o,query:"min",declarations:{"max-width":tn(c(s))}}):0===n&&(O["max-width"]=tn("none"))}}else"fluid"===j?void 0!==R&&(O["max-width"]=((e,t,r)=>{return"number"==typeof e?tn(`${e}px`):t.has(e)?{ref:"base"===(n=e)?"layout.sizes":`layout.sizes.${n}`}:void 0!==r[e]?tn(`${r[e]}px`):tn(e);var n})(R,r,t)):O["max-width"]=tn("number"==typeof j?`${j}px`:j);d[b(e)]={kind:"recipe",declarations:O,overrides:C}};v(null,m);for(const[e,t]of Object.entries(h))v(e,sn(t));for(const e of g){const t=e.target,r=b(null!=t?t:null),n=d[r];if(!n)continue;const o={};if(e.direction&&(o["flex-direction"]=tn(e.direction)),e.align&&(o["align-items"]=tn(e.align)),e.justify&&(o["justify-content"]=tn(e.justify)),e.inset){const e=t?`container--${t}--inset`:"container--inset";o["padding-left"]=en(e),o["padding-right"]=en(e)}if(e.gutter){const e=t?`container--${t}--gutter`:"container--gutter";o.gap=en(e)}Object.keys(o).length&&n.overrides.push({breakpoint:e.breakpoint,query:null!==(a=e.query)&&void 0!==a?a:"exact",declarations:o})}return{ruleSetGroups:{container:d},configProperties:u}},ln=(e,t,r)=>{const n={},o={},s=e=>{e&&(Object.assign(n,e.ruleSetGroups),Object.assign(o,e.configProperties))};return s(((e,t)=>{var r,n;if(!e)return;const o="number"==typeof e?{size:e}:e,s=o.size,i=null!==(r=o.gutter)&&void 0!==r?r:"base",a=null!==(n=o.inset)&&void 0!==n?n:"none",l={"columns--size":{base:tn(String(s))},"columns--gutter":{base:Qr(i)},"columns--inset":{base:Zr(a)}},c={},u=Array.from({length:s},(e,t)=>t+1);for(const e of rn(t))for(const r of u){const n=`col-${e}-${r}`,o=`offset-${e}-${r}`,s={"grid-column-end":tn(`span ${r}`)},i={"grid-column-start":tn(String(r+1))};0===t[e]?(c[n]={kind:"utility",declarations:s,overrides:[]},c[o]={kind:"utility",declarations:i,overrides:[]}):(c[n]={kind:"utility",declarations:{},overrides:[{breakpoint:e,query:"min",declarations:s}]},c[o]={kind:"utility",declarations:{},overrides:[{breakpoint:e,query:"min",declarations:i}]})}return{ruleSetGroups:{columns:c},configProperties:l}})(e.columns,t)),s((e=>{var t,r;if(!e||!Object.keys(e).length)return;const n={};for(const[o,s]of Object.entries(e)){const e=on(s,!0),i=[];for(const e of null!==(t=s.responsive)&&void 0!==t?t:[]){const t=on(e,!1);Object.keys(t).length&&i.push({breakpoint:e.breakpoint,query:null!==(r=e.query)&&void 0!==r?r:"exact",declarations:t})}n[`grid-${o}`]={kind:"recipe",declarations:e,overrides:i}}return{ruleSetGroups:{grids:n},configProperties:{}}})(e.grids)),s((e=>{var t,r,n;if(!e||!Object.keys(e).length)return;const o={};for(const[s,i]of Object.entries(e)){const e={display:tn(i.inline?"inline-flex":"flex"),"flex-direction":tn(null!==(t=i.direction)&&void 0!==t?t:"column")};i.align&&(e["align-items"]=tn(i.align)),i.justify&&(e["justify-content"]=tn(i.justify)),i.wrap&&(e["flex-wrap"]=tn(i.wrap)),i.gap&&(e.gap=Zr(i.gap));const a=[];for(const e of null!==(r=i.responsive)&&void 0!==r?r:[]){const t={};void 0!==e.inline&&(t.display=tn(e.inline?"inline-flex":"flex")),e.direction&&(t["flex-direction"]=tn(e.direction)),e.align&&(t["align-items"]=tn(e.align)),e.justify&&(t["justify-content"]=tn(e.justify)),e.wrap&&(t["flex-wrap"]=tn(e.wrap)),Object.keys(t).length&&a.push({breakpoint:e.breakpoint,query:null!==(n=e.query)&&void 0!==n?n:"exact",declarations:t})}o[`stack-${s}`]={kind:"recipe",declarations:e,overrides:a}}return{ruleSetGroups:{stacks:o},configProperties:{}}})(e.stacks)),s(an(e.container,t,(e=>{const t=new Set;if(e&&"object"==typeof e&&!Array.isArray(e)){const r=e;"base"in r&&t.add("base");const n=r.variants;if(n&&"object"==typeof n)for(const e of Object.keys(n))t.add(e)}return t})(e.sizes),r)),{ruleSetGroups:n,configProperties:o}},cn=new Set(Ir),un={key:"layout",derivations:{scaleStep:(e,t)=>((e,t)=>{const r=null!=t?t:{};if("linear"===r.curve)return Vr(Number(r.step)*Number(r.mult));const n=void 0!==r.base?Number(r.base):Number(e);return Vr(n*Math.pow(Number(r.ratio),Number(r.exp)))})(e,t)},normalizeProperties(e,t){const r={};if(!e)return r;for(const n of Ir){const o=e[n];if(void 0===o||!cn.has(n))continue;const s=ve(o,{propertyPath:`layout.${n}`,allowedBreakpoints:t.allowedBreakpoints}),i=Wr(n,s);ce(i,{propertyPath:`layout.${n}`}),r[n]=i}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>{var n;const o=`${null!==(n=r.groupPath)&&void 0!==n?n:"layout.recipes"}.${e}`;return{base:Xr(t.base,o),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:s,variant:i,target:a,orientation:l,container:c,size:u,...d}=e,f={declarations:{...i?{...r.resolveRecipeVariant(i).base}:{},...Xr(d,o)}};return t&&(f.breakpoint=t,f.query=null!=n?n:"exact"),c&&(f.container=c,u&&(f.size=u),f.query=null!=n?n:"min"),s&&(f.state=s),a&&(f.target=a),l&&(f.orientation=l),f})}})(e,t,r),buildStructural:(e,t)=>ln(e,t.breakpoints,t.mediaConfig)},dn=new Set(["breakpoint","query","state","variant","target","orientation"]),fn={boxShadow:"box-shadow",opacity:"opacity",blur:"filter",transition:"transition",zIndex:"z-index"},pn={boxShadow:"shadow",opacity:"opacity",blur:"blur",transition:"transitions",zIndex:"zIndex"},mn=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(!n||dn.has(r))continue;const e=fn[r],o=pn[r];if(!e||!o)continue;const s={ref:hn(o,n)};"blur"===r&&(s.wrap="blur"),t[e]=s}return t},hn=(e,t)=>"base"===t?`effects.${e}`:`effects.${e}.${t}`,gn=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),bn=(e,t)=>{if(void 0!==e){if("number"!=typeof e||Number.isNaN(e))throw new O("REFRACT_E_EFFECTS",`${t} must be a number, received ${JSON.stringify(e)}.`);return e}},vn=(e,t)=>{if(void 0!==e){if("number"==typeof e){if(Number.isNaN(e))throw new O("REFRACT_E_EFFECTS",`${t} must be a number or length string, received ${JSON.stringify(e)}.`);return e}if("string"==typeof e){const r=K(e);if("raw"in r)throw new O("REFRACT_E_EFFECTS",`${t} must be a number or a <number><unit> length (received ${JSON.stringify(e)}).`);return void 0===r.unit?r.value:{value:r.value,unit:r.unit}}throw new O("REFRACT_E_EFFECTS",`${t} must be a number or length string, received ${JSON.stringify(e)}.`)}},yn=new Set(["offsetX","offsetY","blur","spread","color","inset"]),wn=(e,t)=>{if(!gn(e))throw new O("REFRACT_E_EFFECTS",`${t} must be a shadow-layer object, received ${JSON.stringify(e)}.`);for(const r of Object.keys(e))if(!yn.has(r))throw new O("REFRACT_E_EFFECTS",`${t} has unknown shadow field "${r}" (allowed: ${[...yn].join(", ")}).`);const r={},n=vn(e.offsetX,`${t}.offsetX`),o=vn(e.offsetY,`${t}.offsetY`),s=vn(e.blur,`${t}.blur`),i=vn(e.spread,`${t}.spread`);if(void 0!==n&&(r.offsetX=n),void 0!==o&&(r.offsetY=o),void 0!==s&&(r.blur=s),void 0!==i&&(r.spread=i),void 0!==e.color){if("string"!=typeof e.color||!e.color)throw new O("REFRACT_E_EFFECTS",`${t}.color must be a "colors.*" token-path string.`);r.color=e.color}if(void 0!==e.inset){if("boolean"!=typeof e.inset)throw new O("REFRACT_E_EFFECTS",`${t}.inset must be a boolean.`);e.inset&&(r.inset=!0)}return r},$n=new Set(["property","duration","timingFunction","delay"]),kn=(e,t)=>{if(!gn(e))throw new O("REFRACT_E_EFFECTS",`${t} must be a transition-part object, received ${JSON.stringify(e)}.`);for(const r of Object.keys(e))if(!$n.has(r))throw new O("REFRACT_E_EFFECTS",`${t} has unknown transition field "${r}" (allowed: ${[...$n].join(", ")}).`);if("string"!=typeof e.property||!e.property)throw new O("REFRACT_E_EFFECTS",`${t}.property is required (the CSS property to transition).`);const r={property:e.property},n=bn(e.duration,`${t}.duration`),o=bn(e.delay,`${t}.delay`);if(void 0!==n&&(r.duration=n),void 0!==e.timingFunction){if("string"!=typeof e.timingFunction||!e.timingFunction)throw new O("REFRACT_E_EFFECTS",`${t}.timingFunction must be a keyword or cubic-bezier(...) string.`);r.timingFunction=e.timingFunction}return void 0!==o&&(r.delay=o),r},xn=new Set(["recipes"]),jn={shadow:["offsetX","offsetY","blur","spread","color","inset"],transitions:["property","duration","timingFunction","delay"]},An=e=>"shadow"===e?t=>((e,t="effects.shadow")=>{if("string"==typeof e){if("none"===e)return"none";throw new O("REFRACT_E_EFFECTS",`${t} must be structured shadow layer(s) or "none" — raw CSS strings are not accepted (received ${JSON.stringify(e)}).`)}if(Array.isArray(e)){if(!e.length)throw new O("REFRACT_E_EFFECTS",`${t} is an empty shadow-layer array.`);return e.map((e,r)=>wn(e,`${t}[${r}]`))}return[wn(e,t)]})(t,`effects.${e}`):"transitions"===e?t=>((e,t="effects.transitions")=>{if("string"==typeof e){if("none"===e)return"none";throw new O("REFRACT_E_EFFECTS",`${t} must be structured transition part(s) or "none" — raw CSS strings are not accepted (received ${JSON.stringify(e)}).`)}if(Array.isArray(e)){if(!e.length)throw new O("REFRACT_E_EFFECTS",`${t} is an empty transition-part array.`);return e.map((e,r)=>kn(e,`${t}[${r}]`))}return[kn(e,t)]})(t,`effects.${e}`):void 0,En={key:"effects",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(xn.has(n))continue;const e=jn[n],s=An(n),i=ve(o,{propertyPath:`effects.${n}`,allowedBreakpoints:t.allowedBreakpoints,...e?{leafFields:e}:{},...s?{coerceValue:s}:{},...e?{fallbackBase:"none"}:{}});ce(i,{propertyPath:`effects.${n}`}),r[n]=i}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:mn(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:s,target:i,orientation:a,container:l,size:c,...u}=e,d={declarations:{...s?{...r.resolveRecipeVariant(s).base}:{},...mn(u)}};return t&&(d.breakpoint=t,d.query=null!=n?n:"exact"),l&&(d.container=l,c&&(d.size=c),d.query=null!=n?n:"min"),o&&(d.state=o),i&&(d.target=i),a&&(d.orientation=a),d})}))(0,t,r)},Sn=new Set(["breakpoint","query","state","variant","target","orientation","container","size"]),Rn=new Set(["as","side"]),On=new Set(["width","style","offset","radius","color"]),Cn=(e,t,r)=>"radius"===r?"border-radius":"offset"===r?"outline-offset":"outline"===e?`outline-${r}`:t?`border-${t}-${r}`:`border-${r}`,Tn=(e,t)=>"color"===e?{ref:t}:{ref:"base"===t?`borders.${e}`:`borders.${e}.${t}`},Fn=(e,t,r)=>{const n={};if(!e)return n;for(const[o,s]of Object.entries(e))s&&!Sn.has(o)&&!Rn.has(o)&&On.has(o)&&(n[Cn(t,r,o)]=Tn(o,s));return n},Nn=new Set(["recipes"]),_n={key:"borders",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(Nn.has(n))continue;const e=ve(o,{propertyPath:`borders.${n}`,allowedBreakpoints:t.allowedBreakpoints});ce(e,{propertyPath:`borders.${n}`}),r[n]=e}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>{var n;const o=null!==(n=t.base.as)&&void 0!==n?n:"border",s=t.base.side,i=Fn(t.base,o,s),a=t.responsive.map(e=>{var t,n;const{breakpoint:i,query:a,state:l,variant:c,target:u,orientation:d,container:f,size:p,as:m,side:h,...g}=e,b=null!==(t=m)&&void 0!==t?t:o,v=null!==(n=h)&&void 0!==n?n:s,y={declarations:{...c?{...r.resolveRecipeVariant(c).base}:{},...Fn(g,b,v)}};return i&&(y.breakpoint=i,y.query=null!=a?a:"exact"),f&&(y.container=f,p&&(y.size=p),y.query=null!=a?a:"min"),l&&(y.state=l),d&&(y.orientation=d),u&&(y.target=u),y});return{base:i,responsive:a}})(0,t,r)},Pn=new Set(["breakpoint","query","state","variant","target","orientation"]),zn={keyframes:"animation-name",duration:"animation-duration",easing:"animation-timing-function",delay:"animation-delay",iterationCount:"animation-iteration-count",direction:"animation-direction",fillMode:"animation-fill-mode",playState:"animation-play-state"},Mn={duration:"duration",easing:"easing",delay:"delay"},qn=(e,t)=>"base"===t?`animation.${e}`:`animation.${e}.${t}`,Ln=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e)){if(void 0===n||""===n||Pn.has(r))continue;const e=zn[r];e&&(t[e]="keyframes"===r?{ref:`animation.keyframes.${n}`}:Mn[r]?{ref:qn(Mn[r],String(n))}:{value:n})}return t},In=new Set(["keyframes","recipes"]),Bn=e=>e&&"object"==typeof e&&"ref"in e?{ref:String(e.ref)}:"string"==typeof e||"number"==typeof e?{value:e}:void 0,Un=e=>{const t={};for(const[r,n]of Object.entries(e)){const e=Bn(n);e&&(t[r]=e)}return t},Dn=e=>{const t=[];for(const[r,n]of Object.entries(e))t.push({stop:r,declarations:Un(n)});return{steps:t}},Vn=e=>{if(!e||"object"!=typeof e)return{};const t={};for(const[r,n]of Object.entries(e))n&&"object"==typeof n&&(t[r]=Dn(n));return t},Wn={key:"animation",normalizeProperties(e,t){const r={};if(!e)return r;for(const[n,o]of Object.entries(e)){if(In.has(n))continue;const e=ve(o,{propertyPath:`animation.${n}`,allowedBreakpoints:t.allowedBreakpoints});ce(e,{propertyPath:`animation.${n}`}),r[n]=e}return r},interpretRecipe:(e,t,r)=>((e,t,r)=>({base:Ln(t.base),responsive:t.responsive.map(e=>{const{breakpoint:t,query:n,state:o,variant:s,target:i,orientation:a,container:l,size:c,...u}=e,d={declarations:{...s?{...r.resolveRecipeVariant(s).base}:{},...Ln(u)}};return t&&(d.breakpoint=t,d.query=null!=n?n:"exact"),l&&(d.container=l,c&&(d.size=c),d.query=null!=n?n:"min"),o&&(d.state=o),i&&(d.target=i),a&&(d.orientation=a),d})}))(0,t,r),buildStructural:e=>({ruleSetGroups:{},configProperties:{},keyframes:Vn(e.keyframes)})},Yn=e=>{const t={};if(!e)return t;for(const[r,n]of Object.entries(e))t[Gn(r)]=Hn(n);return t},Hn=e=>"object"==typeof e?{ref:e.ref}:{value:e},Gn=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Jn={key:"components",normalizeProperties:()=>({}),interpretRecipe:(e,t,r)=>((e,t)=>({base:Yn(t.base.css),responsive:t.responsive.map(e=>{var t,r;const n=e,o={declarations:Yn(n.css)};return n.breakpoint&&(o.breakpoint=n.breakpoint,o.query=null!==(t=n.query)&&void 0!==t?t:"exact"),n.container&&(o.container=n.container,n.size&&(o.size=n.size),o.query=null!==(r=n.query)&&void 0!==r?r:"min"),n.state&&(o.state=n.state),n.orientation&&(o.orientation=n.orientation),n.target&&(o.target=n.target),o})}))(0,t),extractReferences:e=>(e=>{const t=[];for(const[r,n]of Object.entries(e))D.has(r)&&"string"==typeof n&&n.includes(".")&&t.push(`${r}:${n}`);return t})(e)},Kn=e=>({value:e}),Xn=e=>({ref:e}),Zn=(e,t)=>({kind:"reset",selector:e,declarations:t,overrides:[]}),Qn=e=>{const t={};for(const[r,n,o]of e){const e={};for(const[t,r]of Object.entries(o))e[t]=Kn(r);t[r]=Zn(n,e)}return t},eo=[["h1","4xl"],["h2","3xl"],["h3","2xl"],["h4","xl"],["h5","lg"],["h6","md"]],to={preflight:{static:[["box","*,::before,::after",{"box-sizing":"border-box","border-width":"0","border-style":"solid"}],["body","body",{margin:"0","line-height":"inherit"}],["headings","h1,h2,h3,h4,h5,h6",{"font-size":"inherit","font-weight":"inherit",margin:"0"}],["blocks","p,figure,blockquote,dl,dd",{margin:"0"}],["lists","ul,ol",{"list-style":"none",margin:"0",padding:"0"}],["media","img,picture,video,canvas,svg",{display:"block","max-width":"100%"}],["forms","button,input,select,textarea",{font:"inherit",color:"inherit"}],["anchors","a",{color:"inherit","text-decoration":"inherit"}]],headings:!0},normalize:{static:[["box","*,::before,::after",{"box-sizing":"border-box"}],["body","body",{margin:"0"}],["media","img,picture,video,canvas,svg",{"max-width":"100%"}]],headings:!1},reset:{static:[["box","*,::before,::after",{"box-sizing":"border-box"}],["all","*",{margin:"0",padding:"0",border:"0",font:"inherit","vertical-align":"baseline"}],["headings","h1,h2,h3,h4,h5,h6",{"font-size":"inherit","font-weight":"inherit"}],["lists","ul,ol",{"list-style":"none"}],["media","img,picture,video,canvas,svg",{display:"block","max-width":"100%"}]],headings:!0}},ro=Object.keys(to),no=e=>{if(!1===e)return{};const t=to[e];if(!t)throw new O("REFRACT_E_PRESET",`globals: unknown preset "${e}" — expected one of ${ro.join(", ")} or false`);const r={static:Qn(t.static)};return t.headings&&(r.defaults=(()=>{const e={};for(const[t,r]of eo)e[t]=Zn(t,{"font-size":Xn(`typography.fontSize.${r}`)});return e})()),r},oo=new Set(["state","breakpoint","query","orientation","container","size","variant","target"]),so=e=>null!==e&&"object"==typeof e?{ref:e.ref}:{value:e},io=e=>e.startsWith("--")?e:e.replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),ao=e=>{const t={};for(const[r,n]of Object.entries(e))null==n||oo.has(r)||(t[io(r)]=so(n));return t},lo=e=>{const t={declarations:ao(e)},r=e;for(const e of oo)void 0!==r[e]&&(t[e]=r[e]);return t},co=(e,t,r)=>(e=>({declarations:ao(e.base),overrides:e.responsive.map(lo)}))(Ce({[e]:t},r)[e]),uo=(e,t)=>{const r=null!=e?e:{},n={};if(void 0!==r.preset){const e=no(r.preset);e.static&&(n.static=e.static),e.defaults&&(n.defaults=e.defaults)}const o=((e,t)=>{if(!e||!Object.keys(e).length)return;const r=Object.keys(t.breakpoints),n={};for(const[o,s]of Object.entries(e)){if(!s||"object"!=typeof s)continue;const e={propertyPath:`globals.elements.${o}`,allowedBreakpoints:r,allowedStates:t.allowedStates,allowedContainers:t.allowedContainers},{variants:i,...a}=s,l=co(o,a,e),c={kind:"globals",selector:o,declarations:l.declarations,overrides:l.overrides};if(i&&"object"==typeof i&&Object.keys(i).length){const t={};for(const[r,n]of Object.entries(i))n&&"object"==typeof n&&(t[r]=co(r,n,{...e,propertyPath:`${e.propertyPath}.variants.${r}`}));Object.keys(t).length&&(c.variants=t)}n[o]=c}return Object.keys(n).length?n:void 0})(r.elements,t);return o&&(n.elements=o),n},fo=[Or,Lr,un,En,_n,Wn,Jn,{key:"globals",normalizeProperties:()=>({}),buildStructural:(e,t)=>({ruleSetGroups:uo(e,t),configProperties:{}})}];const po=(e,t)=>Ve(e,e=>Ke(e,Ge(t))),mo=e=>{var t;if(!e||"object"!=typeof e)return;const r={};for(const[n,o]of Object.entries(e))o&&"object"==typeof o&&o.sizes&&Object.keys(o.sizes).length&&(r[n]={type:null!==(t=o.type)&&void 0!==t?t:"inline-size",sizes:{...o.sizes}});return Object.keys(r).length?r:void 0},ho=e=>{if(!e)return;const t=new Map;for(const[r,n]of Object.entries(e))t.set(r,new Set(Object.keys(n.sizes)));return t},go=(e,t)=>{if(e.startsWith("--"))return e;const r=e.split(".").join("-").toLowerCase();return t?`--${t}-${r}`:`--${r}`};function bo(e,t,r){const{clean:n,externals:o}=((e,t)=>{if(!e)return{clean:e,externals:{}};const r={},n={};for(const[o,s]of Object.entries(e))if(null===s||"object"!=typeof s||Array.isArray(s)||"string"!=typeof s.external)r[o]=s;else{const e=go(s.external,t);n[o]={base:`var(${e})`,external:e,responsive:[]}}return{clean:r,externals:n}})(t,r.extendsPrefix),s=e.normalizeProperties(n,{allowedBreakpoints:r.allowedBreakpoints});Object.assign(s,o);const i=r.inheritedProperties?{...r.inheritedProperties,...s}:s,a=function(e,t,r){var n,o;if(!e.interpretRecipe||!t||!Object.keys(t).length)return{};const s={};for(const[i,a]of Object.entries(t)){const t=`${e.key}.recipes.${i}`,l=Ce(a,{propertyPath:t,allowedBreakpoints:r.allowedBreakpoints,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers}),c=Pe(l,(n,o,s)=>e.interpretRecipe(n,o,{breakpoints:r.breakpoints,media:r.media,properties:r.properties,resolveRecipeVariant:s,groupPath:t}),{groupPath:t}),u=c.resolveAll(),d={};for(const[t,r]of Object.entries(u))if(e.extractReferences){const s=e.extractReferences(null!==(o=null===(n=l[t])||void 0===n?void 0:n.base)&&void 0!==o?o:{});d[t]=U(r,s)}else d[t]=B(r);s[i]=d}return s}(e,null==t?void 0:t.recipes,{breakpoints:r.breakpoints,media:r.media,properties:i,allowedBreakpoints:r.allowedBreakpoints,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers});let l,c,u=a;if(e.buildStructural&&t){const n=e.buildStructural(t,{breakpoints:r.breakpoints,media:r.media,mediaConfig:r.mediaConfig,allowedStates:r.allowedStates,allowedContainers:r.allowedContainers});u={...n.ruleSetGroups,...a},Object.keys(n.configProperties).length&&(l=n.configProperties),n.keyframes&&Object.keys(n.keyframes).length&&(c=n.keyframes)}const d={};return Object.keys(s).length&&(d.properties=s),Object.keys(u).length&&(d.ruleSetGroups=u),l&&(d.extraProperties=l),c&&(d.keyframes=c),d}function vo(e){const t={};if(!(null==e?void 0:e.properties))return t;for(const[r,n]of Object.entries(e.properties)){const e={base:n.base.value};if(n.variants&&Object.keys(n.variants).length){const t={};for(const[e,r]of Object.entries(n.variants)){const n={base:r.base.value};if(r.extras)for(const[e,t]of Object.entries(r.extras))n[e]=t.value;t[e]=n}e.variants=t}if(n.extras)for(const[t,r]of Object.entries(n.extras))e[t]=r.value;t[r]=e}return t}function yo(e,t){var r,n,o,s,i;if(!e)return t;const a={...e};if(t.properties&&(a.properties={...null!==(r=e.properties)&&void 0!==r?r:{},...t.properties}),t.ruleSets){const r={...null!==(n=e.ruleSets)&&void 0!==n?n:{}};for(const[n,i]of Object.entries(t.ruleSets))r[n]={...null!==(s=null===(o=e.ruleSets)||void 0===o?void 0:o[n])&&void 0!==s?s:{},...i};a.ruleSets=r}return t.keyframes&&(a.keyframes={...null!==(i=e.keyframes)&&void 0!==i?i:{},...t.keyframes}),a}function wo(e,t){var r,n,o,s;const{adapter:i}=t,a=e,l=null!==(r=a.breakpoints)&&void 0!==r?r:Ze,c=Object.keys(l),u=null!==(o=null===(n=a.extends)||void 0===n?void 0:n.prefix)&&void 0!==o?o:"dt",d=i.allowedStates,f=new Set(null!==(s=a.modes)&&void 0!==s?s:["dark","light"]),p=t.media,m=po(l,p),h=mo(a.containers),g=ho(h),b={};for(const e of fo){const t=bo(e,a[e.key],{breakpoints:l,extendsPrefix:u,media:m,mediaConfig:p,allowedBreakpoints:c,allowedStates:d,allowedContainers:g});Object.keys(t).length&&(b[e.key]=t)}const v=(e=>{var t;const r={},n=W(e.colors);n&&(r.colors=n);const o=W(e.typography);o&&(r.typography=o);const s=W(e.layout);s&&(r.layout=s);const i=W(e.effects);i&&(r.effects=i);const a=W(e.borders);a&&(r.borders=a);const l=W(e.animation);l&&(r.animation=l),V(null===(t=e.components)||void 0===t?void 0:t.ruleSetGroups)&&(r.components={ruleSets:e.components.ruleSetGroups});const c=W(e.globals);c&&(r.globals=c);const u={breakpoints:e.breakpoints,subsystems:r};return e.containers&&Object.keys(e.containers).length&&(u.containers=e.containers),u})({breakpoints:l,containers:h,...b}),y={units:t.units,baseFontSize:t.baseFontSize},w=function(e,t){var r;const{propertiesOverlay:n,ruleSetsOverlay:o,keyframesOverlay:s,containersOverlay:i}=t;if(!(n||o||s||i))return e;const a={...e.subsystems},l=new Set([...Object.keys(null!=n?n:{}),...Object.keys(null!=o?o:{}),...Object.keys(null!=s?s:{})]);for(const e of l)a[e]=yo(a[e],{properties:null==n?void 0:n[e],ruleSets:null==o?void 0:o[e],keyframes:null==s?void 0:s[e]});const c={...e,subsystems:a};return i&&(c.containers={...null!==(r=e.containers)&&void 0!==r?r:{},...i}),c}(ie(v,y),t),$=(e=>{const t={};for(const r of e)for(const[e,n]of Object.entries(r)){if(e in t)throw new O("REFRACT_E_TOKEN_PATH",`Duplicate derivation fn "${e}" registered by two subsystems.`);t[e]=n}return t})(fo.flatMap(e=>e.derivations?[e.derivations]:[])),k=Be(w,$),x=[...ko(k),...xo(k),...jo(k),...$o(k,f)];if(x.length>0){const e=x.map(e=>` - ${e}`).join("\n");throw new O("REFRACT_E_VALIDATION",`refract: ${x.length} validation error(s):\n${e}`,x)}return Ao(k,{adapter:i,derivationRegistry:$,allowedStates:d,mediaConfig:p,unitConfig:y})}function $o(e,t){var r,n,o;const s=[],i=(e,r,n,o)=>{t.has(n)||s.push(`${e}.${r}${o}: unknown appearance mode '${n}' — declare it in the top-level 'modes' registry (known: ${[...t].join(", ")})`)};for(const[t,s]of Object.entries(e.subsystems))for(const[e,a]of Object.entries(null!==(r=s.properties)&&void 0!==r?r:{})){for(const r of null!==(n=a.modes)&&void 0!==n?n:[])r.mode&&i(t,e,r.mode,"");for(const r of null!==(o=a.responsive)&&void 0!==o?o:[])r.mode&&i(t,e,r.mode," (responsive)")}return s}function ko(e){var t,r,n,o,s;const i=null===(t=e.subsystems.components)||void 0===t?void 0:t.ruleSets;if(!i)return[];const a=[];for(const[t,l]of Object.entries(i))for(const[i,c]of Object.entries(l))for(const l of null!==(r=c.references)&&void 0!==r?r:[]){const[r,c=""]=l.split(":"),u=c.indexOf("."),d=u>=0?c.slice(0,u):c,f=u>=0?c.slice(u+1):"";(null===(s=null===(o=null===(n=e.subsystems[r])||void 0===n?void 0:n.ruleSets)||void 0===o?void 0:o[d])||void 0===s?void 0:s[f])||a.push(`components.${t}.${i}: Recipe variant "${f}" is not defined in "${r}:${d}". Check the subsystem:group.variant reference against what the subsystem declares.`)}return a}function xo(e){var t,r;const n=null===(t=e.subsystems.components)||void 0===t?void 0:t.ruleSets;if(!n)return[];const o=Y(e),s=[],i=(e,t,r,n)=>{for(const[i,a]of Object.entries(null!=e?e:{}))void 0===a.ref||a.ref in o||s.push(`components.${t}.${r}: css '${i}'${n} references unknown token '${a.ref}' — check the token path, or use a bare string / number for a raw CSS value`)};for(const[e,t]of Object.entries(n))for(const[n,o]of Object.entries(t)){i(o.declarations,e,n,"");for(const t of null!==(r=o.overrides)&&void 0!==r?r:[])i(t.declarations,e,n," (override)")}return s}function jo(e){var t,r,n,o,s;const i=null===(t=e.subsystems.globals)||void 0===t?void 0:t.ruleSets;if(!i)return[];const a=Y(e),l=[],c=(e,t,r)=>{for(const[n,o]of Object.entries(null!=e?e:{}))void 0===o.ref||o.ref in a||l.push(`globals element '${t}'${r}: '${n}' references unknown token '${o.ref}' — check the token path, or use a bare string / number for a raw CSS value`)};for(const e of Object.values(i))for(const t of Object.values(e)){if("globals"!==t.kind)continue;const e=null!==(r=t.selector)&&void 0!==r?r:"";c(t.declarations,e,"");for(const r of null!==(n=t.overrides)&&void 0!==n?n:[])c(r.declarations,e," (override)");for(const[r,n]of Object.entries(null!==(o=t.variants)&&void 0!==o?o:{})){const t=` (variant '${r}')`;c(n.declarations,e,t);for(const r of null!==(s=n.overrides)&&void 0!==s?s:[])c(r.declarations,e,`${t} (override)`)}}return l}function Ao(e,t){var r;const n=po(e.breakpoints,t.mediaConfig),o=Qe(e.containers,t.mediaConfig),s=new WeakMap,i=()=>{let t=s.get(e);return t||(t=Y(e),s.set(e,t)),t},a=e=>ze(i(),t.derivationRegistry,e),l={media:n,containers:o,resolve:a},c=t.adapter.bind(e,l),u={model:e,get tokens(){return i()},resolveToken:a,override:r=>function(e,t,r){var n,o,s;const i=t.breakpoints,a=i?{...e.breakpoints,...i}:e.breakpoints,l=Object.keys(a),c=po(a,r.mediaConfig),u=mo(t.containers),d=u?{...null!==(n=e.containers)&&void 0!==n?n:{},...u}:e.containers,f=ho(d),p={...e.subsystems};for(const n of fo){const i=t[n.key];if(void 0===i)continue;const u=vo(e.subsystems[n.key]),d=bo(n,i,{breakpoints:a,extendsPrefix:null!==(s=null===(o=t.extends)||void 0===o?void 0:o.prefix)&&void 0!==s?s:"dt",media:c,mediaConfig:r.mediaConfig,allowedBreakpoints:l,allowedStates:r.allowedStates,allowedContainers:f,inheritedProperties:u}),m=W(d);m&&(p[n.key]=yo(e.subsystems[n.key],m))}const m={breakpoints:a,subsystems:p};d&&Object.keys(d).length&&(m.containers=d);const h=ie(m,r.unitConfig),g=Be(h,r.derivationRegistry);return Ao(g,r)}(e,r,t)},d=null===(r=c.extend)||void 0===r?void 0:r.call(c,u);return d&&Object.defineProperties(u,Object.getOwnPropertyDescriptors(d)),u}const Eo="theme.css",So="styles.css",Ro="variables.css",Oo=(e,t)=>"variables"===t?`${e}.variables.css`:`${e}.css`,Co=e=>`${e.group}-${e.variant}.css`,To="variables.css";function Fo(e){var t,r,n,o,s,i,a,l;if(void 0===e)return{type:"single",file:Eo};if("string"==typeof e)switch(e){case"single":return{type:"single",file:Eo};case"split":return{type:"split",file:So,variables:Ro};case"subsystem":return{type:"subsystem",filename:Oo};case"components":return{type:"components",inline:!0,filename:Co,variables:To}}switch(null!==(t=e.type)&&void 0!==t?t:"variables"in e?"split":"single"){case"single":return{type:"single",file:null!==(r=e.file)&&void 0!==r?r:Eo};case"split":{const t=e;return{type:"split",file:null!==(n=t.file)&&void 0!==n?n:So,variables:null!==(o=t.variables)&&void 0!==o?o:Ro}}case"subsystem":return{type:"subsystem",filename:null!==(s=e.filename)&&void 0!==s?s:Oo};case"components":{const t=e;return{type:"components",inline:null===(i=t.inline)||void 0===i||i,filename:null!==(a=t.filename)&&void 0!==a?a:Co,variables:null!==(l=t.variables)&&void 0!==l?l:To}}}throw new Error("resolveEmitPlan: unrecognized emit directive.")}const No="com.theme-registry.refract",_o=e=>"object"==typeof e&&null!==e&&"$value"in e,Po=/^\{([^}]+)\}$/,zo=(e,t,r=new Set)=>{if("string"==typeof e){const n=e.match(Po);if(n){const o=n[1];if(r.has(o))throw new O("REFRACT_E_CYCLE",`Circular token reference: ${o}`);const s=t.get(o);return s?(r.add(o),zo(s.value,t,r)):e}return e}if(Array.isArray(e))return e.map(e=>zo(e,t,new Set(r)));if("object"==typeof e&&null!==e){const n={};for(const[o,s]of Object.entries(e))n[o]=zo(s,t,new Set(r));return n}return e};function Mo(e){var t;const r=[];for(const[n,o]of Object.entries(e.subsystems))for(const[e,s]of Object.entries(null!==(t=o.ruleSets)&&void 0!==t?t:{}))for(const t of Object.keys(s))r.push({subsystem:n,group:e,variant:t});return r}function qo(){return{name:(e={name:"noop",version:1,bind:()=>({recipeName:()=>"",renderRecipe:()=>"",renderVariables:()=>"",join:e=>e.join(""),emit:()=>({files:{}})})}).name,version:e.version,allowedStates:e.allowedStates,bind(t,r){var n,o,s,i;const a=e.bind(t,r),l=null!==(n=a.renderAllRecipes)&&void 0!==n?n:()=>a.join(Mo(t).map(({subsystem:e,group:t,variant:r})=>a.renderRecipe(e,t,r))),c=null!==(o=a.renderAllVariables)&&void 0!==o?o:()=>a.join(Object.keys(t.subsystems).map(e=>a.renderVariables(e))),u=null!==(s=a.renderAll)&&void 0!==s?s:()=>a.join([c(),l()]),d=null!==(i=a.describeUsage)&&void 0!==i?i:()=>({format:e.name,summary:[`This theme was built with the "${e.name}" refract adapter.`],recipes:Mo(t).map(({subsystem:e,group:t,variant:r})=>({subsystem:e,group:t,variant:r,name:a.recipeName(e,t,r)}))});return{...a,renderAllRecipes:l,renderAllVariables:c,renderAll:u,describeUsage:d}}};var e}const Lo=(e,t)=>{var r,n,o;const s=(e=>{const t=[],r=new Map,n=(e,o,s)=>{var i,a,l;const c=null!==(i=e.$type)&&void 0!==i?i:s;for(const[s,i]of Object.entries(e)){if(s.startsWith("$"))continue;if("object"!=typeof i||null===i)continue;const e=[...o,s];if(_o(i)){const n=i,o={path:e,type:null!==(l=null!==(a=n.$type)&&void 0!==a?a:c)&&void 0!==l?l:"color",value:n.$value,description:n.$description,extensions:n.$extensions};t.push(o),r.set(e.join("."),o)}else n(i,e,c)}};n(e,[]);for(const e of t)e.value=zo(e.value,r);return t})(e),i=null!==(r=null==t?void 0:t.groupMapping)&&void 0!==r?r:{},a={},l={},c={},u={},d={};let f=null!==(n=null==t?void 0:t.breakpoints)&&void 0!==n?n:{};const p=new Map;for(const e of s){const t=e.path[0];p.has(t)||p.set(t,[]),p.get(t).push(e)}const m=null==t?void 0:t.breakpointGroup;if(m&&p.has(m)){f={};for(const e of p.get(m)){f[e.path[e.path.length-1]]=ts(e.value)}p.delete(m)}for(const[e,t]of p){const r=null!==(o=i[e])&&void 0!==o?o:Io(e,t);if("ignore"!==r)switch(r){case"colors":Do(t,e,a);break;case"typography":Wo(t,e,l);break;case"effects":Go(t,e,c);break;case"borders":Ko(t,e,u);break;case"layout":Zo(t,e,d)}}const h={};return Object.keys(f).length&&(h.breakpoints=f),Object.keys(a).length&&(h.colors=a),Object.keys(l).length&&(h.typography=l),Object.keys(c).length&&(h.effects=c),Object.keys(u).length&&(h.borders=u),Object.keys(d).length&&(h.layout=d),h},Io=(e,t)=>{var r;const n=null===(r=t[0])||void 0===r?void 0:r.type;if("color"===n)return"colors";if("typography"===n)return"typography";if("shadow"===n)return"effects";if("border"===n)return"borders";if("strokeStyle"===n)return"borders";if("transition"===n)return"effects";const o=e.toLowerCase();if(o.includes("color")||o.includes("palette"))return"colors";if(o.includes("font")||o.includes("typo")||o.includes("text"))return"typography";if(o.includes("spacing")||o.includes("space")||o.includes("gutter"))return"layout";if(o.includes("radius")||o.includes("border")||o.includes("outline"))return"borders";if(o.includes("shadow")||o.includes("blur")||o.includes("opacity")||o.includes("z-index")||o.includes("zindex")||o.includes("transition")||o.includes("effect"))return"effects";if("dimension"===n){if(o.includes("spacing")||o.includes("gap"))return"layout";if(o.includes("radius")||o.includes("border"))return"borders";if(o.includes("font")||o.includes("size"))return"typography"}return"ignore"},Bo=/^\{([^}]+)\}$/,Uo=e=>{if("string"!=typeof e)return;const t=e.match(Bo);if(!t)return;const r=t[1],n=r.indexOf("."),o=n<0?r:r.slice(0,n),s=n<0?"":r.slice(n+1),i="color"===o?"colors":o;return s?`${i}.${s}`:i},Do=(e,t,r)=>{var n;const o=new Map,s=[];for(const t of e)if(t.path.length<=2)s.push(t);else{const e=t.path[1];o.has(e)||o.set(e,[]),o.get(e).push(t)}for(const e of s){const t=e.path[e.path.length-1];if(!r[t]){const n=Uo(e.value);r[t]=n?{external:n}:{base:String(e.value)}}}for(const[e,t]of o)if(1===t.length){const n=t[0],o=n.path[n.path.length-1];o===e?r[e]={base:String(n.value)}:(r[e]||(r[e]={base:String(t[0].value)}),r[e].variants={[o]:String(n.value)})}else{const o=null!==(n=t.find(e=>{const t=e.path[e.path.length-1];return"base"===t||"default"===t||"500"===t}))&&void 0!==n?n:t[0],s={};for(const e of t){if(e===o)continue;s[e.path.slice(2).join("-")]=String(e.value)}r[e]={base:String(o.value),...Object.keys(s).length?{variants:s}:{}}}},Vo={fontfamily:"fontFamily",fontsize:"fontSize",fontweight:"fontWeight",lineheight:"lineHeight",letterspacing:"letterSpacing",fontstyle:"fontStyle",texttransform:"textTransform",textdecoration:"textDecoration",textalign:"textAlign"},Wo=(e,t,r)=>{for(const n of e)if("typography"===n.type){const e=n.value,t=n.path.slice(1).join("-")||n.path[n.path.length-1];e.fontFamily&&Yo(r,"fontFamily",Array.isArray(e.fontFamily)?e.fontFamily.join(", "):e.fontFamily,t),e.fontSize&&Yo(r,"fontSize",rs(e.fontSize),t),void 0!==e.fontWeight&&Yo(r,"fontWeight",e.fontWeight,t),void 0!==e.lineHeight&&Yo(r,"lineHeight",e.lineHeight,t),e.letterSpacing&&Yo(r,"letterSpacing",e.letterSpacing,t)}else{const e=Ho(n,t);if(!e)continue;const o=n.path[n.path.length-1],s="fontFamily"===n.type&&Array.isArray(n.value)?n.value.join(", "):"dimension"===n.type?rs(n.value):n.value;Yo(r,e,s,o)}},Yo=(e,t,r,n)=>{if(!e[t])return void(e[t]={base:r,variants:{}});const o=e[t];"base"===n||"default"===n||"md"===n?o.base=r:o.variants[n]=r},Ho=(e,t)=>{if("fontFamily"===e.type)return"fontFamily";if("fontWeight"===e.type)return"fontWeight";const r=e.path.join(".").toLowerCase();for(const[e,t]of Object.entries(Vo))if(r.includes(e))return t;const n=t.toLowerCase();for(const[e,t]of Object.entries(Vo))if(n.includes(e))return t;return null},Go=(e,t,r)=>{for(const t of e){const e=t.path[t.path.length-1];switch(t.type){case"shadow":{const n=Qo(t.value);Jo(r,"shadow",n,e);break}case"transition":{const n=t.value,o=n.timingFunction?`cubic-bezier(${n.timingFunction.join(", ")})`:"ease",s=`all ${n.duration} ${o}`;Jo(r,"transitions",s,e);break}case"dimension":t.path.join(".").toLowerCase().includes("blur")&&Jo(r,"blur",rs(t.value),e);break;case"number":{const n=t.path.join(".").toLowerCase();n.includes("opacity")?Jo(r,"opacity",t.value,e):(n.includes("z-index")||n.includes("zindex"))&&Jo(r,"zIndex",t.value,e);break}}}},Jo=(e,t,r,n)=>{if(!e[t])return void(e[t]={base:r,variants:{}});const o=e[t];"base"===n||"default"===n||"md"===n?o.base=r:o.variants[n]=r},Ko=(e,t,r)=>{for(const t of e){const e=t.path[t.path.length-1];switch(t.type){case"border":{const n=t.value;Xo(r,"width",rs(n.width),e),n.style&&Xo(r,"style",n.style,e);break}case"strokeStyle":Xo(r,"style",String(t.value),e);break;case"dimension":{const n=t.path.join(".").toLowerCase();n.includes("radius")?Xo(r,"radius",rs(t.value),e):n.includes("offset")?Xo(r,"offset",rs(t.value),e):n.includes("width")&&Xo(r,"width",rs(t.value),e);break}}}},Xo=(e,t,r,n)=>{if(!e[t])return void(e[t]={base:r,variants:{}});const o=e[t];"base"===n||"default"===n||"md"===n?o.base=r:o.variants[n]=r},Zo=(e,t,r)=>{for(const t of e){if("dimension"!==t.type)continue;const e=t.path[t.path.length-1],n=ts(t.value);r.spacing||(r.spacing={base:n,variants:{}});const o=r.spacing;"base"===e||"default"===e||"4"===e?o.base=n:o.variants[e]=n}},Qo=e=>Array.isArray(e)?e.map(e=>es(e)).join(", "):es(e),es=e=>{const t=[];return e.inset&&t.push("inset"),t.push(e.offsetX,e.offsetY,e.blur,e.spread,e.color),t.join(" ")},ts=e=>{if("number"==typeof e)return e;const t=parseFloat(e);return isNaN(t)?0:e.endsWith("rem")?Math.round(16*t):t},rs=e=>{if("number"==typeof e)return e;const t=parseFloat(e);return isNaN(t)?e:e.endsWith("px")?t:e},ns=(e,t)=>{var r;const n={};(null==t?void 0:t.name)&&(n.$name=t.name);const o=e.model.breakpoints;if(!1!==(null==t?void 0:t.includeBreakpoints)&&o&&Object.keys(o).length){const e={$type:"dimension"};for(const[t,r]of Object.entries(o))e[t]={$value:`${r}px`};n.breakpoint=e}const s=ss(e),i=t=>{try{return String(e.resolveToken(t))}catch{return t}},a=s.get("colors");if(a){const e={$type:"color"};for(const[t,r]of a){const n={};void 0!==r.base&&(n.base={$value:wt(String(r.base))});for(const[e,t]of Object.entries(r.members))n[e]={$value:wt(String(t))};e[t]=n}n.color=e}const l=s.get("typography");if(l){const e={};for(const[t,r]of l){const n={$type:is(t)};void 0!==r.base&&(n.base={$value:as(r.base,r.baseUnit)});for(const[e,t]of Object.entries(r.members))n[e]={$value:as(t,r.memberUnits[e])};e[t]=n}n.typography=e}const c=s.get("effects");if(c)for(const[e,t]of c){const{groupName:r,type:o}=ls(e);n[r]||(n[r]={$type:o});const s=n[r];void 0!==t.base&&(s.base={$value:cs(e,t.base,i,t.baseUnit)});for(const[r,n]of Object.entries(t.members))s[r]={$value:cs(e,n,i,t.memberUnits[r])}}const u=s.get("borders");if(u)for(const[e,t]of u){const{groupName:r,type:o}=us(e);n[r]||(n[r]={$type:o});const s=n[r];void 0!==t.base&&(s.base={$value:ds(t.base,t.baseUnit)});for(const[e,r]of Object.entries(t.members))s[e]={$value:ds(r,t.memberUnits[e])}}const d=s.get("layout");if(d)for(const[e,t]of d){if(e.includes("--"))continue;const r=e;n[r]||(n[r]={$type:"dimension"});const o=n[r];void 0!==t.base&&(o.base={$value:fs(t.base,t.baseUnit)});for(const[e,r]of Object.entries(t.members))o[e]={$value:fs(r,t.memberUnits[e])}}if(null==t?void 0:t.includeRecipes){const t=(e=>{const t={},r={},n={};for(const[o,s]of Object.entries(e.subsystems))s.properties&&Object.keys(s.properties).length&&(t[o]=s.properties),s.ruleSets&&Object.keys(s.ruleSets).length&&(r[o]=s.ruleSets),s.keyframes&&Object.keys(s.keyframes).length&&(n[o]=s.keyframes);const o=Object.keys(t).length>0,s=Object.keys(r).length>0,i=Object.keys(n).length>0,a=!!e.containers&&Object.keys(e.containers).length>0;if(o||s||i||a)return{version:1,...o?{properties:t}:{},...s?{ruleSets:r}:{},...i?{keyframes:n}:{},...a?{containers:e.containers}:{}}})(e.model);t&&(n.$extensions={...null!==(r=n.$extensions)&&void 0!==r?r:{},[No]:t})}return n},os=(e,t)=>void 0!==t?`${e}${t}`:e,ss=e=>{const t=new Map;for(const r of Object.keys(e.tokens)){const n=r.indexOf(".");if(n<0)continue;const o=r.slice(0,n),s=r.slice(n+1),i=s.indexOf("."),a=i<0?s:s.slice(0,i),l=i<0?void 0:s.slice(i+1),c=e.tokens[r];if(void 0!==(null==c?void 0:c.external))continue;let u;if(void 0!==(null==c?void 0:c.struct))u=c.struct;else try{u=e.resolveToken(r)}catch{continue}const d=null==c?void 0:c.unit;let f=t.get(o);f||(f=new Map,t.set(o,f));let p=f.get(a);p||(p={members:{},memberUnits:{}},f.set(a,p)),void 0===l?(p.base=u,void 0!==d&&(p.baseUnit=d)):(p.members[l]=u,void 0!==d&&(p.memberUnits[l]=d))}return t},is=e=>{switch(e){case"fontFamily":return"fontFamily";case"fontWeight":return"fontWeight";case"fontSize":case"letterSpacing":return"dimension";default:return"number"}},as=(e,t)=>os(e,t),ls=e=>{switch(e){case"shadow":return{groupName:"shadow",type:"shadow"};case"transitions":return{groupName:"transition",type:"transition"};case"blur":default:return{groupName:e,type:"dimension"};case"opacity":case"zIndex":return{groupName:e,type:"number"}}},cs=(e,t,r,n)=>Array.isArray(t)?"transitions"===e?t.map(e=>{var t;const r=[e.property];return null==e.duration&&null==e.delay||r.push(`${null!==(t=e.duration)&&void 0!==t?t:0}ms`),e.timingFunction&&r.push(e.timingFunction),null!=e.delay&&r.push(`${e.delay}ms`),r.join(" ")}).join(", "):((e,t)=>e.map(e=>{const r=`0${(e=>{for(const t of[e.offsetX,e.offsetY,e.blur,e.spread])if(void 0!==t&&"number"!=typeof t)return t.unit;return"px"})(e)}`,n=e=>void 0===e?r:(e=>"number"==typeof e?`${e}px`:`${e.value}${e.unit}`)(e),o=[];return e.inset&&o.push("inset"),o.push(n(e.offsetX),n(e.offsetY)),null!=e.spread?o.push(n(e.blur),n(e.spread)):null!=e.blur&&o.push(n(e.blur)),e.color&&o.push(t(e.color)),o.join(" ")}).join(", "))(t,r):os(t,n),us=e=>{switch(e){case"radius":return{groupName:"radius",type:"dimension"};case"width":return{groupName:"borderWidth",type:"dimension"};case"offset":return{groupName:"outlineOffset",type:"dimension"};case"style":return{groupName:"borderStyle",type:"strokeStyle"};default:return{groupName:e,type:"dimension"}}},ds=(e,t)=>os(e,t),fs=(e,t)=>os(e,t);async function ps(e){var t;const{raw:n,adapter:s,outDir:l,helpers:c=[],emit:u,media:d,units:f,baseFontSize:p,guide:m}=e,h=wo(n,{adapter:s,media:d,units:f,baseFontSize:p}),g=Ve(h.model.breakpoints,e=>Ke(e,Ge(d))),y=Qe(h.model.containers,d),$=s.bind(h.model,{media:g,containers:y,resolve:h.resolveToken});if(!$.emit)throw new Error(`Adapter "${s.name}" does not implement emit(); it cannot build to disk.`);const x=$.emit(Fo(u)),j=[];o(l,{recursive:!0});const A=(e,t)=>{const n=i(l,e);o(a(n),{recursive:!0}),r(n,t,"utf8"),j.push(n)};for(const[e,t]of Object.entries(x.files))A(e,t);for(const[e,r]of Object.entries(null!==(t=x.vendorHelpers)&&void 0!==t?t:{}))A(e,r);for(const e of c){const t=v(e);if(!t)throw new Error(`Unknown vendor helper "${e}". Known: ${b.map(e=>e.id).join(", ")}.`);A(t.outfile,await k(w(t.source)))}if(m){const e=!0===m?{}:m,t=R($.describeUsage(),ns(h),{files:Object.keys(x.files),packageName:e.packageName,llmsFile:e.llmsFile,manifestFile:e.manifestFile});for(const[e,r]of Object.entries(t.files))A(e,r)}return{outDir:l,files:j}}const ms=e=>e,hs="theme.config",gs=[".ts",".mjs",".js"],bs=(t=process.cwd())=>{for(const r of gs){const n=i(t,`${hs}${r}`);if(e(n))return n}};let vs=0;async function ys(t={}){var r,n,o;const s=null!==(r=t.cwd)&&void 0!==r?r:process.cwd(),i=t.configPath?l(s,t.configPath):bs(s);if(!i||!e(i)){const e=t.configPath?`"${t.configPath}"`:`${hs}.(ts|mjs|js) in "${s}"`;throw new Error(`No theme config found at ${e}.`)}const a=await async function(e){if(".ts"!==u(e)){const t=`${f(e).href}?v=${++vs}`;return await import(t)}const{entry:t,cleanup:r}=await A(e);try{return await import(f(t).href)}finally{r()}}(i),c=null!==(o=null!==(n=a.default)&&void 0!==n?n:a.config)&&void 0!==o?o:a;if(!c||"object"!=typeof c||!Array.isArray(c.targets))throw new Error(`"${i}" must export (default) a defineConfig({ raw, targets }) object.`);return{config:c,path:i}}const ws="@theme-registry/refract-css";function $s(){var e;const r=i(y(),"package.json");return null!==(e=JSON.parse(t(r,"utf8")).name)&&void 0!==e?e:"@theme-registry/refract"}const ks="theme.raw",xs=[".ts",".mts",".mjs",".js",".json"],js=(t=process.cwd())=>{for(const r of xs){const n=i(t,`${ks}${r}`);if(e(n))return{path:n,filename:`${ks}${r}`,ext:r}}};function As(e){if(".json"===e.ext)return{head:`import { readFileSync } from "node:fs";\n\n// The theme is JSON, so it's read rather than imported — no module-attribute support needed.\nconst raw = JSON.parse(readFileSync(new URL("./${e.filename}", import.meta.url), "utf8"));\n`,expression:"raw"};return{head:`import { raw } from "${".ts"===e.ext||".mts"===e.ext?`./${ks}`:`./${e.filename}`}";\n`,expression:"raw"}}function Es(e,t){const{head:r,expression:n}=As(t);return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${ws}";\n${r}\n// refract build config. \`refract build\` reads this file, builds the theme once, and writes each\n// target's emitted files into that target's \`outDir\`. The config is your code: it \`import\`s the\n// adapters it wants and passes their options at construction (not via CLI flags).\n//\n// Your tokens live in \`${t.filename}\` — edit them there, not here.\nexport default defineConfig({\n raw: ${n},\n targets: [\n // The CSS adapter (from @theme-registry/refract-css). Pass its options here, at construction.\n { adapter: createCssAdapter(/* { colors: { prefix: "app" } } */), outDir: "dist/theme" },\n\n // Add another adapter target once its package is installed, e.g.:\n // import { createStyledComponentsAdapter } from "@theme-registry/refract-styled-components";\n // { adapter: createStyledComponentsAdapter(), outDir: "dist/theme-sc" },\n ],\n});\n`}function Ss(e){return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${ws}";\n\n// refract build config. \`refract build\` reads this file, builds the theme once, and writes\n// each target's emitted files into that target's \`outDir\`. The config is your code: it \`import\`s\n// the adapters it wants and passes their options at construction (not via CLI flags).\nexport default defineConfig({\n // The raw theme — authored in refract's nested slices. Extend with typography/effects/layout.\n raw: {\n breakpoints: { sm: 576, md: 768, lg: 1024, xl: 1280 },\n colors: {\n // Starter palette passes its own contrast audit (WCAG AA): white text clears 4.5:1 on both\n // bases. Keep that when you retune — the auditor is a shipped feature; the default should model it.\n primary: { base: "#1864ab", text: "#fff", variants: { dark: "#0b4a86", light: "#a5d8ff" } },\n neutral: { base: "#495057", text: "#fff", variants: { light: "#f1f3f5", dark: "#212529" } },\n recipes: {\n solid: {\n primary: { background: "primary", color: "primary.text" },\n neutral: { background: "neutral.light", color: "neutral.dark" },\n },\n },\n },\n },\n targets: [\n // The CSS adapter (from @theme-registry/refract-css). Pass its options here, at construction.\n { adapter: createCssAdapter(/* { colors: { prefix: "app" } } */), outDir: "dist/theme" },\n\n // Add another adapter target once its package is installed, e.g.:\n // import { createStyledComponentsAdapter } from "@theme-registry/refract-styled-components";\n // { adapter: createStyledComponentsAdapter(), outDir: "dist/theme-sc" },\n ],\n});\n`}function Rs(t={}){var n,o,s,a;const l=null!==(n=t.cwd)&&void 0!==n?n:process.cwd(),c=null!==(o=t.variant)&&void 0!==o?o:"ts",u=null!==(s=t.packageName)&&void 0!==s?s:$s(),d=i(l,`theme.config.${c}`);if(e(d)&&!t.force)throw new Error(`theme.config.${c} already exists at "${d}". Pass --force to overwrite it.`);const f=null===t.rawTheme?void 0:null!==(a=t.rawTheme)&&void 0!==a?a:js(l),p=f?Es(u,f):Ss(u);return r(d,p,"utf8"),{path:d,variant:c,packageName:u,rawTheme:f}}const Os=[["xs",-2],["sm",-1],["md",0],["lg",1],["xl",2],["2xl",3],["3xl",4],["4xl",5]],Cs={"minor-second":1.067,"major-second":1.125,"minor-third":1.2,"major-third":1.25,"perfect-fourth":1.333,"augmented-fourth":1.414,"perfect-fifth":1.5,golden:1.618},Ts={complement:[180],analogous:[-30,30],"split-complement":[150,210],triadic:[120,240],tetradic:[90,180,270],pentadic:[72,144,216,288]},Fs=["primary","secondary","tertiary","quaternary","quinary"],Ns=[["success","#2f9e44","#ffffff"],["info","#1c7ed6","#ffffff"],["warning","#e89012","#1f2733"],["danger","#e03131","#ffffff"]],_s=[50,100,200,300,400,500,600,700,800,900],Ps=[8,14,22],zs="system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",Ms="ui-monospace, 'SF Mono', Menlo, Consolas, monospace",qs={neutral:{label:"Neutral",blurb:"system type, comfortable spacing, soft corners",fontFamily:{base:zs,mono:Ms},spacing:{xs:1,sm:2,md:4,lg:6,xl:8,"2xl":12},radius:{base:8,variants:{none:0,sm:4,lg:14,pill:"9999px"}},ratio:"major-third"},compact:{label:"Compact",blurb:"dense UI, tight scale, small radius",fontFamily:{base:zs,mono:Ms},spacing:{xs:1,sm:2,md:3,lg:4,xl:6,"2xl":8},radius:{base:4,variants:{none:0,sm:2,lg:8,pill:"9999px"}},ratio:"major-second"},editorial:{label:"Editorial",blurb:"serif display, spacious, generous leading",fontFamily:{base:"'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif",mono:Ms},spacing:{xs:2,sm:4,md:6,lg:8,xl:12,"2xl":16},radius:{base:2,variants:{none:0,sm:1,lg:4,pill:"9999px"}},ratio:"perfect-fourth"},technical:{label:"Technical",blurb:"mono accents, compact, sharp corners",fontFamily:{base:Ms,mono:Ms},spacing:{xs:1,sm:2,md:3,lg:4,xl:6,"2xl":8},radius:{base:0,variants:{none:0,sm:0,lg:2,pill:"9999px"}},ratio:"minor-third"}},Ls=(e,t)=>Number(e.toFixed(t)),Is=e=>st(at(e).rgb),Bs=e=>Ls(Math.min(1.7,Math.max(1.1,1.5*Math.pow(16/e,.22))),2),Us=e=>`${Ls(.36/e-.0225,3)}em`,Ds=e=>{const t=1e3-10*e;let r=_s[0];for(const e of _s)Math.abs(e-t)<Math.abs(r-t)&&(r=e);return r},Vs=e=>{if(!(e<=1))return 2===e?"complement":3===e?"triadic":4===e?"tetradic":"pentadic"},Ws=e=>Object.keys(Ts).filter(t=>Ts[t].length===e-1);function Ys(e){var t,r,n,o,s,i,a,l,c;const u=null!==(t=e.mode)&&void 0!==t?t:"auto",d=qs[null!==(r=e.feel)&&void 0!==r?r:"neutral"],f=Math.min(5,Math.max(1,null!==(n=e.brandCount)&&void 0!==n?n:2)),p=null!==(o=e.baseFontSize)&&void 0!==o?o:16,m=null!==(s=e.ratio)&&void 0!==s?s:d.ratio,h=Cs[m];if(!h)throw new Error(`Unknown type ratio "${m}". Use one of: ${Object.keys(Cs).join(", ")}.`);const g=Is(e.seed),b=[{name:Fs[0],hex:g,rotation:0}];if("manual"===u)(null!==(i=e.extraColors)&&void 0!==i?i:[]).slice(0,Fs.length-1).forEach((e,t)=>{b.push({name:Fs[t+1],hex:Is(e),rotation:0})});else if(f>1){const t=null!==(a=e.scheme)&&void 0!==a?a:Vs(f),r=Ts[t];if(!r)throw new Error(`Unknown harmony scheme "${t}".`);r.slice(0,f-1).forEach((e,t)=>{b.push({name:Fs[t+1],hex:Is(vt(g,e)),rotation:e})})}const v=null!==(l=e.contrast)&&void 0!==l?l:"AA",y=[...b.map(e=>({name:e.name,base:e.hex,text:"#ffffff"})),...!1===e.semantics?[]:Ns.map(([e,t,r])=>({name:e,base:t,text:r})),...!1===e.neutral?[]:[{name:"neutral",base:"#6b7280",text:"#ffffff"}]],{palettes:w,adjustments:$}="none"===v?{palettes:y,adjustments:[]}:function(e,t){var r;const n=e.map(e=>({...e})),o=new Map(n.map(e=>[e.name,0])),s=new Map,i=()=>{var e,r;const o={};for(const e of n)o[e.name]={base:e.base,text:e.text};const s=wo({colors:o},{adapter:qo()}),i=Ar(s,{minWcag:t,includeRecipes:!1}),a=new Map;for(const t of i.pairings){if(t.skipped||void 0===t.wcagRatio)continue;const n=t.label.replace(/^colors\./,"");a.set(n,{ratio:t.wcagRatio,level:null!==(e=t.wcagLevel)&&void 0!==e?e:"fail",pass:null!==(r=t.pass)&&void 0!==r&&r})}return a};let a=i();for(const[e,t]of a)s.has(e)||s.set(e,t.ratio);for(let e=0;e<40;e++){const e=n.filter(e=>a.get(e.name)&&!a.get(e.name).pass);if(!e.length)break;for(const t of e)t.base=Is(gt(t.base,1)),o.set(t.name,(null!==(r=o.get(t.name))&&void 0!==r?r:0)+1);a=i()}const l=n.map((t,r)=>{var n,i,l,c;const u=a.get(t.name);return{name:t.name,seed:e[r].base,final:t.base,nudge:null!==(n=o.get(t.name))&&void 0!==n?n:0,ratioBefore:Ls(null!==(i=s.get(t.name))&&void 0!==i?i:0,2),ratioAfter:Ls(null!==(l=null==u?void 0:u.ratio)&&void 0!==l?l:0,2),levelAfter:null!==(c=null==u?void 0:u.level)&&void 0!==c?c:"fail",unresolved:!!u&&!u.pass}});return{palettes:n,adjustments:l}}(y,v),k={};for(const e of w)k[e.name]={base:e.base,text:e.text,steps:[..._s]};if(!1!==e.shadows){const e={};for(const t of Ps)e[`a${String(t).padStart(2,"0")}`]={modifiers:[{alpha:t}]};k.shadow={base:"#18274b",variants:e}}const x=Os.map(([e,t])=>({step:e,px:Ls(p*Math.pow(h,t),2)})),j={},A={};for(const{step:e,px:t}of x)"md"!==e&&(j[e]=Bs(t),A[e]=Us(t));A.caps="0.06em";const E={fontFamily:{base:d.fontFamily.base,variants:{mono:d.fontFamily.mono}},fontWeight:{base:400,variants:{medium:500,semibold:600,bold:700}},fontSize:{base:p,ratio:m},lineHeight:{base:Bs(p),variants:j},letterSpacing:{base:"0em",variants:A}},S={spacing:{base:4,step:4,steps:{...d.spacing}}},R={width:{base:1,variants:{thick:2}},style:{base:"solid"},radius:{base:d.radius.base,variants:{...d.radius.variants}}},O=!1===e.shadows?void 0:{shadow:{offsetY:1,blur:3,color:"colors.shadow.a08",variants:{md:{offsetY:6,blur:16,color:"colors.shadow.a14"},lg:{offsetY:14,blur:34,color:"colors.shadow.a22"},none:"none"}}},C={colors:k,typography:E,layout:S,borders:R,...O?{effects:O}:{},animation:{duration:{base:200,variants:{fast:120,slow:400}},easing:{base:"cubic-bezier(.2,.7,.3,1)",variants:{out:"cubic-bezier(.16,.84,.44,1)"}}},..."none"===e.reset?{}:{globals:{preset:null!==(c=e.reset)&&void 0!==c?c:"preflight"}}},T=Ls(ft(at(g).rgb).L,1);return{raw:C,report:{seedLightness:T,nearestStep:Ds(T),brand:b.map(e=>{var t;const r=$.find(t=>t.name===e.name);return{name:e.name,hex:null!==(t=null==r?void 0:r.final)&&void 0!==t?t:e.hex,rotation:e.rotation}}),contrast:$,type:x.map(({step:e,px:t})=>({step:e,px:t,leading:Bs(t),tracking:Us(t)})),spacing:Object.entries(d.spacing).map(([e,t])=>({step:e,px:4*t}))}}}const Hs="theme.raw",Gs=/^[A-Za-z_$][A-Za-z0-9_$]*$/,Js=e=>JSON.stringify(e);function Ks(e,t=0){const r=" ".repeat(t),n=" ".repeat(t+1);if(null===e)return"null";if("string"==typeof e)return Js(e);if("number"==typeof e||"boolean"==typeof e)return String(e);if(Array.isArray(e)){if(!e.length)return"[]";if(e.every(e=>null===e||"object"!=typeof e)){const t=`[${e.map(e=>Ks(e)).join(", ")}]`;if(r.length+t.length<=76)return t}return`[\n${e.map(e=>`${n}${Ks(e,t+1)}`).join(",\n")}\n${r}]`}const o=Object.entries(e);if(!o.length)return"{}";return`{\n${o.map(([e,r])=>{const o=Gs.test(e)?e:Js(e);return`${n}${o}: ${Ks(r,t+1)}`}).join(",\n")}\n${r}}`}const Xs=(e,t)=>`// Generated by \`refract create\` — seed ${e} · ${t}.\n// This is YOUR theme now: every value is a literal you can read, edit and delete. The generator\n// does not run again. Tonal ladders, the type scale and the spacing ramp are synthesized by the\n// engine from the declarations below — re-tune a scale by editing one word, not eight numbers.\n`;function Zs(e,t){if("json"===t.format)return`${JSON.stringify(e,null,2)}\n`;const r=Ks(e);return"js"===t.format?`${Xs(t.seed,t.detail)}\n/** @type {import("${t.packageName}/build").RawTheme} */\nexport const raw = ${r};\n`:`${Xs(t.seed,t.detail)}import type { RawTheme } from "${t.packageName}/build";\n\nexport const raw = ${r} satisfies RawTheme;\n`}function Qs(e){var t,r,n,o,s,i;const a=[],l="manual"===e.mode?(null!==(r=null===(t=e.extraColors)||void 0===t?void 0:t.length)&&void 0!==r?r:0)+1:null!==(n=e.brandCount)&&void 0!==n?n:2;return a.push(`${l} brand colour${1===l?"":"s"}`),"manual"!==e.mode&&l>1&&a.push(null!==(o=e.scheme)&&void 0!==o?o:"auto"),a.push(null!==(s=e.feel)&&void 0!==s?s:"neutral"),"none"!==e.contrast&&a.push(`WCAG ${null!==(i=e.contrast)&&void 0!==i?i:"AA"}`),a.join(" · ")}function ei(t){var n,o,s,a;const l=null!==(n=t.cwd)&&void 0!==n?n:process.cwd(),c=null!==(o=t.format)&&void 0!==o?o:"ts",u=null!==(s=t.out)&&void 0!==s?s:`${Hs}.${c}`,d=i(l,u);if(e(d)&&!t.force)throw new Error(`"${u}" already exists. Re-run with --force to overwrite it.`);const{raw:f,report:p}=Ys(t),m=Zs(f,{format:c,packageName:null!==(a=t.packageName)&&void 0!==a?a:$s(),seed:t.seed,detail:Qs(t)});return r(d,m,"utf8"),{path:d,format:c,raw:f,report:p,sections:Object.keys(f)}}const ti=(e,t)=>Boolean(process.stdout.isTTY)&&!process.env.NO_COLOR?`[${e}m${t}[0m`:t,ri=e=>ti("1",e),ni=e=>ti("2",e),oi=e=>ti("36",e),si=e=>ti("32",e),ii=e=>ti("33",e),ai=e=>e>0?`[${e}A`:"",li="[0J";function ci(e){switch(e){case"[A":case"k":return"up";case"[B":case"j":return"down";case" ":return"space";case"\r":case"\n":return"submit";case"a":return"all";case"":case"":return"cancel";default:return"none"}}function ui(e){const t=[];for(let r=0;r<e.length;)""===e[r]&&"["===e[r+1]&&r+2<e.length?(t.push(ci(e.slice(r,r+3))),r+=3):(t.push(ci(e[r])),r+=1);return t}function di(e,t,r,n){if(e.done||e.cancelled||0===r)return e;switch(t){case"up":return{...e,cursor:(e.cursor-1+r)%r};case"down":return{...e,cursor:(e.cursor+1)%r};case"space":{if(!n)return e;const t=new Set(e.selected);return t.has(e.cursor)?t.delete(e.cursor):t.add(e.cursor),{...e,selected:t}}case"all":{if(!n)return e;const t=e.selected.size===r;return{...e,selected:t?new Set:new Set(Array.from({length:r},(e,t)=>t))}}case"submit":return{...e,done:!0};case"cancel":return{...e,cancelled:!0};default:return e}}const fi=()=>Boolean(process.stdin.isTTY)&&"function"==typeof process.stdin.setRawMode;class pi{constructor(e=Boolean(process.stdin.isTTY)&&Boolean(process.stdout.isTTY)){this.interactive=e}get io(){return this.rl||(this.rl=p({input:process.stdin,output:process.stdout})),this.rl}close(){var e;null===(e=this.rl)||void 0===e||e.close(),this.rl=void 0}question(e){return new Promise(t=>this.io.question(e,e=>t(e)))}out(e){process.stdout.write(e)}write(e=""){process.stdout.write(`${e}\n`)}async text(e,t,r){if(!this.interactive)return t;for(;;){const n=(await this.question(`${oi("?")} ${ri(e)} ${ni(`(${t})`)} `)).trim()||t,o=null==r?void 0:r(n);if(!o)return n;this.write(` ${ii("!")} ${o}`)}}async number(e,t,r){const n=await this.text(e,String(t),e=>{const t=Number(e);return Number.isFinite(t)?null==r?void 0:r(t):`"${e}" is not a number.`});return Number(n)}async select(e,t,r=0){var n,o,s;if(!this.interactive||1===t.length)return null!==(o=null===(n=t[r])||void 0===n?void 0:n.value)&&void 0!==o?o:t[0].value;if(fi()){return t[null!==(s=(await this.runList(e,t,{multi:!1,cursor:r,selected:new Set}))[0])&&void 0!==s?s:r].value}return this.selectByNumber(e,t,r)}async multiselect(e,t,r){var n;if(!this.interactive)return r.map(e=>t[e].value);if(fi()){return(await this.runList(e,t,{multi:!0,cursor:null!==(n=r[0])&&void 0!==n?n:0,selected:new Set(r)})).map(e=>t[e].value)}return this.multiselectByNumber(e,t,r)}runList(e,t,r){this.close();const n=process.stdin,{multi:o}=r;let s={cursor:Math.max(0,Math.min(r.cursor,t.length-1)),selected:r.selected,done:!1,cancelled:!1},i=0;const a=o?"↑↓ move · space toggle · a all · enter confirm":"↑↓ move · enter select",l=()=>{i&&this.out(ai(i)+li);const r=(()=>{const r=t.map((e,t)=>{const r=t===s.cursor;return` ${o?s.selected.has(t)?si("◉"):ni("◯"):r?si("❯"):" "} ${r?ri(e.label):e.label}${e.hint?` ${ni(`— ${e.hint}`)}`:""}`});return[`${oi("?")} ${ri(e)} ${ni(a)}`,...r].join("\n")})();this.out(`${r}\n`),i=r.split("\n").length};return new Promise((r,a)=>{const c=()=>{n.removeListener("data",d),n.removeListener("end",u),n.isTTY&&n.setRawMode(!1),n.pause(),this.out("[?25h")},u=()=>{const e=o?[...s.selected].sort((e,t)=>e-t):[s.cursor];this.out(ai(i)+li),c(),r(e)},d=n=>{for(const e of ui(n))if(s=di(s,e,t.length,o),s.done||s.cancelled)break;if(s.cancelled)return this.out(ai(i)+li),c(),void a(new Error("Cancelled."));if(s.done){const n=o?[...s.selected].sort((e,t)=>e-t):[s.cursor];this.out(ai(i)+li);const a=n.length?n.map(e=>t[e].label).join(", "):"none";return this.write(`${oi("?")} ${ri(e)} ${ni("›")} ${si(a)}`),c(),void r(n)}l()};n.setRawMode(!0),n.resume(),n.setEncoding("utf8"),this.out("[?25l"),n.on("data",d),n.on("end",u),l()})}async selectByNumber(e,t,r){for(this.write(`${oi("?")} ${ri(e)}`),t.forEach((e,t)=>{const n=t===r?si("❯"):" ",o=e.hint?` ${ni(`— ${e.hint}`)}`:"";this.write(` ${n} ${ni(`${t+1}.`)} ${t===r?ri(e.label):e.label}${o}`)});;){const e=(await this.question(` ${ni(`1–${t.length}`)} `)).trim();if(!e)return t[r].value;const n=Number(e)-1;if(Number.isInteger(n)&&n>=0&&n<t.length)return t[n].value;this.write(` ${ii("!")} Enter a number between 1 and ${t.length}.`)}}async multiselectByNumber(e,t,r){for(this.write(`${oi("?")} ${ri(e)} ${ni('(comma-separated, blank = keep, "none" = clear)')}`),t.forEach((e,t)=>{const n=r.includes(t),o=e.hint?` ${ni(`— ${e.hint}`)}`:"";this.write(` ${n?si("◉"):ni("◯")} ${ni(`${t+1}.`)} ${e.label}${o}`)});;){const e=(await this.question(` ${ni(`1–${t.length}`)} `)).trim().toLowerCase();if(!e)return r.map(e=>t[e].value);if("none"===e)return[];const n=e.split(",").map(e=>Number(e.trim())-1);if(n.every(e=>Number.isInteger(e)&&e>=0&&e<t.length))return n.map(e=>t[e].value);this.write(` ${ii("!")} Enter numbers between 1 and ${t.length}, separated by commas.`)}}}const mi={complement:"one companion, 180° opposite — maximum separation",analogous:"two neighbours, ±30° — quiet and cohesive","split-complement":"the complement's neighbours — contrast with less tension",triadic:"even thirds, ±120° — three colours of equal weight",tetradic:"two complementary pairs — the most range",pentadic:"five evenly spaced hues — needs a dominant colour picked by hand"},hi=[["major-second","1.125 · 16 · 18 · 20 · 23 · 26 · 29"],["minor-third","1.2 · 16 · 19 · 23 · 28 · 33 · 40"],["major-third","1.25 · 16 · 20 · 25 · 31 · 39 · 49"],["perfect-fourth","1.333 · 16 · 21 · 28 · 38 · 51 · 67"],["perfect-fifth","1.5 · 16 · 24 · 36 · 54 · 81 · 122"],["golden","1.618 · 16 · 26 · 42 · 68 · 110 · 178"]],gi=e=>{try{return void at(e)}catch{return`"${e}" isn't a colour refract can parse. Try a hex like #4c6ef5.`}};async function bi(e,t={}){var r,n,o,s,i,a,l,c;const u=null!==(r=t.seed)&&void 0!==r?r:await e.text("Primary colour","#4c6ef5",gi),d=Math.round(10*ft(at(u).rgb).L)/10;e.write(` ${ni(`parsed · lightness ${d}% — lands at ≈${Ds(d)} on the ladder`)}`),e.write();const f=Boolean(t.manual);let p,m=2,h=[];if(f){if(h=(null!==(n=t.colors)&&void 0!==n?n:"").split(",").map(e=>e.trim()).filter(Boolean),!h.length&&e.interactive){const t=await e.number("How many brand colours in total?",2,e=>Number.isInteger(e)&&e>=1&&e<=5?void 0:"Pick a whole number from 1 to 5.");for(let r=1;r<t;r++)h.push(await e.text(`Brand colour ${r+1}`,"#e64980",gi))}m=h.length+1}else{m=t.colors?Number(t.colors):await e.number("How many brand colours? (including the primary)",2,e=>Number.isInteger(e)&&e>=1&&e<=5?void 0:"Pick a whole number from 1 to 5.");const r=Ws(m);p=null!==(o=t.scheme)&&void 0!==o?o:Vs(m),!t.scheme&&r.length>1&&(p=await e.select("Harmony scheme",r.map(e=>({value:e,label:e,hint:mi[e]})),Math.max(0,r.indexOf(p)))),p&&m>1&&(e.write(` ${ni(`→ ${p} · each member becomes its own palette with a full ladder`)}`),e.write())}const g=t.noSemantics||t.noNeutral||t.noShadows||!e.interactive?{semantics:!t.noSemantics,neutral:!t.noNeutral,shadows:!t.noShadows}:await(async()=>{const t=await e.multiselect("Also add",[{value:"semantics",label:"Semantic colours",hint:"success · info · warning · danger"},{value:"neutral",label:"Neutral ramp",hint:"50 … 900"},{value:"shadows",label:"Shadow tints",hint:"3 alpha levels + the effects ramp"}],[0,1,2]);return{semantics:t.includes("semantics"),neutral:t.includes("neutral"),shadows:t.includes("shadows")}})(),b=null!==(s=t.contrast)&&void 0!==s?s:await e.select("Contrast target",[{value:"AA",label:"WCAG AA",hint:"4.5:1 body text"},{value:"AAA",label:"WCAG AAA",hint:"7:1 — expect heavier nudges"},{value:"none",label:"Skip",hint:"write the colours exactly as given"}]),v=void 0!==t.baseSize?Number(t.baseSize):await e.number("Base font size (px)",16,e=>e>0?void 0:"Must be greater than zero."),y=null!==(i=t.feel)&&void 0!==i?i:await e.select("Overall feel",Object.keys(qs).map(e=>({value:e,label:qs[e].label,hint:qs[e].blurb}))),w=null!==(a=t.ratio)&&void 0!==a?a:await e.select("Type scale",hi.map(([e,t])=>({value:e,label:e,hint:t})),Math.max(0,hi.findIndex(([e])=>e===qs[y].ratio))),$=null!==(l=t.reset)&&void 0!==l?l:await e.select("CSS reset",[{value:"preflight",label:"preflight",hint:"full normalization + an h1–h6 size map"},{value:"normalize",label:"normalize",hint:"the classic, no heading map"},{value:"none",label:"none",hint:"you already ship one"}]),k=null!==(c=t.format)&&void 0!==c?c:await e.select("Format",[{value:"ts",label:"theme.raw.ts",hint:"typed, `satisfies RawTheme`"},{value:"js",label:"theme.raw.js",hint:"plain ESM, no build step"},{value:"json",label:"theme.raw.json",hint:"portable, no code at all"}]);return{seed:u,mode:f?"manual":"auto",brandCount:m,scheme:p,extraColors:h,...g,contrast:b,baseFontSize:v,ratio:w,feel:y,reset:$,format:k}}function vi(e,t){const r=[],{contrast:n}=e.report;if(n.length){r.push(` ${ni(`Contrast · ${n.length} pairings checked`)}`);for(const e of n){const t=e.nudge>0?`${ii(`−${e.nudge}`)} ${si(`${e.ratioAfter} ${e.levelAfter}`)}`:ni("unchanged"),n=e.unresolved?` ${ii("! still short of the bar")}`:"";r.push(` ${e.name.padEnd(10)} ${String(e.ratioBefore).padStart(5)} ${t}${n}`)}r.push("")}const o=n.filter(e=>e.nudge>0).length;return r.push(` ${ni(`${e.sections.length} subsystems · ${t} variables · 0 recipes`)}`),o&&r.push(` ${ni(`${o} colour${1===o?"":"s"} darkened to clear the contrast bar`)}`),r}const yi="theme.config.ts";function wi(e){const t={};for(const r of e.split(",")){const[e,n]=r.split(":"),o=null==e?void 0:e.trim(),s=Number.parseFloat((null!=n?n:"").trim());o&&Number.isFinite(s)&&(t[o]=s)}return t}function $i(e,t,r){return`// Generated by \`refract import\` from ${r}.\n// DTCG carries property tokens ONLY — recipes, components, composition, and states are not imported.\n// The mapping is heuristic (subsystem inferred from \`$type\`/name; \`border\` composite colors dropped;\n// rem rounded to px). Review the seeded tokens, then hand-author the rest of your theme below.\nimport type { RawTheme } from "${e}/build";\n\nexport const raw: RawTheme = ${JSON.stringify(t,null,2)};\n`}function ki(e,t){return`import { defineConfig } from "${e}/build";\nimport { createCssAdapter } from "${ws}";\nimport { raw } from "${t}";\n\n// Generated by \`refract import\`. This is your build config — edit it freely. Add adapter options at\n// construction (\`createCssAdapter({ … })\`) and extra targets (SC/JSON/…) as their packages install.\nexport default defineConfig({\n raw,\n targets: [\n { adapter: createCssAdapter(), outDir: "dist/theme" },\n ],\n});\n`}function xi(e){const t={};for(const[r,n]of Object.entries(e))"breakpoints"!==r&&(t[r]=n&&"object"==typeof n?Object.keys(n).length:0);return t}function ji(n){var s,i;const u=null!==(s=n.cwd)&&void 0!==s?s:process.cwd(),f=null!==(i=n.packageName)&&void 0!==i?i:$s(),p=d(n.input)?n.input:l(u,n.input);if(!e(p))throw new Error(`No DTCG document found at "${n.input}" (resolved to "${p}").`);let m;try{m=JSON.parse(t(p,"utf8"))}catch(e){throw new Error(`"${p}" is not valid JSON: ${e.message}`)}const h={};n.breakpointGroup&&(h.breakpointGroup=n.breakpointGroup),n.breakpoints&&Object.keys(n.breakpoints).length&&(h.breakpoints=n.breakpoints);const g=Lo(m,h),b=n.out?d(n.out)?n.out:l(u,n.out):l(u,"theme.raw.ts");if(e(b)&&!n.force)throw new Error(`${c(b)} already exists at "${b}". Pass --force to overwrite it.`);let v;if(o(a(b),{recursive:!0}),r(b,$i(f,g,JSON.stringify(c(p))),"utf8"),!n.rawOnly){if(v=l(a(b),yi),e(v)&&!n.force)throw new Error(`${yi} already exists at "${v}". Pass --force to overwrite it, or --raw-only to skip writing a config.`);const t=`./${c(b).replace(/\.(ts|mts|cts|tsx)$/,"")}`;r(v,ki(f,t),"utf8")}return{inputFile:p,rawFile:b,configFile:v,sections:Object.keys(g),counts:xi(g)}}async function Ai(e={}){var t;const r=null!==(t=e.cwd)&&void 0!==t?t:process.cwd(),{config:n,path:o}=await ys({cwd:r,configPath:e.configPath});if(!n.targets.length)throw new Error(`"${o}" has no targets to build.`);const s=function(e,t){if(void 0===t)return[...e];const r=e.filter(e=>e.name===t);if(r.length)return r;if(/^\d+$/.test(t)){const r=Number(t);if(r>=0&&r<e.length)return[e[r]]}const n=e.filter(e=>e.outDir===t);if(n.length)return n;throw new Error(`No target matched "${t}". Config has ${e.length} target(s): `+e.map((e,t)=>{var r;return null!==(r=e.name)&&void 0!==r?r:`#${t} (${e.outDir})`}).join(", ")+".")}(n.targets,e.target);if(void 0!==e.out&&s.length>1)throw new Error(`--out is ambiguous across ${s.length} targets; pass --target to pick one first.`);const i=a(o),c=[];for(const t of s){const o=void 0!==e.out?d(e.out)?e.out:l(r,e.out):d(t.outDir)?t.outDir:l(i,t.outDir),s=await ps({raw:n.raw,adapter:t.adapter,outDir:o,helpers:t.helpers,emit:t.emit,media:n.media,units:n.units,baseFontSize:n.baseFontSize,guide:t.guide});c.push({name:t.name,adapter:t.adapter.name,outDir:s.outDir,files:s.files})}return{configPath:o,targets:c}}async function Ei(e={}){var t;const n=null!==(t=e.cwd)&&void 0!==t?t:process.cwd(),{config:s,path:i}=await ys({cwd:n,configPath:e.configPath}),c=wo(s.raw,{adapter:qo()}),u=ns(c),f=e.out?d(e.out)?e.out:l(n,e.out):l(n,"tokens.json");o(a(f),{recursive:!0}),r(f,`${JSON.stringify(u,null,2)}\n`,"utf8");return{configPath:i,outFile:f,groupCount:Object.keys(u).filter(e=>!e.startsWith("$")).length}}async function Si(e={}){var t;const r=null!==(t=e.cwd)&&void 0!==t?t:process.cwd(),{config:n,path:o}=await ys({cwd:r,configPath:e.configPath}),s=wo(n.raw,{adapter:qo()});return{configPath:o,result:Ar(s,{strict:e.strict,minWcag:e.minWcag,largeText:e.largeText})}}const Ri=(e,t)=>{try{return String(e.resolveToken(t))}catch{return null}},Oi=e=>{var t;const r=[];for(const[n,o]of Object.entries(e.model.subsystems))for(const[e,s]of Object.entries(null!==(t=o.ruleSets)&&void 0!==t?t:{}))for(const t of Object.keys(s))r.push({subsystem:n,group:e,variant:t});return r},Ci=(e,t,r,n)=>{var o,s,i;return Boolean(null===(i=null===(s=null===(o=e.model.subsystems[t])||void 0===o?void 0:o.ruleSets)||void 0===s?void 0:s[r])||void 0===i?void 0:i[n])};function Ti(e,t){const r=((e,t)=>{const r=new Set([...Object.keys(e.tokens),...Object.keys(t.tokens)]),n=[];for(const o of r){const r=o in e.tokens,s=o in t.tokens,i=r?Ri(e,o):null,a=s?Ri(t,o):null;r&&!s?n.push({path:o,before:i,after:null,kind:"removed"}):!r&&s?n.push({path:o,before:null,after:a,kind:"added"}):i!==a&&n.push({path:o,before:i,after:a,kind:"changed"})}return n.sort((e,t)=>e.path.localeCompare(t.path))})(e,t),n=((e,t)=>{var r,n,o,s,i,a,l,c;const u=e,d=t;if(!u.renderRecipe&&!d.renderRecipe)return[];const f=new Set,p=[...Oi(e),...Oi(t)].filter(e=>{const t=`${e.subsystem}.${e.group}.${e.variant}`;return!f.has(t)&&(f.add(t),!0)}),m=[];for(const{subsystem:f,group:h,variant:g}of p){const p=Ci(e,f,h,g),b=Ci(t,f,h,g),v=null!==(s=null!==(n=null===(r=d.getClass)||void 0===r?void 0:r.call(d,f,h,g))&&void 0!==n?n:null===(o=u.getClass)||void 0===o?void 0:o.call(u,f,h,g))&&void 0!==s?s:`${f}.${h}.${g}`;p&&!b?m.push({name:v,kind:"removed"}):!p&&b?m.push({name:v,kind:"added"}):(null!==(a=null===(i=u.renderRecipe)||void 0===i?void 0:i.call(u,f,h,g))&&void 0!==a?a:"")!==(null!==(c=null===(l=d.renderRecipe)||void 0===l?void 0:l.call(d,f,h,g))&&void 0!==c?c:"")&&m.push({name:v,kind:"changed"})}return m.sort((e,t)=>e.name.localeCompare(t.name))})(e,t),o=((e,t)=>{var r,n,o,s;const i=e=>e?{ratio:e.wcagRatio,level:e.wcagLevel,pass:e.pass}:null,a=e=>new Map(e.map(e=>[e.label,e])),l=a(Ar(e).pairings),c=a(Ar(t).pairings),u=new Set([...l.keys(),...c.keys()]),d=[];for(const e of u){const t=l.get(e),a=c.get(e),u=i(t),f=i(a);if((null==u?void 0:u.ratio)===(null==f?void 0:f.ratio)&&(null==u?void 0:u.level)===(null==f?void 0:f.level)&&Boolean(t)===Boolean(a))continue;const p=(null!==(r=null==t?void 0:t.pass)&&void 0!==r?r:null)!==(null!==(n=null==a?void 0:a.pass)&&void 0!==n?n:null)||(null!==(o=null==t?void 0:t.wcagLevel)&&void 0!==o?o:null)!==(null!==(s=null==a?void 0:a.wcagLevel)&&void 0!==s?s:null);d.push({label:e,before:u,after:f,crossed:p})}return d.sort((e,t)=>e.label.localeCompare(t.label))})(e,t);return{tokens:r,classes:n,contrast:o,summary:{tokensChanged:r.length,classesChanged:n.length,pairingsCrossed:o.filter(e=>e.crossed).length}}}const Fi={fail:0,"AA-large":1,AA:2,AAA:3};let Ni=0;async function _i(r){var n,o,s,i;if(!e(r))throw new Error(`candidate theme not found at "${r}".`);let a;if(".json"===u(r))a=JSON.parse(t(r,"utf8"));else if(".ts"===u(r)){const{entry:e,cleanup:t}=await A(r);try{const t=await import(f(e).href);a=null!==(o=null!==(n=t.default)&&void 0!==n?n:t.raw)&&void 0!==o?o:t}finally{t()}}else{const e=await import(`${f(r).href}?v=${++Ni}`);a=null!==(i=null!==(s=e.default)&&void 0!==s?s:e.raw)&&void 0!==i?i:e}return function(e,t){const r=t?` (${t})`:"";if(null===e||"object"!=typeof e||Array.isArray(e)){const t=Array.isArray(e)?"an array":null===e?"null":typeof e;throw new O("REFRACT_E_RAW_SHAPE",`Expected a RawTheme object${r}, got ${t}. Pass the raw theme (a module's default export, or a .json raw theme).`)}if(Array.isArray(e.targets))throw new O("REFRACT_E_RAW_SHAPE",`Expected a RawTheme object${r}, but got what looks like a defineConfig({ raw, targets }). Pass its \`raw\` (or a module that default-exports the raw theme), not the whole config.`)}(a,r),a}async function Pi(e){var t,r,n,o,s,i,a,c;const u=null!==(t=e.cwd)&&void 0!==t?t:process.cwd(),{config:d,path:f}=await ys({cwd:u,configPath:e.configPath}),p=l(u,e.candidatePath),m=await _i(p),h={units:d.units,baseFontSize:d.baseFontSize,media:d.media},g=d.targets.map((e,t)=>{var r,n;return{name:null!==(n=null!==(r=e.name)&&void 0!==r?r:e.outDir)&&void 0!==n?n:`target-${t}`,adapter:e.adapter}}),b=g.map(({name:e,adapter:t})=>{var r;try{return wo(m,{adapter:t,...h}),{name:e,ok:!0,errors:[]}}catch(t){const n=t;return{name:e,ok:!1,errors:n.failures?[...n.failures]:[null!==(r=n.message)&&void 0!==r?r:String(t)]}}}),v=null!==(n=null!==(r=g.find(({adapter:e})=>"function"==typeof wo(d.raw,{adapter:e,...h}).renderRecipe))&&void 0!==r?r:g[0])&&void 0!==n?n:{name:"noop",adapter:qo()},y=wo(d.raw,{adapter:v.adapter,...h});let w={tokens:[],classes:[],contrast:[],summary:{tokensChanged:0,classesChanged:0,pairingsCrossed:0}};try{w=Ti(y,wo(m,{adapter:v.adapter,...h}))}catch{}const $=[];if(void 0!==e.maxClassChanges&&w.summary.classesChanged>e.maxClassChanges&&$.push(`${w.summary.classesChanged} classes changed (max ${e.maxClassChanges})`),void 0!==e.maxTokenChanges&&w.summary.tokensChanged>e.maxTokenChanges&&$.push(`${w.summary.tokensChanged} tokens changed (max ${e.maxTokenChanges})`),e.failBelow){const t=null!==(o=Fi[e.failBelow])&&void 0!==o?o:0;for(const r of w.contrast){const n=(null===(s=r.after)||void 0===s?void 0:s.level)&&null!==(i=Fi[r.after.level])&&void 0!==i?i:0,o=(null===(a=r.before)||void 0===a?void 0:a.level)&&null!==(c=Fi[r.before.level])&&void 0!==c?c:0;r.after&&n<t&&n<o&&$.push(`${r.label} drops to ${r.after.level} (below ${e.failBelow})`)}}const k=b.filter(e=>!e.ok).map(e=>e.name);return k.length&&$.push(`candidate no longer builds for: ${k.join(", ")}`),{configPath:f,candidatePath:p,diff:w,targets:b,ok:0===$.length,violations:$}}const zi=["claude","codex","opencode","github-copilot","cursor","generic"],Mi={claude:{kind:"claude",routerFile:".claude/skills"},codex:{kind:"agents-md",routerFile:"AGENTS.md"},opencode:{kind:"agents-md",routerFile:"AGENTS.md"},"github-copilot":{kind:"agents-md",routerFile:".github/copilot-instructions.md"},cursor:{kind:"agents-md",routerFile:".cursor/rules/refract-skills.mdc"},generic:{kind:"agents-md",routerFile:"AGENTS.md"}},qi="\x3c!-- refract-skills:start --\x3e",Li="\x3c!-- refract-skills:end --\x3e",Ii=i(".refract","skills.lock"),Bi=i(".refract","skills");function Ui(e){return null!=e?e:i(y(),"skills")}function Di(r){const n=Ui(r);if(!e(n))throw new Error(`Skills catalog not found at "${n}". Reinstall @theme-registry/refract.`);return s(n,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>i(n,e.name,"SKILL.md")).filter(e).map(e=>function(e,t){var r,n,o;const s=/^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(e),i=s?s[1]:"",l=s?e.slice(s[0].length).replace(/^\s+/,""):e,c=e=>{const t=new RegExp(`^${e}:\\s*(.*)$`,"m").exec(i);return t?t[1].trim():void 0},u=null!==(n=null!==(r=c("name"))&&void 0!==r?r:a(t).split(/[\\/]/).pop())&&void 0!==n?n:"unnamed",d="optional"===c("tier")?"optional":"core";return{name:u,description:null!==(o=c("description"))&&void 0!==o?o:"",tier:d,raw:e,body:l,sourcePath:t}}(t(e,"utf8"),e)).sort((e,t)=>e.name.localeCompare(t.name))}function Vi(e){const t=e.map(e=>`| [${e.name}](${Bi}/${e.name}.md) | ${function(e){const t=e.description.split(/\s*Triggers:/)[0].trim();return(t.split(/\.\s/)[0].trim()||t).replace(/\|/g,"\\|")}(e)} |`).join("\n");return[qi,"","## refract theme skills","","These skills document the [refract](https://github.com/theme-registry/refract) theme toolkit.","When a task matches a row below, read the linked file before working.","","| Skill | Use it for |","| --- | --- |",t,"",Li].join("\n")}function Wi(e,t){const r=e.indexOf(qi),n=e.indexOf(Li);if(-1!==r&&-1!==n&&n>r)return e.slice(0,r)+t+e.slice(n+Li.length);const o=e.replace(/\s+$/,"");return o?`${o}\n\n${t}\n`:`${t}\n`}function Yi(e,t){o(a(e),{recursive:!0}),r(e,t,"utf8")}function Hi(r){var n,o,s;const a=null!==(n=r.scope)&&void 0!==n?n:"local",l="global"===a?null!==(o=r.home)&&void 0!==o?o:m():null!==(s=r.cwd)&&void 0!==s?s:process.cwd(),c=function(e,t){if(t.skills&&t.skills.length>0){const r=new Map(e.map(e=>[e.name,e])),n=[];for(const o of t.skills){const t=r.get(o);if(!t)throw new Error(`Unknown skill "${o}". Available: ${e.map(e=>e.name).join(", ")}.`);n.push(t)}return n}return e.filter(e=>"core"===e.tier||t.includeOptional)}(Di(r.catalogDir),r);if(0===r.agents.length)throw new Error("Pick at least one agent target.");const u=new Set;if(r.agents.some(e=>"agents-md"===Mi[e].kind))for(const e of c){const t=i(l,Bi,`${e.name}.md`);Yi(t,e.body),u.add(t)}for(const n of r.agents){const r=Mi[n];if("claude"===r.kind)for(const e of c){const t=i(l,r.routerFile,e.name,"SKILL.md");Yi(t,e.raw),u.add(t)}else{const n=i(l,r.routerFile);Yi(n,Wi(e(n)?t(n,"utf8"):"",Vi(c))),u.add(n)}}const{name:d,version:f}=function(){var e,r;const n=JSON.parse(t(i(y(),"package.json"),"utf8"));return{name:null!==(e=n.name)&&void 0!==e?e:"@theme-registry/refract",version:null!==(r=n.version)&&void 0!==r?r:"0.0.0"}}(),p={schema:1,packageName:d,refractVersion:f,scope:a,agents:[...r.agents],skills:c.map(e=>e.name)},h=i(l,Ii);return Yi(h,`${JSON.stringify(p,null,2)}\n`),{scope:a,agents:[...r.agents],skills:c.map(e=>e.name),files:[...u].sort(),manifestPath:h}}function Gi(r={}){var n,o,s;const a=null!==(n=r.scope)&&void 0!==n?n:"local",l="global"===a?null!==(o=r.home)&&void 0!==o?o:m():null!==(s=r.cwd)&&void 0!==s?s:process.cwd(),c=i(l,Ii);if(!e(c))throw new Error(`No skills manifest at "${c}". Run \`refract skills install\` first.`);const u=JSON.parse(t(c,"utf8"));return Hi({agents:u.agents,scope:a,skills:u.skills,cwd:r.cwd,home:r.home,catalogDir:r.catalogDir})}const Ji="refract — build a refract theme to disk.\n\nUsage:\n refract create [--seed <color>] [--colors <n|list>] [--scheme <name>] [--manual]\n [--feel <neutral|compact|editorial|technical>] [--ratio <name>]\n [--base-size <px>] [--contrast <AA|AAA|none>] [--reset <name>]\n [--format <ts|js|json>] [--out <file>] [--no-semantics]\n [--no-neutral] [--no-shadows] [--yes] [--force]\n refract init [--js | --mjs] [--force]\n refract import <tokens.json> [--out <file>] [--raw-only] [--force]\n [--breakpoint-group <name>] [--breakpoints <n:px,…>]\n refract build [--config <path>] [--target <name|index>] [--out <dir>]\n refract tokens [--config <path>] [--out <file>]\n refract diff <candidate> [--config <path>] [--max-class-changes <n>]\n [--max-token-changes <n>] [--fail-below <AA|AAA|AA-large>]\n refract audit [--config <path>] [--strict] [--min-wcag <AA|AAA|AA-large>] [--large]\n refract skills <install|list|update> [--agent <a,b|all>] [--global|--local]\n [--only <names>] [--optional]\n refract help\n\nCommands:\n create Design a theme.raw.(ts|js|json) from one seed colour and a short interview.\n init Scaffold a runnable theme.config.(ts|js|mjs) in the current directory.\n import Seed a theme.raw.ts (+ theme.config.ts) from a DTCG tokens.json (one-shot).\n build Load the config and emit every target's files to its outDir.\n tokens Export the theme's tokens as a DTCG tokens.json (adapter-free).\n diff Show a candidate theme's blast radius vs the config (tokens/classes/contrast); thresholds gate CI.\n audit Score colour pairings for WCAG-2 contrast (+ advisory APCA). Reports; --strict fails.\n skills Install the bundled AI skills into your agent CLI(s) (claude/codex/…).\n";function Ki(e,t){var r;const n=t,o="string"==typeof n.code&&n.code.startsWith("REFRACT_E_")?`[${n.code}] `:"";if(process.stderr.write(`refract ${e}: ${o}${null!==(r=n.message)&&void 0!==r?r:String(t)}\n`),n.failures)for(const e of n.failures)process.stderr.write(` - ${e}\n`);return 1}async function Xi(e){var t;const{values:r}=g({args:e,options:{seed:{type:"string"},colors:{type:"string"},scheme:{type:"string"},manual:{type:"boolean",default:!1},feel:{type:"string"},ratio:{type:"string"},"base-size":{type:"string"},contrast:{type:"string"},reset:{type:"string"},format:{type:"string"},out:{type:"string"},"no-semantics":{type:"boolean",default:!1},"no-neutral":{type:"boolean",default:!1},"no-shadows":{type:"boolean",default:!1},yes:{type:"boolean",default:!1},force:{type:"boolean",default:!1}},allowPositionals:!1}),n=new pi(!r.yes&&void 0);try{n.write(),n.write(` ${ri("refract")} ${ni("· raw-theme scaffold")}`),n.write();const e=ei({...await bi(n,{seed:r.seed,colors:r.colors,scheme:r.scheme,manual:r.manual,feel:r.feel,ratio:r.ratio,baseSize:r["base-size"],contrast:r.contrast,reset:r.reset,format:r.format,noSemantics:r["no-semantics"],noNeutral:r["no-neutral"],noShadows:r["no-shadows"]}),out:r.out,force:Boolean(r.force)});n.write();for(const t of vi(e,function(e){try{const t=wo(e,{adapter:qo()});return Object.keys(t.tokens).length}catch{return 0}}(e.raw)))n.write(t);return n.write(),n.write(` ${ri(null!==(t=e.path.split(/[\\/]/).pop())&&void 0!==t?t:"")} written`),n.write(),n.write(` ${ni("Next — wire up a build:")} ${ri("refract init")}`),n.write(),0}catch(e){return Ki("create",e)}finally{n.close()}}const Zi=new Set(["AAA","AA","AA-large"]);async function Qi(e){const[t,...r]=e;if("list"===t)try{for(const e of Di())process.stdout.write(` ${e.name.padEnd(26)} [${e.tier}] ${e.description.split(/\s*Triggers:/)[0].trim().slice(0,80)}\n`);return 0}catch(e){return Ki("skills list",e)}const{values:n}=g({args:r,options:{agent:{type:"string"},global:{type:"boolean",default:!1},local:{type:"boolean",default:!1},only:{type:"string"},optional:{type:"boolean",default:!1}},allowPositionals:!1});if(n.global&&n.local)return process.stderr.write("refract skills: pass at most one of --global / --local.\n"),1;const o=n.global?"global":"local";try{if("update"===t){const e=Gi({scope:o});return process.stdout.write(`Updated ${e.skills.length} skill(s) for ${e.agents.join(", ")} (${e.scope}).\n`),0}if("install"===t||void 0===t){let e,t=Boolean(n.optional),r=o;if(n.agent)e=function(e){if("all"===e.trim())return[...zi];const t=e.split(",").map(e=>e.trim()).filter(Boolean),r=t.filter(e=>!zi.includes(e));if(r.length>0)throw new Error(`unknown agent(s) ${r.map(e=>`"${e}"`).join(", ")}. Known: ${zi.join(", ")}.`);return t}(n.agent);else{if(!process.stdin.isTTY)return process.stderr.write("refract skills install: pass --agent <a,b|all> (no TTY for prompts).\n"),1;{const o=await async function(){const e=h({input:process.stdin,output:process.stdout});try{process.stdout.write("Install refract skills for which agent(s)?\n"),zi.forEach((e,t)=>process.stdout.write(` ${t+1}) ${e}\n`));const t=await e.question("Enter numbers (comma-separated), or 'all': "),r="all"===t.trim()||""===t.trim()?[...zi]:t.split(",").map(e=>zi[Number(e.trim())-1]).filter(e=>Boolean(e));if(0===r.length)throw new Error("no agents selected.");return{agents:r,scope:(await e.question("Scope — [l]ocal (project) or [g]lobal (home)? [l]: ")).trim().toLowerCase().startsWith("g")?"global":"local",includeOptional:(await e.question("Include optional skills (adapter-scaffold, troubleshooting)? [y/N]: ")).trim().toLowerCase().startsWith("y")}}finally{e.close()}}();e=o.agents,t=o.includeOptional,n.global||n.local||(r=o.scope)}}const s=Hi({agents:e,scope:r,skills:n.only?n.only.split(",").map(e=>e.trim()).filter(Boolean):void 0,includeOptional:t});process.stdout.write(`Installed ${s.skills.length} skill(s) for ${s.agents.join(", ")} (${s.scope}):\n`);for(const e of s.files)process.stdout.write(` ${e}\n`);return process.stdout.write(` manifest → ${s.manifestPath}\n`),0}return process.stderr.write(`refract skills: unknown subcommand "${t}". Use install | list | update.\n`),1}catch(e){return Ki("skills",e)}}async function ea(e){const[t,...r]=e;switch(t){case"create":return Xi(r);case"init":return async function(e){const{values:t}=g({args:e,options:{js:{type:"boolean",default:!1},mjs:{type:"boolean",default:!1},force:{type:"boolean",default:!1}},allowPositionals:!1});if(t.js&&t.mjs)return process.stderr.write("refract init: pass at most one of --js / --mjs.\n"),1;const r=t.mjs?"mjs":t.js?"js":"ts";try{const e=Rs({variant:r,force:Boolean(t.force)});return e.rawTheme&&process.stdout.write(`Found ${e.rawTheme.filename} — wired it up.\n`),process.stdout.write(`Created ${e.path}\n`),process.stdout.write(e.rawTheme?"Next: run `refract build`.\n":"Next: edit the starter theme in the config (or run `refract create` to design one), then `refract build`.\n"),0}catch(e){return Ki("init",e)}}(r);case"import":return async function(e){const{values:t,positionals:r}=g({args:e,options:{out:{type:"string"},"raw-only":{type:"boolean",default:!1},force:{type:"boolean",default:!1},"breakpoint-group":{type:"string"},breakpoints:{type:"string"}},allowPositionals:!0}),n=r[0];if(!n)return process.stderr.write("refract import: pass the DTCG document to import, e.g. `refract import tokens.json`.\n"),1;if(r.length>1)return process.stderr.write(`refract import: unexpected extra argument "${r[1]}".\n`),1;try{const e=ji({input:n,out:t.out,rawOnly:Boolean(t["raw-only"]),force:Boolean(t.force),breakpointGroup:t["breakpoint-group"],breakpoints:t.breakpoints?wi(t.breakpoints):void 0});process.stdout.write(`Imported ${e.inputFile}\n`),process.stdout.write(` raw → ${e.rawFile}\n`),e.configFile&&process.stdout.write(` config → ${e.configFile}\n`);const r=Object.entries(e.counts).map(([e,t])=>`${e} (${t})`).join(", ");return r&&process.stdout.write(` seeded: ${r}\n`),process.stdout.write("Next: review the inferred tokens, then add recipes/components and run `refract build`.\n"),0}catch(e){return Ki("import",e)}}(r);case"build":return async function(e){const{values:t}=g({args:e,options:{config:{type:"string"},target:{type:"string"},out:{type:"string"}},allowPositionals:!1});try{const e=await Ai({configPath:t.config,target:t.target,out:t.out});process.stdout.write(`Built from ${e.configPath}\n`);for(const t of e.targets){const e=t.name?`${t.name} [${t.adapter}]`:t.adapter;process.stdout.write(` ${e} → ${t.outDir} (${t.files.length} file(s))\n`);for(const e of t.files)process.stdout.write(` ${e}\n`)}return 0}catch(e){return Ki("build",e)}}(r);case"tokens":return async function(e){const{values:t}=g({args:e,options:{config:{type:"string"},out:{type:"string"}},allowPositionals:!1});try{const e=await Ei({configPath:t.config,out:t.out});return process.stdout.write(`Exported tokens from ${e.configPath}\n`),process.stdout.write(` ${e.groupCount} group(s) → ${e.outFile}\n`),0}catch(e){return Ki("tokens",e)}}(r);case"diff":return async function(e){var t,r,n,o;const{values:s,positionals:i}=g({args:e,options:{config:{type:"string"},"max-class-changes":{type:"string"},"max-token-changes":{type:"string"},"fail-below":{type:"string"}},allowPositionals:!0}),a=i[0];if(!a)return process.stderr.write("refract diff: pass the candidate theme, e.g. `refract diff candidate.ts`.\n"),1;const l=s["fail-below"];if(void 0!==l&&!Zi.has(l))return process.stderr.write(`refract diff: --fail-below must be one of AAA | AA | AA-large (got "${l}").\n`),1;try{const e=await Pi({configPath:s.config,candidatePath:a,maxClassChanges:void 0!==s["max-class-changes"]?Number(s["max-class-changes"]):void 0,maxTokenChanges:void 0!==s["max-token-changes"]?Number(s["max-token-changes"]):void 0,failBelow:l}),{diff:i}=e;process.stdout.write(`Diffed ${e.candidatePath}\n vs ${e.configPath}\n`),process.stdout.write(` ${i.summary.tokensChanged} token(s), ${i.summary.classesChanged} class(es), ${i.summary.pairingsCrossed} pairing(s) crossed a threshold\n`);for(const e of i.tokens.slice(0,20)){const t="changed"===e.kind?`${e.before} → ${e.after}`:"added"===e.kind?`+ ${e.after}`:`- ${e.before}`;process.stdout.write(` token ${e.path}: ${t}\n`)}i.tokens.length>20&&process.stdout.write(` … +${i.tokens.length-20} more token(s)\n`);for(const e of i.classes)process.stdout.write(` class ${e.kind.padEnd(7)} ${e.name}\n`);for(const e of i.contrast.filter(e=>e.crossed))process.stdout.write(` contrast ${e.label}: ${null!==(r=null===(t=e.before)||void 0===t?void 0:t.level)&&void 0!==r?r:"—"} → ${null!==(o=null===(n=e.after)||void 0===n?void 0:n.level)&&void 0!==o?o:"—"}\n`);if(e.violations.length){process.stderr.write("✗ diff gate failed:\n");for(const t of e.violations)process.stderr.write(` ${t}\n`);return 1}return 0}catch(e){return Ki("diff",e)}}(r);case"audit":return async function(e){const{values:t}=g({args:e,options:{config:{type:"string"},strict:{type:"boolean",default:!1},"min-wcag":{type:"string"},large:{type:"boolean",default:!1}},allowPositionals:!1}),r=t["min-wcag"];if(void 0!==r&&!Zi.has(r))return process.stderr.write(`refract audit: --min-wcag must be one of AAA | AA | AA-large (got "${r}").\n`),1;try{const{configPath:e,result:n}=await Si({configPath:t.config,strict:t.strict,minWcag:r,largeText:t.large});process.stdout.write(`Audited ${e}\n`);for(const e of n.pairings)if(e.skipped)process.stdout.write(` ~ ${e.label} — skipped (${e.skipped})\n`);else{const t=e.pass?"✓":"✗";process.stdout.write(` ${t} ${e.label} — ${e.wcagRatio}:1 ${e.wcagLevel} · APCA Lc ${e.apcaLc}\n`)}const o=n.summary;return process.stdout.write(`${o.passed}/${o.total} pass, ${o.failed} fail, ${o.skipped} skipped\n`),0}catch(e){return Ki("audit",e)}}(r);case"skills":return Qi(r);case void 0:case"help":case"--help":case"-h":return process.stdout.write(Ji),0;default:return process.stderr.write(`refract: unknown command "${t}".\n\n${Ji}`),1}}"undefined"!=typeof require&&"undefined"!=typeof module&&require.main===module&&ea(process.argv.slice(2)).then(e=>process.exit(e),e=>{var t;process.stderr.write(`refract: ${null!==(t=e.stack)&&void 0!==t?t:e}\n`),process.exit(1)});export{zi as AGENT_TARGETS,ws as CSS_ADAPTER_PACKAGE,Hs as DEFAULT_RAW_BASENAME,qs as FEEL_PRESETS,pi as Prompter,mi as SCHEME_HINTS,hi as TYPE_SCALE_CHOICES,b as VENDOR_HELPERS,di as applyKey,ri as bold,R as buildGuide,A as compileTsConfigGraph,vi as createReportLines,oi as cyan,ci as decodeKey,ui as decodeKeys,Vs as defaultSchemeFor,ms as defineConfig,Bs as deriveLeading,Us as deriveTracking,Ti as diffThemes,ni as dim,ps as emitTheme,bs as findConfigFile,y as findPackageRoot,js as findRawTheme,v as findVendorHelper,si as green,Di as listSkills,ys as loadConfig,ea as main,Ds as nearestLadderStep,wi as parseBreakpointsFlag,bi as promptCreateAnswers,As as rawThemeImport,$s as readOwnPackageName,w as readVendorSource,Zs as renderRawTheme,Fo as resolveEmitPlan,Si as runAudit,Ai as runBuild,ei as runCreate,Pi as runDiff,ji as runImport,Rs as runInit,Hi as runSkillsInstall,Gi as runSkillsUpdate,Ei as runTokens,Ss as scaffoldConfig,Es as scaffoldConfigForRaw,ki as scaffoldImportConfig,$i as scaffoldRaw,Ys as scaffoldTheme,Ws as schemesFor,Ui as skillsCatalogDir,k as transpileToEsm,ii as yellow};
|
|
2
2
|
//# sourceMappingURL=build.esm.js.map
|