@apollion-dsi/tokens 5.7.0 → 5.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -43
- package/lib/build.cjs +10 -10
- package/lib/build.esm.js +10 -10
- package/lib/cli.mjs +11 -11
- package/package.json +1 -1
- package/src/builders/breakpoints.ts +25 -0
- package/src/builders/layout.ts +24 -0
- package/src/ir.ts +67 -7
- package/src/renderers/tailwind.ts +12 -1
package/README.md
CHANGED
|
@@ -1,72 +1,81 @@
|
|
|
1
1
|
# @apollion-dsi/tokens
|
|
2
2
|
|
|
3
3
|
Framework-agnostic design tokens for the **Apollion Design System** — an
|
|
4
|
-
OKLch-based
|
|
5
|
-
|
|
6
|
-
variants.
|
|
4
|
+
OKLch-based pipeline that emits CSS variables, structured JSON, TypeScript
|
|
5
|
+
types, and an optional Tailwind preset, in light **and** dark variants.
|
|
7
6
|
|
|
8
7
|
[](https://www.npmjs.com/package/@apollion-dsi/tokens)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
[](https://www.npmjs.com/package/@apollion-dsi/tokens)
|
|
9
|
+
[](https://www.npmjs.com/package/@apollion-dsi/tokens)
|
|
10
|
+
|
|
11
|
+
- **Works without React.** Vue, Flutter, native, or plain CSS stacks read the
|
|
12
|
+
emitted `dist/json` / `dist/css` directly — no framework adapter needed.
|
|
13
|
+
- **Light and dark from one source.** Every variant is emitted for both modes,
|
|
14
|
+
including a CSS-only dark switch for pages that never mount React.
|
|
15
|
+
- **OKLch working space.** Palettes are derived in OKLch with an sRGB `hex`
|
|
16
|
+
fallback, so color math stays perceptually even.
|
|
17
|
+
- **Config-first.** One `apollion.config.mjs` drives palette, dimension, and
|
|
18
|
+
which outputs to emit (CSS / JSON / TS / Tailwind).
|
|
19
|
+
- **Versioned in lockstep with `@apollion-dsi/core`** — both always release the
|
|
20
|
+
same version number.
|
|
13
21
|
|
|
14
22
|
## Installation
|
|
15
23
|
|
|
16
|
-
React consumers
|
|
17
|
-
|
|
18
|
-
non-React stacks (or standalone token builds), install it directly:
|
|
24
|
+
React consumers usually get this transitively via `@apollion-dsi/core`. For
|
|
25
|
+
non-React stacks or standalone token builds, install it directly:
|
|
19
26
|
|
|
20
27
|
```bash
|
|
21
28
|
yarn add @apollion-dsi/tokens
|
|
22
29
|
```
|
|
23
30
|
|
|
24
|
-
##
|
|
31
|
+
## Documentation
|
|
25
32
|
|
|
26
|
-
|
|
33
|
+
- **Docs & token reference:** <https://www.apollion.com.br>
|
|
34
|
+
- **Changelog:** <https://www.apollion.com.br/changelog>
|
|
27
35
|
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
## Runtime API
|
|
37
|
+
|
|
38
|
+
A single, versioned public runtime entry — `@apollion-dsi/tokens/runtime/v1`.
|
|
39
|
+
Future breaking changes go to `runtime/v2`, `runtime/v3`, …; `v1` is preserved
|
|
40
|
+
indefinitely, so consumers migrate on their own schedule.
|
|
30
41
|
|
|
31
42
|
```ts
|
|
32
43
|
import { TOKENS_RUNTIME_API_VERSION } from '@apollion-dsi/tokens/runtime/v1';
|
|
33
44
|
```
|
|
34
45
|
|
|
35
|
-
## Scope
|
|
36
|
-
|
|
37
|
-
- **In:** OKLch palette derivation, dimension scales, Foundation/Surface
|
|
38
|
-
builders, build-time emission of CSS/JSON/TS variants (light **and**
|
|
39
|
-
dark), config-first loader (`apollion.config.mjs`).
|
|
40
|
-
- **Out:** runtime React components (those live in `@apollion-dsi/core`);
|
|
41
|
-
framework adapters — Vue/Flutter/other consumers read `dist/json/*.json`
|
|
42
|
-
directly.
|
|
43
|
-
|
|
44
46
|
## Build outputs (`dist/*`)
|
|
45
47
|
|
|
46
|
-
The build
|
|
48
|
+
The build emits, per variant (light/dark):
|
|
47
49
|
|
|
48
50
|
- **`dist/css/*.css`** — fully resolved CSS custom properties.
|
|
49
|
-
- **`dist/json/*.json`** — tokens as structured
|
|
50
|
-
interop surface
|
|
51
|
+
- **`dist/json/*.json`** — tokens as **structured objects** (the cross-framework
|
|
52
|
+
interop surface), not shorthand strings:
|
|
51
53
|
- `color` → `{ "colorSpace": "oklch", "components": [L, C, H], "hex": "#rrggbb" }`
|
|
52
|
-
|
|
53
|
-
below 1).
|
|
54
|
+
(`alpha` only when below 1).
|
|
54
55
|
- `dimension` → `{ "value": <number>, "unit": "rem" }`.
|
|
55
|
-
- **`dist/ts/*.d.ts`** — typed token surfaces (
|
|
56
|
-
- **`dist/css/<brand>.<surface>.<dimension>.modes.css`** — opt-in
|
|
57
|
-
`output.cssModes`
|
|
58
|
-
`html[data-apollion-mode]` (+ `prefers-color-scheme` fallback)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
-
|
|
69
|
-
|
|
56
|
+
- **`dist/ts/*.d.ts`** — typed token surfaces (hex / `rem` strings).
|
|
57
|
+
- **`dist/css/<brand>.<surface>.<dimension>.modes.css`** — opt-in
|
|
58
|
+
(`output.cssModes`): both modes in one file, scoped by
|
|
59
|
+
`html[data-apollion-mode]` (+ `prefers-color-scheme` fallback) — the CSS-only
|
|
60
|
+
dark mode for pages without React.
|
|
61
|
+
- **`dist/tailwind/preset.mjs` + `tw-merge.mjs`** — opt-in (`output.tailwind`):
|
|
62
|
+
a Tailwind preset mapping foundation tokens over `var(--apollion-*)`, plus a
|
|
63
|
+
matching tailwind-merge extension. Its `screens` scale carries **literal px**
|
|
64
|
+
(custom properties are invalid inside a `@media` prelude).
|
|
65
|
+
|
|
66
|
+
## Breakpoint tokens
|
|
67
|
+
|
|
68
|
+
The viewport scale (`breakpoint.xs/sm/md/lg/xl` = `0/575/767/990/1200`, px) is
|
|
69
|
+
axis-invariant and mirrors `@apollion-dsi/core`:
|
|
70
|
+
|
|
71
|
+
- **Bands are half-open `[value, next)`** over ascending `min-width` sets — every
|
|
72
|
+
width belongs to exactly one band; JS predicates use strict `<` on the upper
|
|
73
|
+
bound.
|
|
74
|
+
- **Unit is px by decision** — the root is fixed at 16px and browser zoom scales
|
|
75
|
+
px media queries correctly.
|
|
76
|
+
- **CSS vars (`--apollion-breakpoint-*`) are informational** (for JS
|
|
77
|
+
`getComputedStyle` readers); the query-capable surfaces are the TS record and
|
|
78
|
+
the Tailwind `screens` scale.
|
|
70
79
|
|
|
71
80
|
## License
|
|
72
81
|
|
package/lib/build.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";var K=Object.defineProperty;var Mn=Object.getOwnPropertyDescriptor;var Gn=Object.getOwnPropertyNames;var On=Object.prototype.hasOwnProperty;var s=(e,n)=>K(e,"name",{value:n,configurable:!0});var En=(e,n)=>{for(var o in n)K(e,o,{get:n[o],enumerable:!0})},Nn=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of Gn(n))!On.call(e,t)&&t!==o&&K(e,t,{get:()=>n[t],enumerable:!(r=Mn(n,t))||r.enumerable});return e};var jn=e=>Nn(K({},"__esModule",{value:!0}),e);var To={};En(To,{build:()=>vo,check:()=>wo});module.exports=jn(To);var S=require("node:fs/promises"),An=require("node:os"),$=require("node:path");var ee=require("culori");var H=require("@apollion-dsi/core/themes/border"),Ce=require("@apollion-dsi/core/themes/colors"),Z=require("@apollion-dsi/core/themes/depth"),T=require("@apollion-dsi/core/themes/font"),me=require("@apollion-dsi/core/themes/spacing"),P=require("culori");var $e=require("@apollion-dsi/core/themes/dimension");function U({multiplier:e=.25,alias:n},o){let r=o!==void 0?$e.DIMENSION_MULTIPLIERS[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(U,"createSpacing");var pe={"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 fe(e){let n=Object.keys(pe).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(fe,"assertTokenMetaResolves");var Fn=(0,P.converter)("oklch");function b(e){return typeof e.type=="string"&&"value"in e}s(b,"isToken");function v(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(v,"kebab");function Ve(e){return e.split(".").map(v).join(".")}s(Ve,"kebabPath");function N(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(N,"rawValue");function X(e,n){return Number(e.toFixed(n))||0}s(X,"round");function ge(e){let n=Fn((0,P.parse)(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=(0,P.formatHex)(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}}s(ge,"toColorValue");var Le=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function E(e){let n=Le.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(E,"toDimensionValue");function x(e){return{type:"color",value:ge(e)}}s(x,"colorToken");function O(e){let n={};for(let[o,r]of Object.entries(e))n[o]=x(r);return n}s(O,"recordColorGroup");function Ae(e){let n=(0,Ce.createReadableTextLayer)(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=x(t);return o.neutral=O(n.neutral),o}s(Ae,"buildReadableTextGroup");var Pn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function Me(e){let n={};for(let o of Pn){let r=e[o];n[o]={base:x(r.base),dark:x(r.dark),action:x(r.action),active:x(r.active),light:x(r.light),onLight:x(r.onLight)}}return n.grayscale=O(e.grayscale),n.neutral=O(e.neutral),n.surface=O(e.surface),n.ink=O(e.ink),n.edge=O(e.edge),n.wash=O(e.wash),n.baseDark=x(e.baseDark??"#000000"),n.baseLight=x(e.baseLight??"#ffffff"),n.deepDark=x(e.deepDark??"#000000"),n.deepLight=x(e.deepLight??"#ffffff"),n}s(Me,"buildColorPrimitives");function Ge(e){let n=U(me.defaultInputSpacing,e),o={};for(let r of Object.keys(me.defaultInputSpacing.alias))o[r]={type:"dimension",value:E(n(r))};return o}s(Ge,"buildSpacePrimitives");function Oe(){let e={};for(let[n,o]of Object.entries(H.defaultInputBorder.borderWidth))e[n]={type:"dimension",value:E(o)};return e}s(Oe,"buildBorderWidthPrimitives");function _n(e,n){return{color:Me(e),space:Ge(n),borderWidth:Oe()}}s(_n,"buildPrimitives");var Ee={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"},Ne={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"},je={hairline:"color.edge.hairline",border:"color.edge.border",strong:"color.edge.strong"};function Bn(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}s(Bn,"lookupPrimitive");function F(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?Bn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:ge(i)}}:x(i)}return r}s(F,"colorRefGroup");var Fe={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},Hn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function Wn(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!b(t)&&i in t)t=t[i];else return;return t&&b(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(Wn,"lookupDimensionPrimitive");function he(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?Wn(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:E(i)}}:{type:"dimension",value:E(i)}}return r}s(he,"dimensionRefGroup");function Pe(e){let n={},o={};for(let[i,a]of Object.entries(H.defaultInputBorder.borderRadius))Le.test(a)?n[i]={type:"dimension",value:E(a)}:o[i]=a;let r=he(H.defaultInputBorder.borderWidth,e,Hn),t={};for(let[i,a]of Object.entries(H.defaultInputBorder.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(Pe,"buildBorder");function _e(e){let n=(0,T.createFont)(T.defaultInputFont,e),o={};for(let[c,l]of Object.entries(T.defaultInputFont.fontFamily)){let m=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,l]of Object.entries(n.fontSize))r[c]={type:"dimension",value:E(l)};let t={};for(let[c,l]of Object.entries(T.defaultInputFont.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(T.defaultInputFont.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:T.defaultInputFont.letterSpacing,textTransform:T.defaultInputFont.textTransform,fontStyle:T.defaultInputFont.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(_e,"buildFont");var Jn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function qn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(Jn),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>E(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}}}s(qn,"parseShadow");function Be(e){let n=(0,Z.createDeth)(e),o={};for(let r of Object.keys(Z.levelValues))o[r]={type:"shadow",value:qn(n(r))};return o}s(Be,"buildShadow");function Y(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${v(t)}`:v(t);if(b(i)){o.add(a);let c=pe[a];r[t]=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 r[t]=Y(i,a,o)}return r}s(Y,"decorateGroup");function zn(e){let n=new Set,o=Y(e.primitives,"",n),r=Y(e.groups,"",n);return fe(n),{...e,primitives:o,groups:r}}s(zn,"decorateMeta");function Q(e,n){return Y(e,"",n)}s(Q,"decorateSlice");function He(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${v(r)}`:v(r);b(t)?o.add(i):He(t,i,o)}}s(He,"collectPaths");function We(e){let n=new Set;for(let o of e)He(o.groups,"",n);fe(n)}s(We,"assertSlicesMetaComplete");function Je(){let e=Oe(),o=Pe({borderWidth:e}),r={};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},t),extensions:r}}s(Je,"buildBaseIR");function qe(e){let n=_e(e),o=new Set;return{groups:Q({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(qe,"buildFontIR");function ze(e,n){let o=Me(n),r=new Set;return{groups:Q({color:o,bg:F(e.bg,n,Ee),text:F(e.text,n,Ne),edge:F(e.edge,n,je),tx:Ae(n),shadow:Be(n)},r),extensions:{}}}s(ze,"buildColorIR");function Ke(e,n){let o=Ge(n),r={space:o},t=new Set;return{groups:Q({space:o,spacing:he(e.spacing,r,Fe)},t),extensions:{}}}s(Ke,"buildSpacingIR");function Kn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=_n(n,o.dimension),i=Pe(t),a=_e(o.dimension),c={"com.apollion.variant":r,"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: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:F(e.bg,n,Ee),text:F(e.text,n,Ne),edge:F(e.edge,n,je),tx:Ae(n),spacing:he(e.spacing,t,Fe),border:i.group,font:a.group,shadow:Be(n)},extensions:c};return zn(l)}s(Kn,"buildIR");var _=Kn;var Un=(0,ee.converter)("rgb"),Ue="// 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}s(ye,"colorPayload");function be(e){return e.alpha===void 0}s(be,"isOpaqueColor");function Xe(e){let n=Un((0,ee.parse)(e.hex));if(!n)return"0 0 0";let o=s(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(Xe,"rgbTriplet");function ne(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let i=[...n,v(r)];if(b(t))o.set(i.join("-"),t);else for(let[a,c]of ne(t,i))o.set(a,c)}return o}s(ne,"flatTokens");function I(e,...n){let o=e[n[0]];for(let r of n.slice(1)){if(!o||b(o))return{};o=o[r]}return o&&!b(o)?o:{}}s(I,"groupAt");function Ye(e){let n=[];for(let o of["bg","text","edge","tx"])for(let[r,t]of ne(I(e.groups,o),[o])){let i=ye(t);i&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:be(i)})}return n}s(Ye,"colorEntries");function L(e,n){return[...ne(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s(L,"varEntries");function A(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(" },")}}s(A,"pushScale");function Ze(e){let n=[Ue,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=Ye(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:i}of o)i?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(" },"),A(n,"spacing",L(I(e.groups,"spacing"),["spacing"])),A(n,"borderRadius",L(I(e.groups,"border","radius"),["border","radius"])),A(n,"borderWidth",L(I(e.groups,"border","width"),["border","width"])),A(n,"fontFamily",L(I(e.groups,"font","family"),["font","family"])),A(n,"fontSize",L(I(e.groups,"font","size"),["font","size"])),A(n,"fontWeight",L(I(e.groups,"font","weight"),["font","weight"])),A(n,"lineHeight",L(I(e.groups,"font","lineHeight"),["font","line-height"])),A(n,"boxShadow",L(I(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
2
|
-
`)}s(
|
|
3
|
-
`)}s(
|
|
4
|
-
`)}s(
|
|
5
|
-
`)}s(
|
|
1
|
+
"use strict";var U=Object.defineProperty;var Bn=Object.getOwnPropertyDescriptor;var Hn=Object.getOwnPropertyNames;var Wn=Object.prototype.hasOwnProperty;var s=(e,n)=>U(e,"name",{value:n,configurable:!0});var zn=(e,n)=>{for(var o in n)U(e,o,{get:n[o],enumerable:!0})},Jn=(e,n,o,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let t of Hn(n))!Wn.call(e,t)&&t!==o&&U(e,t,{get:()=>n[t],enumerable:!(r=Bn(n,t))||r.enumerable});return e};var qn=e=>Jn(U({},"__esModule",{value:!0}),e);var Oo={};zn(Oo,{build:()=>Mo,check:()=>Eo});module.exports=qn(Oo);var x=require("node:fs/promises"),_n=require("node:os"),L=require("node:path");var oe=require("culori");var H=require("@apollion-dsi/core/themes/border"),Ee=require("@apollion-dsi/core/themes/colors"),ee=require("@apollion-dsi/core/themes/depth"),D=require("@apollion-dsi/core/themes/font"),ge=require("@apollion-dsi/core/themes/spacing"),P=require("culori");var Ce=require("@apollion-dsi/core/themes/breakpoints");function Ve(e=Ce.defaultInputBreakpoints){return Object.entries(e.values).map(([n,o])=>[n,`${o}px`])}s(Ve,"breakpointEntries");var X=require("@apollion-dsi/core/themes/layout");function Le(e=X.defaultInputContainerSizes){return Object.entries(e.values).map(([n,o])=>[n,`${o}px`])}s(Le,"containerSizeEntries");function Ae(e=X.defaultInputLayout){return[["page-max-width",`${e.pageMaxWidth}px`]]}s(Ae,"layoutEntries");var Me=require("@apollion-dsi/core/themes/dimension");function Y({multiplier:e=.25,alias:n},o){let r=o!==void 0?Me.DIMENSION_MULTIPLIERS[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(Y,"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.`)}s(me,"assertTokenMetaResolves");var Kn=(0,P.converter)("oklch");function b(e){return typeof e.type=="string"&&"value"in e}s(b,"isToken");function v(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(v,"kebab");function Ge(e){return e.split(".").map(v).join(".")}s(Ge,"kebabPath");function C(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(C,"rawValue");function Z(e,n){return Number(e.toFixed(n))||0}s(Z,"round");function he(e){let n=Kn((0,P.parse)(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[Z(n.l,4),Z(n.c,4),Z(n.h??0,2)],r=(0,P.formatHex)(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:Z(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(he,"toColorValue");var Oe=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function $(e){let n=Oe.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($,"toDimensionValue");function S(e){return{type:"color",value:he(e)}}s(S,"colorToken");function N(e){let n={};for(let[o,r]of Object.entries(e))n[o]=S(r);return n}s(N,"recordColorGroup");function Ne(e){let n=(0,Ee.createReadableTextLayer)(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=S(t);return o.neutral=N(n.neutral),o}s(Ne,"buildReadableTextGroup");var Un=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function je(e){let n={};for(let o of Un){let r=e[o];n[o]={base:S(r.base),dark:S(r.dark),action:S(r.action),active:S(r.active),light:S(r.light),onLight:S(r.onLight)}}return n.grayscale=N(e.grayscale),n.neutral=N(e.neutral),n.surface=N(e.surface),n.ink=N(e.ink),n.edge=N(e.edge),n.wash=N(e.wash),n.baseDark=S(e.baseDark??"#000000"),n.baseLight=S(e.baseLight??"#ffffff"),n.deepDark=S(e.deepDark??"#000000"),n.deepLight=S(e.deepLight??"#ffffff"),n}s(je,"buildColorPrimitives");function Fe(e){let n=Y(ge.defaultInputSpacing,e),o={};for(let r of Object.keys(ge.defaultInputSpacing.alias))o[r]={type:"dimension",value:$(n(r))};return o}s(Fe,"buildSpacePrimitives");function Pe(){let e={};for(let[n,o]of Object.entries(H.defaultInputBorder.borderWidth))e[n]={type:"dimension",value:$(o)};return e}s(Pe,"buildBorderWidthPrimitives");function Xn(e,n){return{color:je(e),space:Fe(n),borderWidth:Pe()}}s(Xn,"buildPrimitives");var _e={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"},Be={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"},He={hairline:"color.edge.hairline",border:"color.edge.border",strong:"color.edge.strong"};function Yn(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}s(Yn,"lookupPrimitive");function F(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?Yn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:he(i)}}:S(i)}return r}s(F,"colorRefGroup");var We={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},Zn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function Qn(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!b(t)&&i in t)t=t[i];else return;return t&&b(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(Qn,"lookupDimensionPrimitive");function ye(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?Qn(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:$(i)}}:{type:"dimension",value:$(i)}}return r}s(ye,"dimensionRefGroup");function ze(e){let n={},o={};for(let[i,a]of Object.entries(H.defaultInputBorder.borderRadius))Oe.test(a)?n[i]={type:"dimension",value:$(a)}:o[i]=a;let r=ye(H.defaultInputBorder.borderWidth,e,Zn),t={};for(let[i,a]of Object.entries(H.defaultInputBorder.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(ze,"buildBorder");function Je(e){let n=(0,D.createFont)(D.defaultInputFont,e),o={};for(let[c,l]of Object.entries(D.defaultInputFont.fontFamily)){let m=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}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(D.defaultInputFont.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(D.defaultInputFont.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:D.defaultInputFont.letterSpacing,textTransform:D.defaultInputFont.textTransform,fontStyle:D.defaultInputFont.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(Je,"buildFont");var eo=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function no(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(eo),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>$(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:he(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(no,"parseShadow");function qe(e){let n=(0,ee.createDeth)(e),o={};for(let r of Object.keys(ee.levelValues))o[r]={type:"shadow",value:no(n(r))};return o}s(qe,"buildShadow");function Q(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${v(t)}`:v(t);if(b(i)){o.add(a);let c=fe[a];r[t]=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 r[t]=Q(i,a,o)}return r}s(Q,"decorateGroup");function oo(e){let n=new Set,o=Q(e.primitives,"",n),r=Q(e.groups,"",n);return me(n),{...e,primitives:o,groups:r}}s(oo,"decorateMeta");function ne(e,n){return Q(e,"",n)}s(ne,"decorateSlice");function Ke(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${v(r)}`:v(r);b(t)?o.add(i):Ke(t,i,o)}}s(Ke,"collectPaths");function Ue(e){let n=new Set;for(let o of e)Ke(o.groups,"",n);me(n)}s(Ue,"assertSlicesMetaComplete");function Xe(){let e={};for(let[n,o]of Ve())e[n]={type:"dimension",value:$(o)};return e}s(Xe,"buildBreakpoints");function Ye(){let e={};for(let[n,o]of Le())e[n]={type:"dimension",value:$(o)};return e}s(Ye,"buildContainerSizes");function Ze(){let e={};for(let[n,o]of Ae())e[n]={type:"dimension",value:$(o)};return e}s(Ze,"buildLayoutConstants");var Qe={unit:"px",interval:"half-open [value, next) \u2014 min-width sets, ascending",cssVarsUsage:"informational only \u2014 var() is invalid inside a @media prelude"};function en(){let e=Pe(),o=ze({borderWidth:e}),r={"com.apollion.breakpoint":Qe};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:ne({"border-width":e,border:o.group,breakpoint:Xe(),"container-size":Ye(),layout:Ze()},t),extensions:r}}s(en,"buildBaseIR");function nn(e){let n=Je(e),o=new Set;return{groups:ne({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(nn,"buildFontIR");function on(e,n){let o=je(n),r=new Set;return{groups:ne({color:o,bg:F(e.bg,n,_e),text:F(e.text,n,Be),edge:F(e.edge,n,He),tx:Ne(n),shadow:qe(n)},r),extensions:{}}}s(on,"buildColorIR");function rn(e,n){let o=Fe(n),r={space:o},t=new Set;return{groups:ne({space:o,spacing:ye(e.spacing,r,We)},t),extensions:{}}}s(rn,"buildSpacingIR");function ro(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=Xn(n,o.dimension),i=ze(t),a=Je(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions,"com.apollion.breakpoint":Qe};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.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,_e),text:F(e.text,n,Be),edge:F(e.edge,n,He),tx:Ne(n),spacing:ye(e.spacing,t,We),border:i.group,breakpoint:Xe(),"container-size":Ye(),layout:Ze(),font:a.group,shadow:qe(n)},extensions:c};return oo(l)}s(ro,"buildIR");var _=ro;var to=(0,oe.converter)("rgb"),tn="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function be(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}s(be,"colorPayload");function Re(e){return e.alpha===void 0}s(Re,"isOpaqueColor");function sn(e){let n=to((0,oe.parse)(e.hex));if(!n)return"0 0 0";let o=s(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(sn,"rgbTriplet");function W(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let i=[...n,v(r)];if(b(t))o.set(i.join("-"),t);else for(let[a,c]of W(t,i))o.set(a,c)}return o}s(W,"flatTokens");function R(e,...n){let o=e[n[0]];for(let r of n.slice(1)){if(!o||b(o))return{};o=o[r]}return o&&!b(o)?o:{}}s(R,"groupAt");function an(e){let n=[];for(let o of["bg","text","edge","tx"])for(let[r,t]of W(R(e.groups,o),[o])){let i=be(t);i&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:Re(i)})}return n}s(an,"colorEntries");function E(e,n){return[...W(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s(E,"varEntries");function V(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(" },")}}s(V,"pushScale");function cn(e){let n=[tn,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=an(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:i}of o)i?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(" },"),V(n,"screens",[...W(R(e.groups,"breakpoint"))].filter(([r])=>r!=="xs").map(([r,t])=>[r,C(t.value)])),V(n,"spacing",E(R(e.groups,"spacing"),["spacing"])),V(n,"borderRadius",E(R(e.groups,"border","radius"),["border","radius"])),V(n,"borderWidth",E(R(e.groups,"border","width"),["border","width"])),V(n,"fontFamily",E(R(e.groups,"font","family"),["font","family"])),V(n,"fontSize",E(R(e.groups,"font","size"),["font","size"])),V(n,"fontWeight",E(R(e.groups,"font","weight"),["font","weight"])),V(n,"lineHeight",E(R(e.groups,"font","lineHeight"),["font","line-height"])),V(n,"boxShadow",E(R(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
2
|
+
`)}s(cn,"renderTailwindPreset");function ln(e){let n=s(t=>[...W(t).keys()],"keys"),o=s(t=>`[${t.map(i=>JSON.stringify(i)).join(", ")}]`,"list");return[tn,"// tailwind-merge extension for the generated preset \u2014 pass to extendTailwindMerge().","","export const twMergeExtension = {"," extend: {"," theme: {",` colors: ${o(an(e).map(t=>t.key))},`,` spacing: ${o(n(R(e.groups,"spacing")))},`,` borderRadius: ${o(n(R(e.groups,"border","radius")))},`,` borderWidth: ${o(n(R(e.groups,"border","width")))},`," },"," classGroups: {",` 'font-family': [{ font: ${o(n(R(e.groups,"font","family")))} }],`,` 'font-size': [{ text: ${o(n(R(e.groups,"font","size")))} }],`,` 'font-weight': [{ font: ${o(n(R(e.groups,"font","weight")))} }],`,` leading: [{ leading: ${o(n(R(e.groups,"font","lineHeight")))} }],`,` shadow: [{ shadow: ${o(n(R(e.groups,"shadow")))} }],`," },"," },","};",""].join(`
|
|
3
|
+
`)}s(ln,"renderTwMergeExtension");var dn="/* 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 i=[...n,v(r)];b(t)?o.push(` --apollion-${i.join("-")}: ${C(t.value)};`):re(t,i,o)}}s(re,"emitVars");function te(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,v(r)];if(!b(t)){te(t,i,o);continue}let a=be(t);a&&Re(a)&&o.push(` --apollion-${i.join("-")}-rgb: ${sn(a)};`)}}s(te,"emitRgbVars");function ke(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,v(r)];b(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${C(t.value)}; }`):ke(t,i,o)}}s(ke,"emitProperties");function un(e,n={}){let{brand:o,mode:r,surface:t,dimension:i}=e.meta,a=[dn,""];return a.push(`/* Variant: brand=${o} mode=${r} surface=${t} dimension=${i} */`,"",":root {"),re(e.groups,[],a),n.rgbCompanions&&(a.push(""," /* -rgb channel triplets \u2014 Tailwind <alpha-value> companions (opaque colour tokens only). */"),te(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(`
|
|
4
|
+
`)}s(un,"renderCss");function pn(e,n,o={}){let{attribute:r="data-apollion-mode",rgbCompanions:t}=o,{brand:i,surface:a,dimension:c}=e.meta,l=[dn,""],m=s((w,d,u)=>{l.push(`${w} {`,` color-scheme: ${u};`),re(d.groups,[],l),t&&te(d.groups,[],l),l.push("}","")},"block");l.push(`/* Variant: brand=${i} surface=${a} dimension=${c} modes=light+dark (attribute ${r}) */`,""),m(`:root, html[${r}="light"]`,e,"light"),m(`html[${r}="dark"]`,n,"dark"),l.push("@media (prefers-color-scheme: dark) {"),l.push(` html:not([${r}]) {`," color-scheme: dark;");let k=[];re(n.groups,[],k),t&&te(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(`
|
|
5
|
+
`)}s(pn,"renderCssModes");var io="<!-- Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. -->";function Ie(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${r}`:r;b(t)?o.push([i,C(t.value)]):Ie(t,i,o)}}s(Ie,"flatten");function so(e){return typeof e=="number"?String(e):`'${String(e).replace(/'/g,"''")}'`}s(so,"yamlEscape");function ao(e){let{mode:n,surface:o,dimension:r}=e.meta;return`${n}.${o}.${r}`}s(ao,"variantKey");function fn(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 i=[];Ie(t.groups,"",i),o.push(` ${ao(t)}:`);for(let[a,c]of i)o.push(` ${a}: ${so(c)}`)}o.push("---");let r=["",io,"",`# 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:i,surface:a,dimension:c}=t.meta;r.push(`## Variant \`${i} \xB7 ${a} \xB7 ${c}\``,"");let l=[];Ie(t.groups,"",l);let m=new Map;for(let[k,w]of l){let d=k.split(".")[0]??k,u=m.get(d)??[];u.push([k,w]),m.set(d,u)}for(let[k,w]of m){r.push(`### ${k}`,"","| Token | Value |","| --- | --- |");for(let[d,u]of w)r.push(`| \`${d}\` | \`${u}\` |`);r.push("")}}return`${o.join(`
|
|
6
6
|
`)}
|
|
7
7
|
${r.join(`
|
|
8
|
-
`)}`}s(
|
|
9
|
-
`}s(
|
|
10
|
-
`}s(
|
|
11
|
-
`)}s(
|
|
12
|
-
`}s(yn,"serializeManifest");var ao="json/sets",bn="json/resolver.json";function ae(e){return`${ao}/${e}.json`}s(ae,"setFile");function co(e,n,o){return`${e}.color.${n}.${o}`}s(co,"colorSetName");function lo(e){return`spacing.${e}`}s(lo,"spacingSetName");function uo(e){return`font.${e}`}s(uo,"fontSetName");function ce(e,n){e.includes(n)||e.push(n)}s(ce,"pushUnique");function Rn(e){let n=ie(e),o=[],r=[],t=[],i=[],a=new Set,c=[],l=new Set,m=[],R=new Set,w=[];for(let d of n){ce(o,d.brand),ce(r,d.mode),ce(t,d.surface),ce(i,d.dimension);let u=co(d.brand,d.mode,d.surface);a.has(u)||(a.add(u),c.push({kind:"color",name:u,file:ae(u),brand:d.brand,mode:d.mode,surface:d.surface}));let y=lo(d.dimension);l.has(y)||(l.add(y),m.push({kind:"spacing",name:y,file:ae(y),dimension:d.dimension}));let f=uo(d.dimension);R.has(f)||(R.add(f),w.push({kind:"font",name:f,file:ae(f),dimension:d.dimension}))}return{base:{kind:"base",name:"base",file:ae("base")},spacing:m,font:w,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:i}}}s(Rn,"planSets");var $n=require("@apollion-dsi/core/themes/colors"),Te=require("@apollion-dsi/core/themes/foundation"),Cn=require("@apollion-dsi/core/themes/semantic"),Vn=require("@apollion-dsi/core/themes/spacing"),Ln=require("@apollion-dsi/core/themes/surface");var h=require("culori");var q=(0,h.converter)("oklch"),po=(0,h.converter)("rgb");function p(e,n,o){let r=(0,h.parse)(e),t=(0,h.parse)(n);if(!r||!t)return e;let i=(0,h.interpolate)([r,t],"oklch");return(0,h.formatHex)(i(o))??e}s(p,"mixOklch");function fo(e){return e?typeof e=="string"?e:e.base:"#000"}s(fo,"coerceToHex");var le=1.3,mo=.05,kn=.04,M=s((e,n)=>{let o=(0,h.parse)(e),r=(0,h.parse)(n);return!o||!r?1:(0,h.wcagContrast)(o,r)},"contrastRatio"),ve=s(e=>{let n=q((0,h.parse)(e));return n?n.l??0:null},"oklchLightness"),go=4.5;function J(e,n,o=go){let r=(0,h.parse)(n),t=q((0,h.parse)(e));if(!r||!t)return e;let i=M("#fff",n)>=M("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=(0,h.formatHex)(t)??e,l=(0,h.parse)(c);if(l&&(0,h.wcagContrast)(l,r)>=o)return c;let m=Math.min(1,Math.max(0,(t.l??0)+i));if(m===(t.l??0))break;t={...t,l:m}}return(0,h.formatHex)(t)??e}s(J,"readableColor");var In=s((e,n)=>{if(M(e,n)>=le)return!0;let o=ve(e),r=ve(n);return o!==null&&r!==null&&Math.abs(o-r)>=mo},"isPerceptibleState"),we=s(e=>e?M("#fff",e)>M("#000",e):!1,"isDarkSurface");function Sn(e,n,o){let r=q((0,h.parse)(e));if(!r)return null;let t={...r,l:o??r.l??0},i=n?kn:-kn;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(t.l??0)+i));if(c===(t.l??0))break;t={...t,l:c};let l=(0,h.formatHex)(t);if(l&&M(e,l)>=le)return l}return(0,h.formatHex)(t)??null}s(Sn,"derivePerceptibleState");function xn(e,n,o){let r=Sn(e,n,o);if(r&&M(e,r)>=le)return r;let t=Sn(e,!n);return t&&M(e,t)>=le?t:r??t}s(xn,"perceptibleStateFor");function D(e,n){let o=typeof e=="object"&&e!==null?e:void 0,r=fo(e),t=n.deepDark,i=n.deepLight,a={base:r,dark:p(r,t,.6),action:p(r,t,.2),active:p(r,i,.6),light:p(r,i,.9),onLight:r};if((0,h.parse)(r)){let c=we(n.baseLight),l=In(r,a.action);if(l||(a.action=xn(r,c)??a.action),!In(r,a.active)){let m=l?void 0:ve(a.action)??void 0;a.active=xn(r,c,m)??a.active}}if(a.onLight=J(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??J(c,l)}}return a}s(D,"mountSingleColor");function vn(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)}}s(vn,"mountGreyscaleColors");function wn(e){let n=e.deepLight,o=e.deepDark,r=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=p(r,o,.5);return{0:p(i,n,t(18)),5:p(i,n,t(17.5)),10:p(i,n,t(17)),20:p(i,n,t(16)),30:p(i,n,t(15)),40:p(i,n,t(14)),50:p(i,n,t(13)),60:p(i,n,t(12)),70:p(i,n,t(11)),80:p(i,n,t(10)),90:p(i,n,t(9)),100:p(i,n,t(8)),110:p(i,n,t(7)),120:p(i,n,t(6)),130:p(i,n,t(5)),140:p(i,n,t(4)),150:p(i,n,t(3)),160:p(i,n,t(2)),170:i,180:p(i,o,.25)}}s(wn,"mountNeutralColors");function B(e,n){let o=q((0,h.parse)(e));if(!o)return e;let r=Math.min(1,Math.max(0,(o.l??0)+n));return(0,h.formatHex)({...o,l:r})??e}s(B,"shiftLightness");function de(e,n){let o=q((0,h.parse)(e));if(!o)return e;let r=o.l??0,t=n.min??0,i=n.max??1;return r>=t&&r<=i?e:(0,h.formatHex)({...o,l:Math.min(i,Math.max(t,r))})??e}s(de,"clampLightness");function j(e,n){let o=po((0,h.parse)(e));if(!o)return e;let r=Math.min(1,Math.max(0,n)),t=s(i=>Math.round((i??0)*255),"channel");return`rgba(${t(o.r)}, ${t(o.g)}, ${t(o.b)}, ${r})`}s(j,"toRgbaString");var g=require("@apollion-dsi/core/themes/colors");var ho="#FFFFFF",De="#000000";function yo(e){return we(e.baseLight)?"dark":"light"}s(yo,"resolvePolarity");function Dn(e,n,o){if(Math.abs((0,g.apcaContrast)(e,n))>=o)return e;let r=Math.abs((0,g.apcaContrast)("#ffffff",n))>=Math.abs((0,g.apcaContrast)("#000000",n)),t=e;for(let i=0;i<40;i+=1){let a=B(t,r?.02:-.02);if(a===t||(t=a,Math.abs((0,g.apcaContrast)(t,n))>=o))break}return t}s(Dn,"ensureApca");function bo(e,n){let o=e.baseLight??ho,r=n==="dark",t=r?de(o,{min:g.HALATION_FLOORS.CANVAS_MIN_L}):o,i=B(t,g.LADDER_DELTAS.sunken);return{canvas:t,sunken:r?de(i,{min:g.HALATION_FLOORS.CANVAS_MIN_L}):i,paper:B(t,g.LADDER_DELTAS.paper),raised:B(t,g.LADDER_DELTAS.raised),overlay:B(t,g.LADDER_DELTAS.overlay),scrim:r?e.deepLight??De:e.neutral?.["180"]??e.baseDark??De}}s(bo,"deriveSurface");function Ro(e,n){let o=e.baseDark??De,r=de(Dn(J(o,n.paper,g.MIN_CONTRAST_AA),n.paper,g.INK_APCA_MIN.primary),{max:g.HALATION_FLOORS.INK_MAX_L}),t=s((i,a)=>Dn(J(p(r,n.canvas,i),n.paper,g.MIN_CONTRAST_AA),n.paper,a),"tier");return{primary:r,secondary:t(g.INK_MIX.secondary,g.INK_APCA_MIN.secondary),muted:t(g.INK_MIX.muted,g.INK_APCA_MIN.muted),disabled:p(r,n.canvas,g.INK_MIX.disabled)}}s(Ro,"deriveInk");function ko(e){return{hairline:j(e.primary,g.EDGE_ALPHA.hairline),border:j(e.primary,g.EDGE_ALPHA.border),strong:j(e.primary,g.EDGE_ALPHA.strong)}}s(ko,"deriveEdge");function Io(e,n){let o=g.WASH_ALPHA[n];return{hover:j(e.primary,o.hover),pressed:j(e.primary,o.pressed),selected:j(e.primary,o.selected)}}s(Io,"deriveWash");function So(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}s(So,"applyOverride");function Tn(e,n){let o=yo(e),r=bo(e,o),t=Ro(e,r),i={surface:r,ink:t,edge:ko(t),wash:Io(t,o)};return So(i,n?.[o])}s(Tn,"resolveSurfaceLadder");function xo(e){let n=wn(e);return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:n,grayscale:vn(e),...Tn({...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)}}s(xo,"composeColors");function G(e,n=Vn.defaultInputSpacing){let o=e.mode==="dark"?(0,$n.toDarkColors)(e.colors):e.colors,r=xo(o),t=U(n,e.dimension),i=(0,Cn.createSemantic)({colors:r,spacing:t}),a=(0,Te.createFoundation)(i);return e.surface==="negative"&&(a=(0,Te.createFoundation)((0,Ln.invertForSurface)({semantic:i,colors:r},"negative").semantic)),{foundation:a,colors:r}}s(G,"buildVariantThemes");async function vo(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=ie(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await(0,S.mkdtemp)((0,$.join)((0,An.tmpdir)(),"apollion-tokens-"));try{let l=[],m=s(async(d,u)=>{await Do(c,d,u),l.push({path:d,sha256:se(u)}),t&&console.log(` \u2713 ${d}`)},"emit");if(a.json){let d=Rn(n),u=[],y=Je();u.push(y),await m(d.base.file,sn(y));for(let f of d.spacing){let k=i.find(z=>z.dimension===f.dimension),{foundation:C}=G(k),V=Ke(C,f.dimension);u.push(V),await m(f.file,cn(V,f.dimension))}for(let f of d.font){let k=qe(f.dimension);u.push(k),await m(f.file,ln(k,f.dimension))}for(let f of d.color){let k=i.find(ue=>ue.brand===f.brand&&ue.mode===f.mode&&ue.surface===f.surface),{foundation:C,colors:V}=G(k),z=ze(C,V);u.push(z),await m(f.file,an(z,f.brand,f.mode,f.surface))}We(u),await m(bn,dn(n,d))}if(a.css||a.ts)for(let d of i){let{foundation:u,colors:y}=G(d),f=_(u,y,d),k=fn(d);a.css&&await m(`css/${k}.css`,nn(f,{rgbCompanions:a.tailwind})),a.ts&&await m(`ts/${k}.d.ts`,pn(f))}if(a.cssModes){let d=new Map;for(let u of i){let y=`${u.brand}.${u.surface}.${u.dimension}`,f=d.get(y)??{};f[u.mode]=u,d.set(y,f)}for(let[u,{light:y,dark:f}]of d){if(!y||!f)throw new Error(`apollion-tokens build: output.cssModes needs both modes for ${u} (config.modes)`);let k=G(y),C=G(f),V=on(_(k.foundation,k.colors,y),_(C.foundation,C.colors,f),{rgbCompanions:a.tailwind});await m(`css/${u}.modes.css`,V)}}if(a.tailwind){let d=i[0],{foundation:u,colors:y}=G(d),f=_(u,y,d);await m("tailwind/preset.mjs",Ze(f)),await m("tailwind/tw-merge.mjs",Qe(f))}if(a.designMd){let d=[...new Set(i.map(u=>u.brand))];for(let u of d){let f=i.filter(k=>k.brand===u).map(k=>{let{foundation:C,colors:V}=G(k);return _(C,V,k)});await m(`design/${u}.design.md`,rn(u,f))}}let R={configHash:xe(n),files:l,gitCommit:gn(r),buildEnv:hn()},w=yn(R);return await(0,S.writeFile)((0,$.join)(c,"manifest.json"),w),await(0,S.rm)(o,{recursive:!0,force:!0}),await(0,S.mkdir)((0,$.dirname)(o),{recursive:!0}),await(0,S.rename)(c,o),t&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:R,outDir:o}}catch(l){throw await(0,S.rm)(c,{recursive:!0,force:!0}).catch(()=>{}),l}}s(vo,"build");async function wo(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await(0,S.readFile)((0,$.join)(o,"manifest.json"),"utf8"))}catch{return!1}if(r.configHash!==xe(n))return!1;for(let t of r.files){let i;try{i=await(0,S.readFile)((0,$.join)(o,t.path))}catch{return!1}if(se(i)!==t.sha256)return!1}return!0}s(wo,"check");async function Do(e,n,o){let r=(0,$.join)(e,n);await(0,S.mkdir)((0,$.dirname)(r),{recursive:!0}),await(0,S.writeFile)(r,o)}s(Do,"writeAt");0&&(module.exports={build,check});
|
|
8
|
+
`)}`}s(fn,"renderDesignMd");function mn(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(mn,"colorValue");function z(e){return{value:e.value,unit:e.unit}}s(z,"dimensionValue");function co(e){let n=e.shadow,o={color:mn(n.color),offsetX:z(n.offsetX),offsetY:z(n.offsetY),blur:z(n.blur),spread:z(n.spread)};return n.inset&&(o.inset=!0),o}s(co,"shadowValue");function lo(e){switch(e.kind){case"ref":return`{${Ge(e.path)}}`;case"color":return mn(e);case"dimension":return z(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return co(e)}}s(lo,"projectValue");function uo(e){let n={$value:lo(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(uo,"projectToken");function xe(e){let n={};for(let[o,r]of Object.entries(e))n[v(o)]=b(r)?uo(r):xe(r);return n}s(xe,"projectGroup");function ie(e,n){let o={$description:n,...xe(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
9
|
+
`}s(ie,"renderSet");function gn(e){return ie(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}s(gn,"renderBaseSet");function hn(e,n,o,r){return ie(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${r}. DTCG 2025.10.`)}s(hn,"renderColorSet");function yn(e,n){return ie(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(yn,"renderSpacingSet");function bn(e,n){return ie(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}s(bn,"renderFontSet");function Rn(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]}],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: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(i,null,2)}
|
|
10
|
+
`}s(Rn,"renderResolver");var po="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function fo(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} */`)}}s(fo,"emitDoc");function kn(e,n,o){let r=" ".repeat(n);for(let[t,i]of Object.entries(e))b(i)?(fo(i,r,o),o.push(`${r}${JSON.stringify(t)}: ${JSON.stringify(C(i.value))},`)):(o.push(`${r}${t}: {`),kn(i,n+1,o),o.push(`${r}},`))}s(kn,"emitGroup");function In(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[po,`// Variant: brand=${n} mode=${o} surface=${r} dimension=${t}`,"","export const tokens = {"];return kn(e.groups,1,i),i.push("} as const;","","export type Tokens = typeof tokens;",""),i.join(`
|
|
11
|
+
`)}s(In,"renderTs");var mo=["light","dark"],go=["positive","negative"],ho=["compact","normal","spacious"];function se(e){let n=e.modes??mo,o=e.surfaces??go,r=e.dimensions??ho,t=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),i=[];for(let[a,c]of t)for(let l of n)for(let m of o)for(let k of r)i.push({brand:a,colors:c,mode:l,surface:m,dimension:k});return i}s(se,"expandVariants");function xn(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(xn,"variantName");var Sn=require("node:crypto");function ae(e){return(0,Sn.createHash)("sha256").update(e).digest("hex")}s(ae,"sha256");function ve(e){return ae(Se(e))}s(ve,"hashConfig");function Se(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(Se).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${Se(e[r])}`).join(",")}}`}s(Se,"stableStringify");function vn(e){try{let{execSync:n}=require("node:child_process");return n("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}s(vn,"detectGitCommit");function wn(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(wn,"buildEnv");function Tn(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)}
|
|
12
|
+
`}s(Tn,"serializeManifest");var yo="json/sets",Dn="json/resolver.json";function ce(e){return`${yo}/${e}.json`}s(ce,"setFile");function bo(e,n,o){return`${e}.color.${n}.${o}`}s(bo,"colorSetName");function Ro(e){return`spacing.${e}`}s(Ro,"spacingSetName");function ko(e){return`font.${e}`}s(ko,"fontSetName");function le(e,n){e.includes(n)||e.push(n)}s(le,"pushUnique");function $n(e){let n=se(e),o=[],r=[],t=[],i=[],a=new Set,c=[],l=new Set,m=[],k=new Set,w=[];for(let d of n){le(o,d.brand),le(r,d.mode),le(t,d.surface),le(i,d.dimension);let u=bo(d.brand,d.mode,d.surface);a.has(u)||(a.add(u),c.push({kind:"color",name:u,file:ce(u),brand:d.brand,mode:d.mode,surface:d.surface}));let y=Ro(d.dimension);l.has(y)||(l.add(y),m.push({kind:"spacing",name:y,file:ce(y),dimension:d.dimension}));let f=ko(d.dimension);k.has(f)||(k.add(f),w.push({kind:"font",name:f,file:ce(f),dimension:d.dimension}))}return{base:{kind:"base",name:"base",file:ce("base")},spacing:m,font:w,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:i}}}s($n,"planSets");var Nn=require("@apollion-dsi/core/themes/colors"),$e=require("@apollion-dsi/core/themes/foundation"),jn=require("@apollion-dsi/core/themes/semantic"),Fn=require("@apollion-dsi/core/themes/spacing"),Pn=require("@apollion-dsi/core/themes/surface");var h=require("culori");var q=(0,h.converter)("oklch"),Io=(0,h.converter)("rgb");function p(e,n,o){let r=(0,h.parse)(e),t=(0,h.parse)(n);if(!r||!t)return e;let i=(0,h.interpolate)([r,t],"oklch");return(0,h.formatHex)(i(o))??e}s(p,"mixOklch");function xo(e){return e?typeof e=="string"?e:e.base:"#000"}s(xo,"coerceToHex");var de=1.3,So=.05,Cn=.04,G=s((e,n)=>{let o=(0,h.parse)(e),r=(0,h.parse)(n);return!o||!r?1:(0,h.wcagContrast)(o,r)},"contrastRatio"),we=s(e=>{let n=q((0,h.parse)(e));return n?n.l??0:null},"oklchLightness"),vo=4.5;function J(e,n,o=vo){let r=(0,h.parse)(n),t=q((0,h.parse)(e));if(!r||!t)return e;let i=G("#fff",n)>=G("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=(0,h.formatHex)(t)??e,l=(0,h.parse)(c);if(l&&(0,h.wcagContrast)(l,r)>=o)return c;let m=Math.min(1,Math.max(0,(t.l??0)+i));if(m===(t.l??0))break;t={...t,l:m}}return(0,h.formatHex)(t)??e}s(J,"readableColor");var Vn=s((e,n)=>{if(G(e,n)>=de)return!0;let o=we(e),r=we(n);return o!==null&&r!==null&&Math.abs(o-r)>=So},"isPerceptibleState"),Te=s(e=>e?G("#fff",e)>G("#000",e):!1,"isDarkSurface");function Ln(e,n,o){let r=q((0,h.parse)(e));if(!r)return null;let t={...r,l:o??r.l??0},i=n?Cn:-Cn;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(t.l??0)+i));if(c===(t.l??0))break;t={...t,l:c};let l=(0,h.formatHex)(t);if(l&&G(e,l)>=de)return l}return(0,h.formatHex)(t)??null}s(Ln,"derivePerceptibleState");function An(e,n,o){let r=Ln(e,n,o);if(r&&G(e,r)>=de)return r;let t=Ln(e,!n);return t&&G(e,t)>=de?t:r??t}s(An,"perceptibleStateFor");function T(e,n){let o=typeof e=="object"&&e!==null?e:void 0,r=xo(e),t=n.deepDark,i=n.deepLight,a={base:r,dark:p(r,t,.6),action:p(r,t,.2),active:p(r,i,.6),light:p(r,i,.9),onLight:r};if((0,h.parse)(r)){let c=Te(n.baseLight),l=Vn(r,a.action);if(l||(a.action=An(r,c)??a.action),!Vn(r,a.active)){let m=l?void 0:we(a.action)??void 0;a.active=An(r,c,m)??a.active}}if(a.onLight=J(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??J(c,l)}}return a}s(T,"mountSingleColor");function Mn(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)}}s(Mn,"mountGreyscaleColors");function En(e){let n=e.deepLight,o=e.deepDark,r=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=p(r,o,.5);return{0:p(i,n,t(18)),5:p(i,n,t(17.5)),10:p(i,n,t(17)),20:p(i,n,t(16)),30:p(i,n,t(15)),40:p(i,n,t(14)),50:p(i,n,t(13)),60:p(i,n,t(12)),70:p(i,n,t(11)),80:p(i,n,t(10)),90:p(i,n,t(9)),100:p(i,n,t(8)),110:p(i,n,t(7)),120:p(i,n,t(6)),130:p(i,n,t(5)),140:p(i,n,t(4)),150:p(i,n,t(3)),160:p(i,n,t(2)),170:i,180:p(i,o,.25)}}s(En,"mountNeutralColors");function B(e,n){let o=q((0,h.parse)(e));if(!o)return e;let r=Math.min(1,Math.max(0,(o.l??0)+n));return(0,h.formatHex)({...o,l:r})??e}s(B,"shiftLightness");function ue(e,n){let o=q((0,h.parse)(e));if(!o)return e;let r=o.l??0,t=n.min??0,i=n.max??1;return r>=t&&r<=i?e:(0,h.formatHex)({...o,l:Math.min(i,Math.max(t,r))})??e}s(ue,"clampLightness");function j(e,n){let o=Io((0,h.parse)(e));if(!o)return e;let r=Math.min(1,Math.max(0,n)),t=s(i=>Math.round((i??0)*255),"channel");return`rgba(${t(o.r)}, ${t(o.g)}, ${t(o.b)}, ${r})`}s(j,"toRgbaString");var g=require("@apollion-dsi/core/themes/colors");var wo="#FFFFFF",De="#000000";function To(e){return Te(e.baseLight)?"dark":"light"}s(To,"resolvePolarity");function Gn(e,n,o){if(Math.abs((0,g.apcaContrast)(e,n))>=o)return e;let r=Math.abs((0,g.apcaContrast)("#ffffff",n))>=Math.abs((0,g.apcaContrast)("#000000",n)),t=e;for(let i=0;i<40;i+=1){let a=B(t,r?.02:-.02);if(a===t||(t=a,Math.abs((0,g.apcaContrast)(t,n))>=o))break}return t}s(Gn,"ensureApca");function Do(e,n){let o=e.baseLight??wo,r=n==="dark",t=r?ue(o,{min:g.HALATION_FLOORS.CANVAS_MIN_L}):o,i=B(t,g.LADDER_DELTAS.sunken);return{canvas:t,sunken:r?ue(i,{min:g.HALATION_FLOORS.CANVAS_MIN_L}):i,paper:B(t,g.LADDER_DELTAS.paper),raised:B(t,g.LADDER_DELTAS.raised),overlay:B(t,g.LADDER_DELTAS.overlay),scrim:r?e.deepLight??De:e.neutral?.["180"]??e.baseDark??De}}s(Do,"deriveSurface");function $o(e,n){let o=e.baseDark??De,r=ue(Gn(J(o,n.paper,g.MIN_CONTRAST_AA),n.paper,g.INK_APCA_MIN.primary),{max:g.HALATION_FLOORS.INK_MAX_L}),t=s((i,a)=>Gn(J(p(r,n.canvas,i),n.paper,g.MIN_CONTRAST_AA),n.paper,a),"tier");return{primary:r,secondary:t(g.INK_MIX.secondary,g.INK_APCA_MIN.secondary),muted:t(g.INK_MIX.muted,g.INK_APCA_MIN.muted),disabled:p(r,n.canvas,g.INK_MIX.disabled)}}s($o,"deriveInk");function Co(e){return{hairline:j(e.primary,g.EDGE_ALPHA.hairline),border:j(e.primary,g.EDGE_ALPHA.border),strong:j(e.primary,g.EDGE_ALPHA.strong)}}s(Co,"deriveEdge");function Vo(e,n){let o=g.WASH_ALPHA[n];return{hover:j(e.primary,o.hover),pressed:j(e.primary,o.pressed),selected:j(e.primary,o.selected)}}s(Vo,"deriveWash");function Lo(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}s(Lo,"applyOverride");function On(e,n){let o=To(e),r=Do(e,o),t=$o(e,r),i={surface:r,ink:t,edge:Co(t),wash:Vo(t,o)};return Lo(i,n?.[o])}s(On,"resolveSurfaceLadder");function Ao(e){let n=En(e);return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:n,grayscale:Mn(e),...On({...e,neutral:n},e.ladder),main:T(e.main,e),opposite:T(e.opposite,e),complementary:T(e.complementary,e),danger:T(e.danger,e),information:T(e.information,e),success:T(e.success,e),warning:T(e.warning,e),primary:T(e.primary,e),secondary:T(e.secondary,e),tertiary:T(e.tertiary,e)}}s(Ao,"composeColors");function O(e,n=Fn.defaultInputSpacing){let o=e.mode==="dark"?(0,Nn.toDarkColors)(e.colors):e.colors,r=Ao(o),t=Y(n,e.dimension),i=(0,jn.createSemantic)({colors:r,spacing:t}),a=(0,$e.createFoundation)(i);return e.surface==="negative"&&(a=(0,$e.createFoundation)((0,Pn.invertForSurface)({semantic:i,colors:r},"negative").semantic)),{foundation:a,colors:r}}s(O,"buildVariantThemes");async function Mo(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=se(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await(0,x.mkdtemp)((0,L.join)((0,_n.tmpdir)(),"apollion-tokens-"));try{let l=[],m=s(async(d,u)=>{await Go(c,d,u),l.push({path:d,sha256:ae(u)}),t&&console.log(` \u2713 ${d}`)},"emit");if(a.json){let d=$n(n),u=[],y=en();u.push(y),await m(d.base.file,gn(y));for(let f of d.spacing){let I=i.find(K=>K.dimension===f.dimension),{foundation:A}=O(I),M=rn(A,f.dimension);u.push(M),await m(f.file,yn(M,f.dimension))}for(let f of d.font){let I=nn(f.dimension);u.push(I),await m(f.file,bn(I,f.dimension))}for(let f of d.color){let I=i.find(pe=>pe.brand===f.brand&&pe.mode===f.mode&&pe.surface===f.surface),{foundation:A,colors:M}=O(I),K=on(A,M);u.push(K),await m(f.file,hn(K,f.brand,f.mode,f.surface))}Ue(u),await m(Dn,Rn(n,d))}if(a.css||a.ts)for(let d of i){let{foundation:u,colors:y}=O(d),f=_(u,y,d),I=xn(d);a.css&&await m(`css/${I}.css`,un(f,{rgbCompanions:a.tailwind})),a.ts&&await m(`ts/${I}.d.ts`,In(f))}if(a.cssModes){let d=new Map;for(let u of i){let y=`${u.brand}.${u.surface}.${u.dimension}`,f=d.get(y)??{};f[u.mode]=u,d.set(y,f)}for(let[u,{light:y,dark:f}]of d){if(!y||!f)throw new Error(`apollion-tokens build: output.cssModes needs both modes for ${u} (config.modes)`);let I=O(y),A=O(f),M=pn(_(I.foundation,I.colors,y),_(A.foundation,A.colors,f),{rgbCompanions:a.tailwind});await m(`css/${u}.modes.css`,M)}}if(a.tailwind){let d=i[0],{foundation:u,colors:y}=O(d),f=_(u,y,d);await m("tailwind/preset.mjs",cn(f)),await m("tailwind/tw-merge.mjs",ln(f))}if(a.designMd){let d=[...new Set(i.map(u=>u.brand))];for(let u of d){let f=i.filter(I=>I.brand===u).map(I=>{let{foundation:A,colors:M}=O(I);return _(A,M,I)});await m(`design/${u}.design.md`,fn(u,f))}}let k={configHash:ve(n),files:l,gitCommit:vn(r),buildEnv:wn()},w=Tn(k);return await(0,x.writeFile)((0,L.join)(c,"manifest.json"),w),await(0,x.rm)(o,{recursive:!0,force:!0}),await(0,x.mkdir)((0,L.dirname)(o),{recursive:!0}),await(0,x.rename)(c,o),t&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:k,outDir:o}}catch(l){throw await(0,x.rm)(c,{recursive:!0,force:!0}).catch(()=>{}),l}}s(Mo,"build");async function Eo(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await(0,x.readFile)((0,L.join)(o,"manifest.json"),"utf8"))}catch{return!1}if(r.configHash!==ve(n))return!1;for(let t of r.files){let i;try{i=await(0,x.readFile)((0,L.join)(o,t.path))}catch{return!1}if(ae(i)!==t.sha256)return!1}return!0}s(Eo,"check");async function Go(e,n,o){let r=(0,L.join)(e,n);await(0,x.mkdir)((0,L.dirname)(r),{recursive:!0}),await(0,x.writeFile)(r,o)}s(Go,"writeAt");0&&(module.exports={build,check});
|
package/lib/build.esm.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var Gn=Object.defineProperty;var s=(e,n)=>Gn(e,"name",{value:n,configurable:!0}),On=(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{mkdir as Ln,mkdtemp as jo,readFile as Cn,rename as Fo,rm as Vn,writeFile as An}from"node:fs/promises";import{tmpdir as Po}from"node:os";import{dirname as Mn,join as H}from"node:path";import{converter as eo,parse as no}from"culori";import{defaultInputBorder as z}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as Nn}from"@apollion-dsi/core/themes/colors";import{createDeth as jn,levelValues as Fn}from"@apollion-dsi/core/themes/depth";import{createFont as Pn,defaultInputFont as L}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as Te}from"@apollion-dsi/core/themes/spacing";import{converter as _n,formatHex as Bn,parse as Hn}from"culori";import{DIMENSION_MULTIPLIERS as En}from"@apollion-dsi/core/themes/dimension";function J({multiplier:e=.25,alias:n},o){let r=o!==void 0?En[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(J,"createSpacing");var le={"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 de(e){let n=Object.keys(le).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(de,"assertTokenMetaResolves");var Wn=_n("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 $e(e){return e.split(".").map(I).join(".")}s($e,"kebabPath");function G(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(G,"rawValue");function q(e,n){return Number(e.toFixed(n))||0}s(q,"round");function ue(e){let n=Wn(Hn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[q(n.l,4),q(n.c,4),q(n.h??0,2)],r=Bn(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:q(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(ue,"toColorValue");var Ce=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function M(e){let n=Ce.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(M,"toDimensionValue");function k(e){return{type:"color",value:ue(e)}}s(k,"colorToken");function A(e){let n={};for(let[o,r]of Object.entries(e))n[o]=k(r);return n}s(A,"recordColorGroup");function Ve(e){let n=Nn(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=k(t);return o.neutral=A(n.neutral),o}s(Ve,"buildReadableTextGroup");var Jn=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function Le(e){let n={};for(let o of Jn){let r=e[o];n[o]={base:k(r.base),dark:k(r.dark),action:k(r.action),active:k(r.active),light:k(r.light),onLight:k(r.onLight)}}return n.grayscale=A(e.grayscale),n.neutral=A(e.neutral),n.surface=A(e.surface),n.ink=A(e.ink),n.edge=A(e.edge),n.wash=A(e.wash),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(Le,"buildColorPrimitives");function Ae(e){let n=J(Te,e),o={};for(let r of Object.keys(Te.alias))o[r]={type:"dimension",value:M(n(r))};return o}s(Ae,"buildSpacePrimitives");function Me(){let e={};for(let[n,o]of Object.entries(z.borderWidth))e[n]={type:"dimension",value:M(o)};return e}s(Me,"buildBorderWidthPrimitives");function qn(e,n){return{color:Le(e),space:Ae(n),borderWidth:Me()}}s(qn,"buildPrimitives");var Ge={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"},Oe={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"},Ee={hairline:"color.edge.hairline",border:"color.edge.border",strong:"color.edge.strong"};function zn(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}s(zn,"lookupPrimitive");function N(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?zn(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:ue(i)}}:k(i)}return r}s(N,"colorRefGroup");var Ne={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},Kn={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function Un(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!h(t)&&i in t)t=t[i];else return;return t&&h(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(Un,"lookupDimensionPrimitive");function pe(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?Un(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:M(i)}}:{type:"dimension",value:M(i)}}return r}s(pe,"dimensionRefGroup");function je(e){let n={},o={};for(let[i,a]of Object.entries(z.borderRadius))Ce.test(a)?n[i]={type:"dimension",value:M(a)}:o[i]=a;let r=pe(z.borderWidth,e,Kn),t={};for(let[i,a]of Object.entries(z.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(je,"buildBorder");function Fe(e){let n=Pn(L,e),o={};for(let[c,l]of Object.entries(L.fontFamily)){let m=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,l]of Object.entries(n.fontSize))r[c]={type:"dimension",value:M(l)};let t={};for(let[c,l]of Object.entries(L.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(L.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:L.letterSpacing,textTransform:L.textTransform,fontStyle:L.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(Fe,"buildFont");var Xn=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function Yn(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(Xn),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>M(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:ue(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(Yn,"parseShadow");function Pe(e){let n=jn(e),o={};for(let r of Object.keys(Fn))o[r]={type:"shadow",value:Yn(n(r))};return o}s(Pe,"buildShadow");function K(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${I(t)}`:I(t);if(h(i)){o.add(a);let c=le[a];r[t]=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 r[t]=K(i,a,o)}return r}s(K,"decorateGroup");function Zn(e){let n=new Set,o=K(e.primitives,"",n),r=K(e.groups,"",n);return de(n),{...e,primitives:o,groups:r}}s(Zn,"decorateMeta");function U(e,n){return K(e,"",n)}s(U,"decorateSlice");function _e(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${I(r)}`:I(r);h(t)?o.add(i):_e(t,i,o)}}s(_e,"collectPaths");function Be(e){let n=new Set;for(let o of e)_e(o.groups,"",n);de(n)}s(Be,"assertSlicesMetaComplete");function He(){let e=Me(),o=je({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:U({"border-width":e,border:o.group},t),extensions:r}}s(He,"buildBaseIR");function We(e){let n=Fe(e),o=new Set;return{groups:U({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(We,"buildFontIR");function Je(e,n){let o=Le(n),r=new Set;return{groups:U({color:o,bg:N(e.bg,n,Ge),text:N(e.text,n,Oe),edge:N(e.edge,n,Ee),tx:Ve(n),shadow:Pe(n)},r),extensions:{}}}s(Je,"buildColorIR");function qe(e,n){let o=Ae(n),r={space:o},t=new Set;return{groups:U({space:o,spacing:pe(e.spacing,r,Ne)},t),extensions:{}}}s(qe,"buildSpacingIR");function Qn(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=qn(n,o.dimension),i=je(t),a=Fe(o.dimension),c={"com.apollion.variant":r,"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: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:N(e.bg,n,Ge),text:N(e.text,n,Oe),edge:N(e.edge,n,Ee),tx:Ve(n),spacing:pe(e.spacing,t,Ne),border:i.group,font:a.group,shadow:Pe(n)},extensions:c};return Zn(l)}s(Qn,"buildIR");var j=Qn;var oo=eo("rgb"),ze="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function fe(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}s(fe,"colorPayload");function me(e){return e.alpha===void 0}s(me,"isOpaqueColor");function Ke(e){let n=oo(no(e.hex));if(!n)return"0 0 0";let o=s(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(Ke,"rgbTriplet");function X(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];if(h(t))o.set(i.join("-"),t);else for(let[a,c]of X(t,i))o.set(a,c)}return o}s(X,"flatTokens");function R(e,...n){let o=e[n[0]];for(let r of n.slice(1)){if(!o||h(o))return{};o=o[r]}return o&&!h(o)?o:{}}s(R,"groupAt");function Ue(e){let n=[];for(let o of["bg","text","edge","tx"])for(let[r,t]of X(R(e.groups,o),[o])){let i=fe(t);i&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:me(i)})}return n}s(Ue,"colorEntries");function T(e,n){return[...X(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s(T,"varEntries");function $(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(" },")}}s($,"pushScale");function Xe(e){let n=[ze,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=Ue(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:i}of o)i?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(" },"),$(n,"spacing",T(R(e.groups,"spacing"),["spacing"])),$(n,"borderRadius",T(R(e.groups,"border","radius"),["border","radius"])),$(n,"borderWidth",T(R(e.groups,"border","width"),["border","width"])),$(n,"fontFamily",T(R(e.groups,"font","family"),["font","family"])),$(n,"fontSize",T(R(e.groups,"font","size"),["font","size"])),$(n,"fontWeight",T(R(e.groups,"font","weight"),["font","weight"])),$(n,"lineHeight",T(R(e.groups,"font","lineHeight"),["font","line-height"])),$(n,"boxShadow",T(R(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
2
|
-
`)}s(
|
|
3
|
-
`)}s(
|
|
4
|
-
`)}s(
|
|
5
|
-
`)}s(
|
|
1
|
+
var _n=Object.defineProperty;var s=(e,n)=>_n(e,"name",{value:n,configurable:!0}),Bn=(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{mkdir as jn,mkdtemp as Ko,readFile as On,rename as Uo,rm as Nn,writeFile as Fn}from"node:fs/promises";import{tmpdir as Xo}from"node:os";import{dirname as Pn,join as W}from"node:path";import{converter as uo,parse as po}from"culori";import{defaultInputBorder as K}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as qn}from"@apollion-dsi/core/themes/colors";import{createDeth as Kn,levelValues as Un}from"@apollion-dsi/core/themes/depth";import{createFont as Xn,defaultInputFont as M}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as Ve}from"@apollion-dsi/core/themes/spacing";import{converter as Yn,formatHex as Zn,parse as Qn}from"culori";import{defaultInputBreakpoints as Hn}from"@apollion-dsi/core/themes/breakpoints";function De(e=Hn){return Object.entries(e.values).map(([n,o])=>[n,`${o}px`])}s(De,"breakpointEntries");import{defaultInputContainerSizes as Wn,defaultInputLayout as zn}from"@apollion-dsi/core/themes/layout";function $e(e=Wn){return Object.entries(e.values).map(([n,o])=>[n,`${o}px`])}s($e,"containerSizeEntries");function Ce(e=zn){return[["page-max-width",`${e.pageMaxWidth}px`]]}s(Ce,"layoutEntries");import{DIMENSION_MULTIPLIERS as Jn}from"@apollion-dsi/core/themes/dimension";function J({multiplier:e=.25,alias:n},o){let r=o!==void 0?Jn[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(J,"createSpacing");var le={"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 de(e){let n=Object.keys(le).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(de,"assertTokenMetaResolves");var eo=Yn("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 Le(e){return e.split(".").map(I).join(".")}s(Le,"kebabPath");function T(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(T,"rawValue");function q(e,n){return Number(e.toFixed(n))||0}s(q,"round");function ue(e){let n=eo(Qn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[q(n.l,4),q(n.c,4),q(n.h??0,2)],r=Zn(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:q(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(ue,"toColorValue");var Ae=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function w(e){let n=Ae.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(w,"toDimensionValue");function k(e){return{type:"color",value:ue(e)}}s(k,"colorToken");function E(e){let n={};for(let[o,r]of Object.entries(e))n[o]=k(r);return n}s(E,"recordColorGroup");function Me(e){let n=qn(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=k(t);return o.neutral=E(n.neutral),o}s(Me,"buildReadableTextGroup");var no=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function Ee(e){let n={};for(let o of no){let r=e[o];n[o]={base:k(r.base),dark:k(r.dark),action:k(r.action),active:k(r.active),light:k(r.light),onLight:k(r.onLight)}}return n.grayscale=E(e.grayscale),n.neutral=E(e.neutral),n.surface=E(e.surface),n.ink=E(e.ink),n.edge=E(e.edge),n.wash=E(e.wash),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(Ee,"buildColorPrimitives");function Ge(e){let n=J(Ve,e),o={};for(let r of Object.keys(Ve.alias))o[r]={type:"dimension",value:w(n(r))};return o}s(Ge,"buildSpacePrimitives");function Oe(){let e={};for(let[n,o]of Object.entries(K.borderWidth))e[n]={type:"dimension",value:w(o)};return e}s(Oe,"buildBorderWidthPrimitives");function oo(e,n){return{color:Ee(e),space:Ge(n),borderWidth:Oe()}}s(oo,"buildPrimitives");var Ne={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"},je={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"},Fe={hairline:"color.edge.hairline",border:"color.edge.border",strong:"color.edge.strong"};function ro(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}s(ro,"lookupPrimitive");function N(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?ro(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:ue(i)}}:k(i)}return r}s(N,"colorRefGroup");var Pe={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},to={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function io(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!h(t)&&i in t)t=t[i];else return;return t&&h(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(io,"lookupDimensionPrimitive");function pe(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?io(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:w(i)}}:{type:"dimension",value:w(i)}}return r}s(pe,"dimensionRefGroup");function _e(e){let n={},o={};for(let[i,a]of Object.entries(K.borderRadius))Ae.test(a)?n[i]={type:"dimension",value:w(a)}:o[i]=a;let r=pe(K.borderWidth,e,to),t={};for(let[i,a]of Object.entries(K.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(_e,"buildBorder");function Be(e){let n=Xn(M,e),o={};for(let[c,l]of Object.entries(M.fontFamily)){let m=l.replace(/;\s*$/,"").trim();o[c]={type:"fontFamily",value:{kind:"fontFamily",raw:m,family:m}}}let r={};for(let[c,l]of Object.entries(n.fontSize))r[c]={type:"dimension",value:w(l)};let t={};for(let[c,l]of Object.entries(M.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(M.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:M.letterSpacing,textTransform:M.textTransform,fontStyle:M.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(Be,"buildFont");var so=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function ao(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(so),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>w(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:ue(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(ao,"parseShadow");function He(e){let n=Kn(e),o={};for(let r of Object.keys(Un))o[r]={type:"shadow",value:ao(n(r))};return o}s(He,"buildShadow");function U(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${I(t)}`:I(t);if(h(i)){o.add(a);let c=le[a];r[t]=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 r[t]=U(i,a,o)}return r}s(U,"decorateGroup");function co(e){let n=new Set,o=U(e.primitives,"",n),r=U(e.groups,"",n);return de(n),{...e,primitives:o,groups:r}}s(co,"decorateMeta");function X(e,n){return U(e,"",n)}s(X,"decorateSlice");function We(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${I(r)}`:I(r);h(t)?o.add(i):We(t,i,o)}}s(We,"collectPaths");function ze(e){let n=new Set;for(let o of e)We(o.groups,"",n);de(n)}s(ze,"assertSlicesMetaComplete");function Je(){let e={};for(let[n,o]of De())e[n]={type:"dimension",value:w(o)};return e}s(Je,"buildBreakpoints");function qe(){let e={};for(let[n,o]of $e())e[n]={type:"dimension",value:w(o)};return e}s(qe,"buildContainerSizes");function Ke(){let e={};for(let[n,o]of Ce())e[n]={type:"dimension",value:w(o)};return e}s(Ke,"buildLayoutConstants");var Ue={unit:"px",interval:"half-open [value, next) \u2014 min-width sets, ascending",cssVarsUsage:"informational only \u2014 var() is invalid inside a @media prelude"};function Xe(){let e=Oe(),o=_e({borderWidth:e}),r={"com.apollion.breakpoint":Ue};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:X({"border-width":e,border:o.group,breakpoint:Je(),"container-size":qe(),layout:Ke()},t),extensions:r}}s(Xe,"buildBaseIR");function Ye(e){let n=Be(e),o=new Set;return{groups:X({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(Ye,"buildFontIR");function Ze(e,n){let o=Ee(n),r=new Set;return{groups:X({color:o,bg:N(e.bg,n,Ne),text:N(e.text,n,je),edge:N(e.edge,n,Fe),tx:Me(n),shadow:He(n)},r),extensions:{}}}s(Ze,"buildColorIR");function Qe(e,n){let o=Ge(n),r={space:o},t=new Set;return{groups:X({space:o,spacing:pe(e.spacing,r,Pe)},t),extensions:{}}}s(Qe,"buildSpacingIR");function lo(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=oo(n,o.dimension),i=_e(t),a=Be(o.dimension),c={"com.apollion.variant":r,"com.apollion.font":a.extensions,"com.apollion.breakpoint":Ue};Object.keys(i.extensions).length>0&&(c["com.apollion.border"]={radius:i.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:N(e.bg,n,Ne),text:N(e.text,n,je),edge:N(e.edge,n,Fe),tx:Me(n),spacing:pe(e.spacing,t,Pe),border:i.group,breakpoint:Je(),"container-size":qe(),layout:Ke(),font:a.group,shadow:He(n)},extensions:c};return co(l)}s(lo,"buildIR");var j=lo;var fo=uo("rgb"),en="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function fe(e){if(e.value.kind==="color")return e.value;if(e.value.kind==="ref"&&e.value.resolved.kind==="color")return e.value.resolved}s(fe,"colorPayload");function me(e){return e.alpha===void 0}s(me,"isOpaqueColor");function nn(e){let n=fo(po(e.hex));if(!n)return"0 0 0";let o=s(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(nn,"rgbTriplet");function P(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];if(h(t))o.set(i.join("-"),t);else for(let[a,c]of P(t,i))o.set(a,c)}return o}s(P,"flatTokens");function y(e,...n){let o=e[n[0]];for(let r of n.slice(1)){if(!o||h(o))return{};o=o[r]}return o&&!h(o)?o:{}}s(y,"groupAt");function on(e){let n=[];for(let o of["bg","text","edge","tx"])for(let[r,t]of P(y(e.groups,o),[o])){let i=fe(t);i&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:me(i)})}return n}s(on,"colorEntries");function V(e,n){return[...P(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s(V,"varEntries");function D(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(" },")}}s(D,"pushScale");function rn(e){let n=[en,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=on(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:i}of o)i?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(" },"),D(n,"screens",[...P(y(e.groups,"breakpoint"))].filter(([r])=>r!=="xs").map(([r,t])=>[r,T(t.value)])),D(n,"spacing",V(y(e.groups,"spacing"),["spacing"])),D(n,"borderRadius",V(y(e.groups,"border","radius"),["border","radius"])),D(n,"borderWidth",V(y(e.groups,"border","width"),["border","width"])),D(n,"fontFamily",V(y(e.groups,"font","family"),["font","family"])),D(n,"fontSize",V(y(e.groups,"font","size"),["font","size"])),D(n,"fontWeight",V(y(e.groups,"font","weight"),["font","weight"])),D(n,"lineHeight",V(y(e.groups,"font","lineHeight"),["font","line-height"])),D(n,"boxShadow",V(y(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
2
|
+
`)}s(rn,"renderTailwindPreset");function tn(e){let n=s(t=>[...P(t).keys()],"keys"),o=s(t=>`[${t.map(i=>JSON.stringify(i)).join(", ")}]`,"list");return[en,"// tailwind-merge extension for the generated preset \u2014 pass to extendTailwindMerge().","","export const twMergeExtension = {"," extend: {"," theme: {",` colors: ${o(on(e).map(t=>t.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(`
|
|
3
|
+
`)}s(tn,"renderTwMergeExtension");var sn="/* Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. */";function Y(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];h(t)?o.push(` --apollion-${i.join("-")}: ${T(t.value)};`):Y(t,i,o)}}s(Y,"emitVars");function Z(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];if(!h(t)){Z(t,i,o);continue}let a=fe(t);a&&me(a)&&o.push(` --apollion-${i.join("-")}-rgb: ${nn(a)};`)}}s(Z,"emitRgbVars");function ge(e,n,o){for(let[r,t]of Object.entries(e)){let i=[...n,I(r)];h(t)?t.type==="color"&&o.push(` @property --apollion-${i.join("-")} { syntax: '<color>'; inherits: true; initial-value: ${T(t.value)}; }`):ge(t,i,o)}}s(ge,"emitProperties");function an(e,n={}){let{brand:o,mode:r,surface:t,dimension:i}=e.meta,a=[sn,""];return a.push(`/* Variant: brand=${o} mode=${r} surface=${t} dimension=${i} */`,"",":root {"),Y(e.groups,[],a),n.rgbCompanions&&(a.push(""," /* -rgb channel triplets \u2014 Tailwind <alpha-value> companions (opaque colour tokens only). */"),Z(e.groups,[],a)),a.push("}",""),a.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),ge(e.groups,[],a),a.push("}",""),a.join(`
|
|
4
|
+
`)}s(an,"renderCss");function cn(e,n,o={}){let{attribute:r="data-apollion-mode",rgbCompanions:t}=o,{brand:i,surface:a,dimension:c}=e.meta,l=[sn,""],m=s((S,d,u)=>{l.push(`${S} {`,` color-scheme: ${u};`),Y(d.groups,[],l),t&&Z(d.groups,[],l),l.push("}","")},"block");l.push(`/* Variant: brand=${i} surface=${a} dimension=${c} modes=light+dark (attribute ${r}) */`,""),m(`:root, html[${r}="light"]`,e,"light"),m(`html[${r}="dark"]`,n,"dark"),l.push("@media (prefers-color-scheme: dark) {"),l.push(` html:not([${r}]) {`," color-scheme: dark;");let b=[];Y(n.groups,[],b),t&&Z(n.groups,[],b);for(let S of b)l.push(` ${S}`);return l.push(" }","}",""),l.push("@supports (background: paint(squircle)) or (color: oklch(0% 0 0)) {"),ge(e.groups,[],l),l.push("}",""),l.join(`
|
|
5
|
+
`)}s(cn,"renderCssModes");var mo="<!-- Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs. -->";function he(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${r}`:r;h(t)?o.push([i,T(t.value)]):he(t,i,o)}}s(he,"flatten");function go(e){return typeof e=="number"?String(e):`'${String(e).replace(/'/g,"''")}'`}s(go,"yamlEscape");function ho(e){let{mode:n,surface:o,dimension:r}=e.meta;return`${n}.${o}.${r}`}s(ho,"variantKey");function ln(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 i=[];he(t.groups,"",i),o.push(` ${ho(t)}:`);for(let[a,c]of i)o.push(` ${a}: ${go(c)}`)}o.push("---");let r=["",mo,"",`# 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:i,surface:a,dimension:c}=t.meta;r.push(`## Variant \`${i} \xB7 ${a} \xB7 ${c}\``,"");let l=[];he(t.groups,"",l);let m=new Map;for(let[b,S]of l){let d=b.split(".")[0]??b,u=m.get(d)??[];u.push([b,S]),m.set(d,u)}for(let[b,S]of m){r.push(`### ${b}`,"","| Token | Value |","| --- | --- |");for(let[d,u]of S)r.push(`| \`${d}\` | \`${u}\` |`);r.push("")}}return`${o.join(`
|
|
6
6
|
`)}
|
|
7
7
|
${r.join(`
|
|
8
|
-
`)}`}s(
|
|
9
|
-
`}s(Q,"renderSet");function
|
|
10
|
-
`}s(
|
|
11
|
-
`)}s(
|
|
12
|
-
`}s(
|
|
8
|
+
`)}`}s(ln,"renderDesignMd");function dn(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(dn,"colorValue");function _(e){return{value:e.value,unit:e.unit}}s(_,"dimensionValue");function yo(e){let n=e.shadow,o={color:dn(n.color),offsetX:_(n.offsetX),offsetY:_(n.offsetY),blur:_(n.blur),spread:_(n.spread)};return n.inset&&(o.inset=!0),o}s(yo,"shadowValue");function bo(e){switch(e.kind){case"ref":return`{${Le(e.path)}}`;case"color":return dn(e);case"dimension":return _(e);case"fontFamily":return e.family;case"fontWeight":return e.weight;case"number":return e.number;case"strokeStyle":return e.style;case"shadow":return yo(e)}}s(bo,"projectValue");function Ro(e){let n={$value:bo(e.value),$type:e.type};return e.description!==void 0&&(n.$description=e.description),e.deprecated!==void 0&&(n.$deprecated=e.deprecated),n}s(Ro,"projectToken");function ye(e){let n={};for(let[o,r]of Object.entries(e))n[I(o)]=h(r)?Ro(r):ye(r);return n}s(ye,"projectGroup");function Q(e,n){let o={$description:n,...ye(e.groups)};return Object.keys(e.extensions).length>0&&(o.$extensions=e.extensions),`${JSON.stringify(o,null,2)}
|
|
9
|
+
`}s(Q,"renderSet");function un(e){return Q(e,"Apollion DS \u2014 base set (axis-invariant: border). DTCG 2025.10.")}s(un,"renderBaseSet");function pn(e,n,o,r){return Q(e,`Apollion DS \u2014 colour set. brand=${n} mode=${o} surface=${r}. DTCG 2025.10.`)}s(pn,"renderColorSet");function fn(e,n){return Q(e,`Apollion DS \u2014 spacing set. dimension=${n}. DTCG 2025.10.`)}s(fn,"renderSpacingSet");function mn(e,n){return Q(e,`Apollion DS \u2014 font set. dimension=${n}. DTCG 2025.10.`)}s(mn,"renderFontSet");function gn(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]}],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: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(i,null,2)}
|
|
10
|
+
`}s(gn,"renderResolver");var ko="// Generated by apollion-tokens build \u2014 DO NOT EDIT. See apollion.config.mjs.";function Io(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} */`)}}s(Io,"emitDoc");function hn(e,n,o){let r=" ".repeat(n);for(let[t,i]of Object.entries(e))h(i)?(Io(i,r,o),o.push(`${r}${JSON.stringify(t)}: ${JSON.stringify(T(i.value))},`)):(o.push(`${r}${t}: {`),hn(i,n+1,o),o.push(`${r}},`))}s(hn,"emitGroup");function yn(e){let{brand:n,mode:o,surface:r,dimension:t}=e.meta,i=[ko,`// Variant: brand=${n} mode=${o} surface=${r} dimension=${t}`,"","export const tokens = {"];return hn(e.groups,1,i),i.push("} as const;","","export type Tokens = typeof tokens;",""),i.join(`
|
|
11
|
+
`)}s(yn,"renderTs");var xo=["light","dark"],So=["positive","negative"],vo=["compact","normal","spacious"];function ee(e){let n=e.modes??xo,o=e.surfaces??So,r=e.dimensions??vo,t=Object.entries(e.brands).sort(([a],[c])=>a.localeCompare(c)),i=[];for(let[a,c]of t)for(let l of n)for(let m of o)for(let b of r)i.push({brand:a,colors:c,mode:l,surface:m,dimension:b});return i}s(ee,"expandVariants");function bn(e){return`${e.brand}.${e.mode}.${e.surface}.${e.dimension}`}s(bn,"variantName");import{createHash as wo}from"node:crypto";function ne(e){return wo("sha256").update(e).digest("hex")}s(ne,"sha256");function Re(e){return ne(be(e))}s(Re,"hashConfig");function be(e){return e===null||typeof e!="object"?JSON.stringify(e):Array.isArray(e)?`[${e.map(be).join(",")}]`:`{${Object.keys(e).sort().map(r=>`${JSON.stringify(r)}:${be(e[r])}`).join(",")}}`}s(be,"stableStringify");function Rn(e){try{let{execSync:n}=Bn("node:child_process");return n("git rev-parse --short HEAD",{cwd:e,stdio:["ignore","pipe","ignore"],encoding:"utf8"}).trim()}catch{return""}}s(Rn,"detectGitCommit");function kn(){return{node:process.version,platform:`${process.platform}-${process.arch}`}}s(kn,"buildEnv");function In(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)}
|
|
12
|
+
`}s(In,"serializeManifest");var To="json/sets",xn="json/resolver.json";function oe(e){return`${To}/${e}.json`}s(oe,"setFile");function Do(e,n,o){return`${e}.color.${n}.${o}`}s(Do,"colorSetName");function $o(e){return`spacing.${e}`}s($o,"spacingSetName");function Co(e){return`font.${e}`}s(Co,"fontSetName");function re(e,n){e.includes(n)||e.push(n)}s(re,"pushUnique");function Sn(e){let n=ee(e),o=[],r=[],t=[],i=[],a=new Set,c=[],l=new Set,m=[],b=new Set,S=[];for(let d of n){re(o,d.brand),re(r,d.mode),re(t,d.surface),re(i,d.dimension);let u=Do(d.brand,d.mode,d.surface);a.has(u)||(a.add(u),c.push({kind:"color",name:u,file:oe(u),brand:d.brand,mode:d.mode,surface:d.surface}));let g=$o(d.dimension);l.has(g)||(l.add(g),m.push({kind:"spacing",name:g,file:oe(g),dimension:d.dimension}));let f=Co(d.dimension);b.has(f)||(b.add(f),S.push({kind:"font",name:f,file:oe(f),dimension:d.dimension}))}return{base:{kind:"base",name:"base",file:oe("base")},spacing:m,font:S,color:c,modifiers:{brand:o,mode:r,surface:t,dimension:i}}}s(Sn,"planSets");import{toDarkColors as Ho}from"@apollion-dsi/core/themes/colors";import{createFoundation as Gn}from"@apollion-dsi/core/themes/foundation";import{createSemantic as Wo}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as zo}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as Jo}from"@apollion-dsi/core/themes/surface";import{converter as $n,formatHex as G,interpolate as Vo,parse as x,wcagContrast as Cn}from"culori";var H=$n("oklch"),Lo=$n("rgb");function p(e,n,o){let r=x(e),t=x(n);if(!r||!t)return e;let i=Vo([r,t],"oklch");return G(i(o))??e}s(p,"mixOklch");function Ao(e){return e?typeof e=="string"?e:e.base:"#000"}s(Ao,"coerceToHex");var te=1.3,Mo=.05,vn=.04,L=s((e,n)=>{let o=x(e),r=x(n);return!o||!r?1:Cn(o,r)},"contrastRatio"),ke=s(e=>{let n=H(x(e));return n?n.l??0:null},"oklchLightness"),Eo=4.5;function B(e,n,o=Eo){let r=x(n),t=H(x(e));if(!r||!t)return e;let i=L("#fff",n)>=L("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=G(t)??e,l=x(c);if(l&&Cn(l,r)>=o)return c;let m=Math.min(1,Math.max(0,(t.l??0)+i));if(m===(t.l??0))break;t={...t,l:m}}return G(t)??e}s(B,"readableColor");var wn=s((e,n)=>{if(L(e,n)>=te)return!0;let o=ke(e),r=ke(n);return o!==null&&r!==null&&Math.abs(o-r)>=Mo},"isPerceptibleState"),Ie=s(e=>e?L("#fff",e)>L("#000",e):!1,"isDarkSurface");function Tn(e,n,o){let r=H(x(e));if(!r)return null;let t={...r,l:o??r.l??0},i=n?vn:-vn;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(t.l??0)+i));if(c===(t.l??0))break;t={...t,l:c};let l=G(t);if(l&&L(e,l)>=te)return l}return G(t)??null}s(Tn,"derivePerceptibleState");function Dn(e,n,o){let r=Tn(e,n,o);if(r&&L(e,r)>=te)return r;let t=Tn(e,!n);return t&&L(e,t)>=te?t:r??t}s(Dn,"perceptibleStateFor");function v(e,n){let o=typeof e=="object"&&e!==null?e:void 0,r=Ao(e),t=n.deepDark,i=n.deepLight,a={base:r,dark:p(r,t,.6),action:p(r,t,.2),active:p(r,i,.6),light:p(r,i,.9),onLight:r};if(x(r)){let c=Ie(n.baseLight),l=wn(r,a.action);if(l||(a.action=Dn(r,c)??a.action),!wn(r,a.active)){let m=l?void 0:ke(a.action)??void 0;a.active=Dn(r,c,m)??a.active}}if(a.onLight=B(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??B(c,l)}}return a}s(v,"mountSingleColor");function Vn(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)}}s(Vn,"mountGreyscaleColors");function Ln(e){let n=e.deepLight,o=e.deepDark,r=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=p(r,o,.5);return{0:p(i,n,t(18)),5:p(i,n,t(17.5)),10:p(i,n,t(17)),20:p(i,n,t(16)),30:p(i,n,t(15)),40:p(i,n,t(14)),50:p(i,n,t(13)),60:p(i,n,t(12)),70:p(i,n,t(11)),80:p(i,n,t(10)),90:p(i,n,t(9)),100:p(i,n,t(8)),110:p(i,n,t(7)),120:p(i,n,t(6)),130:p(i,n,t(5)),140:p(i,n,t(4)),150:p(i,n,t(3)),160:p(i,n,t(2)),170:i,180:p(i,o,.25)}}s(Ln,"mountNeutralColors");function F(e,n){let o=H(x(e));if(!o)return e;let r=Math.min(1,Math.max(0,(o.l??0)+n));return G({...o,l:r})??e}s(F,"shiftLightness");function ie(e,n){let o=H(x(e));if(!o)return e;let r=o.l??0,t=n.min??0,i=n.max??1;return r>=t&&r<=i?e:G({...o,l:Math.min(i,Math.max(t,r))})??e}s(ie,"clampLightness");function O(e,n){let o=Lo(x(e));if(!o)return e;let r=Math.min(1,Math.max(0,n)),t=s(i=>Math.round((i??0)*255),"channel");return`rgba(${t(o.r)}, ${t(o.g)}, ${t(o.b)}, ${r})`}s(O,"toRgbaString");import{apcaContrast as se,EDGE_ALPHA as xe,HALATION_FLOORS as we,INK_APCA_MIN as Se,INK_MIX as ve,LADDER_DELTAS as ae,MIN_CONTRAST_AA as An,WASH_ALPHA as Go}from"@apollion-dsi/core/themes/colors";var Oo="#FFFFFF",Te="#000000";function No(e){return Ie(e.baseLight)?"dark":"light"}s(No,"resolvePolarity");function Mn(e,n,o){if(Math.abs(se(e,n))>=o)return e;let r=Math.abs(se("#ffffff",n))>=Math.abs(se("#000000",n)),t=e;for(let i=0;i<40;i+=1){let a=F(t,r?.02:-.02);if(a===t||(t=a,Math.abs(se(t,n))>=o))break}return t}s(Mn,"ensureApca");function jo(e,n){let o=e.baseLight??Oo,r=n==="dark",t=r?ie(o,{min:we.CANVAS_MIN_L}):o,i=F(t,ae.sunken);return{canvas:t,sunken:r?ie(i,{min:we.CANVAS_MIN_L}):i,paper:F(t,ae.paper),raised:F(t,ae.raised),overlay:F(t,ae.overlay),scrim:r?e.deepLight??Te:e.neutral?.["180"]??e.baseDark??Te}}s(jo,"deriveSurface");function Fo(e,n){let o=e.baseDark??Te,r=ie(Mn(B(o,n.paper,An),n.paper,Se.primary),{max:we.INK_MAX_L}),t=s((i,a)=>Mn(B(p(r,n.canvas,i),n.paper,An),n.paper,a),"tier");return{primary:r,secondary:t(ve.secondary,Se.secondary),muted:t(ve.muted,Se.muted),disabled:p(r,n.canvas,ve.disabled)}}s(Fo,"deriveInk");function Po(e){return{hairline:O(e.primary,xe.hairline),border:O(e.primary,xe.border),strong:O(e.primary,xe.strong)}}s(Po,"deriveEdge");function _o(e,n){let o=Go[n];return{hover:O(e.primary,o.hover),pressed:O(e.primary,o.pressed),selected:O(e.primary,o.selected)}}s(_o,"deriveWash");function Bo(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}s(Bo,"applyOverride");function En(e,n){let o=No(e),r=jo(e,o),t=Fo(e,r),i={surface:r,ink:t,edge:Po(t),wash:_o(t,o)};return Bo(i,n?.[o])}s(En,"resolveSurfaceLadder");function qo(e){let n=Ln(e);return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:n,grayscale:Vn(e),...En({...e,neutral:n},e.ladder),main:v(e.main,e),opposite:v(e.opposite,e),complementary:v(e.complementary,e),danger:v(e.danger,e),information:v(e.information,e),success:v(e.success,e),warning:v(e.warning,e),primary:v(e.primary,e),secondary:v(e.secondary,e),tertiary:v(e.tertiary,e)}}s(qo,"composeColors");function A(e,n=zo){let o=e.mode==="dark"?Ho(e.colors):e.colors,r=qo(o),t=J(n,e.dimension),i=Wo({colors:r,spacing:t}),a=Gn(i);return e.surface==="negative"&&(a=Gn(Jo({semantic:i,colors:r},"negative").semantic)),{foundation:a,colors:r}}s(A,"buildVariantThemes");async function Tt(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=ee(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await Ko(W(Xo(),"apollion-tokens-"));try{let l=[],m=s(async(d,u)=>{await Yo(c,d,u),l.push({path:d,sha256:ne(u)}),t&&console.log(` \u2713 ${d}`)},"emit");if(a.json){let d=Sn(n),u=[],g=Xe();u.push(g),await m(d.base.file,un(g));for(let f of d.spacing){let R=i.find(z=>z.dimension===f.dimension),{foundation:$}=A(R),C=Qe($,f.dimension);u.push(C),await m(f.file,fn(C,f.dimension))}for(let f of d.font){let R=Ye(f.dimension);u.push(R),await m(f.file,mn(R,f.dimension))}for(let f of d.color){let R=i.find(ce=>ce.brand===f.brand&&ce.mode===f.mode&&ce.surface===f.surface),{foundation:$,colors:C}=A(R),z=Ze($,C);u.push(z),await m(f.file,pn(z,f.brand,f.mode,f.surface))}ze(u),await m(xn,gn(n,d))}if(a.css||a.ts)for(let d of i){let{foundation:u,colors:g}=A(d),f=j(u,g,d),R=bn(d);a.css&&await m(`css/${R}.css`,an(f,{rgbCompanions:a.tailwind})),a.ts&&await m(`ts/${R}.d.ts`,yn(f))}if(a.cssModes){let d=new Map;for(let u of i){let g=`${u.brand}.${u.surface}.${u.dimension}`,f=d.get(g)??{};f[u.mode]=u,d.set(g,f)}for(let[u,{light:g,dark:f}]of d){if(!g||!f)throw new Error(`apollion-tokens build: output.cssModes needs both modes for ${u} (config.modes)`);let R=A(g),$=A(f),C=cn(j(R.foundation,R.colors,g),j($.foundation,$.colors,f),{rgbCompanions:a.tailwind});await m(`css/${u}.modes.css`,C)}}if(a.tailwind){let d=i[0],{foundation:u,colors:g}=A(d),f=j(u,g,d);await m("tailwind/preset.mjs",rn(f)),await m("tailwind/tw-merge.mjs",tn(f))}if(a.designMd){let d=[...new Set(i.map(u=>u.brand))];for(let u of d){let f=i.filter(R=>R.brand===u).map(R=>{let{foundation:$,colors:C}=A(R);return j($,C,R)});await m(`design/${u}.design.md`,ln(u,f))}}let b={configHash:Re(n),files:l,gitCommit:Rn(r),buildEnv:kn()},S=In(b);return await Fn(W(c,"manifest.json"),S),await Nn(o,{recursive:!0,force:!0}),await jn(Pn(o),{recursive:!0}),await Uo(c,o),t&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:b,outDir:o}}catch(l){throw await Nn(c,{recursive:!0,force:!0}).catch(()=>{}),l}}s(Tt,"build");async function Dt(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await On(W(o,"manifest.json"),"utf8"))}catch{return!1}if(r.configHash!==Re(n))return!1;for(let t of r.files){let i;try{i=await On(W(o,t.path))}catch{return!1}if(ne(i)!==t.sha256)return!1}return!0}s(Dt,"check");async function Yo(e,n,o){let r=W(e,n);await jn(Pn(r),{recursive:!0}),await Fn(r,o)}s(Yo,"writeAt");export{Tt as build,Dt as check};
|
package/lib/cli.mjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var Wn=Object.defineProperty;var s=(e,n)=>Wn(e,"name",{value:n,configurable:!0}),Jn=(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 sr}from"node:fs/promises";import{resolve as Le}from"node:path";import{mkdir as jn,mkdtemp as Uo,readFile as En,rename as Ko,rm as Gn,writeFile as Pn}from"node:fs/promises";import{tmpdir as Xo}from"node:os";import{dirname as Nn,join as z}from"node:path";import{converter as uo,parse as po}from"culori";import{defaultInputBorder as X}from"@apollion-dsi/core/themes/border";import{createReadableTextLayer as qn}from"@apollion-dsi/core/themes/colors";import{createDeth as Un,levelValues as Kn}from"@apollion-dsi/core/themes/depth";import{createFont as Xn,defaultInputFont as M}from"@apollion-dsi/core/themes/font";import{defaultInputSpacing as Me}from"@apollion-dsi/core/themes/spacing";import{converter as Yn,formatHex as Zn,parse as Qn}from"culori";import{DIMENSION_MULTIPLIERS as zn}from"@apollion-dsi/core/themes/dimension";function U({multiplier:e=.25,alias:n},o){let r=o!==void 0?zn[o]:e;return(...t)=>t.map(i=>{let a=typeof i=="string"?n[i]:i;return`${r*a}rem`}).join(" ")}s(U,"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 ge(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.`)}s(ge,"assertTokenMetaResolves");var eo=Yn("oklch");function y(e){return typeof e.type=="string"&&"value"in e}s(y,"isToken");function x(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}s(x,"kebab");function Oe(e){return e.split(".").map(x).join(".")}s(Oe,"kebabPath");function G(e){return e.kind==="ref"?e.resolved.raw:e.raw}s(G,"rawValue");function K(e,n){return Number(e.toFixed(n))||0}s(K,"round");function me(e){let n=eo(Qn(e));if(!n)return{kind:"color",raw:e,components:[0,0,0],hex:"#000000"};let o=[K(n.l,4),K(n.c,4),K(n.h??0,2)],r=Zn(n)??"#000000";return n.alpha!==void 0&&n.alpha!==1?{kind:"color",raw:e,components:o,alpha:K(n.alpha,4),hex:r}:{kind:"color",raw:e,components:o,hex:r}}s(me,"toColorValue");var Ee=/^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/;function E(e){let n=Ee.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(E,"toDimensionValue");function I(e){return{type:"color",value:me(e)}}s(I,"colorToken");function O(e){let n={};for(let[o,r]of Object.entries(e))n[o]=I(r);return n}s(O,"recordColorGroup");function Ge(e){let n=qn(e),o={};for(let[r,t]of Object.entries(n.palettes))o[r]=I(t);return o.neutral=O(n.neutral),o}s(Ge,"buildReadableTextGroup");var no=["main","opposite","complementary","primary","secondary","tertiary","success","danger","warning","information"];function je(e){let n={};for(let o of no){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=O(e.grayscale),n.neutral=O(e.neutral),n.surface=O(e.surface),n.ink=O(e.ink),n.edge=O(e.edge),n.wash=O(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}s(je,"buildColorPrimitives");function Pe(e){let n=U(Me,e),o={};for(let r of Object.keys(Me.alias))o[r]={type:"dimension",value:E(n(r))};return o}s(Pe,"buildSpacePrimitives");function Ne(){let e={};for(let[n,o]of Object.entries(X.borderWidth))e[n]={type:"dimension",value:E(o)};return e}s(Ne,"buildBorderWidthPrimitives");function oo(e,n){return{color:je(e),space:Pe(n),borderWidth:Ne()}}s(oo,"buildPrimitives");var Fe={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"},_e={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"},Be={hairline:"color.edge.hairline",border:"color.edge.border",strong:"color.edge.strong"};function ro(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}s(ro,"lookupPrimitive");function F(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?ro(n,a):void 0;r[t]=a&&c===i?{type:"color",value:{kind:"ref",path:a,resolved:me(i)}}:I(i)}return r}s(F,"colorRefGroup");var He={xs:"space.xs",sm:"space.small",md:"space.medium",lg:"space.large",xl:"space.xl",xxl:"space.xxl"},to={none:"border-width.none",thin:"border-width.thin",regular:"border-width.regular",great:"border-width.great",bold:"border-width.bold"};function io(e,n){let o=n.split("."),r=o[0]==="border-width"?"borderWidth":o[0],t=e[r];for(let i of o.slice(1))if(t&&!y(t)&&i in t)t=t[i];else return;return t&&y(t)&&t.value.kind==="dimension"?t.value.raw:void 0}s(io,"lookupDimensionPrimitive");function he(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=o[t],c=a?io(n,a):void 0;r[t]=a&&c===i?{type:"dimension",value:{kind:"ref",path:a,resolved:E(i)}}:{type:"dimension",value:E(i)}}return r}s(he,"dimensionRefGroup");function We(e){let n={},o={};for(let[i,a]of Object.entries(X.borderRadius))Ee.test(a)?n[i]={type:"dimension",value:E(a)}:o[i]=a;let r=he(X.borderWidth,e,to),t={};for(let[i,a]of Object.entries(X.borderStyle))t[i]={type:"strokeStyle",value:{kind:"strokeStyle",raw:a,style:a}};return{group:{radius:n,width:r,style:t},extensions:o}}s(We,"buildBorder");function Je(e){let n=Xn(M,e),o={};for(let[c,l]of Object.entries(M.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:E(l)};let t={};for(let[c,l]of Object.entries(M.fontWeight))t[c]={type:"fontWeight",value:{kind:"fontWeight",raw:`${l}`,weight:l}};let i={};for(let[c,l]of Object.entries(M.lineHeight))i[c]={type:"number",value:{kind:"number",raw:`${l}`,number:l}};let a={letterSpacing:M.letterSpacing,textTransform:M.textTransform,fontStyle:M.fontStyle};return{group:{family:o,size:r,weight:t,lineHeight:i},extensions:a}}s(Je,"buildFont");var so=/rgba?\([^)]*\)|#[0-9a-fA-F]+|[a-zA-Z]+$/;function ao(e){let n=e.trim(),o=n.startsWith("inset");o&&(n=n.slice(5).trim());let r=n.match(so),t=r?r[0]:"#000000",a=(r?n.slice(0,r.index).trim():n).split(/\s+/).filter(Boolean),c=s(l=>E(a[l]??"0px"),"dim");return{kind:"shadow",raw:e,shadow:{color:me(t),offsetX:c(0),offsetY:c(1),blur:c(2),spread:c(3),inset:o}}}s(ao,"parseShadow");function ze(e){let n=Un(e),o={};for(let r of Object.keys(Kn))o[r]={type:"shadow",value:ao(n(r))};return o}s(ze,"buildShadow");function Y(e,n,o){let r={};for(let[t,i]of Object.entries(e)){let a=n?`${n}.${x(t)}`:x(t);if(y(i)){o.add(a);let c=fe[a];r[t]=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 r[t]=Y(i,a,o)}return r}s(Y,"decorateGroup");function co(e){let n=new Set,o=Y(e.primitives,"",n),r=Y(e.groups,"",n);return ge(n),{...e,primitives:o,groups:r}}s(co,"decorateMeta");function Z(e,n){return Y(e,"",n)}s(Z,"decorateSlice");function qe(e,n,o){for(let[r,t]of Object.entries(e)){let i=n?`${n}.${x(r)}`:x(r);y(t)?o.add(i):qe(t,i,o)}}s(qe,"collectPaths");function Ue(e){let n=new Set;for(let o of e)qe(o.groups,"",n);ge(n)}s(Ue,"assertSlicesMetaComplete");function Ke(){let e=Ne(),o=We({borderWidth:e}),r={};Object.keys(o.extensions).length>0&&(r["com.apollion.border"]={radius:o.extensions});let t=new Set;return{groups:Z({"border-width":e,border:o.group},t),extensions:r}}s(Ke,"buildBaseIR");function Xe(e){let n=Je(e),o=new Set;return{groups:Z({font:n.group},o),extensions:{"com.apollion.font":n.extensions}}}s(Xe,"buildFontIR");function Ye(e,n){let o=je(n),r=new Set;return{groups:Z({color:o,bg:F(e.bg,n,Fe),text:F(e.text,n,_e),edge:F(e.edge,n,Be),tx:Ge(n),shadow:ze(n)},r),extensions:{}}}s(Ye,"buildColorIR");function Ze(e,n){let o=Pe(n),r={space:o},t=new Set;return{groups:Z({space:o,spacing:he(e.spacing,r,He)},t),extensions:{}}}s(Ze,"buildSpacingIR");function lo(e,n,o){let r={brand:o.brand,mode:o.mode,surface:o.surface,dimension:o.dimension},t=oo(n,o.dimension),i=We(t),a=Je(o.dimension),c={"com.apollion.variant":r,"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: ${r.brand}/${r.mode}/${r.surface}/${r.dimension}.`,meta:r,primitives:t,groups:{bg:F(e.bg,n,Fe),text:F(e.text,n,_e),edge:F(e.edge,n,Be),tx:Ge(n),spacing:he(e.spacing,t,He),border:i.group,font:a.group,shadow:ze(n)},extensions:c};return co(l)}s(lo,"buildIR");var _=lo;var fo=uo("rgb"),Qe="// 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}s(ye,"colorPayload");function be(e){return e.alpha===void 0}s(be,"isOpaqueColor");function en(e){let n=fo(po(e.hex));if(!n)return"0 0 0";let o=s(r=>Math.min(255,Math.max(0,Math.round(r*255))),"channel");return`${o(n.r)} ${o(n.g)} ${o(n.b)}`}s(en,"rgbTriplet");function Q(e,n=[]){let o=new Map;for(let[r,t]of Object.entries(e)){let i=[...n,x(r)];if(y(t))o.set(i.join("-"),t);else for(let[a,c]of Q(t,i))o.set(a,c)}return o}s(Q,"flatTokens");function k(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:{}}s(k,"groupAt");function nn(e){let n=[];for(let o of["bg","text","edge","tx"])for(let[r,t]of Q(k(e.groups,o),[o])){let i=ye(t);i&&n.push({key:r,cssVar:`--apollion-${r}`,opaque:be(i)})}return n}s(nn,"colorEntries");function C(e,n){return[...Q(e)].map(([o])=>[o,`var(--apollion-${[...n,o].join("-")})`])}s(C,"varEntries");function A(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(" },")}}s(A,"pushScale");function on(e){let n=[Qe,"// Tailwind preset over the Apollion foundation tokens \u2014 requires dist/css/ vars in scope.","","const preset = {"," theme: {"," extend: {"],o=nn(e);n.push(" colors: {");for(let{key:r,cssVar:t,opaque:i}of o)i?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(" },"),A(n,"spacing",C(k(e.groups,"spacing"),["spacing"])),A(n,"borderRadius",C(k(e.groups,"border","radius"),["border","radius"])),A(n,"borderWidth",C(k(e.groups,"border","width"),["border","width"])),A(n,"fontFamily",C(k(e.groups,"font","family"),["font","family"])),A(n,"fontSize",C(k(e.groups,"font","size"),["font","size"])),A(n,"fontWeight",C(k(e.groups,"font","weight"),["font","weight"])),A(n,"lineHeight",C(k(e.groups,"font","lineHeight"),["font","line-height"])),A(n,"boxShadow",C(k(e.groups,"shadow"),["shadow"])),n.push(" },"," },","};","","export default preset;",""),n.join(`
|
|
3
|
-
`)}
|
|
4
|
-
`)}
|
|
5
|
-
`)}
|
|
6
|
-
`)}
|
|
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(`
|
|
7
7
|
`)}
|
|
8
8
|
${r.join(`
|
|
9
|
-
`)}`}
|
|
10
|
-
`}
|
|
11
|
-
`}
|
|
12
|
-
`)}
|
|
13
|
-
`}s(kn,"serializeManifest");var Do="json/sets",In="json/resolver.json";function ie(e){return`${Do}/${e}.json`}s(ie,"setFile");function $o(e,n,o){return`${e}.color.${n}.${o}`}s($o,"colorSetName");function To(e){return`spacing.${e}`}s(To,"spacingSetName");function Co(e){return`font.${e}`}s(Co,"fontSetName");function se(e,n){e.includes(n)||e.push(n)}s(se,"pushUnique");function xn(e){let n=re(e),o=[],r=[],t=[],i=[],a=new Set,c=[],l=new Set,f=[],b=new Set,w=[];for(let d of n){se(o,d.brand),se(r,d.mode),se(t,d.surface),se(i,d.dimension);let u=$o(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=To(d.dimension);l.has(h)||(l.add(h),f.push({kind:"spacing",name:h,file:ie(h),dimension:d.dimension}));let g=Co(d.dimension);b.has(g)||(b.add(g),w.push({kind:"font",name:g,file:ie(g),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:i}}}s(xn,"planSets");import{toDarkColors as Ho}from"@apollion-dsi/core/themes/colors";import{createFoundation as On}from"@apollion-dsi/core/themes/foundation";import{createSemantic as Wo}from"@apollion-dsi/core/themes/semantic";import{defaultInputSpacing as Jo}from"@apollion-dsi/core/themes/spacing";import{invertForSurface as zo}from"@apollion-dsi/core/themes/surface";import{converter as $n,formatHex as j,interpolate as Ao,parse as S,wcagContrast as Tn}from"culori";var J=$n("oklch"),Vo=$n("rgb");function p(e,n,o){let r=S(e),t=S(n);if(!r||!t)return e;let i=Ao([r,t],"oklch");return j(i(o))??e}s(p,"mixOklch");function Lo(e){return e?typeof e=="string"?e:e.base:"#000"}s(Lo,"coerceToHex");var ae=1.3,Mo=.05,Sn=.04,V=s((e,n)=>{let o=S(e),r=S(n);return!o||!r?1:Tn(o,r)},"contrastRatio"),we=s(e=>{let n=J(S(e));return n?n.l??0:null},"oklchLightness"),Oo=4.5;function W(e,n,o=Oo){let r=S(n),t=J(S(e));if(!r||!t)return e;let i=V("#fff",n)>=V("#000",n)?.04:-.04;for(let a=0;a<25;a+=1){let c=j(t)??e,l=S(c);if(l&&Tn(l,r)>=o)return c;let f=Math.min(1,Math.max(0,(t.l??0)+i));if(f===(t.l??0))break;t={...t,l:f}}return j(t)??e}s(W,"readableColor");var wn=s((e,n)=>{if(V(e,n)>=ae)return!0;let o=we(e),r=we(n);return o!==null&&r!==null&&Math.abs(o-r)>=Mo},"isPerceptibleState"),ve=s(e=>e?V("#fff",e)>V("#000",e):!1,"isDarkSurface");function vn(e,n,o){let r=J(S(e));if(!r)return null;let t={...r,l:o??r.l??0},i=n?Sn:-Sn;for(let a=0;a<25;a+=1){let c=Math.min(1,Math.max(0,(t.l??0)+i));if(c===(t.l??0))break;t={...t,l:c};let l=j(t);if(l&&V(e,l)>=ae)return l}return j(t)??null}s(vn,"derivePerceptibleState");function Dn(e,n,o){let r=vn(e,n,o);if(r&&V(e,r)>=ae)return r;let t=vn(e,!n);return t&&V(e,t)>=ae?t:r??t}s(Dn,"perceptibleStateFor");function D(e,n){let o=typeof e=="object"&&e!==null?e:void 0,r=Lo(e),t=n.deepDark,i=n.deepLight,a={base:r,dark:p(r,t,.6),action:p(r,t,.2),active:p(r,i,.6),light:p(r,i,.9),onLight:r};if(S(r)){let c=ve(n.baseLight),l=wn(r,a.action);if(l||(a.action=Dn(r,c)??a.action),!wn(r,a.active)){let f=l?void 0:we(a.action)??void 0;a.active=Dn(r,c,f)??a.active}}if(a.onLight=W(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??W(c,l)}}return a}s(D,"mountSingleColor");function Cn(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)}}s(Cn,"mountGreyscaleColors");function An(e){let n=e.deepLight,o=e.deepDark,r=typeof e.primary=="object"&&e.primary?e.primary.base:e.primary,t=s(a=>1/17*(a-1),"interpolation"),i=p(r,o,.5);return{0:p(i,n,t(18)),5:p(i,n,t(17.5)),10:p(i,n,t(17)),20:p(i,n,t(16)),30:p(i,n,t(15)),40:p(i,n,t(14)),50:p(i,n,t(13)),60:p(i,n,t(12)),70:p(i,n,t(11)),80:p(i,n,t(10)),90:p(i,n,t(9)),100:p(i,n,t(8)),110:p(i,n,t(7)),120:p(i,n,t(6)),130:p(i,n,t(5)),140:p(i,n,t(4)),150:p(i,n,t(3)),160:p(i,n,t(2)),170:i,180:p(i,o,.25)}}s(An,"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}s(B,"shiftLightness");function ce(e,n){let o=J(S(e));if(!o)return e;let r=o.l??0,t=n.min??0,i=n.max??1;return r>=t&&r<=i?e:j({...o,l:Math.min(i,Math.max(t,r))})??e}s(ce,"clampLightness");function P(e,n){let o=Vo(S(e));if(!o)return e;let r=Math.min(1,Math.max(0,n)),t=s(i=>Math.round((i??0)*255),"channel");return`rgba(${t(o.r)}, ${t(o.g)}, ${t(o.b)}, ${r})`}s(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 Vn,WASH_ALPHA as Eo}from"@apollion-dsi/core/themes/colors";var Go="#FFFFFF",Ae="#000000";function jo(e){return ve(e.baseLight)?"dark":"light"}s(jo,"resolvePolarity");function Ln(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 i=0;i<40;i+=1){let a=B(t,r?.02:-.02);if(a===t||(t=a,Math.abs(le(t,n))>=o))break}return t}s(Ln,"ensureApca");function Po(e,n){let o=e.baseLight??Go,r=n==="dark",t=r?ce(o,{min:Ce.CANVAS_MIN_L}):o,i=B(t,de.sunken);return{canvas:t,sunken:r?ce(i,{min:Ce.CANVAS_MIN_L}):i,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}}s(Po,"deriveSurface");function No(e,n){let o=e.baseDark??Ae,r=ce(Ln(W(o,n.paper,Vn),n.paper,$e.primary),{max:Ce.INK_MAX_L}),t=s((i,a)=>Ln(W(p(r,n.canvas,i),n.paper,Vn),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)}}s(No,"deriveInk");function Fo(e){return{hairline:P(e.primary,De.hairline),border:P(e.primary,De.border),strong:P(e.primary,De.strong)}}s(Fo,"deriveEdge");function _o(e,n){let o=Eo[n];return{hover:P(e.primary,o.hover),pressed:P(e.primary,o.pressed),selected:P(e.primary,o.selected)}}s(_o,"deriveWash");function Bo(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}s(Bo,"applyOverride");function Mn(e,n){let o=jo(e),r=Po(e,o),t=No(e,r),i={surface:r,ink:t,edge:Fo(t),wash:_o(t,o)};return Bo(i,n?.[o])}s(Mn,"resolveSurfaceLadder");function qo(e){let n=An(e);return{baseDark:e.baseDark,baseLight:e.baseLight,deepDark:e.deepDark,deepLight:e.deepLight,transparent:e.transparent??"transparent",neutral:n,grayscale:Cn(e),...Mn({...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)}}s(qo,"composeColors");function L(e,n=Jo){let o=e.mode==="dark"?Ho(e.colors):e.colors,r=qo(o),t=U(n,e.dimension),i=Wo({colors:r,spacing:t}),a=On(i);return e.surface==="negative"&&(a=On(zo({semantic:i,colors:r},"negative").semantic)),{foundation:a,colors:r}}s(L,"buildVariantThemes");async function Fn(e){let{config:n,outDir:o,cwd:r=process.cwd(),verbose:t=!1}=e,i=re(n),a=n.output??{};if(i.length===0)throw new Error("apollion-tokens build: no variants (config.brands is empty)");let c=await Uo(z(Xo(),"apollion-tokens-"));try{let l=[],f=s(async(d,u)=>{await Yo(c,d,u),l.push({path:d,sha256:te(u)}),t&&console.log(` \u2713 ${d}`)},"emit");if(a.json){let d=xn(n),u=[],h=Ke();u.push(h),await f(d.base.file,dn(h));for(let g of d.spacing){let R=i.find(q=>q.dimension===g.dimension),{foundation:$}=L(R),T=Ze($,g.dimension);u.push(T),await f(g.file,pn(T,g.dimension))}for(let g of d.font){let R=Xe(g.dimension);u.push(R),await f(g.file,fn(R,g.dimension))}for(let g of d.color){let R=i.find(pe=>pe.brand===g.brand&&pe.mode===g.mode&&pe.surface===g.surface),{foundation:$,colors:T}=L(R),q=Ye($,T);u.push(q),await f(g.file,un(q,g.brand,g.mode,g.surface))}Ue(u),await f(In,gn(n,d))}if(a.css||a.ts)for(let d of i){let{foundation:u,colors:h}=L(d),g=_(u,h,d),R=yn(d);a.css&&await f(`css/${R}.css`,sn(g,{rgbCompanions:a.tailwind})),a.ts&&await f(`ts/${R}.d.ts`,hn(g))}if(a.cssModes){let d=new Map;for(let u of i){let h=`${u.brand}.${u.surface}.${u.dimension}`,g=d.get(h)??{};g[u.mode]=u,d.set(h,g)}for(let[u,{light:h,dark:g}]of d){if(!h||!g)throw new Error(`apollion-tokens build: output.cssModes needs both modes for ${u} (config.modes)`);let R=L(h),$=L(g),T=an(_(R.foundation,R.colors,h),_($.foundation,$.colors,g),{rgbCompanions:a.tailwind});await f(`css/${u}.modes.css`,T)}}if(a.tailwind){let d=i[0],{foundation:u,colors:h}=L(d),g=_(u,h,d);await f("tailwind/preset.mjs",on(g)),await f("tailwind/tw-merge.mjs",rn(g))}if(a.designMd){let d=[...new Set(i.map(u=>u.brand))];for(let u of d){let g=i.filter(R=>R.brand===u).map(R=>{let{foundation:$,colors:T}=L(R);return _($,T,R)});await f(`design/${u}.design.md`,cn(u,g))}}let b={configHash:Se(n),files:l,gitCommit:bn(r),buildEnv:Rn()},w=kn(b);return await Pn(z(c,"manifest.json"),w),await Gn(o,{recursive:!0,force:!0}),await jn(Nn(o),{recursive:!0}),await Ko(c,o),t&&console.log(`\u2713 ${l.length} files \u2192 ${o}`),{manifest:b,outDir:o}}catch(l){throw await Gn(c,{recursive:!0,force:!0}).catch(()=>{}),l}}s(Fn,"build");async function _n(e){let{config:n,outDir:o}=e,r;try{r=JSON.parse(await En(z(o,"manifest.json"),"utf8"))}catch{return!1}if(r.configHash!==Se(n))return!1;for(let t of r.files){let i;try{i=await En(z(o,t.path))}catch{return!1}if(te(i)!==t.sha256)return!1}return!0}s(_n,"check");async function Yo(e,n,o){let r=z(e,n);await jn(Nn(r),{recursive:!0}),await Pn(r,o)}s(Yo,"writeAt");import{readFile as Qo}from"node:fs/promises";import{resolve as er}from"node:path";import{createContext as nr,Script as or}from"node:vm";import{z as m}from"zod";var v=m.string().regex(/^#([0-9a-fA-F]{3}){1,2}$|^transparent$|^rgb\(.*\)$|^oklch\(.*\)$/,{message:'Must be hex, rgb(), oklch(), or "transparent"'}),Zo=m.object({baseDark:m.string().optional(),baseLight:m.string().optional(),deepDark:v,deepLight:v,transparent:m.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(),Bn=m.object({brands:m.record(m.string(),Zo).refine(e=>Object.keys(e).length>0,{message:"apollion.config.mjs: brands must contain at least 1 entry"}),modes:m.array(m.enum(["light","dark"])).optional(),surfaces:m.array(m.enum(["positive","negative"])).optional(),dimensions:m.array(m.enum(["compact","normal","spacious"])).optional(),output:m.object({runtime:m.boolean().optional(),css:m.boolean().optional(),json:m.boolean().optional(),ts:m.boolean().optional(),designMd:m.boolean().optional(),tailwind:m.boolean().optional(),cssModes:m.boolean().optional()}).passthrough().optional()}).passthrough();var rr=[/\brequire\s*\(/,/\bimport\s*\(/,/^\s*import\s+/m],tr=1e3;var Ve=class Ve extends Error{constructor(o,r){super(o);this.configPath=r;this.name="ConfigLoadError"}};s(Ve,"ConfigLoadError");var N=Ve;async function Hn(e){let n=er(e.configPath),o=await Qo(n,"utf8");for(let l of rr)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:ir(),Symbol,Number,String,Boolean,Array,Object,JSON,Math,defineConfig:s(l=>l,"defineConfig")},i=nr(t);try{new or(r,{filename:n}).runInContext(i,{timeout:tr})}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=Bn.safeParse(a);if(!c.success){let l=c.error.issues.map(f=>` ${f.path.join(".")||"(root)"}: ${f.message}`).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
14
|
`);throw new N(`apollion.config: schema validation failed \u2014
|
|
15
|
-
${l}`,n)}return c.data}
|
|
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)});
|
package/package.json
CHANGED
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout builder — **Strangler Fig duplicate** of
|
|
3
|
+
* `@apollion-dsi/core/themes/layout` (ADR-025 invariant 5).
|
|
4
|
+
*
|
|
5
|
+
* Mirrors the container-size scale (the `cq` channel thresholds — px, slot
|
|
6
|
+
* widths, NOT viewport breakpoints) and the page-layout constants
|
|
7
|
+
* (`pageMaxWidth`). Axis-invariant.
|
|
8
|
+
*
|
|
9
|
+
* @see ./colors.ts (Strangler Fig contract notes)
|
|
10
|
+
*/
|
|
11
|
+
import type { ContainerSizesInput, LayoutInput } from '@apollion-dsi/core/themes/layout';
|
|
12
|
+
import { defaultInputContainerSizes, defaultInputLayout } from '@apollion-dsi/core/themes/layout';
|
|
13
|
+
|
|
14
|
+
/** Resolved `[key, '<value>px']` pairs of the container-size scale, ascending. */
|
|
15
|
+
export function containerSizeEntries(
|
|
16
|
+
input: ContainerSizesInput = defaultInputContainerSizes,
|
|
17
|
+
): ReadonlyArray<readonly [string, string]> {
|
|
18
|
+
return Object.entries(input.values).map(([key, value]) => [key, `${value}px`] as const);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Resolved `[key, '<value>px']` pairs of the page-layout constants. */
|
|
22
|
+
export function layoutEntries(input: LayoutInput = defaultInputLayout): ReadonlyArray<readonly [string, string]> {
|
|
23
|
+
return [['page-max-width', `${input.pageMaxWidth}px`] as const];
|
|
24
|
+
}
|
package/src/ir.ts
CHANGED
|
@@ -38,6 +38,8 @@ import type { SpacingAlias } from '@apollion-dsi/core/themes/spacing';
|
|
|
38
38
|
import { defaultInputSpacing } from '@apollion-dsi/core/themes/spacing';
|
|
39
39
|
import { converter, formatHex, parse } from 'culori';
|
|
40
40
|
|
|
41
|
+
import { breakpointEntries } from './builders/breakpoints';
|
|
42
|
+
import { containerSizeEntries, layoutEntries } from './builders/layout';
|
|
41
43
|
import { createSpacing } from './builders/spacing';
|
|
42
44
|
import type { Variant } from './config-schema';
|
|
43
45
|
import type { ColorsThemeInterface } from './theme-factory';
|
|
@@ -661,10 +663,52 @@ export function assertSlicesMetaComplete(slices: readonly IRSlice[]): void {
|
|
|
661
663
|
}
|
|
662
664
|
|
|
663
665
|
/**
|
|
664
|
-
*
|
|
665
|
-
*
|
|
666
|
-
*
|
|
667
|
-
*
|
|
666
|
+
* Viewport breakpoint scale (APOLLION-BREAKPOINT-TOKENS) — axis-invariant,
|
|
667
|
+
* px by contract, half-open `[value, next)` bands over `min-width` sets.
|
|
668
|
+
* Values mirror `@apollion-dsi/core/themes/breakpoints` via the Strangler Fig
|
|
669
|
+
* builder; the parity suite pins the mirror.
|
|
670
|
+
*
|
|
671
|
+
* CSS emission (`--apollion-breakpoint-*`) is **informational only**: `var()`
|
|
672
|
+
* is invalid inside a `@media` prelude, so those custom properties serve JS
|
|
673
|
+
* `getComputedStyle` readers, never media queries. Query-capable surfaces are
|
|
674
|
+
* the TS record and the Tailwind `screens` scale (literal px).
|
|
675
|
+
*/
|
|
676
|
+
function buildBreakpoints(): IRGroup {
|
|
677
|
+
const out: Record<string, IRToken> = {};
|
|
678
|
+
for (const [key, px] of breakpointEntries()) out[key] = { type: 'dimension', value: toDimensionValue(px) };
|
|
679
|
+
return out;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Container-size scale + page-layout constants (ADR-025 invariant 5) —
|
|
684
|
+
* axis-invariant mirrors of `theme.containerSizes` / `theme.layout`.
|
|
685
|
+
* `container-size.*` are the `cq` channel thresholds (slot widths, a
|
|
686
|
+
* deliberately separate scale from `breakpoint.*`).
|
|
687
|
+
*/
|
|
688
|
+
function buildContainerSizes(): IRGroup {
|
|
689
|
+
const out: Record<string, IRToken> = {};
|
|
690
|
+
for (const [key, px] of containerSizeEntries()) out[key] = { type: 'dimension', value: toDimensionValue(px) };
|
|
691
|
+
return out;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
function buildLayoutConstants(): IRGroup {
|
|
695
|
+
const out: Record<string, IRToken> = {};
|
|
696
|
+
for (const [key, px] of layoutEntries()) out[key] = { type: 'dimension', value: toDimensionValue(px) };
|
|
697
|
+
return out;
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
/** `$extensions` payload documenting the breakpoint interval contract. */
|
|
701
|
+
const BREAKPOINT_EXTENSION = {
|
|
702
|
+
unit: 'px',
|
|
703
|
+
interval: 'half-open [value, next) — min-width sets, ascending',
|
|
704
|
+
cssVarsUsage: 'informational only — var() is invalid inside a @media prelude',
|
|
705
|
+
} as const;
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* Axis-invariant base slice: border (radius/width/style) + the viewport
|
|
709
|
+
* `breakpoint.*` scale. `border.width` references the `border-width.*`
|
|
710
|
+
* primitives, which travel WITH this slice (`border-width` namespace) so the
|
|
711
|
+
* set is reference-closed. Identical for every brand/mode/surface/dimension.
|
|
668
712
|
*
|
|
669
713
|
* **ADR-011:** font left the base set — its `size` scale is now density-aware,
|
|
670
714
|
* so it lives in per-dimension `font.<dimension>` sets ({@link buildFontIR}),
|
|
@@ -675,13 +719,22 @@ export function buildBaseIR(): IRSlice {
|
|
|
675
719
|
const primitives: IRGroup = { borderWidth };
|
|
676
720
|
const border = buildBorder(primitives);
|
|
677
721
|
|
|
678
|
-
const extensions: Record<string, unknown> = {};
|
|
722
|
+
const extensions: Record<string, unknown> = { 'com.apollion.breakpoint': BREAKPOINT_EXTENSION };
|
|
679
723
|
if (Object.keys(border.extensions).length > 0) {
|
|
680
724
|
extensions['com.apollion.border'] = { radius: border.extensions };
|
|
681
725
|
}
|
|
682
726
|
|
|
683
727
|
const seen = new Set<string>();
|
|
684
|
-
const groups = decorateSlice(
|
|
728
|
+
const groups = decorateSlice(
|
|
729
|
+
{
|
|
730
|
+
'border-width': borderWidth,
|
|
731
|
+
border: border.group,
|
|
732
|
+
breakpoint: buildBreakpoints(),
|
|
733
|
+
'container-size': buildContainerSizes(),
|
|
734
|
+
layout: buildLayoutConstants(),
|
|
735
|
+
},
|
|
736
|
+
seen,
|
|
737
|
+
);
|
|
685
738
|
return { groups, extensions };
|
|
686
739
|
}
|
|
687
740
|
|
|
@@ -759,7 +812,11 @@ export function buildIR(foundation: FoundationLayer, colors: ColorsThemeInterfac
|
|
|
759
812
|
const border = buildBorder(primitives);
|
|
760
813
|
const font = buildFont(variant.dimension);
|
|
761
814
|
|
|
762
|
-
const extensions: Record<string, unknown> = {
|
|
815
|
+
const extensions: Record<string, unknown> = {
|
|
816
|
+
'com.apollion.variant': meta,
|
|
817
|
+
'com.apollion.font': font.extensions,
|
|
818
|
+
'com.apollion.breakpoint': BREAKPOINT_EXTENSION,
|
|
819
|
+
};
|
|
763
820
|
if (Object.keys(border.extensions).length > 0) {
|
|
764
821
|
extensions['com.apollion.border'] = { radius: border.extensions };
|
|
765
822
|
}
|
|
@@ -775,6 +832,9 @@ export function buildIR(foundation: FoundationLayer, colors: ColorsThemeInterfac
|
|
|
775
832
|
tx: buildReadableTextGroup(colors),
|
|
776
833
|
spacing: dimensionRefGroup(foundation.spacing as unknown as Record<string, string>, primitives, SPACE_REF),
|
|
777
834
|
border: border.group,
|
|
835
|
+
breakpoint: buildBreakpoints(),
|
|
836
|
+
'container-size': buildContainerSizes(),
|
|
837
|
+
layout: buildLayoutConstants(),
|
|
778
838
|
font: font.group,
|
|
779
839
|
shadow: buildShadow(colors),
|
|
780
840
|
},
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
import { converter, parse } from 'culori';
|
|
31
31
|
|
|
32
32
|
import type { IRColorValue, IRDocument, IRGroup, IRToken } from '../ir';
|
|
33
|
-
import { isToken, kebab } from '../ir';
|
|
33
|
+
import { isToken, kebab, rawValue } from '../ir';
|
|
34
34
|
|
|
35
35
|
const toRgb = converter('rgb');
|
|
36
36
|
|
|
@@ -145,6 +145,17 @@ export function renderTailwindPreset(ir: IRDocument): string {
|
|
|
145
145
|
}
|
|
146
146
|
out.push(' },');
|
|
147
147
|
|
|
148
|
+
// `screens` takes LITERAL px, never `var()` — custom properties are invalid
|
|
149
|
+
// inside a `@media` prelude. `xs` (0) is the unprefixed base band, omitted by
|
|
150
|
+
// Tailwind convention. APOLLION-BREAKPOINT-TOKENS.
|
|
151
|
+
pushScale(
|
|
152
|
+
out,
|
|
153
|
+
'screens',
|
|
154
|
+
[...flatTokens(groupAt(ir.groups, 'breakpoint'))]
|
|
155
|
+
.filter(([key]) => key !== 'xs')
|
|
156
|
+
.map(([key, token]) => [key, rawValue(token.value)] as const),
|
|
157
|
+
);
|
|
158
|
+
|
|
148
159
|
pushScale(out, 'spacing', varEntries(groupAt(ir.groups, 'spacing'), ['spacing']));
|
|
149
160
|
pushScale(out, 'borderRadius', varEntries(groupAt(ir.groups, 'border', 'radius'), ['border', 'radius']));
|
|
150
161
|
pushScale(out, 'borderWidth', varEntries(groupAt(ir.groups, 'border', 'width'), ['border', 'width']));
|