@apollion-dsi/tokens 5.6.0 → 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cli.mjs CHANGED
@@ -1,14 +1,15 @@
1
1
  #!/usr/bin/env node
2
- var Tn=Object.defineProperty;var s=(e,n)=>Tn(e,"name",{value:n,configurable:!0}),Dn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,o)=>(typeof require<"u"?require:n)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{readFile as Mo}from"node:fs/promises";import{resolve as ye}from"node:path";import{mkdir as Rn,mkdtemp as wo,readFile as yn,rename as vo,rm as bn,writeFile as kn}from"node:fs/promises";import{tmpdir as To}from"node:os";import{dirname as In,join as F}from"node:path";import{converter as zn,parse as qn}from"culori";import{defaultInputBorder as H}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as Cn}from"@apollion-dsi/core/themes/colors";import{createDeth as Vn,levelValues as On}from"@apollion-dsi/core/themes/depth";import{createFont as En,defaultInputFont as V}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as be}from"@apollion-dsi/core/themes/spacing";import{converter as An,formatHex as jn,parse as Gn}from"culori";import{DIMENSION_MULTIPLIERS as $n}from"@apollion-dsi/core/themes/dimension";function _({multiplier:e=.25,alias:n},o){let t=o!==void 0?$n[o]:e;return(...r)=>r.map(i=>{let a=typeof i=="string"?n[i]:i;return`${t*a}rem`}).join(" ")}s(_,"createSpacing");var te={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function re(e){let n=Object.keys(te).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}s(re,"assertTokenMetaResolves");var Mn=An("oklch");function h(e){return typeof e.type=="string"&&"value"in e}s(h,"isToken");function I(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(I,"kebab");function Re(e){return e.split(".").map(I).join(".")}s(Re,"kebabPath");function E(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(E,"rawValue");function B(e,n){return Number(e.toFixed(n))||0}s(B,"round");function se(e){let n=Mn(Gn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[B(n.l,4),B(n.c,4),B(n.h??0,2)],t=jn(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:B(n.alpha,4),hex:t}:{kind:"color",raw:e,components:o,hex:t}}s(se,"toColorValue");var ke=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function O(e){let n=ke.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}s(O,"toDimensionValue");function k(e){return{type:"color",value:se(e)}}s(k,"colorToken");function ie(e){let n={};for(let[o,t]of Object.entries(e))n[o]=k(t);return n}s(ie,"recordColorGroup");function Ie(e){let n=Cn(e),o={};for(let[t,r]of Object.entries(n.palettes))o[t]=k(r);return o.neutral=ie(n.neutral),o}s(Ie,"buildReadableTextGroup");var Pn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function xe(e){let n={};for(let o of Pn){let t=e[o];n[o]={base:k(t.base),dark:k(t.dark),action:k(t.action),active:k(t.active),light:k(t.light),onLight:k(t.onLight)}}return n.grayscale=ie(e.grayscale),n.neutral=ie(e.neutral),n.baseDark=k(e.baseDark??"#000000"),n.baseLight=k(e.baseLight??"#ffffff"),n.deepDark=k(e.deepDark??"#000000"),n.deepLight=k(e.deepLight??"#ffffff"),n}s(xe,"buildColorPrimitives");function Se(e){let n=_(be,e),o={};for(let t of Object.keys(be.alias))o[t]={type:"dimension",value:O(n(t))};return o}s(Se,"buildSpacePrimitives");function we(){let e={};for(let[n,o]of Object.entries(H.borderWidth))e[n]={type:"dimension",value:O(o)};return e}s(we,"buildBorderWidthPrimitives");function Nn(e,n){return{color:xe(e),space:Se(n),borderWidth:we()}}s(Nn,"buildPrimitives");var ve={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base"},Te={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight"};function Fn(e,n){let o=e;for(let t of n.split(".").slice(1))if(o&&typeof o=="object"&&t in o)o=o[t];else return;return typeof o=="string"?o:void 0}s(Fn,"lookupPrimitive");function W(e,n,o){let t={};for(let[r,i]of Object.entries(e)){let a=o[r],c=a?Fn(n,a):void 0;t[r]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:se(i)}}:k(i)}return t}s(W,"colorRefGroup");var De={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},Ln={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function _n(e,n){let o=n.split("."),t=o[0]==="border-width"?"borderWidth":o[0],r=e[t];for(let i of o.slice(1))if(r&&!h(r)&&i in r)r=r[i];else return;return r&&h(r)&&r.value.kind==="dimension"?r.value.raw:void 0}s(_n,"lookupDimensionPrimitive");function ae(e,n,o){let t={};for(let[r,i]of Object.entries(e)){let a=o[r],c=a?_n(n,a):void 0;t[r]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:O(i)}}:{type:"dimension",value:O(i)}}return t}s(ae,"dimensionRefGroup");function $e(e){let n={},o={};for(let[i,a]of Object.entries(H.borderRadius))ke.test(a)?n[i]={type:"dimension",value:O(a)}:o[i]=a;let t=ae(H.borderWidth,e,Ln),r={};for(let[i,a]of Object.entries(H.borderStyle))r[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:t,style:r},extensions:o}}s($e,"buildBorder");function Ce(e){let n=En(V,e),o={};for(let[c,l]of Object.entries(V.fontFamily)){let p=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:p,family:p}}}let t={};for(let[c,l]of Object.entries(n.fontSize))t[c]={type:"dimension",value:O(l)};let r={};for(let[c,l]of Object.entries(V.fontWeight))r[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(V.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:V.letterSpacing,textTransform:V.textTransform,fontStyle:V.fontStyle};return{group:{family:o,size:t,weight:r,lineHeight:i},extensions:a}}s(Ce,"buildFont");var Bn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function Hn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let t=n.match(Bn),r=t?t[0]:"#000000",a=(t?n.slice(0,t.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>O(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:se(r),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(Hn,"parseShadow");function Ve(e){let n=Vn(e),o={};for(let t of Object.keys(On))o[t]={type:"shadow",value:Hn(n(t))};return o}s(Ve,"buildShadow");function J(e,n,o){let t={};for(let[r,i]of Object.entries(e)){let a=n?`${n}.${I(r)}`:I(r);if(h(i)){o.add(a);let c=te[a];t[r]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...i,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:i}else t[r]=J(i,a,o)}return t}s(J,"decorateGroup");function Wn(e){let n=new Set,o=J(e.primitives,"",n),t=J(e.groups,"",n);return re(n),{...e,primitives:o,groups:t}}s(Wn,"decorateMeta");function z(e,n){return J(e,"",n)}s(z,"decorateSlice");function Oe(e,n,o){for(let[t,r]of Object.entries(e)){let i=n?`${n}.${I(t)}`:I(t);h(r)?o.add(i):Oe(r,i,o)}}s(Oe,"collectPaths");function Ee(e){let n=new Set;for(let o of e)Oe(o.groups,"",n);re(n)}s(Ee,"assertSlicesMetaComplete");function Ae(){let e=we(),o=$e({borderWidth:e}),t={};Object.keys(o.extensions).length>0&&(t["com.apollion.border"]={radius:o.extensions});let r=new Set;return{groups:z({"border-width":e,border:o.group},r),extensions:t}}s(Ae,"buildBaseIR");function je(e){let n=Ce(e),o=new Set;return{groups:z({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(je,"buildFontIR");function Ge(e,n){let o=xe(n),t=new Set;return{groups:z({color:o,bg:W(e.bg,n,ve),text:W(e.text,n,Te),tx:Ie(n),shadow:Ve(n)},t),extensions:{}}}s(Ge,"buildColorIR");function Me(e,n){let o=Se(n),t={space:o},r=new Set;return{groups:z({space:o,spacing:ae(e.spacing,t,De)},r),extensions:{}}}s(Me,"buildSpacingIR");function Jn(e,n,o){let t={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},r=Nn(n,o.dimension),i=$e(r),a=Ce(o.dimension),c={"com.apollion.variant":t,"com.apollion.font":a.extensions};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${t.brand}/${t.mode}/${t.surface}/${t.dimension}.`,meta:t,primitives:r,groups:{bg:W(e.bg,n,ve),text:W(e.text,n,Te),tx:Ie(n),spacing:ae(e.spacing,r,De),border:i.group,font:a.group,shadow:Ve(n)},extensions:c};return Wn(l)}s(Jn,"buildIR");var q=Jn;var Un=zn("rgb"),Pe="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function ce(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}s(ce,"colorPayload");function le(e){return e.alpha===void 0}s(le,"isOpaqueColor");function Ne(e){let n=Un(qn(e.hex));if(!n)return"0 0 0";let o=s(t=>Math.min(255,Math.max(0,Math.round(t*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(Ne,"rgbTriplet");function U(e,n=[]){let o=new Map;for(let[t,r]of Object.entries(e)){let i=[...n,I(t)];if(h(r))o.set(i.join("-"),r);else for(let[a,c]of U(r,i))o.set(a,c)}return o}s(U,"flatTokens");function y(e,...n){let o=e[n[0]];for(let t of n.slice(1)){if(!o||h(o))return{};o=o[t]}return o&&!h(o)?o:{}}s(y,"groupAt");function Fe(e){let n=[];for(let o of["bg","text","tx"])for(let[t,r]of U(y(e.groups,o),[o])){let i=ce(r);i&&n.push({key:t,cssVar:`--apollion-${t}`,opaque:le(i)})}return n}s(Fe,"colorEntries");function D(e,n){return[...U(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s(D,"varEntries");function $(e,n,o){if(o.length!==0){e.push(` ${n}: {`);for(let[t,r]of o)e.push(` ${JSON.stringify(t)}: ${JSON.stringify(r)},`);e.push(" },")}}s($,"pushScale");function Le(e){let n=[Pe,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=Fe(e);n.push(" colors: {");for(let{key:t,cssVar:r,opaque:i}of o)i?n.push(` ${JSON.stringify(t)}: ${JSON.stringify(`rgb(var(${r}-rgb) / <alpha-value>)`)},`):(n.push(` // ${t} carries its own alpha \u2014 excluded from the <alpha-value> modifier form.`),n.push(` ${JSON.stringify(t)}: ${JSON.stringify(`var(${r})`)},`));return n.push(" },"),$(n,"spacing",D(y(e.groups,"spacing"),["spacing"])),$(n,"borderRadius",D(y(e.groups,"border","radius"),["border","radius"])),$(n,"borderWidth",D(y(e.groups,"border","width"),["border","width"])),$(n,"fontFamily",D(y(e.groups,"font","family"),["font","family"])),$(n,"fontSize",D(y(e.groups,"font","size"),["font","size"])),$(n,"fontWeight",D(y(e.groups,"font","weight"),["font","weight"])),$(n,"lineHeight",D(y(e.groups,"font","lineHeight"),["font","line-height"])),$(n,"boxShadow",D(y(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
3
- `)}s(Le,"renderTailwindPreset");function _e(e){let n=s(r=>[...U(r).keys()],"keys"),o=s(r=>`[${r.map(i=>JSON.stringify(i)).join(", ")}]`,"list");return[Pe,"// tailwind-merge extension for the generated preset \u2014 pass to extendTailwindMerge().","","export const twMergeExtension = {"," extend: {"," theme: {",` colors: ${o(Fe(e).map(r=>r.key))},`,` spacing: ${o(n(y(e.groups,"spacing")))},`,` borderRadius: ${o(n(y(e.groups,"border","radius")))},`,` borderWidth: ${o(n(y(e.groups,"border","width")))},`," },"," classGroups: {",` 'font-family': [{ font: ${o(n(y(e.groups,"font","family")))} }],`,` 'font-size': [{ text: ${o(n(y(e.groups,"font","size")))} }],`,` 'font-weight': [{ font: ${o(n(y(e.groups,"font","weight")))} }],`,` leading: [{ leading: ${o(n(y(e.groups,"font","lineHeight")))} }],`,` shadow: [{ shadow: ${o(n(y(e.groups,"shadow")))} }],`," },"," },","};",""].join(`
4
- `)}s(_e,"renderTwMergeExtension");var Xn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function Be(e,n,o){for(let[t,r]of Object.entries(e)){let i=[...n,I(t)];h(r)?o.push(` --apollion-${i.join("-")}: ${E(r.value)};`):Be(r,i,o)}}s(Be,"emitVars");function He(e,n,o){for(let[t,r]of Object.entries(e)){let i=[...n,I(t)];if(!h(r)){He(r,i,o);continue}let a=ce(r);a&&le(a)&&o.push(` --apollion-${i.join("-")}-rgb: ${Ne(a)};`)}}s(He,"emitRgbVars");function We(e,n,o){for(let[t,r]of Object.entries(e)){let i=[...n,I(t)];h(r)?r.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${E(r.value)}; }`):We(r,i,o)}}s(We,"emitProperties");function Je(e,n={}){let{brand:o,mode:t,surface:r,dimension:i}=e.meta,a=[Xn,""];return a.push(`/* Variant: brand=${o} mode=${t} surface=${r} dimension=${i} */`,"",":root {"),Be(e.groups,[],a),n.rgbCompanions&&(a.push(""," /* -rgb channel triplets \u2014 Tailwind <alpha-value> companions (opaque colour tokens only). */"),He(e.groups,[],a)),a.push("}",""),a.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),We(e.groups,[],a),a.push("}",""),a.join(`
5
- `)}s(Je,"renderCss");var Yn="<!-- Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. -->";function ue(e,n,o){for(let[t,r]of Object.entries(e)){let i=n?`${n}.${t}`:t;h(r)?o.push([i,E(r.value)]):ue(r,i,o)}}s(ue,"flatten");function Kn(e){return typeof e=="number"?String(e):`'${String(e).replace(/'/g,"''")}'`}s(Kn,"yamlEscape");function Zn(e){let{mode:n,surface:o,dimension:t}=e.meta;return`${n}.${o}.${t}`}s(Zn,"variantKey");function ze(e,n){if(n.length===0)throw new Error(`renderDesignMd: no variants for brand "${e}"`);let o=["---",`brand: '${e}'`,"generator: apollion-tokens","variants:"];for(let r of n){let i=[];ue(r.groups,"",i),o.push(` ${Zn(r)}:`);for(let[a,c]of i)o.push(` ${a}: ${Kn(c)}`)}o.push("---");let t=["",Yn,"",`# Design.md \u2014 ${e}`,"","Resolved design-token values for this brand, one section per variant.","Consumption rules (which token to reach for, layer boundaries) live in the","package `llms.txt`; this file carries the values those rules reference.","Regenerate with `apollion-tokens build` \u2014 never edit.",""];for(let r of n){let{mode:i,surface:a,dimension:c}=r.meta;t.push(`## Variant \`${i} \xB7 ${a} \xB7 ${c}\``,"");let l=[];ue(r.groups,"",l);let p=new Map;for(let[R,T]of l){let u=R.split(".")[0]??R,m=p.get(u)??[];m.push([R,T]),p.set(u,m)}for(let[R,T]of p){t.push(`### ${R}`,"","| Token | Value |","| --- | --- |");for(let[u,m]of T)t.push(`| \`${u}\` | \`${m}\` |`);t.push("")}}return`${o.join(`
2
+ var Yn=Object.defineProperty;var i=(e,n)=>Yn(e,"name",{value:n,configurable:!0}),Zn=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(n,o)=>(typeof require<"u"?require:n)[o]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{readFile as hr}from"node:fs/promises";import{resolve as Le}from"node:path";import{mkdir as Wn,mkdtemp as tr,readFile as Bn,rename as ir,rm as Hn,writeFile as zn}from"node:fs/promises";import{tmpdir as sr}from"node:os";import{dirname as Jn,join as q}from"node:path";import{converter as Io,parse as xo}from"culori";import{defaultInputBorder as Y}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as ro}from"@apollion-dsi/core/themes/colors";import{createDeth as to,levelValues as io}from"@apollion-dsi/core/themes/depth";import{createFont as so,defaultInputFont as E}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as Ge}from"@apollion-dsi/core/themes/spacing";import{converter as ao,formatHex as co,parse as lo}from"culori";import{defaultInputBreakpoints as Qn}from"@apollion-dsi/core/themes/breakpoints";function Oe(e=Qn){return Object.entries(e.values).map(([n,o])=>[n,`${o}px`])}i(Oe,"breakpointEntries");import{defaultInputContainerSizes as eo,defaultInputLayout as no}from"@apollion-dsi/core/themes/layout";function Me(e=eo){return Object.entries(e.values).map(([n,o])=>[n,`${o}px`])}i(Me,"containerSizeEntries");function Ee(e=no){return[["page-max-width",`${e.pageMaxWidth}px`]]}i(Ee,"layoutEntries");import{DIMENSION_MULTIPLIERS as oo}from"@apollion-dsi/core/themes/dimension";function K({multiplier:e=.25,alias:n},o){let r=o!==void 0?oo[o]:e;return(...t)=>t.map(s=>{let a=typeof s=="string"?n[s]:s;return`${r*a}rem`}).join(" ")}i(K,"createSpacing");var fe={"bg.primary":{description:"Primary action surface \u2014 the brand\u2019s dominant call-to-action background."},"bg.secondary":{description:"Secondary action surface \u2014 supporting actions paired with the primary."},"bg.danger":{description:"Destructive / error surface \u2014 irreversible or failing actions."},"bg.success":{description:"Positive confirmation surface \u2014 completed or healthy states."},"bg.info":{description:"Informational surface \u2014 neutral, non-blocking notices.",deprecated:"Use bg.information once the foundation role is renamed (tracked for S6)."},"bg.canvas":{description:"Page ground \u2014 the theme canvas (never pure black in dark)."},"bg.paper":{description:"Component ground (cards, inputs, tables) \u2014 lighter than the canvas in both modes."},"bg.overlay":{description:"Top of the elevation ladder \u2014 modal / dialog panels."},"text.primary":{description:"Primary neutral ink \u2014 AA + APCA Lc \u2265 75 over bg.paper and bg.canvas."},"text.muted":{description:"Muted neutral ink \u2014 AA + APCA Lc \u2265 45 over bg.paper."},"edge.border":{description:"Default control outline \u2014 primary ink at 20 % alpha, legible on any ground."},"edge.hairline":{description:"Dividers and card outlines \u2014 primary ink at 10 % alpha."},"text.on-primary":{description:"Text/icon colour with guaranteed contrast over bg.primary."},"text.on-danger":{description:"Text/icon colour with guaranteed contrast over bg.danger."},"space.medium":{description:"Base spacing step (1rem at normal density) \u2014 the layout rhythm unit."},"space.large":{description:"Comfortable spacing step \u2014 section padding and card gutters."},"spacing.md":{description:"Medium foundation spacing alias \u2014 references the space.medium primitive."},"spacing.lg":{description:"Large foundation spacing alias \u2014 references the space.large primitive."},"border.radius.md":{description:"Default card corner radius."},"border.width.thin":{description:"Hairline border \u2014 dividers and default input outlines."},"border.width.regular":{description:"Standard emphasis border \u2014 focused/active controls."}};function me(e){let n=Object.keys(fe).filter(o=>!e.has(o));if(n.length>0)throw new Error(`token-meta: ${n.length} stale TOKEN_META key(s) resolve to no IR node: ${n.join(", ")}. Update src/token-meta.ts to match the current IR paths.`)}i(me,"assertTokenMetaResolves");var uo=ao("oklch");function y(e){return typeof e.type=="string"&&"value"in e}i(y,"isToken");function x(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}i(x,"kebab");function je(e){return e.split(".").map(x).join(".")}i(je,"kebabPath");function T(e){return e.kind==="ref"?e.resolved.raw:e.raw}i(T,"rawValue");function X(e,n){return Number(e.toFixed(n))||0}i(X,"round");function ge(e){let n=uo(lo(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[X(n.l,4),X(n.c,4),X(n.h??0,2)],r=co(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:X(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}i(ge,"toColorValue");var Pe=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function $(e){let n=Pe.exec(e.trim());if(n)return{kind:"dimension",raw:e,value:Number(n[1]),unit:n[2]};let o=Number.parseFloat(e);return{kind:"dimension",raw:e,value:Number.isFinite(o)?o:0,unit:"rem"}}i($,"toDimensionValue");function I(e){return{type:"color",value:ge(e)}}i(I,"colorToken");function G(e){let n={};for(let[o,r]of Object.entries(e))n[o]=I(r);return n}i(G,"recordColorGroup");function Ne(e){let n=ro(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=I(t);return o.neutral=G(n.neutral),o}i(Ne,"buildReadableTextGroup");var po=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function Fe(e){let n={};for(let o of po){let r=e[o];n[o]={base:I(r.base),dark:I(r.dark),action:I(r.action),active:I(r.active),light:I(r.light),onLight:I(r.onLight)}}return n.grayscale=G(e.grayscale),n.neutral=G(e.neutral),n.surface=G(e.surface),n.ink=G(e.ink),n.edge=G(e.edge),n.wash=G(e.wash),n.baseDark=I(e.baseDark??"#000000"),n.baseLight=I(e.baseLight??"#ffffff"),n.deepDark=I(e.deepDark??"#000000"),n.deepLight=I(e.deepLight??"#ffffff"),n}i(Fe,"buildColorPrimitives");function _e(e){let n=K(Ge,e),o={};for(let r of Object.keys(Ge.alias))o[r]={type:"dimension",value:$(n(r))};return o}i(_e,"buildSpacePrimitives");function Be(){let e={};for(let[n,o]of Object.entries(Y.borderWidth))e[n]={type:"dimension",value:$(o)};return e}i(Be,"buildBorderWidthPrimitives");function fo(e,n){return{color:Fe(e),space:_e(n),borderWidth:Be()}}i(fo,"buildPrimitives");var He={primary:"color.primary.base",secondary:"color.secondary.base",tertiary:"color.tertiary.base",success:"color.success.base",danger:"color.danger.base",warning:"color.warning.base",info:"color.information.base",canvas:"color.surface.canvas",sunken:"color.surface.sunken",paper:"color.surface.paper",raised:"color.surface.raised",overlay:"color.surface.overlay"},We={onPrimary:"color.baseLight",onSecondary:"color.baseLight",onTertiary:"color.baseDark",onSuccess:"color.baseLight",onDanger:"color.baseLight",onWarning:"color.baseDark",onInfo:"color.baseLight",primary:"color.ink.primary",secondary:"color.ink.secondary",muted:"color.ink.muted",disabled:"color.ink.disabled"},ze={hairline:"color.edge.hairline",border:"color.edge.border",strong:"color.edge.strong"};function mo(e,n){let o=e;for(let r of n.split(".").slice(1))if(o&&typeof o=="object"&&r in o)o=o[r];else return;return typeof o=="string"?o:void 0}i(mo,"lookupPrimitive");function F(e,n,o){let r={};for(let[t,s]of Object.entries(e)){let a=o[t],c=a?mo(n,a):void 0;r[t]=a&&c===s?{type:"color",value:{kind:"ref",path:a,resolved:ge(s)}}:I(s)}return r}i(F,"colorRefGroup");var Je={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},go={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function ho(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let s of o.slice(1))if(t&&!y(t)&&s in t)t=t[s];else return;return t&&y(t)&&t.value.kind==="dimension"?t.value.raw:void 0}i(ho,"lookupDimensionPrimitive");function he(e,n,o){let r={};for(let[t,s]of Object.entries(e)){let a=o[t],c=a?ho(n,a):void 0;r[t]=a&&c===s?{type:"dimension",value:{kind:"ref",path:a,resolved:$(s)}}:{type:"dimension",value:$(s)}}return r}i(he,"dimensionRefGroup");function qe(e){let n={},o={};for(let[s,a]of Object.entries(Y.borderRadius))Pe.test(a)?n[s]={type:"dimension",value:$(a)}:o[s]=a;let r=he(Y.borderWidth,e,go),t={};for(let[s,a]of Object.entries(Y.borderStyle))t[s]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}i(qe,"buildBorder");function Ue(e){let n=so(E,e),o={};for(let[c,l]of Object.entries(E.fontFamily)){let f=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:f,family:f}}}let r={};for(let[c,l]of Object.entries(n.fontSize))r[c]={type:"dimension",value:$(l)};let t={};for(let[c,l]of Object.entries(E.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let s={};for(let[c,l]of Object.entries(E.lineHeight))s[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:E.letterSpacing,textTransform:E.textTransform,fontStyle:E.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:s},extensions:a}}i(Ue,"buildFont");var yo=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function bo(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(yo),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=i(l=>$(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:ge(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}i(bo,"parseShadow");function Ke(e){let n=to(e),o={};for(let r of Object.keys(io))o[r]={type:"shadow",value:bo(n(r))};return o}i(Ke,"buildShadow");function Z(e,n,o){let r={};for(let[t,s]of Object.entries(e)){let a=n?`${n}.${x(t)}`:x(t);if(y(s)){o.add(a);let c=fe[a];r[t]=c&&(c.description!==void 0||c.deprecated!==void 0)?{...s,...c.description!==void 0?{description:c.description}:{},...c.deprecated!==void 0?{deprecated:c.deprecated}:{}}:s}else r[t]=Z(s,a,o)}return r}i(Z,"decorateGroup");function ko(e){let n=new Set,o=Z(e.primitives,"",n),r=Z(e.groups,"",n);return me(n),{...e,primitives:o,groups:r}}i(ko,"decorateMeta");function Q(e,n){return Z(e,"",n)}i(Q,"decorateSlice");function Xe(e,n,o){for(let[r,t]of Object.entries(e)){let s=n?`${n}.${x(r)}`:x(r);y(t)?o.add(s):Xe(t,s,o)}}i(Xe,"collectPaths");function Ye(e){let n=new Set;for(let o of e)Xe(o.groups,"",n);me(n)}i(Ye,"assertSlicesMetaComplete");function Ze(){let e={};for(let[n,o]of Oe())e[n]={type:"dimension",value:$(o)};return e}i(Ze,"buildBreakpoints");function Qe(){let e={};for(let[n,o]of Me())e[n]={type:"dimension",value:$(o)};return e}i(Qe,"buildContainerSizes");function en(){let e={};for(let[n,o]of Ee())e[n]={type:"dimension",value:$(o)};return e}i(en,"buildLayoutConstants");var nn={unit:"px",interval:"half-open [value, next) \u2014 min-width sets, ascending",cssVarsUsage:"informational only \u2014 var() is invalid inside a @media prelude"};function on(){let e=Be(),o=qe({borderWidth:e}),r={"com.apollion.breakpoint":nn};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:Q({"border-width":e,border:o.group,breakpoint:Ze(),"container-size":Qe(),layout:en()},t),extensions:r}}i(on,"buildBaseIR");function rn(e){let n=Ue(e),o=new Set;return{groups:Q({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}i(rn,"buildFontIR");function tn(e,n){let o=Fe(n),r=new Set;return{groups:Q({color:o,bg:F(e.bg,n,He),text:F(e.text,n,We),edge:F(e.edge,n,ze),tx:Ne(n),shadow:Ke(n)},r),extensions:{}}}i(tn,"buildColorIR");function sn(e,n){let o=_e(n),r={space:o},t=new Set;return{groups:Q({space:o,spacing:he(e.spacing,r,Je)},t),extensions:{}}}i(sn,"buildSpacingIR");function Ro(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=fo(n,o.dimension),s=qe(t),a=Ue(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions,"com.apollion.breakpoint":nn};Object.keys(s.extensions).length>0&&(c["com.apollion.border"]={radius:s.extensions});let l={description:`Apollion DS tokens \u2014 DTCG 2025.10. Variant: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:F(e.bg,n,He),text:F(e.text,n,We),edge:F(e.edge,n,ze),tx:Ne(n),spacing:he(e.spacing,t,Je),border:s.group,breakpoint:Ze(),"container-size":Qe(),layout:en(),font:a.group,shadow:Ke(n)},extensions:c};return ko(l)}i(Ro,"buildIR");var _=Ro;var So=Io("rgb"),an="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function ye(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}i(ye,"colorPayload");function be(e){return e.alpha===void 0}i(be,"isOpaqueColor");function cn(e){let n=So(xo(e.hex));if(!n)return"0 0 0";let o=i(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}i(cn,"rgbTriplet");function H(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let s=[...n,x(r)];if(y(t))o.set(s.join("-"),t);else for(let[a,c]of H(t,s))o.set(a,c)}return o}i(H,"flatTokens");function b(e,...n){let o=e[n[0]];for(let r of n.slice(1)){if(!o||y(o))return{};o=o[r]}return o&&!y(o)?o:{}}i(b,"groupAt");function ln(e){let n=[];for(let o of["bg","text","edge","tx"])for(let[r,t]of H(b(e.groups,o),[o])){let s=ye(t);s&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:be(s)})}return n}i(ln,"colorEntries");function L(e,n){return[...H(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}i(L,"varEntries");function C(e,n,o){if(o.length!==0){e.push(` ${n}: {`);for(let[r,t]of o)e.push(` ${JSON.stringify(r)}: ${JSON.stringify(t)},`);e.push(" },")}}i(C,"pushScale");function dn(e){let n=[an,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=ln(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:s}of o)s?n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`rgb(var(${t}-rgb) / <alpha-value>)`)},`):(n.push(` // ${r} carries its own alpha \u2014 excluded from the <alpha-value> modifier form.`),n.push(` ${JSON.stringify(r)}: ${JSON.stringify(`var(${t})`)},`));return n.push(" },"),C(n,"screens",[...H(b(e.groups,"breakpoint"))].filter(([r])=>r!=="xs").map(([r,t])=>[r,T(t.value)])),C(n,"spacing",L(b(e.groups,"spacing"),["spacing"])),C(n,"borderRadius",L(b(e.groups,"border","radius"),["border","radius"])),C(n,"borderWidth",L(b(e.groups,"border","width"),["border","width"])),C(n,"fontFamily",L(b(e.groups,"font","family"),["font","family"])),C(n,"fontSize",L(b(e.groups,"font","size"),["font","size"])),C(n,"fontWeight",L(b(e.groups,"font","weight"),["font","weight"])),C(n,"lineHeight",L(b(e.groups,"font","lineHeight"),["font","line-height"])),C(n,"boxShadow",L(b(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
3
+ `)}i(dn,"renderTailwindPreset");function un(e){let n=i(t=>[...H(t).keys()],"keys"),o=i(t=>`[${t.map(s=>JSON.stringify(s)).join(", ")}]`,"list");return[an,"// tailwind-merge extension for the generated preset \u2014 pass to extendTailwindMerge().","","export const twMergeExtension = {"," extend: {"," theme: {",` colors: ${o(ln(e).map(t=>t.key))},`,` spacing: ${o(n(b(e.groups,"spacing")))},`,` borderRadius: ${o(n(b(e.groups,"border","radius")))},`,` borderWidth: ${o(n(b(e.groups,"border","width")))},`," },"," classGroups: {",` 'font-family': [{ font: ${o(n(b(e.groups,"font","family")))} }],`,` 'font-size': [{ text: ${o(n(b(e.groups,"font","size")))} }],`,` 'font-weight': [{ font: ${o(n(b(e.groups,"font","weight")))} }],`,` leading: [{ leading: ${o(n(b(e.groups,"font","lineHeight")))} }],`,` shadow: [{ shadow: ${o(n(b(e.groups,"shadow")))} }],`," },"," },","};",""].join(`
4
+ `)}i(un,"renderTwMergeExtension");var pn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function ee(e,n,o){for(let[r,t]of Object.entries(e)){let s=[...n,x(r)];y(t)?o.push(` --apollion-${s.join("-")}: ${T(t.value)};`):ee(t,s,o)}}i(ee,"emitVars");function ne(e,n,o){for(let[r,t]of Object.entries(e)){let s=[...n,x(r)];if(!y(t)){ne(t,s,o);continue}let a=ye(t);a&&be(a)&&o.push(` --apollion-${s.join("-")}-rgb: ${cn(a)};`)}}i(ne,"emitRgbVars");function ke(e,n,o){for(let[r,t]of Object.entries(e)){let s=[...n,x(r)];y(t)?t.type==="color"&&o.push(` @property --apollion-${s.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${T(t.value)}; }`):ke(t,s,o)}}i(ke,"emitProperties");function fn(e,n={}){let{brand:o,mode:r,surface:t,dimension:s}=e.meta,a=[pn,""];return a.push(`/* Variant: brand=${o} mode=${r} surface=${t} dimension=${s} */`,"",":root {"),ee(e.groups,[],a),n.rgbCompanions&&(a.push(""," /* -rgb channel triplets \u2014 Tailwind <alpha-value> companions (opaque colour tokens only). */"),ne(e.groups,[],a)),a.push("}",""),a.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),ke(e.groups,[],a),a.push("}",""),a.join(`
5
+ `)}i(fn,"renderCss");function mn(e,n,o={}){let{attribute:r="data-apollion-mode",rgbCompanions:t}=o,{brand:s,surface:a,dimension:c}=e.meta,l=[pn,""],f=i((w,d,u)=>{l.push(`${w} {`,` color-scheme: ${u};`),ee(d.groups,[],l),t&&ne(d.groups,[],l),l.push("}","")},"block");l.push(`/* Variant: brand=${s} surface=${a} dimension=${c} modes=light+dark (attribute ${r}) */`,""),f(`:root, html[${r}="light"]`,e,"light"),f(`html[${r}="dark"]`,n,"dark"),l.push("@media (prefers-color-scheme: dark) {"),l.push(` html:not([${r}]) {`," color-scheme: dark;");let k=[];ee(n.groups,[],k),t&&ne(n.groups,[],k);for(let w of k)l.push(` ${w}`);return l.push(" }","}",""),l.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),ke(e.groups,[],l),l.push("}",""),l.join(`
6
+ `)}i(mn,"renderCssModes");var wo="<!-- Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. -->";function Re(e,n,o){for(let[r,t]of Object.entries(e)){let s=n?`${n}.${r}`:r;y(t)?o.push([s,T(t.value)]):Re(t,s,o)}}i(Re,"flatten");function vo(e){return typeof e=="number"?String(e):`'${String(e).replace(/'/g,"''")}'`}i(vo,"yamlEscape");function Do(e){let{mode:n,surface:o,dimension:r}=e.meta;return`${n}.${o}.${r}`}i(Do,"variantKey");function gn(e,n){if(n.length===0)throw new Error(`renderDesignMd: no variants for brand "${e}"`);let o=["---",`brand: '${e}'`,"generator: apollion-tokens","variants:"];for(let t of n){let s=[];Re(t.groups,"",s),o.push(` ${Do(t)}:`);for(let[a,c]of s)o.push(` ${a}: ${vo(c)}`)}o.push("---");let r=["",wo,"",`# Design.md \u2014 ${e}`,"","Resolved design-token values for this brand, one section per variant.","Consumption rules (which token to reach for, layer boundaries) live in the","package `llms.txt`; this file carries the values those rules reference.","Regenerate with `apollion-tokens build` \u2014 never edit.",""];for(let t of n){let{mode:s,surface:a,dimension:c}=t.meta;r.push(`## Variant \`${s} \xB7 ${a} \xB7 ${c}\``,"");let l=[];Re(t.groups,"",l);let f=new Map;for(let[k,w]of l){let d=k.split(".")[0]??k,u=f.get(d)??[];u.push([k,w]),f.set(d,u)}for(let[k,w]of f){r.push(`### ${k}`,"","| Token | Value |","| --- | --- |");for(let[d,u]of w)r.push(`| \`${d}\` | \`${u}\` |`);r.push("")}}return`${o.join(`
6
7
  `)}
7
- ${t.join(`
8
- `)}`}s(ze,"renderDesignMd");function qe(e){return e.alpha!==void 0?{colorSpace:"oklch",components:[...e.components],alpha:e.alpha,hex:e.hex}:{colorSpace:"oklch",components:[...e.components],hex:e.hex}}s(qe,"colorValue");function P(e){return{value:e.value,unit:e.unit}}s(P,"dimensionValue");function Qn(e){let n=e.shadow,o={color:qe(n.color),offsetX:P(n.offsetX),offsetY:P(n.offsetY),blur:P(n.blur),spread:P(n.spread)};return n.inset&&(o.inset=!0),o}s(Qn,"shadowValue");function eo(e){switch(e.kind){case"ref":return`{${Re(e.path)}}`;case"color":return qe(e);case"dimension":return P(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return Qn(e)}}s(eo,"projectValue");function no(e){let n={$value:eo(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(no,"projectToken");function de(e){let n={};for(let[o,t]of Object.entries(e))n[I(o)]=h(t)?no(t):de(t);return n}s(de,"projectGroup");function X(e,n){let o={$description:n,...de(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
9
- `}s(X,"renderSet");function Ue(e){return X(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}s(Ue,"renderBaseSet");function Xe(e,n,o,t){return X(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${t}. DTCG 2025.10.`)}s(Xe,"renderColorSet");function Ye(e,n){return X(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(Ye,"renderSpacingSet");function Ke(e,n){return X(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}s(Ke,"renderFontSet");function Ze(e,n){let{modifiers:o}=n,t=[{name:"brand",values:[...o.brand],default:o.brand[0]},{name:"mode",values:[...o.mode],default:o.mode[0]},{name:"surface",values:[...o.surface],default:o.surface[0]},{name:"dimension",values:[...o.dimension],default:o.dimension[0]}],i={name:"apollion-tokens",description:"Apollion DS token resolver \u2014 DTCG 2025.10. Compose the base set with the colour set for the chosen brand/mode/surface and the spacing + font sets for the chosen dimension. NOTE: mode is a topology placeholder in this release (dark resolves identically to light until S6).",sets:[{name:n.base.name,source:n.base.file},...n.spacing.map(a=>({name:a.name,source:a.file})),...n.font.map(a=>({name:a.name,source:a.file})),...n.color.map(a=>({name:a.name,source:a.file}))],modifiers:t,$extensions:{"com.apollion.resolver":{composition:{always:[n.base.name],byModifier:{color:"${brand}.color.${mode}.${surface}",spacing:"spacing.${dimension}",font:"font.${dimension}"}},modeIsPlaceholder:!0}}};return`${JSON.stringify(i,null,2)}
10
- `}s(Ze,"renderResolver");var oo="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function to(e,n,o){let t=[];if(e.description!==void 0&&t.push(e.description),e.deprecated===!0?t.push("@deprecated"):typeof e.deprecated=="string"&&t.push(`@deprecated ${e.deprecated}`),t.length!==0){o.push(`${n}/**`);for(let r of t)o.push(`${n} * ${r.replace(/\*\//g,"*\\/")}`);o.push(`${n} */`)}}s(to,"emitDoc");function Qe(e,n,o){let t=" ".repeat(n);for(let[r,i]of Object.entries(e))h(i)?(to(i,t,o),o.push(`${t}${JSON.stringify(r)}: ${JSON.stringify(E(i.value))},`)):(o.push(`${t}${r}: {`),Qe(i,n+1,o),o.push(`${t}},`))}s(Qe,"emitGroup");function en(e){let{brand:n,mode:o,surface:t,dimension:r}=e.meta,i=[oo,`// Variant: brand=${n} mode=${o} surface=${t} dimension=${r}`,"","export const tokens = {"];return Qe(e.groups,1,i),i.push("} as const;","","export type Tokens = typeof tokens;",""),i.join(`
11
- `)}s(en,"renderTs");var ro=["light","dark"],io=["positive","negative"],so=["compact","normal","spacious"];function Y(e){let n=e.modes??ro,o=e.surfaces??io,t=e.dimensions??so,r=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),i=[];for(let[a,c]of r)for(let l of n)for(let p of o)for(let R of t)i.push({brand:a,colors:c,mode:l,surface:p,dimension:R});return i}s(Y,"expandVariants");function nn(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(nn,"variantName");import{createHash as ao}from"node:crypto";function K(e){return ao("sha256").update(e).digest("hex")}s(K,"sha256");function fe(e){return K(pe(e))}s(fe,"hashConfig");function pe(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(pe).join(",")}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${pe(e[t])}`).join(",")}}`}s(pe,"stableStringify");function on(e){try{let{execSync:n}=Dn("node:child_process");return n("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}s(on,"detectGitCommit");function tn(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(tn,"buildEnv");function rn(e){let n=[...e.files].sort((t,r)=>t.path.localeCompare(r.path)),o={configHash:e.configHash,files:n,gitCommit:e.gitCommit,buildEnv:e.buildEnv};return`${JSON.stringify(o,null,2)}
12
- `}s(rn,"serializeManifest");var co="json/sets",sn="json/resolver.json";function Z(e){return`${co}/${e}.json`}s(Z,"setFile");function lo(e,n,o){return`${e}.color.${n}.${o}`}s(lo,"colorSetName");function uo(e){return`spacing.${e}`}s(uo,"spacingSetName");function po(e){return`font.${e}`}s(po,"fontSetName");function Q(e,n){e.includes(n)||e.push(n)}s(Q,"pushUnique");function an(e){let n=Y(e),o=[],t=[],r=[],i=[],a=new Set,c=[],l=new Set,p=[],R=new Set,T=[];for(let u of n){Q(o,u.brand),Q(t,u.mode),Q(r,u.surface),Q(i,u.dimension);let m=lo(u.brand,u.mode,u.surface);a.has(m)||(a.add(m),c.push({kind:"color",name:m,file:Z(m),brand:u.brand,mode:u.mode,surface:u.surface}));let x=uo(u.dimension);l.has(x)||(l.add(x),p.push({kind:"spacing",name:x,file:Z(x),dimension:u.dimension}));let f=po(u.dimension);R.has(f)||(R.add(f),T.push({kind:"font",name:f,file:Z(f),dimension:u.dimension}))}return{base:{kind:"base",name:"base",file:Z("base")},spacing:p,font:T,color:c,modifiers:{brand:o,mode:t,surface:r,dimension:i}}}s(an,"planSets");import{toDarkColors as Ro}from"@apollion-dsi/core/themes/colors";import{createFoundation as hn}from"@apollion-dsi/core/themes/foundation";import{createSemantic as ko}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as Io}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as xo}from"@apollion-dsi/core/themes/surface";import{converter as fo,formatHex as N,interpolate as mo,parse as v,wcagContrast as fn}from"culori";var ge=fo("oklch");function d(e,n,o){let t=v(e),r=v(n);if(!t||!r)return e;let i=mo([t,r],"oklch");return N(i(o))??e}s(d,"mixOklch");function go(e){return e?typeof e=="string"?e:e.base:"#000"}s(go,"coerceToHex");var ee=1.3,ho=.05,cn=.04,C=s((e,n)=>{let o=v(e),t=v(n);return!o||!t?1:fn(o,t)},"contrastRatio"),me=s(e=>{let n=ge(v(e));return n?n.l??0:null},"oklchLightness"),yo=4.5;function ln(e,n,o=yo){let t=v(n),r=ge(v(e));if(!t||!r)return e;let i=C("#fff",n)>=C("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=N(r)??e,l=v(c);if(l&&fn(l,t)>=o)return c;let p=Math.min(1,Math.max(0,(r.l??0)+i));if(p===(r.l??0))break;r={...r,l:p}}return N(r)??e}s(ln,"readableColor");var un=s((e,n)=>{if(C(e,n)>=ee)return!0;let o=me(e),t=me(n);return o!==null&&t!==null&&Math.abs(o-t)>=ho},"isPerceptibleState"),bo=s(e=>e?C("#fff",e)>C("#000",e):!1,"isDarkSurface");function dn(e,n,o){let t=ge(v(e));if(!t)return null;let r={...t,l:o??t.l??0},i=n?cn:-cn;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(r.l??0)+i));if(c===(r.l??0))break;r={...r,l:c};let l=N(r);if(l&&C(e,l)>=ee)return l}return N(r)??null}s(dn,"derivePerceptibleState");function pn(e,n,o){let t=dn(e,n,o);if(t&&C(e,t)>=ee)return t;let r=dn(e,!n);return r&&C(e,r)>=ee?r:t??r}s(pn,"perceptibleStateFor");function w(e,n){let o=typeof e=="object"&&e!==null?e:void 0,t=go(e),r=n.deepDark,i=n.deepLight,a={base:t,dark:d(t,r,.6),action:d(t,r,.2),active:d(t,i,.6),light:d(t,i,.9),onLight:t};if(v(t)){let c=bo(n.baseLight),l=un(t,a.action);if(l||(a.action=pn(t,c)??a.action),!un(t,a.active)){let p=l?void 0:me(a.action)??void 0;a.active=pn(t,c,p)??a.active}}if(a.onLight=ln(a.action,a.light),o){let c=o.action??a.action,l=o.light??a.light;return{base:t,dark:o.dark??a.dark,action:c,active:o.active??a.active,light:l,onLight:o.onLight??ln(c,l)}}return a}s(w,"mountSingleColor");function mn(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:d(n,o,.05),10:d(n,o,.1),20:d(n,o,.2),30:d(n,o,.3),40:d(n,o,.4),50:d(n,o,.5),60:d(n,o,.6),70:d(n,o,.7),80:d(n,o,.8),90:d(n,o,.9),100:d(n,o,1)}}s(mn,"mountGreyscaleColors");function gn(e){let n=e.deepLight,o=e.deepDark,t=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,r=s(a=>1/17*(a-1),"interpolation"),i=d(t,o,.5);return{0:d(i,n,r(18)),5:d(i,n,r(17.5)),10:d(i,n,r(17)),20:d(i,n,r(16)),30:d(i,n,r(15)),40:d(i,n,r(14)),50:d(i,n,r(13)),60:d(i,n,r(12)),70:d(i,n,r(11)),80:d(i,n,r(10)),90:d(i,n,r(9)),100:d(i,n,r(8)),110:d(i,n,r(7)),120:d(i,n,r(6)),130:d(i,n,r(5)),140:d(i,n,r(4)),150:d(i,n,r(3)),160:d(i,n,r(2)),170:i,180:d(i,o,.25)}}s(gn,"mountNeutralColors");function So(e){return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:gn(e),grayscale:mn(e),main:w(e.main,e),opposite:w(e.opposite,e),complementary:w(e.complementary,e),danger:w(e.danger,e),information:w(e.information,e),success:w(e.success,e),warning:w(e.warning,e),primary:w(e.primary,e),secondary:w(e.secondary,e),tertiary:w(e.tertiary,e)}}s(So,"composeColors");function G(e,n=Io){let o=e.mode==="dark"?Ro(e.colors):e.colors,t=So(o),r=_(n,e.dimension),i=ko({colors:t,spacing:r}),a=hn(i);return e.surface==="negative"&&(a=hn(xo({semantic:i,colors:t},"negative").semantic)),{foundation:a,colors:t}}s(G,"buildVariantThemes");async function xn(e){let{config:n,outDir:o,cwd:t=process.cwd(),verbose:r=!1}=e,i=Y(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await wo(F(To(),"apollion-tokens-"));try{let l=[],p=s(async(u,m)=>{await Do(c,u,m),l.push({path:u,sha256:K(m)}),r&&console.log(` \u2713 ${u}`)},"emit");if(a.json){let u=an(n),m=[],x=Ae();m.push(x),await p(u.base.file,Ue(x));for(let f of u.spacing){let b=i.find(L=>L.dimension===f.dimension),{foundation:M}=G(b),j=Me(M,f.dimension);m.push(j),await p(f.file,Ye(j,f.dimension))}for(let f of u.font){let b=je(f.dimension);m.push(b),await p(f.file,Ke(b,f.dimension))}for(let f of u.color){let b=i.find(oe=>oe.brand===f.brand&&oe.mode===f.mode&&oe.surface===f.surface),{foundation:M,colors:j}=G(b),L=Ge(M,j);m.push(L),await p(f.file,Xe(L,f.brand,f.mode,f.surface))}Ee(m),await p(sn,Ze(n,u))}if(a.css||a.ts)for(let u of i){let{foundation:m,colors:x}=G(u),f=q(m,x,u),b=nn(u);a.css&&await p(`css/${b}.css`,Je(f,{rgbCompanions:a.tailwind})),a.ts&&await p(`ts/${b}.d.ts`,en(f))}if(a.tailwind){let u=i[0],{foundation:m,colors:x}=G(u),f=q(m,x,u);await p("tailwind/preset.mjs",Le(f)),await p("tailwind/tw-merge.mjs",_e(f))}if(a.designMd){let u=[...new Set(i.map(m=>m.brand))];for(let m of u){let f=i.filter(b=>b.brand===m).map(b=>{let{foundation:M,colors:j}=G(b);return q(M,j,b)});await p(`design/${m}.design.md`,ze(m,f))}}let R={configHash:fe(n),files:l,gitCommit:on(t),buildEnv:tn()},T=rn(R);return await kn(F(c,"manifest.json"),T),await bn(o,{recursive:!0,force:!0}),await Rn(In(o),{recursive:!0}),await vo(c,o),r&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:R,outDir:o}}catch(l){throw await bn(c,{recursive:!0,force:!0}).catch(()=>{}),l}}s(xn,"build");async function Sn(e){let{config:n,outDir:o}=e,t;try{t=JSON.parse(await yn(F(o,"manifest.json"),"utf8"))}catch{return!1}if(t.configHash!==fe(n))return!1;for(let r of t.files){let i;try{i=await yn(F(o,r.path))}catch{return!1}if(K(i)!==r.sha256)return!1}return!0}s(Sn,"check");async function Do(e,n,o){let t=F(e,n);await Rn(In(t),{recursive:!0}),await kn(t,o)}s(Do,"writeAt");import{readFile as Co}from"node:fs/promises";import{resolve as Vo}from"node:path";import{createContext as Oo,Script as Eo}from"node:vm";import{z as g}from"zod";var S=g.string().regex(/^#([0-9a-fA-F]{3}){1,2}$|^transparent$|^rgb\(.*\)$|^oklch\(.*\)$/,{message:'Must be hex, rgb(), oklch(), or "transparent"'}),$o=g.object({baseDark:g.string().optional(),baseLight:g.string().optional(),deepDark:S,deepLight:S,transparent:g.string().optional(),main:S.optional(),opposite:S.optional(),complementary:S.optional(),information:S.optional(),success:S.optional(),danger:S.optional(),warning:S.optional(),primary:S.optional(),secondary:S.optional(),tertiary:S.optional()}).passthrough(),wn=g.object({brands:g.record(g.string(),$o).refine(e=>Object.keys(e).length>0,{message:"apollion.config.mjs: brands must contain at least 1 entry"}),modes:g.array(g.enum(["light","dark"])).optional(),surfaces:g.array(g.enum(["positive","negative"])).optional(),dimensions:g.array(g.enum(["compact","normal","spacious"])).optional(),output:g.object({runtime:g.boolean().optional(),css:g.boolean().optional(),json:g.boolean().optional(),ts:g.boolean().optional(),designMd:g.boolean().optional(),tailwind:g.boolean().optional()}).passthrough().optional()}).passthrough();var Ao=[/\brequire\s*\(/,/\bimport\s*\(/,/^\s*import\s+/m],jo=1e3;var he=class he extends Error{constructor(o,t){super(o);this.configPath=t;this.name="ConfigLoadError"}};s(he,"ConfigLoadError");var A=he;async function vn(e){let n=Vo(e.configPath),o=await Co(n,"utf8");for(let l of Ao)if(l.test(o))throw new A(`apollion.config: dynamic require/import not allowed (matched ${l}). Declarative config only \u2014 see ADR-006 \xA73.8 B3.`,n);let t=o.replace(/(^|\n)\s*export\s+default\s+/,(l,p)=>`${p}__apollion_config_export = `);if(t===o)throw new A("apollion.config: missing `export default <object>;` \u2014 config must export a default object literal.",n);let r={__apollion_config_export:void 0,console:Go(),Symbol,Number,String,Boolean,Array,Object,JSON,Math,defineConfig:s(l=>l,"defineConfig")},i=Oo(r);try{new Eo(t,{filename:n}).runInContext(i,{timeout:jo})}catch(l){throw new A(`apollion.config: evaluation failed \u2014 ${l instanceof Error?l.message:String(l)}`,n)}let a=r.__apollion_config_export;if(a===void 0)throw new A("apollion.config: `export default` produced undefined.",n);let c=wn.safeParse(a);if(!c.success){let l=c.error.issues.map(p=>` ${p.path.join(".")||"(root)"}: ${p.message}`).join(`
13
- `);throw new A(`apollion.config: schema validation failed \u2014
14
- ${l}`,n)}return c.data}s(vn,"loadConfig");function Go(){return{log:s((...e)=>console.log("[apollion.config]",...e),"log"),warn:s((...e)=>console.warn("[apollion.config]",...e),"warn"),error:s((...e)=>console.error("[apollion.config]",...e),"error")}}s(Go,"makeReadOnlyConsole");function Po(e){let n=e.slice(2),o=n[0];o!=="build"&&ne(`Unknown command "${o??""}". Usage: apollion-tokens build [--check] [--verbose] --config <path> [--out <dir>]`);let t="apollion.config.mjs",r="dist",i=!1,a=!1;for(let c=1;c<n.length;c++){let l=n[c];switch(l){case"--config":t=n[++c]??ne("--config needs a path");break;case"--out":r=n[++c]??ne("--out needs a path");break;case"--check":i=!0;break;case"--verbose":a=!0;break;default:ne(`Unknown flag "${l}"`)}}return{command:o,configPath:t,outDir:r,check:i,verbose:a}}s(Po,"parseArgs");function ne(e){console.error(`apollion-tokens: ${e}`),process.exit(2)}s(ne,"fail");async function No(e){let n=ye(e);if(n.endsWith(".json")){let o=await Mo(n,"utf8");return JSON.parse(o)}return vn({configPath:n})}s(No,"loadConfigFromPath");async function Fo(){let e=Po(process.argv),n=await No(e.configPath);if(e.check){await Sn({config:n,outDir:ye(e.outDir)})||(console.error("apollion-tokens: dist/ is stale, missing, or has drifted from its manifest. Re-run `apollion-tokens build` without --check."),process.exit(1)),console.log("apollion-tokens: dist/ is up-to-date with config.");return}let{manifest:o}=await xn({config:n,outDir:ye(e.outDir),verbose:e.verbose});console.log(`apollion-tokens: wrote ${o.files.length} file(s) \u2014 configHash=${o.configHash.slice(0,12)}\u2026`)}s(Fo,"main");Fo().catch(e=>{console.error(`apollion-tokens: ${e instanceof Error?e.message:String(e)}`),process.exit(1)});
8
+ ${r.join(`
9
+ `)}`}i(gn,"renderDesignMd");function hn(e){return e.alpha!==void 0?{colorSpace:"oklch",components:[...e.components],alpha:e.alpha,hex:e.hex}:{colorSpace:"oklch",components:[...e.components],hex:e.hex}}i(hn,"colorValue");function W(e){return{value:e.value,unit:e.unit}}i(W,"dimensionValue");function $o(e){let n=e.shadow,o={color:hn(n.color),offsetX:W(n.offsetX),offsetY:W(n.offsetY),blur:W(n.blur),spread:W(n.spread)};return n.inset&&(o.inset=!0),o}i($o,"shadowValue");function To(e){switch(e.kind){case"ref":return`{${je(e.path)}}`;case"color":return hn(e);case"dimension":return W(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return $o(e)}}i(To,"projectValue");function Co(e){let n={$value:To(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}i(Co,"projectToken");function Ie(e){let n={};for(let[o,r]of Object.entries(e))n[x(o)]=y(r)?Co(r):Ie(r);return n}i(Ie,"projectGroup");function oe(e,n){let o={$description:n,...Ie(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
10
+ `}i(oe,"renderSet");function yn(e){return oe(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}i(yn,"renderBaseSet");function bn(e,n,o,r){return oe(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${r}. DTCG 2025.10.`)}i(bn,"renderColorSet");function kn(e,n){return oe(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}i(kn,"renderSpacingSet");function Rn(e,n){return oe(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}i(Rn,"renderFontSet");function In(e,n){let{modifiers:o}=n,r=[{name:"brand",values:[...o.brand],default:o.brand[0]},{name:"mode",values:[...o.mode],default:o.mode[0]},{name:"surface",values:[...o.surface],default:o.surface[0]},{name:"dimension",values:[...o.dimension],default:o.dimension[0]}],s={name:"apollion-tokens",description:"Apollion DS token resolver \u2014 DTCG 2025.10. Compose the base set with the colour set for the chosen brand/mode/surface and the spacing + font sets for the chosen dimension. NOTE: mode is a topology placeholder in this release (dark resolves identically to light until S6).",sets:[{name:n.base.name,source:n.base.file},...n.spacing.map(a=>({name:a.name,source:a.file})),...n.font.map(a=>({name:a.name,source:a.file})),...n.color.map(a=>({name:a.name,source:a.file}))],modifiers:r,$extensions:{"com.apollion.resolver":{composition:{always:[n.base.name],byModifier:{color:"${brand}.color.${mode}.${surface}",spacing:"spacing.${dimension}",font:"font.${dimension}"}},modeIsPlaceholder:!0}}};return`${JSON.stringify(s,null,2)}
11
+ `}i(In,"renderResolver");var Ao="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function Vo(e,n,o){let r=[];if(e.description!==void 0&&r.push(e.description),e.deprecated===!0?r.push("@deprecated"):typeof e.deprecated=="string"&&r.push(`@deprecated ${e.deprecated}`),r.length!==0){o.push(`${n}/**`);for(let t of r)o.push(`${n} * ${t.replace(/\*\//g,"*\\/")}`);o.push(`${n} */`)}}i(Vo,"emitDoc");function xn(e,n,o){let r=" ".repeat(n);for(let[t,s]of Object.entries(e))y(s)?(Vo(s,r,o),o.push(`${r}${JSON.stringify(t)}: ${JSON.stringify(T(s.value))},`)):(o.push(`${r}${t}: {`),xn(s,n+1,o),o.push(`${r}},`))}i(xn,"emitGroup");function Sn(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,s=[Ao,`// Variant: brand=${n} mode=${o} surface=${r} dimension=${t}`,"","export const tokens = {"];return xn(e.groups,1,s),s.push("} as const;","","export type Tokens = typeof tokens;",""),s.join(`
12
+ `)}i(Sn,"renderTs");var Lo=["light","dark"],Oo=["positive","negative"],Mo=["compact","normal","spacious"];function re(e){let n=e.modes??Lo,o=e.surfaces??Oo,r=e.dimensions??Mo,t=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),s=[];for(let[a,c]of t)for(let l of n)for(let f of o)for(let k of r)s.push({brand:a,colors:c,mode:l,surface:f,dimension:k});return s}i(re,"expandVariants");function wn(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}i(wn,"variantName");import{createHash as Eo}from"node:crypto";function te(e){return Eo("sha256").update(e).digest("hex")}i(te,"sha256");function Se(e){return te(xe(e))}i(Se,"hashConfig");function xe(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(xe).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${xe(e[r])}`).join(",")}}`}i(xe,"stableStringify");function vn(e){try{let{execSync:n}=Zn("node:child_process");return n("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}i(vn,"detectGitCommit");function Dn(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}i(Dn,"buildEnv");function $n(e){let n=[...e.files].sort((r,t)=>r.path.localeCompare(t.path)),o={configHash:e.configHash,files:n,gitCommit:e.gitCommit,buildEnv:e.buildEnv};return`${JSON.stringify(o,null,2)}
13
+ `}i($n,"serializeManifest");var Go="json/sets",Tn="json/resolver.json";function ie(e){return`${Go}/${e}.json`}i(ie,"setFile");function jo(e,n,o){return`${e}.color.${n}.${o}`}i(jo,"colorSetName");function Po(e){return`spacing.${e}`}i(Po,"spacingSetName");function No(e){return`font.${e}`}i(No,"fontSetName");function se(e,n){e.includes(n)||e.push(n)}i(se,"pushUnique");function Cn(e){let n=re(e),o=[],r=[],t=[],s=[],a=new Set,c=[],l=new Set,f=[],k=new Set,w=[];for(let d of n){se(o,d.brand),se(r,d.mode),se(t,d.surface),se(s,d.dimension);let u=jo(d.brand,d.mode,d.surface);a.has(u)||(a.add(u),c.push({kind:"color",name:u,file:ie(u),brand:d.brand,mode:d.mode,surface:d.surface}));let h=Po(d.dimension);l.has(h)||(l.add(h),f.push({kind:"spacing",name:h,file:ie(h),dimension:d.dimension}));let m=No(d.dimension);k.has(m)||(k.add(m),w.push({kind:"font",name:m,file:ie(m),dimension:d.dimension}))}return{base:{kind:"base",name:"base",file:ie("base")},spacing:f,font:w,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:s}}}i(Cn,"planSets");import{toDarkColors as Qo}from"@apollion-dsi/core/themes/colors";import{createFoundation as _n}from"@apollion-dsi/core/themes/foundation";import{createSemantic as er}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as nr}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as or}from"@apollion-dsi/core/themes/surface";import{converter as Mn,formatHex as j,interpolate as Fo,parse as S,wcagContrast as En}from"culori";var J=Mn("oklch"),_o=Mn("rgb");function p(e,n,o){let r=S(e),t=S(n);if(!r||!t)return e;let s=Fo([r,t],"oklch");return j(s(o))??e}i(p,"mixOklch");function Bo(e){return e?typeof e=="string"?e:e.base:"#000"}i(Bo,"coerceToHex");var ae=1.3,Ho=.05,An=.04,O=i((e,n)=>{let o=S(e),r=S(n);return!o||!r?1:En(o,r)},"contrastRatio"),we=i(e=>{let n=J(S(e));return n?n.l??0:null},"oklchLightness"),Wo=4.5;function z(e,n,o=Wo){let r=S(n),t=J(S(e));if(!r||!t)return e;let s=O("#fff",n)>=O("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=j(t)??e,l=S(c);if(l&&En(l,r)>=o)return c;let f=Math.min(1,Math.max(0,(t.l??0)+s));if(f===(t.l??0))break;t={...t,l:f}}return j(t)??e}i(z,"readableColor");var Vn=i((e,n)=>{if(O(e,n)>=ae)return!0;let o=we(e),r=we(n);return o!==null&&r!==null&&Math.abs(o-r)>=Ho},"isPerceptibleState"),ve=i(e=>e?O("#fff",e)>O("#000",e):!1,"isDarkSurface");function Ln(e,n,o){let r=J(S(e));if(!r)return null;let t={...r,l:o??r.l??0},s=n?An:-An;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(t.l??0)+s));if(c===(t.l??0))break;t={...t,l:c};let l=j(t);if(l&&O(e,l)>=ae)return l}return j(t)??null}i(Ln,"derivePerceptibleState");function On(e,n,o){let r=Ln(e,n,o);if(r&&O(e,r)>=ae)return r;let t=Ln(e,!n);return t&&O(e,t)>=ae?t:r??t}i(On,"perceptibleStateFor");function D(e,n){let o=typeof e=="object"&&e!==null?e:void 0,r=Bo(e),t=n.deepDark,s=n.deepLight,a={base:r,dark:p(r,t,.6),action:p(r,t,.2),active:p(r,s,.6),light:p(r,s,.9),onLight:r};if(S(r)){let c=ve(n.baseLight),l=Vn(r,a.action);if(l||(a.action=On(r,c)??a.action),!Vn(r,a.active)){let f=l?void 0:we(a.action)??void 0;a.active=On(r,c,f)??a.active}}if(a.onLight=z(a.action,a.light),o){let c=o.action??a.action,l=o.light??a.light;return{base:r,dark:o.dark??a.dark,action:c,active:o.active??a.active,light:l,onLight:o.onLight??z(c,l)}}return a}i(D,"mountSingleColor");function Gn(e){let n=e.deepLight,o=e.deepDark;return{0:n,5:p(n,o,.05),10:p(n,o,.1),20:p(n,o,.2),30:p(n,o,.3),40:p(n,o,.4),50:p(n,o,.5),60:p(n,o,.6),70:p(n,o,.7),80:p(n,o,.8),90:p(n,o,.9),100:p(n,o,1)}}i(Gn,"mountGreyscaleColors");function jn(e){let n=e.deepLight,o=e.deepDark,r=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,t=i(a=>1/17*(a-1),"interpolation"),s=p(r,o,.5);return{0:p(s,n,t(18)),5:p(s,n,t(17.5)),10:p(s,n,t(17)),20:p(s,n,t(16)),30:p(s,n,t(15)),40:p(s,n,t(14)),50:p(s,n,t(13)),60:p(s,n,t(12)),70:p(s,n,t(11)),80:p(s,n,t(10)),90:p(s,n,t(9)),100:p(s,n,t(8)),110:p(s,n,t(7)),120:p(s,n,t(6)),130:p(s,n,t(5)),140:p(s,n,t(4)),150:p(s,n,t(3)),160:p(s,n,t(2)),170:s,180:p(s,o,.25)}}i(jn,"mountNeutralColors");function B(e,n){let o=J(S(e));if(!o)return e;let r=Math.min(1,Math.max(0,(o.l??0)+n));return j({...o,l:r})??e}i(B,"shiftLightness");function ce(e,n){let o=J(S(e));if(!o)return e;let r=o.l??0,t=n.min??0,s=n.max??1;return r>=t&&r<=s?e:j({...o,l:Math.min(s,Math.max(t,r))})??e}i(ce,"clampLightness");function P(e,n){let o=_o(S(e));if(!o)return e;let r=Math.min(1,Math.max(0,n)),t=i(s=>Math.round((s??0)*255),"channel");return`rgba(${t(o.r)}, ${t(o.g)}, ${t(o.b)}, ${r})`}i(P,"toRgbaString");import{apcaContrast as le,EDGE_ALPHA as De,HALATION_FLOORS as Ce,INK_APCA_MIN as $e,INK_MIX as Te,LADDER_DELTAS as de,MIN_CONTRAST_AA as Pn,WASH_ALPHA as zo}from"@apollion-dsi/core/themes/colors";var Jo="#FFFFFF",Ae="#000000";function qo(e){return ve(e.baseLight)?"dark":"light"}i(qo,"resolvePolarity");function Nn(e,n,o){if(Math.abs(le(e,n))>=o)return e;let r=Math.abs(le("#ffffff",n))>=Math.abs(le("#000000",n)),t=e;for(let s=0;s<40;s+=1){let a=B(t,r?.02:-.02);if(a===t||(t=a,Math.abs(le(t,n))>=o))break}return t}i(Nn,"ensureApca");function Uo(e,n){let o=e.baseLight??Jo,r=n==="dark",t=r?ce(o,{min:Ce.CANVAS_MIN_L}):o,s=B(t,de.sunken);return{canvas:t,sunken:r?ce(s,{min:Ce.CANVAS_MIN_L}):s,paper:B(t,de.paper),raised:B(t,de.raised),overlay:B(t,de.overlay),scrim:r?e.deepLight??Ae:e.neutral?.["180"]??e.baseDark??Ae}}i(Uo,"deriveSurface");function Ko(e,n){let o=e.baseDark??Ae,r=ce(Nn(z(o,n.paper,Pn),n.paper,$e.primary),{max:Ce.INK_MAX_L}),t=i((s,a)=>Nn(z(p(r,n.canvas,s),n.paper,Pn),n.paper,a),"tier");return{primary:r,secondary:t(Te.secondary,$e.secondary),muted:t(Te.muted,$e.muted),disabled:p(r,n.canvas,Te.disabled)}}i(Ko,"deriveInk");function Xo(e){return{hairline:P(e.primary,De.hairline),border:P(e.primary,De.border),strong:P(e.primary,De.strong)}}i(Xo,"deriveEdge");function Yo(e,n){let o=zo[n];return{hover:P(e.primary,o.hover),pressed:P(e.primary,o.pressed),selected:P(e.primary,o.selected)}}i(Yo,"deriveWash");function Zo(e,n){return n?{surface:{...e.surface,...n.surface},ink:{...e.ink,...n.ink},edge:{...e.edge,...n.edge},wash:{...e.wash,...n.wash}}:e}i(Zo,"applyOverride");function Fn(e,n){let o=qo(e),r=Uo(e,o),t=Ko(e,r),s={surface:r,ink:t,edge:Xo(t),wash:Yo(t,o)};return Zo(s,n?.[o])}i(Fn,"resolveSurfaceLadder");function rr(e){let n=jn(e);return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:n,grayscale:Gn(e),...Fn({...e,neutral:n},e.ladder),main:D(e.main,e),opposite:D(e.opposite,e),complementary:D(e.complementary,e),danger:D(e.danger,e),information:D(e.information,e),success:D(e.success,e),warning:D(e.warning,e),primary:D(e.primary,e),secondary:D(e.secondary,e),tertiary:D(e.tertiary,e)}}i(rr,"composeColors");function M(e,n=nr){let o=e.mode==="dark"?Qo(e.colors):e.colors,r=rr(o),t=K(n,e.dimension),s=er({colors:r,spacing:t}),a=_n(s);return e.surface==="negative"&&(a=_n(or({semantic:s,colors:r},"negative").semantic)),{foundation:a,colors:r}}i(M,"buildVariantThemes");async function qn(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,s=re(n),a=n.output??{};if(s.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await tr(q(sr(),"apollion-tokens-"));try{let l=[],f=i(async(d,u)=>{await ar(c,d,u),l.push({path:d,sha256:te(u)}),t&&console.log(` \u2713 ${d}`)},"emit");if(a.json){let d=Cn(n),u=[],h=on();u.push(h),await f(d.base.file,yn(h));for(let m of d.spacing){let R=s.find(U=>U.dimension===m.dimension),{foundation:A}=M(R),V=sn(A,m.dimension);u.push(V),await f(m.file,kn(V,m.dimension))}for(let m of d.font){let R=rn(m.dimension);u.push(R),await f(m.file,Rn(R,m.dimension))}for(let m of d.color){let R=s.find(pe=>pe.brand===m.brand&&pe.mode===m.mode&&pe.surface===m.surface),{foundation:A,colors:V}=M(R),U=tn(A,V);u.push(U),await f(m.file,bn(U,m.brand,m.mode,m.surface))}Ye(u),await f(Tn,In(n,d))}if(a.css||a.ts)for(let d of s){let{foundation:u,colors:h}=M(d),m=_(u,h,d),R=wn(d);a.css&&await f(`css/${R}.css`,fn(m,{rgbCompanions:a.tailwind})),a.ts&&await f(`ts/${R}.d.ts`,Sn(m))}if(a.cssModes){let d=new Map;for(let u of s){let h=`${u.brand}.${u.surface}.${u.dimension}`,m=d.get(h)??{};m[u.mode]=u,d.set(h,m)}for(let[u,{light:h,dark:m}]of d){if(!h||!m)throw new Error(`apollion-tokens build: output.cssModes needs both modes for ${u} (config.modes)`);let R=M(h),A=M(m),V=mn(_(R.foundation,R.colors,h),_(A.foundation,A.colors,m),{rgbCompanions:a.tailwind});await f(`css/${u}.modes.css`,V)}}if(a.tailwind){let d=s[0],{foundation:u,colors:h}=M(d),m=_(u,h,d);await f("tailwind/preset.mjs",dn(m)),await f("tailwind/tw-merge.mjs",un(m))}if(a.designMd){let d=[...new Set(s.map(u=>u.brand))];for(let u of d){let m=s.filter(R=>R.brand===u).map(R=>{let{foundation:A,colors:V}=M(R);return _(A,V,R)});await f(`design/${u}.design.md`,gn(u,m))}}let k={configHash:Se(n),files:l,gitCommit:vn(r),buildEnv:Dn()},w=$n(k);return await zn(q(c,"manifest.json"),w),await Hn(o,{recursive:!0,force:!0}),await Wn(Jn(o),{recursive:!0}),await ir(c,o),t&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:k,outDir:o}}catch(l){throw await Hn(c,{recursive:!0,force:!0}).catch(()=>{}),l}}i(qn,"build");async function Un(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await Bn(q(o,"manifest.json"),"utf8"))}catch{return!1}if(r.configHash!==Se(n))return!1;for(let t of r.files){let s;try{s=await Bn(q(o,t.path))}catch{return!1}if(te(s)!==t.sha256)return!1}return!0}i(Un,"check");async function ar(e,n,o){let r=q(e,n);await Wn(Jn(r),{recursive:!0}),await zn(r,o)}i(ar,"writeAt");import{readFile as lr}from"node:fs/promises";import{resolve as dr}from"node:path";import{createContext as ur,Script as pr}from"node:vm";import{z as g}from"zod";var v=g.string().regex(/^#([0-9a-fA-F]{3}){1,2}$|^transparent$|^rgb\(.*\)$|^oklch\(.*\)$/,{message:'Must be hex, rgb(), oklch(), or "transparent"'}),cr=g.object({baseDark:g.string().optional(),baseLight:g.string().optional(),deepDark:v,deepLight:v,transparent:g.string().optional(),main:v.optional(),opposite:v.optional(),complementary:v.optional(),information:v.optional(),success:v.optional(),danger:v.optional(),warning:v.optional(),primary:v.optional(),secondary:v.optional(),tertiary:v.optional()}).passthrough(),Kn=g.object({brands:g.record(g.string(),cr).refine(e=>Object.keys(e).length>0,{message:"apollion.config.mjs: brands must contain at least 1 entry"}),modes:g.array(g.enum(["light","dark"])).optional(),surfaces:g.array(g.enum(["positive","negative"])).optional(),dimensions:g.array(g.enum(["compact","normal","spacious"])).optional(),output:g.object({runtime:g.boolean().optional(),css:g.boolean().optional(),json:g.boolean().optional(),ts:g.boolean().optional(),designMd:g.boolean().optional(),tailwind:g.boolean().optional(),cssModes:g.boolean().optional()}).passthrough().optional()}).passthrough();var fr=[/\brequire\s*\(/,/\bimport\s*\(/,/^\s*import\s+/m],mr=1e3;var Ve=class Ve extends Error{constructor(o,r){super(o);this.configPath=r;this.name="ConfigLoadError"}};i(Ve,"ConfigLoadError");var N=Ve;async function Xn(e){let n=dr(e.configPath),o=await lr(n,"utf8");for(let l of fr)if(l.test(o))throw new N(`apollion.config: dynamic require/import not allowed (matched ${l}). Declarative config only \u2014 see ADR-006 \xA73.8 B3.`,n);let r=o.replace(/(^|\n)\s*export\s+default\s+/,(l,f)=>`${f}__apollion_config_export = `);if(r===o)throw new N("apollion.config: missing `export default <object>;` \u2014 config must export a default object literal.",n);let t={__apollion_config_export:void 0,console:gr(),Symbol,Number,String,Boolean,Array,Object,JSON,Math,defineConfig:i(l=>l,"defineConfig")},s=ur(t);try{new pr(r,{filename:n}).runInContext(s,{timeout:mr})}catch(l){throw new N(`apollion.config: evaluation failed \u2014 ${l instanceof Error?l.message:String(l)}`,n)}let a=t.__apollion_config_export;if(a===void 0)throw new N("apollion.config: `export default` produced undefined.",n);let c=Kn.safeParse(a);if(!c.success){let l=c.error.issues.map(f=>` ${f.path.join(".")||"(root)"}: ${f.message}`).join(`
14
+ `);throw new N(`apollion.config: schema validation failed \u2014
15
+ ${l}`,n)}return c.data}i(Xn,"loadConfig");function gr(){return{log:i((...e)=>console.log("[apollion.config]",...e),"log"),warn:i((...e)=>console.warn("[apollion.config]",...e),"warn"),error:i((...e)=>console.error("[apollion.config]",...e),"error")}}i(gr,"makeReadOnlyConsole");function yr(e){let n=e.slice(2),o=n[0];o!=="build"&&ue(`Unknown command "${o??""}". Usage: apollion-tokens build [--check] [--verbose] --config <path> [--out <dir>]`);let r="apollion.config.mjs",t="dist",s=!1,a=!1;for(let c=1;c<n.length;c++){let l=n[c];switch(l){case"--config":r=n[++c]??ue("--config needs a path");break;case"--out":t=n[++c]??ue("--out needs a path");break;case"--check":s=!0;break;case"--verbose":a=!0;break;default:ue(`Unknown flag "${l}"`)}}return{command:o,configPath:r,outDir:t,check:s,verbose:a}}i(yr,"parseArgs");function ue(e){console.error(`apollion-tokens: ${e}`),process.exit(2)}i(ue,"fail");async function br(e){let n=Le(e);if(n.endsWith(".json")){let o=await hr(n,"utf8");return JSON.parse(o)}return Xn({configPath:n})}i(br,"loadConfigFromPath");async function kr(){let e=yr(process.argv),n=await br(e.configPath);if(e.check){await Un({config:n,outDir:Le(e.outDir)})||(console.error("apollion-tokens: dist/ is stale, missing, or has drifted from its manifest. Re-run `apollion-tokens build` without --check."),process.exit(1)),console.log("apollion-tokens: dist/ is up-to-date with config.");return}let{manifest:o}=await qn({config:n,outDir:Le(e.outDir),verbose:e.verbose});console.log(`apollion-tokens: wrote ${o.files.length} file(s) \u2014 configHash=${o.configHash.slice(0,12)}\u2026`)}i(kr,"main");kr().catch(e=>{console.error(`apollion-tokens: ${e instanceof Error?e.message:String(e)}`),process.exit(1)});
@@ -1,3 +1,3 @@
1
- "use strict";var f=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var a=(n,t)=>f(n,"name",{value:t,configurable:!0});var k=(n,t)=>{for(var r in t)f(n,r,{get:t[r],enumerable:!0})},j=(n,t,r,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of C(t))!_.call(n,s)&&s!==r&&f(n,s,{get:()=>t[s],enumerable:!(p=y(t,s))||p.enumerable});return n};var A=n=>j(f({},"__esModule",{value:!0}),n);var v={};k(v,{ConfigLoadError:()=>l,defineConfig:()=>P,loadConfig:()=>D});module.exports=A(v);var b=require("node:fs/promises"),w=require("node:path"),g=require("node:vm");var o=require("zod"),i=o.z.string().regex(/^#([0-9a-fA-F]{3}){1,2}$|^transparent$|^rgb\(.*\)$|^oklch\(.*\)$/,{message:'Must be hex, rgb(), oklch(), or "transparent"'}),S=o.z.object({baseDark:o.z.string().optional(),baseLight:o.z.string().optional(),deepDark:i,deepLight:i,transparent:o.z.string().optional(),main:i.optional(),opposite:i.optional(),complementary:i.optional(),information:i.optional(),success:i.optional(),danger:i.optional(),warning:i.optional(),primary:i.optional(),secondary:i.optional(),tertiary:i.optional()}).passthrough(),h=o.z.object({brands:o.z.record(o.z.string(),S).refine(n=>Object.keys(n).length>0,{message:"apollion.config.mjs: brands must contain at least 1 entry"}),modes:o.z.array(o.z.enum(["light","dark"])).optional(),surfaces:o.z.array(o.z.enum(["positive","negative"])).optional(),dimensions:o.z.array(o.z.enum(["compact","normal","spacious"])).optional(),output:o.z.object({runtime:o.z.boolean().optional(),css:o.z.boolean().optional(),json:o.z.boolean().optional(),ts:o.z.boolean().optional(),designMd:o.z.boolean().optional(),tailwind:o.z.boolean().optional()}).passthrough().optional()}).passthrough();var $=[/\brequire\s*\(/,/\bimport\s*\(/,/^\s*import\s+/m],O=1e3;function P(n){return n}a(P,"defineConfig");var u=class u extends Error{constructor(r,p){super(r);this.configPath=p;this.name="ConfigLoadError"}};a(u,"ConfigLoadError");var l=u;async function D(n){let t=(0,w.resolve)(n.configPath),r=await(0,b.readFile)(t,"utf8");for(let e of $)if(e.test(r))throw new l(`apollion.config: dynamic require/import not allowed (matched ${e}). Declarative config only \u2014 see ADR-006 \xA73.8 B3.`,t);let p=r.replace(/(^|\n)\s*export\s+default\s+/,(e,c)=>`${c}__apollion_config_export = `);if(p===r)throw new l("apollion.config: missing `export default <object>;` \u2014 config must export a default object literal.",t);let s={__apollion_config_export:void 0,console:T(),Symbol,Number,String,Boolean,Array,Object,JSON,Math,defineConfig:a(e=>e,"defineConfig")},x=(0,g.createContext)(s);try{new g.Script(p,{filename:t}).runInContext(x,{timeout:O})}catch(e){throw new l(`apollion.config: evaluation failed \u2014 ${e instanceof Error?e.message:String(e)}`,t)}let d=s.__apollion_config_export;if(d===void 0)throw new l("apollion.config: `export default` produced undefined.",t);let m=h.safeParse(d);if(!m.success){let e=m.error.issues.map(c=>` ${c.path.join(".")||"(root)"}: ${c.message}`).join(`
1
+ "use strict";var f=Object.defineProperty;var y=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var a=(n,t)=>f(n,"name",{value:t,configurable:!0});var k=(n,t)=>{for(var r in t)f(n,r,{get:t[r],enumerable:!0})},j=(n,t,r,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of C(t))!_.call(n,s)&&s!==r&&f(n,s,{get:()=>t[s],enumerable:!(p=y(t,s))||p.enumerable});return n};var A=n=>j(f({},"__esModule",{value:!0}),n);var v={};k(v,{ConfigLoadError:()=>l,defineConfig:()=>P,loadConfig:()=>D});module.exports=A(v);var b=require("node:fs/promises"),w=require("node:path"),g=require("node:vm");var o=require("zod"),i=o.z.string().regex(/^#([0-9a-fA-F]{3}){1,2}$|^transparent$|^rgb\(.*\)$|^oklch\(.*\)$/,{message:'Must be hex, rgb(), oklch(), or "transparent"'}),S=o.z.object({baseDark:o.z.string().optional(),baseLight:o.z.string().optional(),deepDark:i,deepLight:i,transparent:o.z.string().optional(),main:i.optional(),opposite:i.optional(),complementary:i.optional(),information:i.optional(),success:i.optional(),danger:i.optional(),warning:i.optional(),primary:i.optional(),secondary:i.optional(),tertiary:i.optional()}).passthrough(),h=o.z.object({brands:o.z.record(o.z.string(),S).refine(n=>Object.keys(n).length>0,{message:"apollion.config.mjs: brands must contain at least 1 entry"}),modes:o.z.array(o.z.enum(["light","dark"])).optional(),surfaces:o.z.array(o.z.enum(["positive","negative"])).optional(),dimensions:o.z.array(o.z.enum(["compact","normal","spacious"])).optional(),output:o.z.object({runtime:o.z.boolean().optional(),css:o.z.boolean().optional(),json:o.z.boolean().optional(),ts:o.z.boolean().optional(),designMd:o.z.boolean().optional(),tailwind:o.z.boolean().optional(),cssModes:o.z.boolean().optional()}).passthrough().optional()}).passthrough();var $=[/\brequire\s*\(/,/\bimport\s*\(/,/^\s*import\s+/m],O=1e3;function P(n){return n}a(P,"defineConfig");var u=class u extends Error{constructor(r,p){super(r);this.configPath=p;this.name="ConfigLoadError"}};a(u,"ConfigLoadError");var l=u;async function D(n){let t=(0,w.resolve)(n.configPath),r=await(0,b.readFile)(t,"utf8");for(let e of $)if(e.test(r))throw new l(`apollion.config: dynamic require/import not allowed (matched ${e}). Declarative config only \u2014 see ADR-006 \xA73.8 B3.`,t);let p=r.replace(/(^|\n)\s*export\s+default\s+/,(e,c)=>`${c}__apollion_config_export = `);if(p===r)throw new l("apollion.config: missing `export default <object>;` \u2014 config must export a default object literal.",t);let s={__apollion_config_export:void 0,console:T(),Symbol,Number,String,Boolean,Array,Object,JSON,Math,defineConfig:a(e=>e,"defineConfig")},x=(0,g.createContext)(s);try{new g.Script(p,{filename:t}).runInContext(x,{timeout:O})}catch(e){throw new l(`apollion.config: evaluation failed \u2014 ${e instanceof Error?e.message:String(e)}`,t)}let d=s.__apollion_config_export;if(d===void 0)throw new l("apollion.config: `export default` produced undefined.",t);let m=h.safeParse(d);if(!m.success){let e=m.error.issues.map(c=>` ${c.path.join(".")||"(root)"}: ${c.message}`).join(`
2
2
  `);throw new l(`apollion.config: schema validation failed \u2014
3
3
  ${e}`,t)}return m.data}a(D,"loadConfig");function T(){return{log:a((...n)=>console.log("[apollion.config]",...n),"log"),warn:a((...n)=>console.warn("[apollion.config]",...n),"warn"),error:a((...n)=>console.error("[apollion.config]",...n),"error")}}a(T,"makeReadOnlyConsole");0&&(module.exports={ConfigLoadError,defineConfig,loadConfig});
@@ -1,3 +1,3 @@
1
- var h=Object.defineProperty;var r=(n,i)=>h(n,"name",{value:i,configurable:!0});import{readFile as w}from"node:fs/promises";import{resolve as x}from"node:path";import{createContext as y,Script as C}from"node:vm";import{z as o}from"zod";var e=o.string().regex(/^#([0-9a-fA-F]{3}){1,2}$|^transparent$|^rgb\(.*\)$|^oklch\(.*\)$/,{message:'Must be hex, rgb(), oklch(), or "transparent"'}),b=o.object({baseDark:o.string().optional(),baseLight:o.string().optional(),deepDark:e,deepLight:e,transparent:o.string().optional(),main:e.optional(),opposite:e.optional(),complementary:e.optional(),information:e.optional(),success:e.optional(),danger:e.optional(),warning:e.optional(),primary:e.optional(),secondary:e.optional(),tertiary:e.optional()}).passthrough(),u=o.object({brands:o.record(o.string(),b).refine(n=>Object.keys(n).length>0,{message:"apollion.config.mjs: brands must contain at least 1 entry"}),modes:o.array(o.enum(["light","dark"])).optional(),surfaces:o.array(o.enum(["positive","negative"])).optional(),dimensions:o.array(o.enum(["compact","normal","spacious"])).optional(),output:o.object({runtime:o.boolean().optional(),css:o.boolean().optional(),json:o.boolean().optional(),ts:o.boolean().optional(),designMd:o.boolean().optional(),tailwind:o.boolean().optional()}).passthrough().optional()}).passthrough();var _=[/\brequire\s*\(/,/\bimport\s*\(/,/^\s*import\s+/m],k=1e3;function v(n){return n}r(v,"defineConfig");var f=class f extends Error{constructor(s,p){super(s);this.configPath=p;this.name="ConfigLoadError"}};r(f,"ConfigLoadError");var a=f;async function I(n){let i=x(n.configPath),s=await w(i,"utf8");for(let t of _)if(t.test(s))throw new a(`apollion.config: dynamic require/import not allowed (matched ${t}). Declarative config only \u2014 see ADR-006 \xA73.8 B3.`,i);let p=s.replace(/(^|\n)\s*export\s+default\s+/,(t,l)=>`${l}__apollion_config_export = `);if(p===s)throw new a("apollion.config: missing `export default <object>;` \u2014 config must export a default object literal.",i);let g={__apollion_config_export:void 0,console:j(),Symbol,Number,String,Boolean,Array,Object,JSON,Math,defineConfig:r(t=>t,"defineConfig")},d=y(g);try{new C(p,{filename:i}).runInContext(d,{timeout:k})}catch(t){throw new a(`apollion.config: evaluation failed \u2014 ${t instanceof Error?t.message:String(t)}`,i)}let m=g.__apollion_config_export;if(m===void 0)throw new a("apollion.config: `export default` produced undefined.",i);let c=u.safeParse(m);if(!c.success){let t=c.error.issues.map(l=>` ${l.path.join(".")||"(root)"}: ${l.message}`).join(`
1
+ var h=Object.defineProperty;var r=(n,i)=>h(n,"name",{value:i,configurable:!0});import{readFile as w}from"node:fs/promises";import{resolve as x}from"node:path";import{createContext as y,Script as C}from"node:vm";import{z as o}from"zod";var e=o.string().regex(/^#([0-9a-fA-F]{3}){1,2}$|^transparent$|^rgb\(.*\)$|^oklch\(.*\)$/,{message:'Must be hex, rgb(), oklch(), or "transparent"'}),b=o.object({baseDark:o.string().optional(),baseLight:o.string().optional(),deepDark:e,deepLight:e,transparent:o.string().optional(),main:e.optional(),opposite:e.optional(),complementary:e.optional(),information:e.optional(),success:e.optional(),danger:e.optional(),warning:e.optional(),primary:e.optional(),secondary:e.optional(),tertiary:e.optional()}).passthrough(),u=o.object({brands:o.record(o.string(),b).refine(n=>Object.keys(n).length>0,{message:"apollion.config.mjs: brands must contain at least 1 entry"}),modes:o.array(o.enum(["light","dark"])).optional(),surfaces:o.array(o.enum(["positive","negative"])).optional(),dimensions:o.array(o.enum(["compact","normal","spacious"])).optional(),output:o.object({runtime:o.boolean().optional(),css:o.boolean().optional(),json:o.boolean().optional(),ts:o.boolean().optional(),designMd:o.boolean().optional(),tailwind:o.boolean().optional(),cssModes:o.boolean().optional()}).passthrough().optional()}).passthrough();var _=[/\brequire\s*\(/,/\bimport\s*\(/,/^\s*import\s+/m],k=1e3;function v(n){return n}r(v,"defineConfig");var f=class f extends Error{constructor(s,p){super(s);this.configPath=p;this.name="ConfigLoadError"}};r(f,"ConfigLoadError");var a=f;async function M(n){let i=x(n.configPath),s=await w(i,"utf8");for(let t of _)if(t.test(s))throw new a(`apollion.config: dynamic require/import not allowed (matched ${t}). Declarative config only \u2014 see ADR-006 \xA73.8 B3.`,i);let p=s.replace(/(^|\n)\s*export\s+default\s+/,(t,l)=>`${l}__apollion_config_export = `);if(p===s)throw new a("apollion.config: missing `export default <object>;` \u2014 config must export a default object literal.",i);let g={__apollion_config_export:void 0,console:j(),Symbol,Number,String,Boolean,Array,Object,JSON,Math,defineConfig:r(t=>t,"defineConfig")},d=y(g);try{new C(p,{filename:i}).runInContext(d,{timeout:k})}catch(t){throw new a(`apollion.config: evaluation failed \u2014 ${t instanceof Error?t.message:String(t)}`,i)}let m=g.__apollion_config_export;if(m===void 0)throw new a("apollion.config: `export default` produced undefined.",i);let c=u.safeParse(m);if(!c.success){let t=c.error.issues.map(l=>` ${l.path.join(".")||"(root)"}: ${l.message}`).join(`
2
2
  `);throw new a(`apollion.config: schema validation failed \u2014
3
- ${t}`,i)}return c.data}r(I,"loadConfig");function j(){return{log:r((...n)=>console.log("[apollion.config]",...n),"log"),warn:r((...n)=>console.warn("[apollion.config]",...n),"warn"),error:r((...n)=>console.error("[apollion.config]",...n),"error")}}r(j,"makeReadOnlyConsole");export{a as ConfigLoadError,v as defineConfig,I as loadConfig};
3
+ ${t}`,i)}return c.data}r(M,"loadConfig");function j(){return{log:r((...n)=>console.log("[apollion.config]",...n),"log"),warn:r((...n)=>console.warn("[apollion.config]",...n),"warn"),error:r((...n)=>console.error("[apollion.config]",...n),"error")}}r(j,"makeReadOnlyConsole");export{a as ConfigLoadError,v as defineConfig,M as loadConfig};
@@ -1 +1 @@
1
- "use strict";var t=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var c=(o,n)=>t(o,"name",{value:n,configurable:!0});var g=(o,n)=>{for(var s in n)t(o,s,{get:n[s],enumerable:!0})},D=(o,n,s,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of f(n))!b.call(o,e)&&e!==s&&t(o,e,{get:()=>n[e],enumerable:!(r=u(n,e))||r.enumerable});return o};var S=o=>D(t({},"__esModule",{value:!0}),o);var M={};g(M,{expandVariants:()=>C,variantName:()=>E});module.exports=S(M);var x=["light","dark"],A=["positive","negative"],y=["compact","normal","spacious"];function C(o){let n=o.modes??x,s=o.surfaces??A,r=o.dimensions??y,e=Object.entries(o.brands).sort(([i],[a])=>i.localeCompare(a)),d=[];for(let[i,a]of e)for(let l of n)for(let p of s)for(let m of r)d.push({brand:i,colors:a,mode:l,surface:p,dimension:m});return d}c(C,"expandVariants");function E(o){return`${o.brand}.${o.mode}.${o.surface}.${o.dimension}`}c(E,"variantName");0&&(module.exports={expandVariants,variantName});
1
+ "use strict";var t=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var c=(o,n)=>t(o,"name",{value:n,configurable:!0});var g=(o,n)=>{for(var s in n)t(o,s,{get:n[s],enumerable:!0})},D=(o,n,s,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of f(n))!b.call(o,e)&&e!==s&&t(o,e,{get:()=>n[e],enumerable:!(r=u(n,e))||r.enumerable});return o};var S=o=>D(t({},"__esModule",{value:!0}),o);var E={};g(E,{expandVariants:()=>y,variantName:()=>C});module.exports=S(E);var x=["light","dark"],A=["positive","negative"],M=["compact","normal","spacious"];function y(o){let n=o.modes??x,s=o.surfaces??A,r=o.dimensions??M,e=Object.entries(o.brands).sort(([i],[a])=>i.localeCompare(a)),d=[];for(let[i,a]of e)for(let l of n)for(let p of s)for(let m of r)d.push({brand:i,colors:a,mode:l,surface:p,dimension:m});return d}c(y,"expandVariants");function C(o){return`${o.brand}.${o.mode}.${o.surface}.${o.dimension}`}c(C,"variantName");0&&(module.exports={expandVariants,variantName});
@@ -1 +1 @@
1
- "use strict";var g=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var l=(e,t)=>g(e,"name",{value:t,configurable:!0});var R=(e,t)=>{for(var r in t)g(e,r,{get:t[r],enumerable:!0})},F=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of E(t))!D.call(e,n)&&n!==r&&g(e,n,{get:()=>t[n],enumerable:!(o=P(t,n))||o.enumerable});return e};var G=e=>F(g({},"__esModule",{value:!0}),e);var V={};R(V,{TOKENS_RUNTIME_API_VERSION:()=>U,createFoundation:()=>C.createFoundation,createSpacing:()=>O,getOppositeColor:()=>A,invertForSurface:()=>S.invertForSurface,mountGreyscaleColors:()=>N,mountNeutralColors:()=>M,mountSingleColor:()=>v});module.exports=G(V);var a=require("culori");var h=(0,a.converter)("oklch");function i(e,t,r){let o=(0,a.parse)(e),n=(0,a.parse)(t);if(!o||!n)return e;let c=(0,a.interpolate)([o,n],"oklch");return(0,a.formatHex)(c(r))??e}l(i,"mixOklch");function L(e){return e?typeof e=="string"?e:e.base:"#000"}l(L,"coerceToHex");function A(e){let t=L(e),r=h((0,a.parse)(t));if(!r)return t;let o={...r,h:((r.h??0)+180)%360};return(0,a.formatHex)(o)??t}l(A,"getOppositeColor");var d=1.3,j=.05,T=.04,f=l((e,t)=>{let r=(0,a.parse)(e),o=(0,a.parse)(t);return!r||!o?1:(0,a.wcagContrast)(r,o)},"contrastRatio"),y=l(e=>{let t=h((0,a.parse)(e));return t?t.l??0:null},"oklchLightness"),B=4.5;function x(e,t,r=B){let o=(0,a.parse)(t),n=h((0,a.parse)(e));if(!o||!n)return e;let c=f("#fff",t)>=f("#000",t)?.04:-.04;for(let s=0;s<25;s+=1){let u=(0,a.formatHex)(n)??e,p=(0,a.parse)(u);if(p&&(0,a.wcagContrast)(p,o)>=r)return u;let m=Math.min(1,Math.max(0,(n.l??0)+c));if(m===(n.l??0))break;n={...n,l:m}}return(0,a.formatHex)(n)??e}l(x,"readableColor");var I=l((e,t)=>{if(f(e,t)>=d)return!0;let r=y(e),o=y(t);return r!==null&&o!==null&&Math.abs(r-o)>=j},"isPerceptibleState"),H=l(e=>e?f("#fff",e)>f("#000",e):!1,"isDarkSurface");function b(e,t,r){let o=h((0,a.parse)(e));if(!o)return null;let n={...o,l:r??o.l??0},c=t?T:-T;for(let s=0;s<25;s+=1){let u=Math.min(1,Math.max(0,(n.l??0)+c));if(u===(n.l??0))break;n={...n,l:u};let p=(0,a.formatHex)(n);if(p&&f(e,p)>=d)return p}return(0,a.formatHex)(n)??null}l(b,"derivePerceptibleState");function k(e,t,r){let o=b(e,t,r);if(o&&f(e,o)>=d)return o;let n=b(e,!t);return n&&f(e,n)>=d?n:o??n}l(k,"perceptibleStateFor");function v(e,t){let r=typeof e=="object"&&e!==null?e:void 0,o=L(e),n=t.deepDark,c=t.deepLight,s={base:o,dark:i(o,n,.6),action:i(o,n,.2),active:i(o,c,.6),light:i(o,c,.9),onLight:o};if((0,a.parse)(o)){let u=H(t.baseLight),p=I(o,s.action);if(p||(s.action=k(o,u)??s.action),!I(o,s.active)){let m=p?void 0:y(s.action)??void 0;s.active=k(o,u,m)??s.active}}if(s.onLight=x(s.action,s.light),r){let u=r.action??s.action,p=r.light??s.light;return{base:o,dark:r.dark??s.dark,action:u,active:r.active??s.active,light:p,onLight:r.onLight??x(u,p)}}return s}l(v,"mountSingleColor");function N(e){let t=e.deepLight,r=e.deepDark;return{0:t,5:i(t,r,.05),10:i(t,r,.1),20:i(t,r,.2),30:i(t,r,.3),40:i(t,r,.4),50:i(t,r,.5),60:i(t,r,.6),70:i(t,r,.7),80:i(t,r,.8),90:i(t,r,.9),100:i(t,r,1)}}l(N,"mountGreyscaleColors");function M(e){let t=e.deepLight,r=e.deepDark,o=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,n=l(s=>1/17*(s-1),"interpolation"),c=i(o,r,.5);return{0:i(c,t,n(18)),5:i(c,t,n(17.5)),10:i(c,t,n(17)),20:i(c,t,n(16)),30:i(c,t,n(15)),40:i(c,t,n(14)),50:i(c,t,n(13)),60:i(c,t,n(12)),70:i(c,t,n(11)),80:i(c,t,n(10)),90:i(c,t,n(9)),100:i(c,t,n(8)),110:i(c,t,n(7)),120:i(c,t,n(6)),130:i(c,t,n(5)),140:i(c,t,n(4)),150:i(c,t,n(3)),160:i(c,t,n(2)),170:c,180:i(c,r,.25)}}l(M,"mountNeutralColors");var _=require("@apollion-dsi/core/themes/dimension");function O({multiplier:e=.25,alias:t},r){let o=r!==void 0?_.DIMENSION_MULTIPLIERS[r]:e;return(...n)=>n.map(c=>{let s=typeof c=="string"?t[c]:c;return`${o*s}rem`}).join(" ")}l(O,"createSpacing");var C=require("@apollion-dsi/core/themes/foundation");var S=require("@apollion-dsi/core/themes/surface");var U="v1";0&&(module.exports={TOKENS_RUNTIME_API_VERSION,createFoundation,createSpacing,getOppositeColor,invertForSurface,mountGreyscaleColors,mountNeutralColors,mountSingleColor});
1
+ "use strict";var g=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var l=(e,t)=>g(e,"name",{value:t,configurable:!0});var D=(e,t)=>{for(var r in t)g(e,r,{get:t[r],enumerable:!0})},F=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of E(t))!R.call(e,n)&&n!==r&&g(e,n,{get:()=>t[n],enumerable:!(o=P(t,n))||o.enumerable});return e};var $=e=>F(g({},"__esModule",{value:!0}),e);var U={};D(U,{TOKENS_RUNTIME_API_VERSION:()=>H,createFoundation:()=>b.createFoundation,createSpacing:()=>O,getOppositeColor:()=>M,invertForSurface:()=>y.invertForSurface,mountGreyscaleColors:()=>v,mountNeutralColors:()=>N,mountSingleColor:()=>A});module.exports=$(U);var c=require("culori");var d=(0,c.converter)("oklch"),w=(0,c.converter)("rgb");function i(e,t,r){let o=(0,c.parse)(e),n=(0,c.parse)(t);if(!o||!n)return e;let a=(0,c.interpolate)([o,n],"oklch");return(0,c.formatHex)(a(r))??e}l(i,"mixOklch");function L(e){return e?typeof e=="string"?e:e.base:"#000"}l(L,"coerceToHex");function M(e){let t=L(e),r=d((0,c.parse)(t));if(!r)return t;let o={...r,h:((r.h??0)+180)%360};return(0,c.formatHex)(o)??t}l(M,"getOppositeColor");var h=1.3,G=.05,C=.04,f=l((e,t)=>{let r=(0,c.parse)(e),o=(0,c.parse)(t);return!r||!o?1:(0,c.wcagContrast)(r,o)},"contrastRatio"),x=l(e=>{let t=d((0,c.parse)(e));return t?t.l??0:null},"oklchLightness"),j=4.5;function S(e,t,r=j){let o=(0,c.parse)(t),n=d((0,c.parse)(e));if(!o||!n)return e;let a=f("#fff",t)>=f("#000",t)?.04:-.04;for(let s=0;s<25;s+=1){let u=(0,c.formatHex)(n)??e,p=(0,c.parse)(u);if(p&&(0,c.wcagContrast)(p,o)>=r)return u;let m=Math.min(1,Math.max(0,(n.l??0)+a));if(m===(n.l??0))break;n={...n,l:m}}return(0,c.formatHex)(n)??e}l(S,"readableColor");var T=l((e,t)=>{if(f(e,t)>=h)return!0;let r=x(e),o=x(t);return r!==null&&o!==null&&Math.abs(r-o)>=G},"isPerceptibleState"),B=l(e=>e?f("#fff",e)>f("#000",e):!1,"isDarkSurface");function I(e,t,r){let o=d((0,c.parse)(e));if(!o)return null;let n={...o,l:r??o.l??0},a=t?C:-C;for(let s=0;s<25;s+=1){let u=Math.min(1,Math.max(0,(n.l??0)+a));if(u===(n.l??0))break;n={...n,l:u};let p=(0,c.formatHex)(n);if(p&&f(e,p)>=h)return p}return(0,c.formatHex)(n)??null}l(I,"derivePerceptibleState");function k(e,t,r){let o=I(e,t,r);if(o&&f(e,o)>=h)return o;let n=I(e,!t);return n&&f(e,n)>=h?n:o??n}l(k,"perceptibleStateFor");function A(e,t){let r=typeof e=="object"&&e!==null?e:void 0,o=L(e),n=t.deepDark,a=t.deepLight,s={base:o,dark:i(o,n,.6),action:i(o,n,.2),active:i(o,a,.6),light:i(o,a,.9),onLight:o};if((0,c.parse)(o)){let u=B(t.baseLight),p=T(o,s.action);if(p||(s.action=k(o,u)??s.action),!T(o,s.active)){let m=p?void 0:x(s.action)??void 0;s.active=k(o,u,m)??s.active}}if(s.onLight=S(s.action,s.light),r){let u=r.action??s.action,p=r.light??s.light;return{base:o,dark:r.dark??s.dark,action:u,active:r.active??s.active,light:p,onLight:r.onLight??S(u,p)}}return s}l(A,"mountSingleColor");function v(e){let t=e.deepLight,r=e.deepDark;return{0:t,5:i(t,r,.05),10:i(t,r,.1),20:i(t,r,.2),30:i(t,r,.3),40:i(t,r,.4),50:i(t,r,.5),60:i(t,r,.6),70:i(t,r,.7),80:i(t,r,.8),90:i(t,r,.9),100:i(t,r,1)}}l(v,"mountGreyscaleColors");function N(e){let t=e.deepLight,r=e.deepDark,o=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,n=l(s=>1/17*(s-1),"interpolation"),a=i(o,r,.5);return{0:i(a,t,n(18)),5:i(a,t,n(17.5)),10:i(a,t,n(17)),20:i(a,t,n(16)),30:i(a,t,n(15)),40:i(a,t,n(14)),50:i(a,t,n(13)),60:i(a,t,n(12)),70:i(a,t,n(11)),80:i(a,t,n(10)),90:i(a,t,n(9)),100:i(a,t,n(8)),110:i(a,t,n(7)),120:i(a,t,n(6)),130:i(a,t,n(5)),140:i(a,t,n(4)),150:i(a,t,n(3)),160:i(a,t,n(2)),170:a,180:i(a,r,.25)}}l(N,"mountNeutralColors");var _=require("@apollion-dsi/core/themes/dimension");function O({multiplier:e=.25,alias:t},r){let o=r!==void 0?_.DIMENSION_MULTIPLIERS[r]:e;return(...n)=>n.map(a=>{let s=typeof a=="string"?t[a]:a;return`${o*s}rem`}).join(" ")}l(O,"createSpacing");var b=require("@apollion-dsi/core/themes/foundation");var y=require("@apollion-dsi/core/themes/surface");var H="v1";0&&(module.exports={TOKENS_RUNTIME_API_VERSION,createFoundation,createSpacing,getOppositeColor,invertForSurface,mountGreyscaleColors,mountNeutralColors,mountSingleColor});
@@ -1 +1 @@
1
- var L=Object.defineProperty;var s=(e,t)=>L(e,"name",{value:t,configurable:!0});import{converter as A,formatHex as m,interpolate as v,parse as u,wcagContrast as b}from"culori";var h=A("oklch");function i(e,t,r){let o=u(e),n=u(t);if(!o||!n)return e;let c=v([o,n],"oklch");return m(c(r))??e}s(i,"mixOklch");function k(e){return e?typeof e=="string"?e:e.base:"#000"}s(k,"coerceToHex");function N(e){let t=k(e),r=h(u(t));if(!r)return t;let o={...r,h:((r.h??0)+180)%360};return m(o)??t}s(N,"getOppositeColor");var d=1.3,M=.05,C=.04,f=s((e,t)=>{let r=u(e),o=u(t);return!r||!o?1:b(r,o)},"contrastRatio"),y=s(e=>{let t=h(u(e));return t?t.l??0:null},"oklchLightness"),_=4.5;function S(e,t,r=_){let o=u(t),n=h(u(e));if(!o||!n)return e;let c=f("#fff",t)>=f("#000",t)?.04:-.04;for(let a=0;a<25;a+=1){let p=m(n)??e,l=u(p);if(l&&b(l,o)>=r)return p;let g=Math.min(1,Math.max(0,(n.l??0)+c));if(g===(n.l??0))break;n={...n,l:g}}return m(n)??e}s(S,"readableColor");var T=s((e,t)=>{if(f(e,t)>=d)return!0;let r=y(e),o=y(t);return r!==null&&o!==null&&Math.abs(r-o)>=M},"isPerceptibleState"),O=s(e=>e?f("#fff",e)>f("#000",e):!1,"isDarkSurface");function x(e,t,r){let o=h(u(e));if(!o)return null;let n={...o,l:r??o.l??0},c=t?C:-C;for(let a=0;a<25;a+=1){let p=Math.min(1,Math.max(0,(n.l??0)+c));if(p===(n.l??0))break;n={...n,l:p};let l=m(n);if(l&&f(e,l)>=d)return l}return m(n)??null}s(x,"derivePerceptibleState");function I(e,t,r){let o=x(e,t,r);if(o&&f(e,o)>=d)return o;let n=x(e,!t);return n&&f(e,n)>=d?n:o??n}s(I,"perceptibleStateFor");function P(e,t){let r=typeof e=="object"&&e!==null?e:void 0,o=k(e),n=t.deepDark,c=t.deepLight,a={base:o,dark:i(o,n,.6),action:i(o,n,.2),active:i(o,c,.6),light:i(o,c,.9),onLight:o};if(u(o)){let p=O(t.baseLight),l=T(o,a.action);if(l||(a.action=I(o,p)??a.action),!T(o,a.active)){let g=l?void 0:y(a.action)??void 0;a.active=I(o,p,g)??a.active}}if(a.onLight=S(a.action,a.light),r){let p=r.action??a.action,l=r.light??a.light;return{base:o,dark:r.dark??a.dark,action:p,active:r.active??a.active,light:l,onLight:r.onLight??S(p,l)}}return a}s(P,"mountSingleColor");function E(e){let t=e.deepLight,r=e.deepDark;return{0:t,5:i(t,r,.05),10:i(t,r,.1),20:i(t,r,.2),30:i(t,r,.3),40:i(t,r,.4),50:i(t,r,.5),60:i(t,r,.6),70:i(t,r,.7),80:i(t,r,.8),90:i(t,r,.9),100:i(t,r,1)}}s(E,"mountGreyscaleColors");function D(e){let t=e.deepLight,r=e.deepDark,o=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,n=s(a=>1/17*(a-1),"interpolation"),c=i(o,r,.5);return{0:i(c,t,n(18)),5:i(c,t,n(17.5)),10:i(c,t,n(17)),20:i(c,t,n(16)),30:i(c,t,n(15)),40:i(c,t,n(14)),50:i(c,t,n(13)),60:i(c,t,n(12)),70:i(c,t,n(11)),80:i(c,t,n(10)),90:i(c,t,n(9)),100:i(c,t,n(8)),110:i(c,t,n(7)),120:i(c,t,n(6)),130:i(c,t,n(5)),140:i(c,t,n(4)),150:i(c,t,n(3)),160:i(c,t,n(2)),170:c,180:i(c,r,.25)}}s(D,"mountNeutralColors");import{DIMENSION_MULTIPLIERS as R}from"@apollion-dsi/core/themes/dimension";function F({multiplier:e=.25,alias:t},r){let o=r!==void 0?R[r]:e;return(...n)=>n.map(c=>{let a=typeof c=="string"?t[c]:c;return`${o*a}rem`}).join(" ")}s(F,"createSpacing");import{createFoundation as G}from"@apollion-dsi/core/themes/foundation";import{invertForSurface as j}from"@apollion-dsi/core/themes/surface";var W="v1";export{W as TOKENS_RUNTIME_API_VERSION,G as createFoundation,F as createSpacing,N as getOppositeColor,j as invertForSurface,E as mountGreyscaleColors,D as mountNeutralColors,P as mountSingleColor};
1
+ var M=Object.defineProperty;var s=(e,t)=>M(e,"name",{value:t,configurable:!0});import{converter as I,formatHex as m,interpolate as A,parse as u,wcagContrast as k}from"culori";var d=I("oklch"),H=I("rgb");function i(e,t,r){let o=u(e),n=u(t);if(!o||!n)return e;let a=A([o,n],"oklch");return m(a(r))??e}s(i,"mixOklch");function L(e){return e?typeof e=="string"?e:e.base:"#000"}s(L,"coerceToHex");function v(e){let t=L(e),r=d(u(t));if(!r)return t;let o={...r,h:((r.h??0)+180)%360};return m(o)??t}s(v,"getOppositeColor");var h=1.3,N=.05,b=.04,f=s((e,t)=>{let r=u(e),o=u(t);return!r||!o?1:k(r,o)},"contrastRatio"),x=s(e=>{let t=d(u(e));return t?t.l??0:null},"oklchLightness"),_=4.5;function y(e,t,r=_){let o=u(t),n=d(u(e));if(!o||!n)return e;let a=f("#fff",t)>=f("#000",t)?.04:-.04;for(let c=0;c<25;c+=1){let p=m(n)??e,l=u(p);if(l&&k(l,o)>=r)return p;let g=Math.min(1,Math.max(0,(n.l??0)+a));if(g===(n.l??0))break;n={...n,l:g}}return m(n)??e}s(y,"readableColor");var C=s((e,t)=>{if(f(e,t)>=h)return!0;let r=x(e),o=x(t);return r!==null&&o!==null&&Math.abs(r-o)>=N},"isPerceptibleState"),O=s(e=>e?f("#fff",e)>f("#000",e):!1,"isDarkSurface");function S(e,t,r){let o=d(u(e));if(!o)return null;let n={...o,l:r??o.l??0},a=t?b:-b;for(let c=0;c<25;c+=1){let p=Math.min(1,Math.max(0,(n.l??0)+a));if(p===(n.l??0))break;n={...n,l:p};let l=m(n);if(l&&f(e,l)>=h)return l}return m(n)??null}s(S,"derivePerceptibleState");function T(e,t,r){let o=S(e,t,r);if(o&&f(e,o)>=h)return o;let n=S(e,!t);return n&&f(e,n)>=h?n:o??n}s(T,"perceptibleStateFor");function P(e,t){let r=typeof e=="object"&&e!==null?e:void 0,o=L(e),n=t.deepDark,a=t.deepLight,c={base:o,dark:i(o,n,.6),action:i(o,n,.2),active:i(o,a,.6),light:i(o,a,.9),onLight:o};if(u(o)){let p=O(t.baseLight),l=C(o,c.action);if(l||(c.action=T(o,p)??c.action),!C(o,c.active)){let g=l?void 0:x(c.action)??void 0;c.active=T(o,p,g)??c.active}}if(c.onLight=y(c.action,c.light),r){let p=r.action??c.action,l=r.light??c.light;return{base:o,dark:r.dark??c.dark,action:p,active:r.active??c.active,light:l,onLight:r.onLight??y(p,l)}}return c}s(P,"mountSingleColor");function E(e){let t=e.deepLight,r=e.deepDark;return{0:t,5:i(t,r,.05),10:i(t,r,.1),20:i(t,r,.2),30:i(t,r,.3),40:i(t,r,.4),50:i(t,r,.5),60:i(t,r,.6),70:i(t,r,.7),80:i(t,r,.8),90:i(t,r,.9),100:i(t,r,1)}}s(E,"mountGreyscaleColors");function R(e){let t=e.deepLight,r=e.deepDark,o=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,n=s(c=>1/17*(c-1),"interpolation"),a=i(o,r,.5);return{0:i(a,t,n(18)),5:i(a,t,n(17.5)),10:i(a,t,n(17)),20:i(a,t,n(16)),30:i(a,t,n(15)),40:i(a,t,n(14)),50:i(a,t,n(13)),60:i(a,t,n(12)),70:i(a,t,n(11)),80:i(a,t,n(10)),90:i(a,t,n(9)),100:i(a,t,n(8)),110:i(a,t,n(7)),120:i(a,t,n(6)),130:i(a,t,n(5)),140:i(a,t,n(4)),150:i(a,t,n(3)),160:i(a,t,n(2)),170:a,180:i(a,r,.25)}}s(R,"mountNeutralColors");import{DIMENSION_MULTIPLIERS as D}from"@apollion-dsi/core/themes/dimension";function F({multiplier:e=.25,alias:t},r){let o=r!==void 0?D[r]:e;return(...n)=>n.map(a=>{let c=typeof a=="string"?t[a]:a;return`${o*c}rem`}).join(" ")}s(F,"createSpacing");import{createFoundation as $}from"@apollion-dsi/core/themes/foundation";import{invertForSurface as G}from"@apollion-dsi/core/themes/surface";var X="v1";export{X as TOKENS_RUNTIME_API_VERSION,$ as createFoundation,F as createSpacing,v as getOppositeColor,G as invertForSurface,E as mountGreyscaleColors,R as mountNeutralColors,P as mountSingleColor};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollion-dsi/tokens",
3
- "version": "5.6.0",
3
+ "version": "5.8.0",
4
4
  "description": "Apollion Design System — Framework-agnostic design tokens",
5
5
  "homepage": "https://www.apollion.com.br",
6
6
  "license": "MIT",
package/src/build.ts CHANGED
@@ -33,7 +33,7 @@ import { mkdir, mkdtemp, readFile, rename, rm, writeFile } from 'node:fs/promise
33
33
  import { tmpdir } from 'node:os';
34
34
  import { dirname, join } from 'node:path';
35
35
 
36
- import { renderCss } from './renderers/css';
36
+ import { renderCss, renderCssModes } from './renderers/css';
37
37
  import { renderDesignMd } from './renderers/design-md';
38
38
  import { renderBaseSet, renderColorSet, renderFontSet, renderResolver, renderSpacingSet } from './renderers/resolver';
39
39
  import { renderTailwindPreset, renderTwMergeExtension } from './renderers/tailwind';
@@ -137,6 +137,33 @@ export async function build(opts: BuildOptions): Promise<BuildResult> {
137
137
  }
138
138
  }
139
139
 
140
+ // ── Mode-scoped CSS (ADR-024): one file per (brand × surface × dimension)
141
+ // carrying both modes, scoped by the mode-engine attribute ─────────────────
142
+ if (output.cssModes) {
143
+ const pairs = new Map<string, { light?: Variant; dark?: Variant }>();
144
+ for (const variant of variants) {
145
+ const key = `${variant.brand}.${variant.surface}.${variant.dimension}`;
146
+ const entry = pairs.get(key) ?? {};
147
+ entry[variant.mode] = variant;
148
+ pairs.set(key, entry);
149
+ }
150
+ for (const [key, { light, dark }] of pairs) {
151
+ if (!light || !dark) {
152
+ throw new Error(`apollion-tokens build: output.cssModes needs both modes for ${key} (config.modes)`);
153
+ }
154
+ const l = buildVariantThemes(light);
155
+ const d = buildVariantThemes(dark);
156
+ const css = renderCssModes(
157
+ buildFullIR(l.foundation, l.colors, light),
158
+ buildFullIR(d.foundation, d.colors, dark),
159
+ {
160
+ rgbCompanions: output.tailwind,
161
+ },
162
+ );
163
+ await emit(`css/${key}.modes.css`, css);
164
+ }
165
+ }
166
+
140
167
  // ── Tailwind surface: preset + tw-merge extension (naming layer) ─────────
141
168
  // Token *topology* is variant-invariant (same groups/keys across the axes),
142
169
  // and every entry maps through `var(--apollion-*)` indirection — so one
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Breakpoints builder — **Strangler Fig duplicate** of
3
+ * `@apollion-dsi/core/themes/breakpoints` (APOLLION-BREAKPOINT-TOKENS).
4
+ *
5
+ * The viewport breakpoint scale is axis-invariant (same for every
6
+ * brand × mode × surface × dimension) and px-based by contract: ADR-011 fixed
7
+ * the root at 16px, which removes the classic rem-drift argument, and browser
8
+ * zoom scales px media queries correctly. The interval contract is half-open
9
+ * `[value, next)` — `min-width` sets, ascending.
10
+ *
11
+ * @see ./colors.ts (Strangler Fig contract notes)
12
+ */
13
+ import type { BreakpointInput } from '@apollion-dsi/core/themes/breakpoints';
14
+ import { defaultInputBreakpoints } from '@apollion-dsi/core/themes/breakpoints';
15
+
16
+ /**
17
+ * Resolved `[key, '<value>px']` pairs in ascending order, `xs: '0px'` included
18
+ * (the base band is part of the contract even though prefixless consumers —
19
+ * e.g. the Tailwind `screens` scale — omit it).
20
+ */
21
+ export function breakpointEntries(
22
+ input: BreakpointInput = defaultInputBreakpoints,
23
+ ): ReadonlyArray<readonly [string, string]> {
24
+ return Object.entries(input.values).map(([key, value]) => [key, `${value}px`] as const);
25
+ }
@@ -36,6 +36,7 @@ import type {
36
36
  import { converter, formatHex, interpolate, parse, wcagContrast } from 'culori';
37
37
 
38
38
  const toOklch = converter('oklch');
39
+ const toRgb = converter('rgb');
39
40
 
40
41
  /**
41
42
  * OKLch perceptual lerp wrapper. See core's S2 docs for rationale.
@@ -44,7 +45,7 @@ const toOklch = converter('oklch');
44
45
  * §11.5) confirmou 0 unexpected regressions em 68 deltas; greyscale ramp
45
46
  * 19× mais uniforme em OKLAB L space.
46
47
  */
47
- function mixOklch(a: string, b: string, t: number): string {
48
+ export function mixOklch(a: string, b: string, t: number): string {
48
49
  const colorA = parse(a);
49
50
  const colorB = parse(b);
50
51
  if (!colorA || !colorB) return a;
@@ -97,7 +98,7 @@ const MIN_CONTRAST_AA = 4.5;
97
98
  * (`Colors.helpers.ts`; parity.test.ts). Used to derive the tonal ink
98
99
  * `onLight` (APOLLION-CONTRAST-GUARANTEE).
99
100
  */
100
- function readableColor(color: string, background: string, minRatio = MIN_CONTRAST_AA): string {
101
+ export function readableColor(color: string, background: string, minRatio = MIN_CONTRAST_AA): string {
101
102
  const bgParsed = parse(background);
102
103
  let oklch = toOklch(parse(color));
103
104
  if (!bgParsed || !oklch) return color;
@@ -123,7 +124,7 @@ const isPerceptibleState = (base: string, candidate: string): boolean => {
123
124
  return baseL !== null && candidateL !== null && Math.abs(baseL - candidateL) >= STATE_DELTA_L_JND;
124
125
  };
125
126
 
126
- const isDarkSurface = (baseLight?: string): boolean => {
127
+ export const isDarkSurface = (baseLight?: string): boolean => {
127
128
  if (!baseLight) return false;
128
129
  return contrastRatio('#fff', baseLight) > contrastRatio('#000', baseLight);
129
130
  };
@@ -268,3 +269,33 @@ export function mountNeutralColors(colors: ColorsInput): Record<NeutralColorsTyp
268
269
  '180': mixOklch(n170, darker, 0.25),
269
270
  };
270
271
  }
272
+
273
+ /**
274
+ * Ladder primitives — Strangler Fig mirror of core's `shiftLightness` /
275
+ * `clampLightness` / `toRgbaString` (APOLLION-DARK-MODE-ENGINE S0). Byte parity
276
+ * enforced in `__tests__/parity.test.ts`.
277
+ */
278
+ export function shiftLightness(color: string, delta: number): string {
279
+ const oklch = toOklch(parse(color));
280
+ if (!oklch) return color;
281
+ const l = Math.min(1, Math.max(0, (oklch.l ?? 0) + delta));
282
+ return formatHex({ ...oklch, l }) ?? color;
283
+ }
284
+
285
+ export function clampLightness(color: string, range: { min?: number; max?: number }): string {
286
+ const oklch = toOklch(parse(color));
287
+ if (!oklch) return color;
288
+ const l = oklch.l ?? 0;
289
+ const min = range.min ?? 0;
290
+ const max = range.max ?? 1;
291
+ if (l >= min && l <= max) return color;
292
+ return formatHex({ ...oklch, l: Math.min(max, Math.max(min, l)) }) ?? color;
293
+ }
294
+
295
+ export function toRgbaString(color: string, alpha: number): string {
296
+ const rgb = toRgb(parse(color));
297
+ if (!rgb) return color;
298
+ const a = Math.min(1, Math.max(0, alpha));
299
+ const channel = (value?: number): number => Math.round((value ?? 0) * 255);
300
+ return `rgba(${channel(rgb.r)}, ${channel(rgb.g)}, ${channel(rgb.b)}, ${a})`;
301
+ }
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Surface ladder builder — **Strangler Fig duplicate** of
3
+ * `@apollion-dsi/core/themes/colors` `Colors.ladder.ts` (ADR-023,
4
+ * APOLLION-DARK-MODE-ENGINE). Same contract as `./colors.ts`: the derivation
5
+ * logic is duplicated (pure culori), the constants and the APCA math are
6
+ * imported from the stable core subpath (data, not logic), and parity is
7
+ * enforced in `__tests__/parity.test.ts` — drift = build fail.
8
+ *
9
+ * @see ./colors.ts (Strangler Fig contract notes)
10
+ * @see ../../../core/src/themes/Colors/Colors.ladder.ts (source of truth)
11
+ */
12
+ import type { LadderGroups, LadderInput, LadderOverride, Polarity } from '@apollion-dsi/core/themes/colors';
13
+ import {
14
+ apcaContrast,
15
+ EDGE_ALPHA,
16
+ HALATION_FLOORS,
17
+ INK_APCA_MIN,
18
+ INK_MIX,
19
+ LADDER_DELTAS,
20
+ MIN_CONTRAST_AA,
21
+ WASH_ALPHA,
22
+ } from '@apollion-dsi/core/themes/colors';
23
+
24
+ import { clampLightness, isDarkSurface, mixOklch, readableColor, shiftLightness, toRgbaString } from './colors';
25
+
26
+ const FALLBACK_LIGHT = '#FFFFFF';
27
+ const FALLBACK_DARK = '#000000';
28
+
29
+ export function resolvePolarity(colors: LadderInput): Polarity {
30
+ return isDarkSurface(colors.baseLight) ? 'dark' : 'light';
31
+ }
32
+
33
+ function ensureApca(ink: string, ground: string, minLc: number): string {
34
+ if (Math.abs(apcaContrast(ink, ground)) >= minLc) return ink;
35
+ const towardLight = Math.abs(apcaContrast('#ffffff', ground)) >= Math.abs(apcaContrast('#000000', ground));
36
+ let current = ink;
37
+ for (let i = 0; i < 40; i += 1) {
38
+ const next = shiftLightness(current, towardLight ? 0.02 : -0.02);
39
+ if (next === current) break;
40
+ current = next;
41
+ if (Math.abs(apcaContrast(current, ground)) >= minLc) break;
42
+ }
43
+ return current;
44
+ }
45
+
46
+ function deriveSurface(colors: LadderInput, polarity: Polarity): LadderGroups['surface'] {
47
+ const baseLight = colors.baseLight ?? FALLBACK_LIGHT;
48
+ const isDark = polarity === 'dark';
49
+ const canvas = isDark ? clampLightness(baseLight, { min: HALATION_FLOORS.CANVAS_MIN_L }) : baseLight;
50
+ const sunkenRaw = shiftLightness(canvas, LADDER_DELTAS.sunken);
51
+
52
+ return {
53
+ canvas,
54
+ sunken: isDark ? clampLightness(sunkenRaw, { min: HALATION_FLOORS.CANVAS_MIN_L }) : sunkenRaw,
55
+ paper: shiftLightness(canvas, LADDER_DELTAS.paper),
56
+ raised: shiftLightness(canvas, LADDER_DELTAS.raised),
57
+ overlay: shiftLightness(canvas, LADDER_DELTAS.overlay),
58
+ scrim: isDark ? (colors.deepLight ?? FALLBACK_DARK) : (colors.neutral?.['180'] ?? colors.baseDark ?? FALLBACK_DARK),
59
+ };
60
+ }
61
+
62
+ function deriveInk(colors: LadderInput, surface: LadderGroups['surface']): LadderGroups['ink'] {
63
+ const baseDark = colors.baseDark ?? FALLBACK_DARK;
64
+ const primary = clampLightness(
65
+ ensureApca(readableColor(baseDark, surface.paper, MIN_CONTRAST_AA), surface.paper, INK_APCA_MIN.primary),
66
+ { max: HALATION_FLOORS.INK_MAX_L },
67
+ );
68
+ const tier = (mix: number, minLc: number): string =>
69
+ ensureApca(
70
+ readableColor(mixOklch(primary, surface.canvas, mix), surface.paper, MIN_CONTRAST_AA),
71
+ surface.paper,
72
+ minLc,
73
+ );
74
+
75
+ return {
76
+ primary,
77
+ secondary: tier(INK_MIX.secondary, INK_APCA_MIN.secondary),
78
+ muted: tier(INK_MIX.muted, INK_APCA_MIN.muted),
79
+ disabled: mixOklch(primary, surface.canvas, INK_MIX.disabled),
80
+ };
81
+ }
82
+
83
+ function deriveEdge(ink: LadderGroups['ink']): LadderGroups['edge'] {
84
+ return {
85
+ hairline: toRgbaString(ink.primary, EDGE_ALPHA.hairline),
86
+ border: toRgbaString(ink.primary, EDGE_ALPHA.border),
87
+ strong: toRgbaString(ink.primary, EDGE_ALPHA.strong),
88
+ };
89
+ }
90
+
91
+ function deriveWash(ink: LadderGroups['ink'], polarity: Polarity): LadderGroups['wash'] {
92
+ const alpha = WASH_ALPHA[polarity];
93
+ return {
94
+ hover: toRgbaString(ink.primary, alpha.hover),
95
+ pressed: toRgbaString(ink.primary, alpha.pressed),
96
+ selected: toRgbaString(ink.primary, alpha.selected),
97
+ };
98
+ }
99
+
100
+ function applyOverride(groups: LadderGroups, override?: LadderOverride): LadderGroups {
101
+ if (!override) return groups;
102
+ return {
103
+ surface: { ...groups.surface, ...override.surface },
104
+ ink: { ...groups.ink, ...override.ink },
105
+ edge: { ...groups.edge, ...override.edge },
106
+ wash: { ...groups.wash, ...override.wash },
107
+ };
108
+ }
109
+
110
+ export function resolveSurfaceLadder(colors: LadderInput, override?: LadderInput['ladder']): LadderGroups {
111
+ const polarity = resolvePolarity(colors);
112
+ const surface = deriveSurface(colors, polarity);
113
+ const ink = deriveInk(colors, surface);
114
+ const derived: LadderGroups = { surface, ink, edge: deriveEdge(ink), wash: deriveWash(ink, polarity) };
115
+ return applyOverride(derived, override?.[polarity]);
116
+ }