@taprootio/espalier 4.6.0 → 4.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/fonts/font-fallback-profiles.json +1 -1
- package/custom-elements.json +2789 -2190
- package/dist/header/esp-header.d.ts +4 -1
- package/dist/header/esp-header.js +56 -11
- package/dist/menu/esp-menu-group.d.ts +7 -0
- package/dist/menu/esp-menu-group.js +46 -11
- package/dist/menu/esp-menu-item.d.ts +7 -0
- package/dist/menu/esp-menu-item.js +49 -9
- package/dist/menu/esp-menu.d.ts +74 -0
- package/dist/menu/esp-menu.js +179 -18
- package/dist/menu/swipe-reveal-controller.js +1 -1
- package/dist/root/esp-root.d.ts +2 -0
- package/dist/root/esp-root.js +2 -2
- package/dist/root/helpers/compute-theme-properties.js +1 -1
- package/dist/shared/configured-brand.d.ts +33 -0
- package/dist/shared/events.d.ts +2 -0
- package/dist/shared/events.js +1 -1
- package/dist/shared/font-helpers.js +1 -1
- package/dist/shared/font-plan.d.ts +13 -3
- package/dist/shared/font-plan.js +5 -5
- package/dist/shared/overlay-controller.js +1 -1
- package/dist/shared/theme-properties.d.ts +42 -0
- package/dist/shared/theme-properties.js +1 -0
- package/dist/shared/theme.d.ts +18 -0
- package/dist/shared/theme.js +1 -1
- package/espalier.css-data.json +52 -0
- package/espalier.token-manifest.json +76 -0
- package/package.json +9 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
const m={100:"100 Thin",200:"200 Extra Light",300:"300 Light",400:"400 Regular",500:"500 Medium",600:"600 Semi Bold",700:"700 Bold",800:"800 Extra Bold",900:"900 Black"};function d(e){if(!e)return["400"];const t=new Set;for(const r of e.variants)r.includes("italic")||t.add(r==="regular"?"400":r);const n=[...t].sort((r,o)=>Number(r)-Number(o));return n.length>0?n:["400"]}function h(e,t){return e?e==="bold"?"700":e==="normal"?"400":e:t}function u(e,t){const n=e===void 0||e===""?t:e;if(n===void 0)return null;if(typeof n=="number")return Number.isInteger(n)&&n>=1&&n<=1e3?n:null;const r=n.trim().toLowerCase();if(r==="normal")return 400;if(r==="bold")return 700;if(!/^\d{1,4}$/.test(r))return null;const o=Number(r);return Number.isInteger(o)&&o>=1&&o<=1e3?o:null}function g(e,t){if(t.length===0)return"400";if(t.includes(e))return e;const n=Number(e);let r=t[0],o=Math.abs(Number(r)-n);for(const s of t){const i=Math.abs(Number(s)-n);i<o&&(r=s,o=i)}return r}function p(e){let t="",n="",r=!1,o=0;for(const i of e.trim()){if(r){t+=i,r=!1;continue}if(i==="\\"){t+=i,r=!0;continue}if(n){t+=i,i===n&&(n="");continue}if(i==='"'||i==="'"){t+=i,n=i;continue}if(i==="("&&(o+=1),i===")"&&(o=Math.max(0,o-1)),i===","&&o===0)break;t+=i}const s=t.trim();return s.length>=2&&(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))?s.slice(1,-1).replace(/\\([\\"'])/g,"$1"):s}const l=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","fangsong","-apple-system","blinkmacsystemfont","arial","helvetica","helvetica neue","liberation sans","verdana","tahoma","trebuchet ms","georgia","times new roman","courier new","segoe ui"].map(e=>e.toLowerCase()));function b(e){return l.has(e.trim().toLowerCase())}function x(e){switch(e){case"serif":return"serif";case"monospace":return"monospace";case"handwriting":return"cursive";default:return"sans-serif"}}const a="data-esp-google-font-owner";function f(e,t){const n=u(t,400)??400,r=n!==400?`:wght@${n}`:"";return`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}${r}&display=swap`}function c(e){return document.head.querySelector(`link[${a}="${CSS.escape(e)}"]`)}function y(e){const t=c(e.owner),n=e.family.trim(),r=String(u(e.weight,400)??400);if(e.enabled===!1||!n)return t?.remove(),null;if(t?.dataset.espFamily===n&&t.dataset.espWeight===r)return t;t?.remove();const o=document.createElement("link");o.rel="stylesheet",o.href=f(n,r),o.setAttribute(a,e.owner),o.dataset.espFamily=n,o.dataset.espWeight=r;for(const[s,i]of Object.entries(e.attributes??{}))o.setAttribute(s,i);return document.head.appendChild(o),o}function F(e){c(e)?.remove()}function L(e){for(const t of document.head.querySelectorAll(`link[${a}]`))t.getAttribute(a)?.startsWith(e)&&t.remove()}export{a as RUNTIME_GOOGLE_FONT_OWNER_ATTR,m as WEIGHT_LABELS,g as bestAvailableWeight,p as extractFamily,d as extractWeights,x as getFallbackFont,f as googleFontStylesheetUrl,b as isLocalFontFamily,u as normalizeFontFaceWeight,h as normalizeWeight,F as removeRuntimeGoogleFontLink,L as removeRuntimeGoogleFontLinks,y as syncRuntimeGoogleFontLink};
|
|
1
|
+
const m={100:"100 Thin",200:"200 Extra Light",300:"300 Light",400:"400 Regular",500:"500 Medium",600:"600 Semi Bold",700:"700 Bold",800:"800 Extra Bold",900:"900 Black"};function d(e){if(!e)return["400"];const t=new Set;for(const r of e.variants)r.includes("italic")||t.add(r==="regular"?"400":r);const n=[...t].sort((r,o)=>Number(r)-Number(o));return n.length>0?n:["400"]}function h(e,t){return e?e==="bold"?"700":e==="normal"?"400":e:t}function u(e,t){const n=e===void 0||e===""?t:e;if(n===void 0)return null;if(typeof n=="number")return Number.isInteger(n)&&n>=1&&n<=1e3?n:null;const r=n.trim().toLowerCase();if(r==="normal")return 400;if(r==="bold")return 700;if(!/^\d{1,4}$/.test(r))return null;const o=Number(r);return Number.isInteger(o)&&o>=1&&o<=1e3?o:null}function g(e,t){if(t.length===0)return"400";if(t.includes(e))return e;const n=Number(e);let r=t[0],o=Math.abs(Number(r)-n);for(const s of t){const i=Math.abs(Number(s)-n);i<o&&(r=s,o=i)}return r}function p(e){let t="",n="",r=!1,o=0;for(const i of e.trim()){if(r){t+=i,r=!1;continue}if(i==="\\"){t+=i,r=!0;continue}if(n){t+=i,i===n&&(n="");continue}if(i==='"'||i==="'"){t+=i,n=i;continue}if(i==="("&&(o+=1),i===")"&&(o=Math.max(0,o-1)),i===","&&o===0)break;t+=i}const s=t.trim();return s.length>=2&&(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'"))?s.slice(1,-1).replace(/\\([\\"'])/g,"$1"):s}const l=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","fangsong","-apple-system","blinkmacsystemfont","arial","helvetica","helvetica neue","liberation sans","liberation serif","liberation mono","verdana","tahoma","trebuchet ms","georgia","times new roman","courier new","segoe ui"].map(e=>e.toLowerCase()));function b(e){return l.has(e.trim().toLowerCase())}function x(e){switch(e){case"serif":return"serif";case"monospace":return"monospace";case"handwriting":return"cursive";default:return"sans-serif"}}const a="data-esp-google-font-owner";function f(e,t){const n=u(t,400)??400,r=n!==400?`:wght@${n}`:"";return`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}${r}&display=swap`}function c(e){return document.head.querySelector(`link[${a}="${CSS.escape(e)}"]`)}function y(e){const t=c(e.owner),n=e.family.trim(),r=String(u(e.weight,400)??400);if(e.enabled===!1||!n)return t?.remove(),null;if(t?.dataset.espFamily===n&&t.dataset.espWeight===r)return t;t?.remove();const o=document.createElement("link");o.rel="stylesheet",o.href=f(n,r),o.setAttribute(a,e.owner),o.dataset.espFamily=n,o.dataset.espWeight=r;for(const[s,i]of Object.entries(e.attributes??{}))o.setAttribute(s,i);return document.head.appendChild(o),o}function F(e){c(e)?.remove()}function L(e){for(const t of document.head.querySelectorAll(`link[${a}]`))t.getAttribute(a)?.startsWith(e)&&t.remove()}export{a as RUNTIME_GOOGLE_FONT_OWNER_ATTR,m as WEIGHT_LABELS,g as bestAvailableWeight,p as extractFamily,d as extractWeights,x as getFallbackFont,f as googleFontStylesheetUrl,b as isLocalFontFamily,u as normalizeFontFaceWeight,h as normalizeWeight,F as removeRuntimeGoogleFontLink,L as removeRuntimeGoogleFontLinks,y as syncRuntimeGoogleFontLink};
|
|
@@ -6,8 +6,18 @@
|
|
|
6
6
|
* resulting CSS in the document head before `<esp-root>` can paint.
|
|
7
7
|
*/
|
|
8
8
|
import type { EspalierTheme } from "./theme.js";
|
|
9
|
-
export type FontPlanTheme = Pick<EspalierTheme, "fontBody" | "fontHeadings" | "fontBrand" | "fontMonospace" | "fontWeightBody" | "fontWeightHeadings" | "fontWeightBrand" | "fontWeightMonospace">;
|
|
10
|
-
export type FontPlanSlot = "body" | "headings" | "brand" | "monospace";
|
|
9
|
+
export type FontPlanTheme = Pick<EspalierTheme, "fontBody" | "fontHeadings" | "fontBrand" | "fontMenu" | "fontMonospace" | "fontWeightBody" | "fontWeightHeadings" | "fontWeightBrand" | "fontWeightMenu" | "fontWeightMonospace">;
|
|
10
|
+
export type FontPlanSlot = "body" | "headings" | "brand" | "menu" | "monospace";
|
|
11
|
+
/**
|
|
12
|
+
* Per-scheme effective stacks. The `menu` slot is present only when the
|
|
13
|
+
* theme configures `fontMenu`: an unset menu font resolves to the body slot
|
|
14
|
+
* at use time, so planning it separately would request the body family at
|
|
15
|
+
* the menu weight for every site and change compiled output that had no
|
|
16
|
+
* menu font at all.
|
|
17
|
+
*/
|
|
18
|
+
export type FontPlanStacks = Record<Exclude<FontPlanSlot, "menu">, string> & {
|
|
19
|
+
menu?: string;
|
|
20
|
+
};
|
|
11
21
|
export type FontPlanScheme = "light" | "dark";
|
|
12
22
|
export type FontPlanStyle = "normal" | "italic";
|
|
13
23
|
export type FontFaceRequest = {
|
|
@@ -68,7 +78,7 @@ export type CompiledFontPlan = {
|
|
|
68
78
|
/** Catalog families that lacked the requested weight/style profile. */
|
|
69
79
|
missingProfiles: FontPlanProfileMiss[];
|
|
70
80
|
/** Scheme/slot stacks represented by the emitted private effective tokens. */
|
|
71
|
-
effectiveStacks: Record<FontPlanScheme,
|
|
81
|
+
effectiveStacks: Record<FontPlanScheme, FontPlanStacks>;
|
|
72
82
|
/** UTF-8 byte size of `css`, convenient for static-site budget checks. */
|
|
73
83
|
byteLength: number;
|
|
74
84
|
};
|
package/dist/shared/font-plan.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{extractFamily as R,normalizeFontFaceWeight as
|
|
2
|
-
${
|
|
3
|
-
normal`,
|
|
4
|
-
${
|
|
5
|
-
${
|
|
1
|
+
import{extractFamily as R,normalizeFontFaceWeight as U}from"./font-helpers.js";const N="U+0000-024F,U+1E00-1EFF,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD",b=["body","headings","brand","menu","monospace"],W={"sans-serif":[0,1],display:[0,1],handwriting:[0,1],"not-display":[0,1],serif:[2],monospace:[3]};function E(t){let e="";for(const n of t){const s=n.codePointAt(0)??0;n==="\\"?e+="\\\\":n==='"'?e+='\\"':n==="<"?e+="\\3c ":s<=31||s===127?e+=`\\${s.toString(16)} `:e+=n}return`"${e}"`}function z(t){return`url(${E(t)}) format("woff2")`}function x(t){for(const o of t){const $=o.codePointAt(0)??0;if(o===";"||o==="{"||o==="}"||o==="<"||$<=31||$===127)throw new Error("Font stack contains characters that cannot be embedded in inline CSS")}if(t.includes("/*")||t.includes("*/"))throw new Error("Font stack contains characters that cannot be embedded in inline CSS");const e=[];let n="",s="",i=!1,a=0;for(const o of t){if(i){n+=o,i=!1;continue}if(o==="\\"){n+=o,i=!0;continue}if(s){n+=o,o===s&&(s="");continue}if(o==='"'||o==="'"){n+=o,s=o;continue}if(o==="("&&(a+=1),o===")"&&(a=Math.max(0,a-1)),o===","&&a===0){n.trim()&&e.push(n.trim()),n="";continue}n+=o}if(i||s||a!==0)throw new Error("Font stack contains an unterminated escape, quote, or function");return n.trim()&&e.push(n.trim()),e}function I(t){return U(t)}function _(t,e){return`${t}${e==="italic"?"i":""}`}function q(t,e,n="normal"){return`${encodeURIComponent(t)}~${e}~${n==="italic"?"i":"n"}`}function j(t,e){return t.family.localeCompare(e.family,"en")||t.weight-e.weight||t.style.localeCompare(e.style,"en")}function C(t,e){let n=2166136261;for(const s of`${t}:${e}`)n^=s.charCodeAt(0),n=Math.imul(n,16777619);return`ef${(n>>>0).toString(36)}`}function B(t){return W[t]??[]}function J(t,e,n,s="normal"){const i=U(e);if(!t.trim()||i===null)return[];const a=q(t.trim(),i,s);return B(n).map(o=>C(a,o))}function O(t,e){if(!Number.isInteger(t)||t<0||!Number.isInteger(e)||e<=0)throw new Error("Font fallback catalog contains an invalid encoded percentage");const n=Math.floor(t/e),s=String(t%e).padStart(String(e).length-1,"0").replace(/0+$/,"");return`${n}${s?`.${s}`:""}%`}function F(t,e,n,s){n!==null&&t.push(`${e}:${O(n,s)};`)}function P(t,e){const n=x(t);return n.length===0||e.length===0?t:[n[0],...e,...n.slice(1)].join(",")}function T(t){const e=t.fontBody,n=t.fontHeadings||e,s=t.fontBrand||n,i=t.fontMonospace,a={body:[e,t.fontWeightBody],headings:[n,t.fontWeightHeadings],brand:[s,t.fontWeightBrand],monospace:[i,t.fontWeightMonospace]};return t.fontMenu&&(a.menu=[t.fontMenu,t.fontWeightMenu]),a}function M(t,e,n,s,i){const a={},o={},$=T(e);for(const f of b){const u=$[f];if(!u)continue;const[h,y]=u;a[f]=h,x(h);const r=R(h),k=n.profiles[r];if(!k)continue;const c=I(y);if(c===null){const S=`${r}
|
|
2
|
+
${y}
|
|
3
|
+
normal`,m=i.get(S)??{family:r,weight:null,style:"normal",schemes:[],slots:[]};m.schemes.includes(t)||m.schemes.push(t),m.slots.includes(f)||m.slots.push(f),i.set(S,m);continue}const l="normal",g=k[_(c,l)];if(!g){const S=`${r}
|
|
4
|
+
${c}
|
|
5
|
+
${l}`,m=i.get(S)??{family:r,weight:c,style:l,schemes:[],slots:[]};m.schemes.includes(t)||m.schemes.push(t),m.slots.includes(f)||m.slots.push(f),i.set(S,m);continue}const d=q(r,c,l),w=s.get(d)??{request:{key:d,family:r,weight:c,style:l},profile:g,schemes:new Set,slots:new Set};w.schemes.add(t),w.slots.add(f),s.set(d,w),o[f]=w}return{stacks:a,uses:o}}function L(t){const e=t.trim();if(!/^U\+[0-9A-F?]{1,6}(?:-[0-9A-F]{1,6})?(?:\s*,\s*U\+[0-9A-F?]{1,6}(?:-[0-9A-F]{1,6})?)*$/i.test(e))throw new Error(`Invalid font source unicode-range "${t}"`);return e.replace(/\s+/g,"")}function D(t){return t?Array.isArray(t)?t:[t]:[]}function G(t,e){return e.map(n=>{if(!n.url.trim())throw new Error(`Empty WOFF2 source for ${t.key}`);const s=n.unicodeRange?`unicode-range:${L(n.unicodeRange)};`:"";return`@font-face{font-family:${E(t.family)};src:${z(n.url)};font-style:${t.style};font-weight:${t.weight};font-display:swap;${s}}`}).join("")}function K(t,e,n){const[s,i,a,o,$,f]=e,u=n.bases[s],h=u?.[1]?.[i];if(!u||!h||h.length===0)throw new Error(`Font fallback catalog is missing base ${s} ${i}`);const y=C(t.key,s),r=[`@font-face{font-family:${y};src:${h.map(k=>`local(${E(k)})`).join(",")};`,`font-style:${t.style};font-weight:${t.weight};`];return F(r,"size-adjust",a,n.metadata.percentScale),F(r,"ascent-override",o,n.metadata.percentScale),F(r,"descent-override",$,n.metadata.percentScale),F(r,"line-gap-override",f,n.metadata.percentScale),r.push(`unicode-range:${N};}`),{alias:y,css:r.join("")}}function A(t,e){const n=b.flatMap(s=>{const i=e[s];return i===void 0?[]:[`--_esp-font-${s}-effective:${i};`]}).join("");return`${t}{${n}}`}function v(t){if(t===void 0||t.trim()==="")return"esp-root";const e=t.trim();if(!/^#[A-Za-z_][A-Za-z0-9_-]*$/.test(e))throw new Error('rootSelector must be a unique id selector such as "#site-shell"');return e}function V(t){const{catalog:e}=t;if(e.version!==1||e.metadata?.subset!=="latin"||!/^10+$/.test(String(e.metadata?.percentScale)))throw new Error(`Unsupported font fallback catalog metadata: version ${String(e.version)}, subset ${String(e.metadata?.subset)}, percentScale ${String(e.metadata?.percentScale)}`);const n=new Map,s=v(t.rootSelector),i=new Map,a={light:M("light",t.lightTheme,e,n,i),dark:M("dark",t.darkTheme,e,n,i)},o=[...n.values()].sort((c,l)=>j(c.request,l.request)),$=o.map(({request:c})=>c),f=[],u=[],h=new Map,y=new Map;for(const c of o){const l=D(t.sources?.[c.request.key]);l.length===0?f.push(c.request):u.push(G(c.request,l));const g=[];for(const d of c.profile){const p=K(c.request,d,e),w=y.get(p.alias);if(w&&w!==`${c.request.key}:${d[0]}`)throw new Error(`Generated fallback family collision for ${p.alias}`);y.set(p.alias,`${c.request.key}:${d[0]}`),g.push(p.alias),u.push(p.css)}h.set(c.request.key,g)}const r={light:{},dark:{}};for(const c of["light","dark"]){const l=a[c];for(const g of b){const d=l.stacks[g];if(d===void 0)continue;const p=l.uses[g];r[c][g]=p?P(d,h.get(p.request.key)??[]):d}}(r.light.menu!==void 0||r.dark.menu!==void 0)&&(r.light.menu??=r.light.body,r.dark.menu??=r.dark.body),u.push(A(s,r.light)),JSON.stringify(r.dark)!==JSON.stringify(r.light)&&(u.push(A(`${s}[scheme=dark],${s}[default-scheme=dark]:not([scheme])`,r.dark)),u.push(`@media(prefers-color-scheme:dark){${A(`${s}[default-scheme=system]:not([scheme])`,r.dark)}}`));const k=u.join("");return{css:k,requests:$,missingSources:f,missingProfiles:[...i.values()],effectiveStacks:r,byteLength:new TextEncoder().encode(k).byteLength}}export{V as compileFontPlan,q as fontFaceRequestKey,J as fontFallbackAliases,B as fontFallbackBaseIndexes};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
const c=['a[href]:not([disabled]):not([tabindex="-1"])','button:not([disabled]):not([tabindex="-1"])','input:not([disabled]):not([tabindex="-1"])','select:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not([tabindex="-1"])','[tabindex]:not([tabindex="-1"]):not([disabled])'].join(", "),l="[autofocus]:not([disabled])";class o{static lock(t,e={}){const s=e.preserveScrollPosition===!0,n=o.owners.get(t);n===!0||n===s||(o.owners.size===0&&(o.snapshot={x:window.scrollX,y:window.scrollY,html:o.capture(document.documentElement,["overflow","overflow-x","overflow-y","overscroll-behavior","overscroll-behavior-x","overscroll-behavior-y"]),body:o.capture(document.body,["overflow","overflow-x","overflow-y","overscroll-behavior","overscroll-behavior-x","overscroll-behavior-y","position","top","left","width"])}),o.owners.set(t,s),o.applyCurrentTreatment())}static unlock(t){if(!(!o.owners.delete(t)||!o.snapshot)){if(o.owners.size===0){o.restoreSnapshot(),o.snapshot=null;return}o.applyCurrentTreatment()}}static capture(t,e){return e.map(s=>({name:s,value:t.style.getPropertyValue(s),priority:t.style.getPropertyPriority(s)}))}static restore(t,e){for(const{name:s}of e)t.style.removeProperty(s);for(const{name:s,value:n,priority:i}of e)n&&t.style.setProperty(s,n,i)}static applyCurrentTreatment(){const t=o.snapshot;if(!t)return;const e=[...o.owners.values()].some(Boolean);!e&&o.positionFrozen&&(o.restore(document.documentElement,t.html),o.restore(document.body,t.body),o.restoreViewport(t),o.positionFrozen=!1),document.body.style.overflow="hidden",e&&(o.positionFrozen||(t.x=window.scrollX,t.y=window.scrollY),document.documentElement.style.overflow="hidden",document.documentElement.style.overscrollBehavior="contain",document.body.style.overscrollBehavior="contain",document.body.style.position="fixed",document.body.style.top=`${-t.y}px`,document.body.style.left=`${-t.x}px`,document.body.style.width="100%",o.positionFrozen=!0)}static restoreSnapshot(){const t=o.snapshot;t&&(o.restore(document.documentElement,t.html),o.restore(document.body,t.body),o.positionFrozen&&o.restoreViewport(t),o.positionFrozen=!1)}static restoreViewport(t){window.scrollTo?.({top:t.y,left:t.x,behavior:"instant"})}static _reset(){o.restoreSnapshot(),o.owners.clear(),o.snapshot=null,o.positionFrozen=!1}}o.owners=new Map,o.snapshot=null,o.positionFrozen=!1;function f(){o._reset()}class r{static lock(t){const e=r._counts.get(t);return e!==void 0?(r._counts.set(t,e+1),!0):t.inert?!1:(r._counts.set(t,1),t.inert=!0,!0)}static unlock(t){const e=r._counts.get(t)??0;if(e<=0)return;const s=e-1;s===0?(t.inert=!1,r._counts.delete(t)):r._counts.set(t,s)}static _reset(){r._counts.clear()}}r._counts=new Map;function d(){r._reset()}class u{get isPromoting(){return this._promoting}constructor(t){this._isOpen=!1,this._previouslyFocused=null,this._inertElements=[],this._promoted=!1,this._pendingReactivation=!1,this._dropZone=null,this._promoting=!1,this._host=t.host,this._opts=t,t.host.addController(this)}static addOpenListener(t){u.openListeners.add(t)}static removeOpenListener(t){u.openListeners.delete(t)}redirectFocusRestore(t){this._isOpen&&(this._previouslyFocused=t)}get isOpen(){return this._isOpen}open(){if(!this._isOpen){this._pendingReactivation?this._pendingReactivation=!1:this._previouslyFocused=document.activeElement??null,this._isOpen=!0;for(const t of u.openListeners)t(this);o.lock(this,this._opts.scrollLock),this._opts.promote!==!1&&this._promoteToDropZone(),this._setInert(!0)}}close(){if(this._pendingReactivation=!1,!this._isOpen){this._previouslyFocused?.focus(),this._previouslyFocused=null;return}this._isOpen=!1,o.unlock(this),this._setInert(!1),this._previouslyFocused?.focus(),this._previouslyFocused=null}trapFocus(t){const e=this.getFocusableElements();if(e.length===0)return;const s=e[0],n=e[e.length-1],i=this._getDeepActiveElement();t.shiftKey?(i===s||this._isOrContains(s,i))&&(t.preventDefault(),n.focus()):(i===n||this._isOrContains(n,i))&&(t.preventDefault(),s.focus())}moveFocusInto(){const t=this._getAutofocusElement();if(t&&(t.focus(),this._autofocusLanded(t)))return;const e=this.getFocusableElements();if(e.length>0){e[0].focus();return}const s=this._opts.getFocusFallback?.();if(s){s.focus();return}this._opts.getFocusTrapContainer()?.focus()}_getAutofocusElement(){return this._getMatchingElements(l)[0]??null}getFocusableElements(){return this._getMatchingElements(c)}_getMatchingElements(t){if(t===c&&this._opts.getFocusScope)return this._opts.getFocusScope();const e=this._opts.getFocusTrapContainer();if(!e)return[];const s=[];for(const n of Array.from(e.querySelectorAll("*")))if(n instanceof HTMLElement){if(n.matches(t)&&s.push(n),n.shadowRoot){const i=n.shadowRoot.querySelectorAll(t);s.push(...Array.from(i))}if(n instanceof HTMLSlotElement)for(const i of n.assignedElements({flatten:!0})){if(!(i instanceof HTMLElement))continue;i.matches(t)&&s.push(i);const a=i.querySelectorAll(t);if(s.push(...Array.from(a)),i.shadowRoot){const h=i.shadowRoot.querySelectorAll(t);s.push(...Array.from(h))}}}for(const n of Array.from(this._host.children)){if(!(n instanceof HTMLElement))continue;n.matches(t)&&(s.includes(n)||s.push(n));const i=n.querySelectorAll(t);for(const a of Array.from(i))s.includes(a)||s.push(a);if(n.shadowRoot){const a=n.shadowRoot.querySelectorAll(t);for(const h of Array.from(a))s.includes(h)||s.push(h)}}return s}hostConnected(){}hostDisconnected(){this._promoting||this._isOpen&&(this._setInert(!1),o.unlock(this),this._isOpen=!1,this._pendingReactivation=!0)}_setInert(t){if(t){this._inertElements=[];const e=this._resolveInertAnchor(),s=e.parentElement??document.body;for(const n of s.children)n instanceof HTMLElement&&n!==e&&r.lock(n)&&this._inertElements.push(n)}else{for(const e of this._inertElements)r.unlock(e);this._inertElements=[]}}_resolveInertAnchor(){if(this._dropZone)return this._dropZone;const t=this._opts.getInertAnchor?.();if(t)return t;let e=this._host;for(;!e.parentElement;){const s=e.getRootNode();if(s instanceof ShadowRoot&&s.host instanceof HTMLElement)e=s.host;else break}return e}_getDeepActiveElement(){let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}_isOrContains(t,e){return e?t===e?!0:t.contains(e):!1}_autofocusLanded(t){const e=this._getActiveElementChain(),s=e[0];return e.some(n=>this._isOrContains(t,n)?!0:n!==s&&n instanceof HTMLElement&&this._isOrContains(n,t))}_getActiveElementChain(){const t=[];let e=document.activeElement;for(;e;){t.push(e);const s=e.shadowRoot?.activeElement??null;if(!s||s===e)break;e=s}return t}_promoteToDropZone(){if(this._promoted&&this._dropZone){this._promoting=!0;try{this._dropZone.appendChild(this._host)}finally{this._promoting=!1}return}const t=this._host,e=t.closest("esp-page");if(e){if(customElements.get("esp-page")){this._tryPromote(e);return}customElements.whenDefined("esp-page").then(()=>{if(!this._isOpen||!t.isConnected)return;const s=t.closest("esp-page");this._tryPromote(s)&&(this._setInert(!1),this._setInert(!0))})}}_tryPromote(t){if(!t||this._promoted)return!1;const e=t.AddDialog;if(typeof e=="function"){this._promoting=!0;try{e.call(t,this._host)}finally{this._promoting=!1}return this._promoted=!0,this._dropZone=this._host.parentElement,!0}return!1}}u.openListeners=new Set;export{c as FOCUSABLE_SELECTOR,u as OverlayController,o as ScrollLock,d as _resetInertLock,f as _resetScrollLock};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point for Espalier's theme → CSS custom property computation.
|
|
3
|
+
*
|
|
4
|
+
* `esp-root` hydrates a page by writing the result of this computation onto its
|
|
5
|
+
* host. A generator or server that renders the same page's shell — Taproot
|
|
6
|
+
* computes a published site's first-paint background this way — needs the same
|
|
7
|
+
* answer before any element upgrades, and must get it without importing a
|
|
8
|
+
* component module or a private package path.
|
|
9
|
+
*
|
|
10
|
+
* This module declares its own signature rather than re-exporting the internal
|
|
11
|
+
* implementation, so the published type graph stays limited to `EspalierTheme`
|
|
12
|
+
* from the already-public `./shared/theme` while the runtime still calls the
|
|
13
|
+
* one implementation — a generator and `esp-root` cannot compute different
|
|
14
|
+
* colors. The build-gate rationale for that shape is recorded in the
|
|
15
|
+
* repository's public-type-surface record, which is not published.
|
|
16
|
+
*
|
|
17
|
+
* The module is side-effect free: importing it registers no custom element and
|
|
18
|
+
* touches no DOM.
|
|
19
|
+
*/
|
|
20
|
+
import type { EspalierTheme } from "./theme.js";
|
|
21
|
+
/** The two color schemes a theme resolves for. */
|
|
22
|
+
export type ThemeScheme = "light" | "dark";
|
|
23
|
+
/**
|
|
24
|
+
* Compute every CSS custom property for a resolved theme and scheme.
|
|
25
|
+
*
|
|
26
|
+
* The result is a flat record keyed by property name including the leading
|
|
27
|
+
* `--`, exactly as `esp-root` writes it: scheme indicator, seed, variant and
|
|
28
|
+
* data colors, the lightness ramp, APCA-enforced semantic colors, data
|
|
29
|
+
* companions, the type and space scales, font families and weights, and the
|
|
30
|
+
* optional background-image and vellum properties a theme declares.
|
|
31
|
+
*
|
|
32
|
+
* Pass a **resolved** theme — one merged over `DEFAULT_LIGHT_THEME` or
|
|
33
|
+
* `DEFAULT_DARK_THEME` with `mergeTheme` from `./shared/theme`. An unparseable
|
|
34
|
+
* `seedColor` yields an empty record rather than throwing, and an unresolvable
|
|
35
|
+
* color source falls back to the seed with a `console.warn`, so a bad theme
|
|
36
|
+
* renders branded rather than broken; use `validateTheme(encodeTheme(partial))`
|
|
37
|
+
* from `./shared/theme` to surface those before rendering.
|
|
38
|
+
*
|
|
39
|
+
* @param theme A resolved theme.
|
|
40
|
+
* @param scheme The scheme to compute, matching the theme it came from.
|
|
41
|
+
*/
|
|
42
|
+
export declare function computeThemeProperties(theme: EspalierTheme, scheme: ThemeScheme): Record<string, string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{computeThemeProperties as o}from"../root/helpers/compute-theme-properties.js";function m(e,r){return o(e,r)}export{m as computeThemeProperties};
|
package/dist/shared/theme.d.ts
CHANGED
|
@@ -336,6 +336,14 @@ export interface EspalierTheme {
|
|
|
336
336
|
* @default ""
|
|
337
337
|
*/
|
|
338
338
|
fontBrand: string;
|
|
339
|
+
/**
|
|
340
|
+
* CSS `font-family` for navigation menu items and group labels. When empty,
|
|
341
|
+
* menu recipes fall back to {@link fontBody} — never to headings — so a
|
|
342
|
+
* theme that sets only a heading face keeps its navigation unchanged.
|
|
343
|
+
*
|
|
344
|
+
* @default ""
|
|
345
|
+
*/
|
|
346
|
+
fontMenu: string;
|
|
339
347
|
/**
|
|
340
348
|
* CSS `font-family` for code / monospace text. Empty and omitted overrides
|
|
341
349
|
* resolve to the built-in monospace family.
|
|
@@ -376,6 +384,16 @@ export interface EspalierTheme {
|
|
|
376
384
|
* @default "bold"
|
|
377
385
|
*/
|
|
378
386
|
fontWeightBrand: string;
|
|
387
|
+
/**
|
|
388
|
+
* CSS `font-weight` for horizontal navigation menu items.
|
|
389
|
+
*
|
|
390
|
+
* Accepts the same values as {@link fontWeightBody}.
|
|
391
|
+
*
|
|
392
|
+
* Emitted as `--esp-font-weight-menu`.
|
|
393
|
+
*
|
|
394
|
+
* @default "bold"
|
|
395
|
+
*/
|
|
396
|
+
fontWeightMenu: string;
|
|
379
397
|
/**
|
|
380
398
|
* CSS `font-weight` for code / monospace text.
|
|
381
399
|
*
|
package/dist/shared/theme.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UNSAFE_KEYS as dt,isSafeKey as M}from"./unsafe-keys.js";import{ACCEPTED_COLOR_FORMS as oe,apcaContrast as mt,clampChannel as ge,deltaEOK as gt,deriveSemantic as ae,gamutMapToSRGB as he,linearRgbToOklab as ht,oklchToSRGB as yt,parseCssColor as W,parseOklch as bt,serializeOklch as ce,srgbToLinearRGB as $t}from"./color-engine.js";import{computeVariants as ye,parseAnchorSource as xt,resolveAnchorColor as kt,resolveMappingSource as ue}from"./variant-engine.js";import{auditColorDistances as Fe,auditDataPalette as St,describePaletteCollision as At,DATA_SERIES_KEYS as fe,DEFAULT_DATA_PALETTE as be,DEFAULT_DATA_RAMP_STEPS as Mt,MAX_DATA_RAMP_STEPS as $e,MIN_DATA_RAMP_LIGHTNESS_STEP as We,MIN_DATA_RAMP_STEPS as xe}from"./data-colors.js";const j=/^[a-z][a-z0-9-]*$/;function ke(e){return xt(e)}function je(e,n){return kt(e,n)}function Ot(e,n){const t=ke(e);if(t){const o=je(n,t);return o&&W(o)?o:null}return W(e)?e:null}const se=["canvas","ink","accent","action","structure"],Se={canvas:{color:[["background","surface"],["layer1","raised1"],["layer2","raised2"],["layer3","raised3"],["layer4","raised4"]]},ink:{color:[["text","text"],["typeOverline","text"],["typeLabel","text"],["typeLead","text"],["typeCaption","text"],["inputSelection","text"]],heading:[["headings","muted"],["headingsHover","ink"]]},accent:{color:[["linkHoverBg","raised2"],["inputSelectionBg","raised2"],["inputCaret","ink"]],text:[["link","accent"]],hover:[["linkHover","text"]]},action:{color:[["actionBackground","muted"]],ink:[["actionText","surface"]]},structure:{color:[["border","border"],["shadow","shadow"]]}},Tt=new Set(["action.color"]),Ct={canvas:"background",ink:"text",accent:"link",action:"actionBackground",structure:"border"},Rt={"action.ink":{role:"canvas",slot:"color"}},vt=.45,Et=.045;function ze(e,n,t){const o=Ue.actionText,i=[...U].sort((y,T)=>e[y]-e[T]||U.indexOf(y)-U.indexOf(T)),a=n?i.filter(y=>n(y)>=o.targetLc):i,u=t?a.filter(y=>t(y)>=Et):a,d=u.length>0?u:a,m=d.length>0?d:i;let A,k=1/0;for(const y of m){const T=Math.abs(e[y]-vt);T<k&&(k=T,A=y)}return A??"muted"}function wt(e,n,t){const o=Oe(n,t,e)>.5;let i=U[0];for(const a of U)(o?n[a]<n[i]:n[a]>n[i])&&(i=a);return i}const Bt={"accent.hover":"text"};function _t(e,n){const t=new Map;try{const o=de(n,e),i=(a,u,d,m)=>{const A=ke(u),k=A?je(m,A):null,y=k===null?null:W(k),T=t.get(a)??[];T.some(_=>_.source===u&&_.chroma===y?.c)||(T.push({source:u,where:d,chroma:y?.c}),t.set(a,T))};for(const[a,u]of Object.entries(o.semanticMappings))u.source.startsWith("anchor:")&&i(a,u.source,"the root table",o.anchors);for(const a of Object.keys(o.contexts)){const u=it(o,a);if(u)for(const[d,m]of Object.entries(u.semanticMappings))m.source.startsWith("anchor:")&&i(d,m.source,`contexts.${a}`,u.anchors)}}catch{return new Map}return t}function X(e,n){if(e===void 0)return;if(typeof e=="string")return n==="color"?e:void 0;const t=e[n];return typeof t=="string"?t:void 0}function Ke(e,n,t,o={}){const i={},a={};for(const[u,d]of Object.entries(o.explicitMappings??{}))d!==void 0&&(a[u]=d.lightness);for(const u of se){const d=e[u];if(d!==void 0)for(const[m,A]of Object.entries(Se[u])){const k=Rt[`${u}.${m}`];let y=X(d,m),T=!1;if(y===void 0){k&&(y=X(e[k.role],k.slot),y??=t[Ct[k.role]]?.source,T=y!==void 0);const _=Bt[`${u}.${m}`];_!==void 0&&(y??=X(d,_)),y??=X(d,"color")}if(y!==void 0)for(const[_,z]of A){let H=z;if(Tt.has(`${u}.${m}`))H=ze(n,o.actionSurfaceContrast?s=>o.actionSurfaceContrast(y,s):void 0,o.actionSurfaceSeparation?s=>o.actionSurfaceSeparation(y,s):void 0);else if(T&&k){const s=Ue[_],r=(s&&a[s.bg])??ze(n,o.actionSurfaceContrast?c=>o.actionSurfaceContrast(X(d,"color"),c):void 0,o.actionSurfaceSeparation?c=>o.actionSurfaceSeparation(X(d,"color"),c):void 0);H=wt(r,n,o.tones??{})}i[_]={source:y,lightness:H}}}}return i}const Ue={text:{bg:"background",targetLc:75},typeOverline:{bg:"background",targetLc:90},typeLabel:{bg:"background",targetLc:75},typeLead:{bg:"background",targetLc:75},typeCaption:{bg:"background",targetLc:90},dangerText:{bg:"background",targetLc:75},headings:{bg:"background",targetLc:60},headingsHover:{bg:"background",targetLc:60},link:{bg:"background",targetLc:75},linkHover:{bg:"linkHoverBg",targetLc:75},actionText:{bg:"actionBackground",targetLc:75},inputCaret:{bg:"layer2",targetLc:60},inputSelection:{bg:"inputSelectionBg",targetLc:60}},K=["background","layer1","layer2","layer3","layer4","actionBackground","actionText","border","shadow","text","typeOverline","typeLabel","typeLead","typeCaption","dangerText","headings","headingsHover","link","linkHover","linkHoverBg","inputCaret","inputSelection","inputSelectionBg"];function cn(e){return typeof e=="string"&&K.includes(e)}const Lt=["typeOverline","typeLabel","typeLead","typeCaption"],Ae=["primary","analogous-left","analogous-right","complementary","split-complementary-left","split-complementary-right","triadic-left","triadic-right","danger","success","warning","info"],ee=["danger","success","warning","info"],It=["analogous-left","analogous-right","complementary","split-complementary-left","split-complementary-right","triadic-left","triadic-right","danger","success","warning","info"],U=["surface","raised1","raised2","raised3","raised4","accent","muted","text","border","ink","shadow"],Ge="tone:";function Me(e){if(typeof e!="string"||!e.startsWith(Ge))return null;const n=e.slice(Ge.length);return M(n)&&j.test(n)?n:null}function te(e){return typeof e!="string"?!1:U.includes(e)}function Oe(e,n,t){if(te(t))return e[t];const o=Me(t);return o===null?e.surface:n?.[o]??e.surface}const Nt={surface:.99,raised1:.97,raised2:.9,raised3:.8,raised4:.72,accent:.5,muted:.45,text:.35,border:.3,ink:.25,shadow:.2},Ht={surface:.15,raised1:.2,raised2:.3,raised3:.4,raised4:.36,accent:.6,muted:.75,text:.85,border:.7,ink:.95,shadow:.6},Te={background:{source:"primary",lightness:"surface"},layer1:{source:"primary",lightness:"raised1"},layer2:{source:"primary",lightness:"raised2"},layer3:{source:"primary",lightness:"raised3"},layer4:{source:"primary",lightness:"raised4"},actionBackground:{source:"primary",lightness:"raised3"},actionText:{source:"primary",lightness:"ink"},border:{source:"primary",lightness:"border"},shadow:{source:"primary",lightness:"shadow"},text:{source:"primary",lightness:"text"},typeOverline:{source:"primary",lightness:"text"},typeLabel:{source:"primary",lightness:"text"},typeLead:{source:"primary",lightness:"text"},typeCaption:{source:"primary",lightness:"text"},dangerText:{source:"danger",lightness:"text"},headings:{source:"primary",lightness:"muted"},headingsHover:{source:"primary",lightness:"text"},link:{source:"complementary",lightness:"accent"},linkHover:{source:"complementary",lightness:"text"},linkHoverBg:{source:"triadic-left",lightness:"raised2"},inputCaret:{source:"triadic-right",lightness:"ink"},inputSelection:{source:"complementary",lightness:"text"},inputSelectionBg:{source:"triadic-left",lightness:"raised2"}},Y=.4;function Ce(){const e={};for(const n of K)e[n]={min:0,max:Y};return e}const Ve="system-ui, sans-serif",Je="monospace",Ye={seedColor:"oklch(0.7 0.125 216)",fontBody:Ve,fontHeadings:"",fontBrand:"",fontMonospace:Je,fontWeightBody:"normal",fontWeightHeadings:"bold",fontWeightBrand:"bold",fontWeightMonospace:"normal",stylesheets:[],rootFontSize:16,typeRatio:1.25,spaceRatio:1.618,borderRadius:.2,viewportMin:320,viewportMax:1200,angles:{analogous:30,complementary:180,splitComplementary:30,triadic:120},semanticHues:{danger:27,success:150,warning:90,info:244},variantChroma:{},intents:{},tones:{},chroma:Ce(),semanticMappings:{...Te},explicitMappingTokens:[],anchors:{},roles:{},contexts:{},dataPalette:{...be},dataRamps:{}},Re={...Ye,chroma:Ce(),semanticMappings:{...Te},anchors:{},roles:{},contexts:{},tones:{},dataPalette:{...be},dataRamps:{},lightness:{...Nt}},qe={...Ye,chroma:Ce(),semanticMappings:{...Te},anchors:{},roles:{},contexts:{},tones:{},dataPalette:{...be},dataRamps:{},lightness:{...Ht}},le=new WeakMap;le.set(Re,new Set),le.set(qe,new Set);function Pt(e,n){return dt.has(e)?void 0:n}function pe(e){const n=e.explicitMappingTokens;if(!Array.isArray(n)||n.some(o=>typeof o!="string"||!K.includes(o)))return;const t=new Set(n);if(t.size===n.length&&!(t.size>0&&(!L(e.semanticMappings)||[...t].some(o=>!Object.prototype.hasOwnProperty.call(e.semanticMappings,o)))))return t}function Xe(e){return K.filter(n=>e.has(n))}function un(e){return`--esp-color-${e.replace(/([A-Z])/g,"-$1").replace(/(\d)/g,"-$1").toLowerCase()}`}function Dt(e){try{const n=Ze(e),t=JSON.parse(n,Pt);return typeof t!="object"||t===null||Array.isArray(t)?null:t}catch{return null}}const ve="\xEF\xBB\xBF";function Ft(e){if(/^[\u0000-\u007f]*$/.test(e))return btoa(e);const n=new TextEncoder().encode(e);let t=ve;for(const o of n)t+=String.fromCharCode(o);return btoa(t)}function Ze(e){const n=atob(e);if(!n.startsWith(ve))return n;const t=Uint8Array.from(n.slice(ve.length),o=>o.charCodeAt(0));return new TextDecoder("utf-8",{fatal:!0}).decode(t)}function Ee(e){return Ft(JSON.stringify(e))}function Wt(e){const n={};for(const t of ee){const o=e[t];typeof o=="string"&&(n[t]=o.startsWith("anchor:")?o:re(o))}return n}function re(e){if(bt(e))return e;const n=W(e);return n?ce(n):e}function Qe(e,n){const t={};for(const[o,i]of Object.entries(e))M(o)&&(t[o]=i);if(!n)return t;for(const[o,i]of Object.entries(n)){if(i===void 0||!M(o))continue;const a=t[o];if(a!==void 0&&typeof i=="object"&&i!==null){const u={};if(typeof a=="string")u.color=a;else for(const[d,m]of Object.entries(a))M(d)&&(u[d]=m);for(const[d,m]of Object.entries(i))m!==void 0&&M(d)&&(u[d]=m);t[o]=u;continue}t[o]=i}return t}function we(e){const n={};if(!L(e))return n;for(const[t,o]of Object.entries(e))M(t)&&j.test(t)&&!te(t)&&typeof o=="number"&&Number.isFinite(o)&&o>=0&&o<=1&&(n[t]=o);return n}function jt(e,n){return{...we(e),...we(n)}}function zt(e,n){const t={...e};if(!L(n))return t;for(const o of U){const i=n[o];typeof i=="number"&&Number.isFinite(i)&&i>=0&&i<=1&&(t[o]=i)}return t}function et(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;const n=e,t={};for(const o of se){const i=n[o];i!==void 0&&(t[o]=i)}if(typeof n.lightness=="object"&&n.lightness!==null&&!Array.isArray(n.lightness)){const o={};for(const i of U){const a=n.lightness[i];a!==void 0&&(o[i]=a)}t.lightness=o}if(n.tones!==void 0){const o=we(n.tones);Object.keys(o).length>0&&(t.tones=o)}if(typeof n.semanticMappings=="object"&&n.semanticMappings!==null&&!Array.isArray(n.semanticMappings)){const o={};for(const[i,a]of Object.entries(n.semanticMappings)){if(!M(i)||!K.includes(i)||typeof a!="object"||a===null||Array.isArray(a))continue;const{source:u,lightness:d}=a;typeof u=="string"&&(typeof d!="string"||!te(d)&&Me(d)===null||(o[i]={source:u,lightness:d}))}Object.keys(o).length>0&&(t.semanticMappings=o)}return t}function Kt(e,n){const t={};for(const[o,i]of Object.entries(e)){if(!M(o)||!j.test(o))continue;const a=et(i);a&&(t[o]=a)}if(!n)return t;for(const[o,i]of Object.entries(n)){if(!M(o)||!j.test(o)||i===void 0)continue;const a=et(i);if(!a)continue;const u=t[o];t[o]={...u??{},...a,...u?.lightness||a.lightness?{lightness:{...u?.lightness,...a.lightness}}:{},...u?.tones||a.tones?{tones:{...u?.tones,...a.tones}}:{},...u?.semanticMappings||a.semanticMappings?{semanticMappings:{...u?.semanticMappings,...a.semanticMappings}}:{}}}return t}function L(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function F(e){const n={};for(const[t,o]of Object.entries(e))o!==void 0&&M(t)&&(n[t]=o);return n}function tt(e){if(!L(e))return e;const n=F(e);return L(e.lightness)&&(n.lightness=F(e.lightness)),L(e.tones)&&(n.tones=F(e.tones)),n}function Ut(e,n){const t={};for(const[o,i]of Object.entries(e))M(o)&&(t[o]=tt(i));if(!n)return t;for(const[o,i]of Object.entries(n)){if(!M(o)||i===void 0)continue;const a=t[o];if(!L(a)||!L(i)){t[o]=tt(i);continue}const u={...F(a),...F(i)};L(a.lightness)&&L(i.lightness)?u.lightness={...F(a.lightness),...F(i.lightness)}:L(i.lightness)&&(u.lightness=F(i.lightness)),L(a.tones)&&L(i.tones)?u.tones={...F(a.tones),...F(i.tones)}:L(i.tones)&&(u.tones=F(i.tones)),L(a.semanticMappings)&&L(i.semanticMappings)?u.semanticMappings={...F(a.semanticMappings),...F(i.semanticMappings)}:L(i.semanticMappings)&&(u.semanticMappings=F(i.semanticMappings)),t[o]=u}return t}function Gt(e){const n={};for(const[t,o]of Object.entries(e)){if(!M(t))continue;if(typeof o=="string"){n[t]=re(o);continue}const i={};for(const[a,u]of Object.entries(o))M(a)&&(i[a]=typeof u=="string"?re(u):u);n[t]=i}return n}function ie(e){return typeof e!="string"?"":e.startsWith("anchor:")?e:re(e)}function Vt(e){const n={};for(const t of fe)n[t]=ie(e[t]);return n}function nt(e,n){const t={};for(const[o,i]of Object.entries(e))M(o)&&j.test(o)&&i&&typeof i=="object"&&!Array.isArray(i)&&(t[o]={...i});if(!n)return t;for(const[o,i]of Object.entries(n)){if(!M(o)||!j.test(o)||!i||typeof i!="object"||Array.isArray(i))continue;const a=t[o],u=a!==void 0&&i.type!==void 0&&i.type!==a.type;t[o]={...u?{}:a??{},...i}}return t}function Jt(e){const n={};for(const[t,o]of Object.entries(e))if(M(t)){if(o.type==="sequential"&&typeof o.source=="string"){n[t]={...o,source:ie(o.source)};continue}if(o.type==="diverging"&&typeof o.start=="string"&&typeof o.end=="string"){n[t]={...o,start:ie(o.start),end:ie(o.end),...typeof o.neutral=="string"?{neutral:ie(o.neutral)}:{}};continue}n[t]={...o}}return n}function ot(e){const n=W(e.seedColor);if(!n)return;const t=ye(n,e);return(o,i)=>{const a=ue(o,t,e.anchors)??t.primary,u=e.chroma.actionBackground,d=ae(a,e.lightness[i],u.min,u.max),m={l:d.l>.5?0:1,c:0,h:0};return Math.abs(mt(m,d))}}function Yt(e,n,t){if(n?.background)return n.background;const o=X(e.canvas,"color");if(o!==void 0){const i=Se.canvas.color?.find(([a])=>a==="background");if(i)return{source:o,lightness:i[1]}}return t.background}function st(e,n){const t=W(e.seedColor);if(!t||!n)return;const o=ye(t,e),i=ue(n.source,o,e.anchors)??o.primary,a=e.chroma.background,u=ae(i,Oe(e.lightness,e.tones,n.lightness),a.min,a.max);return(d,m)=>{const A=ue(d,o,e.anchors)??o.primary,k=e.chroma.actionBackground,y=ae(A,e.lightness[m],k.min,k.max);return gt(y,u)}}function qt(e){const n=le.get(e);if(n)return new Set(n);const t=pe(e);if(t)return t;const o=new Set,i=Ke(e.roles,e.lightness,e.semanticMappings,{tones:e.tones,actionSurfaceContrast:ot(e),actionSurfaceSeparation:st(e,e.semanticMappings.background)});for(const[a,u]of Object.entries(i)){const d=e.semanticMappings[a];(d.source!==u.source||d.lightness!==u.lightness)&&o.add(a)}return o}function de(e,n){const t={...e.roles,...n.roles},o=Kt(e.contexts,n.contexts),i=zt(e.lightness,n.lightness),a=jt(e.tones,n.tones),u=Gt(Qe(e.anchors,n.anchors)),d=typeof n.seedColor=="string"?re(n.seedColor):e.seedColor,m=n.semanticMappings,A={...e.angles,...n.angles},k={...e.semanticHues,...n.semanticHues},y={...e.variantChroma,...n.variantChroma},T=Wt({...e.intents,...n.intents}),_=n.chroma,z=ne(e.chroma,_),H=Vt(ne(e.dataPalette,n.dataPalette)),s=Jt(nt(e.dataRamps,n.dataRamps)),r=qt(e),c=new Set(r),l=pe(n),p={};for(const x of r)p[x]=e.semanticMappings[x];for(const[x,O]of Object.entries(m??{}))O!==void 0&&(l===void 0||l.has(x)?(c.add(x),p[x]=O):(c.delete(x),delete p[x]));const g=ne(e.semanticMappings,m),f={angles:A,anchors:u,chroma:z,intents:T,lightness:i,tones:a,seedColor:d,semanticHues:k,variantChroma:y},h=ot(f),$=st(f,Yt(t,p,g)),b=Ke(t,i,g,{explicitMappings:p,tones:a,actionSurfaceContrast:h,actionSurfaceSeparation:$}),R={};for(const[x,O]of Object.entries(b))c.has(x)||(R[x]=O);const C={};for(const x of Lt)!c.has(x)&&R[x]===void 0&&(C[x]={source:g.text.source,lightness:g.text.lightness},_?.text!==void 0&&_[x]===void 0&&(z[x]={...z.text}));const w=ne(ne(ne(e.semanticMappings,C),R),m),S={...e,seedColor:d,fontBody:n.fontBody||e.fontBody||Ve,fontHeadings:n.fontHeadings??e.fontHeadings,fontBrand:n.fontBrand??e.fontBrand,fontMonospace:n.fontMonospace||e.fontMonospace||Je,fontWeightBody:String(n.fontWeightBody??e.fontWeightBody),fontWeightHeadings:String(n.fontWeightHeadings??e.fontWeightHeadings),fontWeightBrand:String(n.fontWeightBrand??e.fontWeightBrand),fontWeightMonospace:String(n.fontWeightMonospace??e.fontWeightMonospace),stylesheets:n.stylesheets??[...e.stylesheets],rootFontSize:n.rootFontSize??e.rootFontSize,typeRatio:n.typeRatio??e.typeRatio,spaceRatio:n.spaceRatio??e.spaceRatio,borderRadius:n.borderRadius??e.borderRadius,viewportMin:n.viewportMin??e.viewportMin,viewportMax:n.viewportMax??e.viewportMax,angles:A,semanticHues:k,variantChroma:y,intents:T,lightness:i,tones:a,chroma:z,semanticMappings:w,explicitMappingTokens:Xe(c),anchors:u,roles:t,contexts:o,dataPalette:H,dataRamps:s};return n.pageBackgroundImage!==void 0&&(S.pageBackgroundImage=n.pageBackgroundImage),n.pageBackgroundImageOpacity!==void 0&&(S.pageBackgroundImageOpacity=n.pageBackgroundImageOpacity),n.boxBackgroundImage!==void 0&&(S.boxBackgroundImage=n.boxBackgroundImage),n.boxBackgroundImageOpacity!==void 0&&(S.boxBackgroundImageOpacity=n.boxBackgroundImageOpacity),n.vellumOpacity!==void 0&&(S.vellumOpacity=n.vellumOpacity),n.vellumBackgroundImage!==void 0&&(S.vellumBackgroundImage=n.vellumBackgroundImage),n.vellumBackgroundImageOpacity!==void 0&&(S.vellumBackgroundImageOpacity=n.vellumBackgroundImageOpacity),le.set(S,new Set(c)),S}const rt=new WeakMap;function it(e,n){const t=e.contexts&&Object.prototype.hasOwnProperty.call(e.contexts,n)?e.contexts[n]:void 0;if(!t)return null;let o=rt.get(e);const i=o?.get(n);if(i)return i;const a={};for(const d of se){const m=t[d];m!==void 0&&(a[d]=m)}const u=de(e,{lightness:t.lightness,tones:t.tones,roles:a,semanticMappings:t.semanticMappings});return o||(o=new Map,rt.set(e,o)),o.set(n,u),u}function ne(e,n){if(!n)return{...e};const t={...e};for(const o of Object.keys(n)){const i=n[o];i!==void 0&&(t[o]=i)}return t}function Be(e){let n;try{n=Ze(e)}catch{return{error:"Failed to decode Base64 string."}}let t;try{t=JSON.parse(n)}catch{return{error:"Decoded string is not valid JSON."}}return typeof t!="object"||t===null||Array.isArray(t)?{error:"Theme must be a JSON object."}:{value:t}}function fn(e){const n=Be(e);return n.error!==void 0?{valid:!1,errors:[n.error],warnings:[]}:_e(n.value)}function _e(e,n=Re){const t=[],o=[];"seedColor"in e&&(typeof e.seedColor!="string"?t.push("seedColor must be a string."):W(e.seedColor)||t.push(`seedColor is not a valid CSS color: "${e.seedColor}". Accepted forms: ${oe}.`));for(const s of["fontBody","fontHeadings","fontBrand","fontMonospace"])s in e&&typeof e[s]!="string"&&t.push(`${s} must be a string.`);const i=["normal","bold","lighter","bolder"],a=["inherit","initial","unset","revert","revert-layer"];for(const s of["fontWeightBody","fontWeightHeadings","fontWeightBrand","fontWeightMonospace"])if(s in e){const r=e[s];if(typeof r=="number")(r<1||r>1e3)&&t.push(`${s} numeric value must be 1\u20131000 (got ${r}).`);else if(typeof r=="string"){const c=i.includes(r)||a.includes(r);if(/^\d+$/.test(r)){const p=Number(r);(p<1||p>1e3)&&t.push(`${s} numeric value must be 1\u20131000 (got "${r}").`)}else c||o.push(`${s} = "${r}" is not a standard font-weight value.`)}else t.push(`${s} must be a string or number.`)}"stylesheets"in e&&(Array.isArray(e.stylesheets)?e.stylesheets.some(s=>typeof s!="string")&&t.push("Every entry in stylesheets must be a string."):t.push("stylesheets must be an array of strings."));const u=[["rootFontSize",1,100],["borderRadius",0,10],["viewportMin",100,1e4],["viewportMax",200,1e4]];for(const[s,r,c]of u)if(s in e)if(typeof e[s]!="number"||!isFinite(e[s]))t.push(`${s} must be a finite number.`);else{const l=e[s];r!==void 0&&l<r&&t.push(`${s} must be \u2265 ${r} (got ${l}).`),c!==void 0&&l>c&&o.push(`${s} = ${l} is unusually high (max ${c}).`)}for(const s of["typeRatio","spaceRatio"])if(s in e)if(typeof e[s]!="number"||!isFinite(e[s]))t.push(`${s} must be a finite number.`);else{const r=e[s];r<=1&&t.push(`${s} must be > 1 (got ${r}).`);const c=s==="typeRatio"?1.3:2;r>c&&o.push(`${s} = ${r} is very high (max ${c}); scales may be extreme.`)}if("viewportMin"in e&&"viewportMax"in e){const s=e.viewportMin,r=e.viewportMax;typeof s=="number"&&typeof r=="number"&&s>=r&&t.push(`viewportMin (${s}) must be less than viewportMax (${r}).`)}if("angles"in e)if(typeof e.angles!="object"||e.angles===null)t.push("angles must be an object.");else{const s=e.angles;for(const r of["analogous","complementary","splitComplementary","triadic"])if(r in s)if(typeof s[r]!="number"||!isFinite(s[r]))t.push(`angles.${r} must be a finite number.`);else{const c=s[r];(c<0||c>360)&&o.push(`angles.${r} = ${c} is outside 0\u2013360.`)}}if("semanticHues"in e)if(typeof e.semanticHues!="object"||e.semanticHues===null)t.push("semanticHues must be an object.");else{const s=e.semanticHues;for(const r of["danger","success","warning","info"])if(r in s)if(typeof s[r]!="number"||!isFinite(s[r]))t.push(`semanticHues.${r} must be a finite number.`);else{const c=s[r];(c<0||c>360)&&o.push(`semanticHues.${r} = ${c} is outside 0\u2013360.`)}}if("variantChroma"in e)if(typeof e.variantChroma!="object"||e.variantChroma===null)t.push("variantChroma must be an object.");else{const s=e.variantChroma;for(const r of It)if(r in s)if(typeof s[r]!="number"||!isFinite(s[r]))t.push(`variantChroma["${r}"] must be a finite number.`);else{const c=s[r];c<0&&t.push(`variantChroma["${r}"] must be \u2265 0 (got ${c}).`),c>Y&&o.push(`variantChroma["${r}"] = ${c} exceeds ${Y}.`)}}function d(s,r){if(typeof s!="object"||s===null||Array.isArray(s)){t.push(`${r} must be an object.`);return}const c=s;for(const l of Object.keys(c))(!M(l)||!te(l))&&t.push(`${r}.${l} is not a built-in lightness stop; expected one of: ${U.join(", ")}.`);for(const l of U)if(l in c)if(typeof c[l]!="number"||!isFinite(c[l]))t.push(`${r}.${l} must be a finite number.`);else{const p=c[l];(p<0||p>1)&&t.push(`${r}.${l} must be 0\u20131 (got ${p}).`)}}"lightness"in e&&d(e.lightness,"lightness");function m(s,r){const c=new Set;if(!L(s))return t.push(`${r} must be an object.`),c;for(const[l,p]of Object.entries(s)){if(!M(l)||!j.test(l)){t.push(`${r}.${l} must be a lowercase slug matching ${j.source}.`);continue}if(te(l)){t.push(`${r}.${l} conflicts with the built-in "${l}" lightness stop; choose a distinct custom tone name.`);continue}c.add(l),typeof p!="number"||!Number.isFinite(p)?t.push(`${r}.${l} must be a finite number.`):(p<0||p>1)&&t.push(`${r}.${l} must be 0\u20131 (got ${p}).`)}return c}const A=new Set(Object.keys(n.tones??{}));if("tones"in e)for(const s of m(e.tones,"tones"))A.add(s);if("chroma"in e)if(typeof e.chroma!="object"||e.chroma===null)t.push("chroma must be an object.");else{const s=e.chroma,r=_t(e,n);for(const c of K)if(c in s){const l=s[c];if(typeof l!="object"||l===null){t.push(`chroma.${c} must be { min, max }.`);continue}const p=l;for(const f of r.get(c)??[])f.chroma!==void 0&&typeof p.min=="number"&&typeof p.max=="number"&&(f.chroma<p.min-1e-9||f.chroma>p.max+1e-9)&&o.push(`chroma.${c} clamps the anchor-sourced token ${c} ("${f.source}", effective in ${f.where}) and moves it off its declared swatch. Remove the band if that is unintended \u2014 anchors otherwise keep their own chroma.`);const g=l;(typeof g.min!="number"||g.min<0)&&t.push(`chroma.${c}.min must be \u2265 0.`),(typeof g.max!="number"||g.max<0||g.max>Y)&&t.push(`chroma.${c}.max must be 0\u2013${Y}.`),typeof g.min=="number"&&typeof g.max=="number"&&g.min>g.max&&t.push(`chroma.${c}.min (${g.min}) must be \u2264 max (${g.max}).`)}}if("anchors"in e)if(typeof e.anchors!="object"||e.anchors===null||Array.isArray(e.anchors))t.push("anchors must be an object of named colors.");else for(const[s,r]of Object.entries(e.anchors))if(M(s)?j.test(s)||t.push(`anchors: "${s}" is not a valid anchor name; use a lowercase slug (letters, digits, hyphens).`):t.push(`anchors: "${s}" is a reserved JavaScript property name and cannot be an anchor name; rename it.`),Ae.includes(s)&&t.push(`anchors: "${s}" collides with a reserved color source name.`),typeof r=="string")W(r)||t.push(`anchors.${s} is not a valid CSS color: "${r}". Accepted forms: ${oe}.`);else if(typeof r=="object"&&r!==null&&!Array.isArray(r)){const c=r;typeof c.color!="string"&&t.push(`anchors.${s} must declare its base "color".`);for(const[l,p]of Object.entries(c))M(l)?l!=="color"&&!j.test(l)&&t.push(`anchors.${s}: "${l}" is not a valid slot name; use a lowercase slug.`):t.push(`anchors.${s}: "${l}" is a reserved JavaScript property name and cannot be a slot name; rename it.`),typeof p!="string"?t.push(`anchors.${s}.${l} must be a CSS color string.`):W(p)||t.push(`anchors.${s}.${l} is not a valid CSS color: "${p}". Accepted forms: ${oe}.`)}else t.push(`anchors.${s} must be a color string or a { color, \u2026slots } object.`);const k=new Map;if("anchors"in e&&typeof e.anchors=="object"&&e.anchors!==null&&!Array.isArray(e.anchors))for(const[s,r]of Object.entries(e.anchors))k.set(s,r);function y(s,r){const c=ke(s);if(!c){t.push(`${r} "${s}" is not valid anchor syntax; use anchor:<name> or anchor:<name>.<slot>.`);return}if(!k.has(c.name)){const l=[...k.keys()];t.push(`${r} references undeclared anchor "${c.name}". Declared anchors: ${l.length>0?l.join(", "):"(none)"}.`);return}if(c.slot!==void 0){const l=k.get(c.name);if(typeof(typeof l=="object"&&l!==null&&!Array.isArray(l)?l[c.slot]:void 0)!="string"){const g=typeof l=="object"&&l!==null?Object.keys(l).filter(f=>f!=="color"):[];t.push(`${r} references unknown slot "${c.slot}" on anchor "${c.name}". Declared slots: ${g.length>0?g.join(", "):"(none)"}.`)}}}function T(s,r){if(s.startsWith("anchor:")){y(s,r);return}Ae.includes(s)||t.push(`${r} must be one of: ${Ae.join(", ")}, or a declared anchor as anchor:<name> / anchor:<name>.<slot>.`)}if("intents"in e)if(typeof e.intents!="object"||e.intents===null||Array.isArray(e.intents))t.push("intents must be an object.");else for(const[s,r]of Object.entries(e.intents)){const c=`intents.${s}`;if(!ee.includes(s)){t.push(`${c} is not a status family; expected one of: ${ee.join(", ")}.`);continue}if(typeof r!="string"){t.push(`${c} must be a string (a CSS color or an anchor: reference).`);continue}if(r.startsWith("anchor:")){y(r,c);continue}W(r)||t.push(`${c} "${r}" is not a supported color form or anchor: reference. Accepted forms: ${oe}, or anchor:<name> / anchor:<name>.<slot>. An override retunes a family with a declared color; it never points one family at another \u2014 retune, never reassign.`)}function _(s,r){if(s.startsWith("anchor:")){y(s,r);return}W(s)||t.push(`${r} is not a valid CSS color: "${s}". Accepted forms: ${oe}, or a declared anchor as anchor:<name> / anchor:<name>.<slot>.`)}if("dataPalette"in e)if(typeof e.dataPalette!="object"||e.dataPalette===null||Array.isArray(e.dataPalette))t.push("dataPalette must be an object with series1\u2013series8 color values.");else{const s=e.dataPalette;for(const[r,c]of Object.entries(s)){if(!fe.includes(r)){t.push(`dataPalette.${r} is not a series slot; expected one of: ${fe.join(", ")}.`);continue}typeof c!="string"?t.push(`dataPalette.${r} must be a CSS color or anchor reference string.`):_(c,`dataPalette.${r}`)}}if("dataRamps"in e)if(typeof e.dataRamps!="object"||e.dataRamps===null||Array.isArray(e.dataRamps))t.push("dataRamps must be an object of named ramp declarations.");else for(const[s,r]of Object.entries(e.dataRamps)){if(M(s)?j.test(s)||t.push(`dataRamps: "${s}" is not a valid ramp name; use a lowercase slug (letters, digits, hyphens).`):t.push(`dataRamps: "${s}" is a reserved JavaScript property name and cannot be a ramp name; rename it.`),typeof r!="object"||r===null||Array.isArray(r)){t.push(`dataRamps.${s} must be a sequential or diverging ramp object.`);continue}const c=r,l=c.steps??Mt;if((typeof l!="number"||!Number.isInteger(l)||l<xe||l>$e)&&t.push(`dataRamps.${s}.steps must be an integer from ${xe} through ${$e}.`),c.type==="sequential"){typeof c.source!="string"?t.push(`dataRamps.${s}.source must be a CSS color or anchor reference string.`):_(c.source,`dataRamps.${s}.source`);const p=c.lightnessStart??.95,g=c.lightnessEnd??.25;for(const[f,h]of[["lightnessStart",p],["lightnessEnd",g]])(typeof h!="number"||!Number.isFinite(h)||h<0||h>1)&&t.push(`dataRamps.${s}.${f} must be a finite number from 0 through 1.`);typeof p=="number"&&typeof g=="number"&&p<=g?t.push(`dataRamps.${s}.lightnessStart must be greater than lightnessEnd.`):typeof p=="number"&&Number.isFinite(p)&&typeof g=="number"&&Number.isFinite(g)&&typeof l=="number"&&Number.isInteger(l)&&l>=xe&&l<=$e&&(p-g)/(l-1)<=We&&t.push(`dataRamps.${s} lightness bounds must leave more than ${We} lightness between serialized stops.`);continue}if(c.type==="diverging"){typeof l=="number"&&Number.isInteger(l)&&l%2===0&&t.push(`dataRamps.${s}.steps must be odd so the neutral is the exact midpoint.`);for(const p of["start","end"])typeof c[p]!="string"?t.push(`dataRamps.${s}.${p} must be a CSS color or anchor reference string.`):_(c[p],`dataRamps.${s}.${p}`);"neutral"in c&&(typeof c.neutral!="string"?t.push(`dataRamps.${s}.neutral must be a CSS color or anchor reference string.`):_(c.neutral,`dataRamps.${s}.neutral`));continue}t.push(`dataRamps.${s}.type must be "sequential" or "diverging".`)}if("dataPalette"in e&&t.length===0){const s=de(Re,e),r={};let c=!0;for(const l of fe){const p=Ot(s.dataPalette[l],s.anchors);if(!p){c=!1;break}r[l]=p}if(c)for(const l of St(r))o.push(At(l))}function z(s,r){if(typeof s!="object"||s===null||Array.isArray(s)){t.push(`${r} must be an object.`);return}const c=s;for(const[l,p]of Object.entries(c)){const g=`${r}.${l}`;if(!se.includes(l)){t.push(`${g} is not a role; expected one of: ${se.join(", ")}. (The status family is reserved and is not a role.)`);continue}const f=l,h=Se[f];if(typeof p=="string"){T(p,g);continue}if(typeof p!="object"||p===null||Array.isArray(p)){t.push(`${g} must be a color source or a { color, \u2026slots } object.`);continue}const $=p;typeof $.color!="string"&&t.push(`${g} must declare its base "color".`);for(const[b,R]of Object.entries($)){if(!Object.prototype.hasOwnProperty.call(h,b)||!M(b)){const C=Object.keys(h).filter(w=>w!=="color");t.push(`${g}.${b} is not a slot of the ${f} role. Declared slots: ${C.length>0?C.join(", "):"(none)"}.`);continue}typeof R!="string"?t.push(`${g}.${b} must be a color source string.`):T(R,`${g}.${b}`)}}}if("roles"in e&&z(e.roles,"roles"),"contexts"in e)if(typeof e.contexts!="object"||e.contexts===null||Array.isArray(e.contexts))t.push("contexts must be an object.");else for(const[s,r]of Object.entries(e.contexts)){if(!M(s)||!j.test(s)){t.push(`contexts.${s} must be a lowercase slug matching ${j.source}.`);continue}if(typeof r!="object"||r===null||Array.isArray(r)){z(r,`contexts.${s}`);continue}const c=r,l=Object.fromEntries(Object.entries(c).filter(([g])=>g!=="lightness"&&g!=="tones"&&g!=="semanticMappings"));z(l,`contexts.${s}`),"lightness"in c&&d(c.lightness,`contexts.${s}.lightness`);const p=new Set(A);if("tones"in c)for(const g of m(c.tones,`contexts.${s}.tones`))p.add(g);"semanticMappings"in c&&H(c.semanticMappings,`contexts.${s}.semanticMappings`,p)}function H(s,r,c){if(typeof s!="object"||s===null||Array.isArray(s)){t.push(`${r} must be an object.`);return}const l=s;for(const p of Object.keys(l))K.includes(p)||t.push(`${r}.${p} is not a semantic token; expected one of: ${K.join(", ")}.`);for(const p of K)if(p in l){const g=l[p];if(typeof g!="object"||g===null){t.push(`${r}.${p} must be { source, lightness }.`);continue}const f=g;if(typeof f.source!="string"?t.push(`${r}.${p}.source must be a string.`):T(f.source,`${r}.${p}.source`),typeof f.lightness!="string")t.push(`${r}.${p}.lightness must be one of: ${U.join(", ")}, or a declared tone:<name>.`);else if(!te(f.lightness)){const h=Me(f.lightness);if(h===null)t.push(`${r}.${p}.lightness must be one of: ${U.join(", ")}, or a declared tone:<name>.`);else if(!c.has(h)){const $=[...c].sort();t.push(`${r}.${p}.lightness references undeclared tone "${h}". Declared tones: ${$.length>0?$.join(", "):"(none)"}.`)}}}}if("semanticMappings"in e&&H(e.semanticMappings,"semanticMappings",A),"explicitMappingTokens"in e)if(!Array.isArray(e.explicitMappingTokens))t.push("explicitMappingTokens must be an array of semantic token names.");else{const s=new Set,r=L(e.semanticMappings)?e.semanticMappings:void 0;for(const c of e.explicitMappingTokens){if(typeof c!="string"||!K.includes(c)){t.push(`explicitMappingTokens entries must be one of: ${K.join(", ")}.`);continue}s.has(c)&&t.push(`explicitMappingTokens contains duplicate token "${c}".`),s.add(c),(!r||!Object.prototype.hasOwnProperty.call(r,c))&&t.push(`explicitMappingTokens names "${c}" without a semanticMappings entry.`)}}for(const s of["pageBackgroundImage","boxBackgroundImage","vellumBackgroundImage"])s in e&&typeof e[s]!="string"&&t.push(`${s} must be a string.`);for(const s of["pageBackgroundImageOpacity","boxBackgroundImageOpacity","vellumOpacity","vellumBackgroundImageOpacity"])if(s in e)if(typeof e[s]!="number"||!isFinite(e[s]))t.push(`${s} must be a finite number.`);else{const r=e[s];(r<0||r>1)&&t.push(`${s} must be 0\u20131 (got ${r}).`)}return o.push(...Xt(e,n)),{valid:t.length===0,errors:t,warnings:o}}const B=.045;function Xt(e,n){try{return Zt(e,n)}catch{return[]}}function Zt(e,n){const t=de(n,e),o=ut(t),i=[...o],a=new Set(o);for(const u of Object.keys(t.contexts)){const d=it(t,u);if(d)for(const m of ut(d))a.has(m)||i.push(`contexts.${u}: ${m}`)}return i}function Qt(e){const n=yt(he(e)),t=$t(n);return ht({r:ge(t.r),g:ge(t.g),b:ge(t.b)})}function Z(e,n){return Math.hypot(e.L-n.L,e.a-n.a,e.b-n.b)}function q(e){return Qt(W(ce(he(e))))}function at(e){return(Math.floor(e*1e4)/1e4).toFixed(4)}const Q=2,ct=1e-4;function ut(e){const n=W(e.seedColor);if(!n)return[];const t=ye(n,e),o=e.semanticMappings.actionBackground,i=e.chroma.actionBackground,a=Oe(e.lightness,e.tones,o.lightness),u=(f,h,$,b)=>he(ae(f,h,$,b)),d=ee.map(f=>({name:f,base:t[f]})),m=[];if(ee.includes(o.source))m.push(`actionBackground is sourced from the "${o.source}" status family: ordinary and ${o.source}-intent action surfaces render identically (their labels may still differ). Remap the action to a non-status source \u2014 retuning "${o.source}" via intents moves both colors together.`);else{const f=ue(o.source,t,e.anchors);f&&d.push({name:"action",base:f})}const A=Fe(d.map(({name:f,base:h})=>[f,ce(u(h,a,i.min,i.max))]),B,["normal"]);if(A.length===0)return m;const k=new Map,y=(f,h)=>{const $=`${f}:${h}`;let b=k.get($);if(!b){b=[];for(let R=0;R<360;R+=Q)b.push(q({l:f,c:h,h:R}));k.set($,b)}return b},T=B-.002,_=(f,h,$,b)=>{const R=Math.hypot(f.a,f.b),C=Math.atan2(f.b,f.a)*180/Math.PI+180;let w=0;for(const S of $===b?[b]:[$,b]){if(S+R<B-1e-4)continue;let x=C,O=Z(q({l:h,c:S,h:C}),f);if(O>=B)return O;const D=y(h,S);for(let E=0;E<D.length;E+=1){const v=Z(D[E],f);if(v>=B)return v;v>O&&(O=v,x=E*Q)}let P=x;for(let E=x-Q;E<=x+Q;E+=.1){const v=Z(q({l:h,c:S,h:E}),f);if(v>=B)return v;v>O&&(O=v,P=E)}if(O>=T)for(let E=P-.1;E<=P+.1;E+=.001){const v=Z(q({l:h,c:S,h:E}),f);if(v>=B)return v;v>O&&(O=v)}O>w&&(w=O)}return w},z=(f,h,$)=>{const b=h===$?[$]:[h,$];let R=0;for(const C of b)for(const w of b){if(C+w<B-1e-4)continue;const S=y(f,C),x=y(f,w);let O=0,D=0,P=-1;for(let N=0;N<S.length;N+=1)for(let G=0;G<x.length;G+=1){const V=Z(S[N],x[G]);if(V>=B)return V;V>P&&(P=V,O=N*Q,D=G*Q)}const E=(N,G,V,Le)=>{const Ie=[];for(let J=G-V;J<=G+V;J+=Le)Ie.push({h:J,lab:q({l:f,c:w,h:J})});let me=-1,Ne=N,He=G;for(let J=N-V;J<=N+V;J+=Le){const pt=q({l:f,c:C,h:J});for(const Pe of Ie){const De=Z(pt,Pe.lab);De>me&&(me=De,Ne=J,He=Pe.h)}}return{distance:me,hueA:Ne,hueB:He}},v=E(O,D,Q,.1);if(v.distance>=B)return v.distance;let I=Math.max(P,v.distance);if(I>=T){const N=E(v.hueA,v.hueB,.1,.001);if(N.distance>I&&(I=N.distance),I>=B)return I}I>R&&(R=I)}return R},H=f=>ee.includes(f),s=(f,h,$,b,R)=>{const C=q(u(f.base,$,b,R)),w=q(u(h.base,$,b,R));if(Z(C,w)>=B)return{outcome:"direct"};const S=H(f.name)&&H(h.name),x=[f,h].filter(P=>H(P.name)),O=S?"one of them":`"${H(f.name)?f.name:h.name}"`;let D;for(const P of x){const E=_(P===f?w:C,$,b,R);if(E>=B)return{outcome:"retune",target:O};E>=B-ct&&(D=D??O)}if(S){const P=z($,b,R);if(P>=B)return{outcome:"retune",target:"both"};P>=B-ct&&(D=D??"both")}return D!==void 0?{outcome:"near",target:D}:{outcome:"no"}},r=f=>f.outcome==="direct"?4:f.outcome==="retune"?f.target==="both"?2:3:f.outcome==="near"?1:0,c=f=>[...f].sort().join("|"),l=new Set(Fe(d.map(({name:f,base:h})=>[f,ce(u(h,a,0,Y))]),B,["normal"]).map(f=>c(f.pair))),p=new Map(d.map(f=>[f.name,f])),g=new Map;for(const{pair:f,distance:h}of A){const $=p.get(f[0]),b=p.get(f[1]),R=H($.name)&&H(b.name),C=s($,b,a,i.min,i.max);if(C.outcome==="direct"||C.outcome==="retune"){const I=C.target??(R?"one of them":`"${H($.name)?$.name:b.name}"`);l.has(c(f))?m.push(`Status colors "${f[0]}" and "${f[1]}" are hard to distinguish under normal vision (distance ${at(h)} < ${B}); status meanings must stay distinguishable \u2014 retune ${I} via intents.`):m.push(`Status colors "${f[0]}" and "${f[1]}" are hard to distinguish as rendered (distance ${at(h)} < ${B}); the actionBackground chroma band ({ min: ${i.min}, max: ${i.max} }) pushes them together \u2014 widen the band, or retune ${I} via intents.`);continue}const w=s($,b,a,0,Y);let S={outcome:"no"};for(let I=1;I<=19&&S.outcome!=="direct";I+=1){const N=I*.05;if(Math.abs(N-a)<.001)continue;const G=s($,b,N,i.min,i.max);r(G)>r(S)&&(S=G)}let x={outcome:"no"};const O=w.outcome==="direct"||w.outcome==="retune",D=S.outcome==="direct"||S.outcome==="retune";if(!O&&!D)for(let I=1;I<=19&&x.outcome!=="direct";I+=1){const N=s($,b,I*.05,0,Y);r(N)>r(x)&&(x=N)}const P=en(w,S,x),E=`${C.outcome}|${P}`;let v=g.get(E);v||(v=[],g.set(E,v)),v.push(f)}for(const[f,h]of g){const $=f.indexOf("|"),b=f.slice(0,$),R=f.slice($+1),C=h.map(([x,O])=>`"${x}"/"${O}"`),w=C.length>1?`${C.slice(0,-1).join(", ")} and ${C[C.length-1]}`:C[0],S=b==="near"?`Status colors ${w} may not separate by retuning as rendered: at the action stop's lightness (${a}) with the actionBackground chroma band ({ min: ${i.min}, max: ${i.max} }), the closest reachable retune found comes within the audit's search margin of the ${B} threshold`:`Status colors ${w} cannot be separated as rendered: at the action stop's lightness (${a}) with the actionBackground chroma band ({ min: ${i.min}, max: ${i.max} }), no intent retuning can pull ${h.length>1?"these pairs":"the pair"} ${B} apart`;m.push(S+R)}return m}function en(e,n,t){if(e.outcome==="direct"&&n.outcome==="direct")return" \u2014 widen the chroma band or move the action lightness stop.";if(e.outcome==="direct")return n.outcome==="no"?"; no other action lightness stop can help while the band holds \u2014 widen the chroma band.":" \u2014 widen the chroma band.";if(n.outcome==="direct")return e.outcome==="no"?"; no wider chroma band can help at this lightness \u2014 move the action lightness stop.":" \u2014 move the action lightness stop.";if(e.outcome==="retune"&&n.outcome==="retune")return` \u2014 widen the chroma band or move the action lightness stop, then retune ${e.target} via intents.`;if(e.outcome==="retune")return n.outcome==="no"?`; no other action lightness stop can help while the band holds \u2014 widen the chroma band, then retune ${e.target} via intents.`:` \u2014 widen the chroma band, then retune ${e.target} via intents.`;if(n.outcome==="retune")return e.outcome==="no"?`; no wider chroma band can help at this lightness \u2014 move the action lightness stop, then retune ${n.target} via intents.`:` \u2014 move the action lightness stop, then retune ${n.target} via intents.`;const o=e.outcome==="no"&&n.outcome==="no"?"; neither a wider chroma band alone nor another stop alone can help":"; neither a wider chroma band alone nor another stop alone provably helps";return t.outcome==="direct"?`${o} \u2014 change the band and the stop together.`:t.outcome==="retune"?`${o} \u2014 change the band and the stop together, then retune ${t.target} via intents.`:"; no explored band or stop change provably separates this pair."}function ln(e,n){const t=Be(e),o=Be(n),i=t.error!==void 0?{valid:!1,errors:[t.error],warnings:[]}:_e(t.value),a=o.error!==void 0?{valid:!1,errors:[o.error],warnings:[]}:_e(o.value,qe),u=[...i.errors.map(m=>`light: ${m}`),...a.errors.map(m=>`dark: ${m}`)],d=[...i.warnings.map(m=>`light: ${m}`),...a.warnings.map(m=>`dark: ${m}`)];if(i.valid&&a.valid){const m=new Set(Object.keys(t.value?.contexts??{})),A=new Set(Object.keys(o.value?.contexts??{})),k=[...A].filter(T=>!m.has(T)).sort(),y=[...m].filter(T=>!A.has(T)).sort();(k.length>0||y.length>0)&&u.push(`contexts must declare the same names in both schemes. Missing from light: ${k.join(", ")||"(none)"}. Missing from dark: ${y.join(", ")||"(none)"}.`)}return{valid:u.length===0,errors:u,warnings:d}}const tn=["anchors","angles","contexts","dataPalette","dataRamps","intents","roles","chroma","lightness","tones","semanticHues","semanticMappings","variantChroma"];function nn(e,n){const t={};for(const[a,u]of Object.entries(e))M(a)&&(t[a]=u);for(const[a,u]of Object.entries(n))u!==void 0&&M(a)&&(t[a]=u);for(const a of tn){const u=e[a],d=n[a];if(u&&typeof u=="object"&&!Array.isArray(u)&&d&&typeof d=="object"&&!Array.isArray(d)){if(a==="anchors"){t[a]=Qe(u,d);continue}if(a==="contexts"){t[a]=Ut(u,d);continue}if(a==="dataRamps"){t[a]=nt(u,d);continue}const m={};for(const[A,k]of Object.entries(u))M(A)&&(m[A]=k);for(const[A,k]of Object.entries(d))k!==void 0&&M(A)&&(m[A]=k);t[a]=m}}const o=pe(e),i=pe(n);if(o!==void 0||i!==void 0){const a=o??new Set(Object.keys(e.semanticMappings??{}).filter(u=>K.includes(u)));for(const u of Object.keys(n.semanticMappings??{}))i===void 0||i.has(u)?a.add(u):a.delete(u);t.explicitMappingTokens=Xe(a)}return t}function pn(...e){let n={};for(const t of e){if(!t)continue;const o=Dt(t);o&&(n=nn(n,o))}return Ee(n)}function ft(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r")}const lt={borderRadius:.1,fontBody:'"Noto Sans", sans-serif',fontWeightBody:"normal",fontHeadings:'"Inika", serif',fontWeightHeadings:"normal",fontBrand:'"Inika", serif',fontWeightBrand:"normal",fontMonospace:'"JetBrains Mono", monospace',fontWeightMonospace:"normal",seedColor:"oklch(.07 0.15 216)"};function dn(e){return Ee({...lt,pageBackgroundImage:`url("${ft(e)}")`,pageBackgroundImageOpacity:.5})}function mn(e){return Ee({...lt,pageBackgroundImage:`url("${ft(e)}")`,pageBackgroundImageOpacity:.55})}export{j as ANCHOR_SLUG_PATTERN,Ae as COLOR_SOURCES,Ve as DEFAULT_BODY_FONT_FAMILY,Ht as DEFAULT_DARK_LIGHTNESS,qe as DEFAULT_DARK_THEME,Nt as DEFAULT_LIGHT_LIGHTNESS,Re as DEFAULT_LIGHT_THEME,Je as DEFAULT_MONOSPACE_FONT_FAMILY,Te as DEFAULT_SEMANTIC_MAPPINGS,U as LIGHTNESS_KEYS,tn as NESTED_THEME_KEYS,se as ROLE_NAMES,Rt as ROLE_PAIRED_INK,Se as ROLE_TOKEN_PLAN,K as SEMANTIC_COLOR_NAMES,ee as STATUS_COLOR_SOURCES,Ue as TOKEN_PAIRINGS,It as VARIANT_COLOR_SOURCES,mn as buildTaprootDarkTheme,dn as buildTaprootLightTheme,Ke as compileRoles,Ee as encodeTheme,qt as explicitMappingTokens,te as isLightnessKey,L as isObjectRecord,cn as isSemanticColorName,pn as layerThemes,nn as mergePartials,de as mergeTheme,ke as parseAnchorSource,Dt as parseTheme,je as resolveAnchorColor,it as resolveContextTheme,Ot as resolveDataColorSource,Oe as resolveLightnessReference,un as semanticToCSS,Me as toneReferenceName,fn as validateTheme,ln as validateThemePair};
|
|
1
|
+
import{UNSAFE_KEYS as dt,isSafeKey as M}from"./unsafe-keys.js";import{ACCEPTED_COLOR_FORMS as oe,apcaContrast as mt,clampChannel as ge,deltaEOK as gt,deriveSemantic as ae,gamutMapToSRGB as he,linearRgbToOklab as ht,oklchToSRGB as yt,parseCssColor as W,parseOklch as bt,serializeOklch as ce,srgbToLinearRGB as $t}from"./color-engine.js";import{computeVariants as ye,parseAnchorSource as xt,resolveAnchorColor as kt,resolveMappingSource as ue}from"./variant-engine.js";import{auditColorDistances as Fe,auditDataPalette as St,describePaletteCollision as At,DATA_SERIES_KEYS as fe,DEFAULT_DATA_PALETTE as be,DEFAULT_DATA_RAMP_STEPS as Mt,MAX_DATA_RAMP_STEPS as $e,MIN_DATA_RAMP_LIGHTNESS_STEP as We,MIN_DATA_RAMP_STEPS as xe}from"./data-colors.js";const j=/^[a-z][a-z0-9-]*$/;function ke(e){return xt(e)}function je(e,n){return kt(e,n)}function Ot(e,n){const t=ke(e);if(t){const o=je(n,t);return o&&W(o)?o:null}return W(e)?e:null}const se=["canvas","ink","accent","action","structure"],Se={canvas:{color:[["background","surface"],["layer1","raised1"],["layer2","raised2"],["layer3","raised3"],["layer4","raised4"]]},ink:{color:[["text","text"],["typeOverline","text"],["typeLabel","text"],["typeLead","text"],["typeCaption","text"],["inputSelection","text"]],heading:[["headings","muted"],["headingsHover","ink"]]},accent:{color:[["linkHoverBg","raised2"],["inputSelectionBg","raised2"],["inputCaret","ink"]],text:[["link","accent"]],hover:[["linkHover","text"]]},action:{color:[["actionBackground","muted"]],ink:[["actionText","surface"]]},structure:{color:[["border","border"],["shadow","shadow"]]}},Tt=new Set(["action.color"]),Ct={canvas:"background",ink:"text",accent:"link",action:"actionBackground",structure:"border"},Rt={"action.ink":{role:"canvas",slot:"color"}},vt=.45,Et=.045;function ze(e,n,t){const o=Ue.actionText,i=[...U].sort((y,T)=>e[y]-e[T]||U.indexOf(y)-U.indexOf(T)),a=n?i.filter(y=>n(y)>=o.targetLc):i,u=t?a.filter(y=>t(y)>=Et):a,d=u.length>0?u:a,m=d.length>0?d:i;let A,k=1/0;for(const y of m){const T=Math.abs(e[y]-vt);T<k&&(k=T,A=y)}return A??"muted"}function wt(e,n,t){const o=Oe(n,t,e)>.5;let i=U[0];for(const a of U)(o?n[a]<n[i]:n[a]>n[i])&&(i=a);return i}const Bt={"accent.hover":"text"};function _t(e,n){const t=new Map;try{const o=de(n,e),i=(a,u,d,m)=>{const A=ke(u),k=A?je(m,A):null,y=k===null?null:W(k),T=t.get(a)??[];T.some(_=>_.source===u&&_.chroma===y?.c)||(T.push({source:u,where:d,chroma:y?.c}),t.set(a,T))};for(const[a,u]of Object.entries(o.semanticMappings))u.source.startsWith("anchor:")&&i(a,u.source,"the root table",o.anchors);for(const a of Object.keys(o.contexts)){const u=it(o,a);if(u)for(const[d,m]of Object.entries(u.semanticMappings))m.source.startsWith("anchor:")&&i(d,m.source,`contexts.${a}`,u.anchors)}}catch{return new Map}return t}function X(e,n){if(e===void 0)return;if(typeof e=="string")return n==="color"?e:void 0;const t=e[n];return typeof t=="string"?t:void 0}function Ke(e,n,t,o={}){const i={},a={};for(const[u,d]of Object.entries(o.explicitMappings??{}))d!==void 0&&(a[u]=d.lightness);for(const u of se){const d=e[u];if(d!==void 0)for(const[m,A]of Object.entries(Se[u])){const k=Rt[`${u}.${m}`];let y=X(d,m),T=!1;if(y===void 0){k&&(y=X(e[k.role],k.slot),y??=t[Ct[k.role]]?.source,T=y!==void 0);const _=Bt[`${u}.${m}`];_!==void 0&&(y??=X(d,_)),y??=X(d,"color")}if(y!==void 0)for(const[_,z]of A){let H=z;if(Tt.has(`${u}.${m}`))H=ze(n,o.actionSurfaceContrast?s=>o.actionSurfaceContrast(y,s):void 0,o.actionSurfaceSeparation?s=>o.actionSurfaceSeparation(y,s):void 0);else if(T&&k){const s=Ue[_],r=(s&&a[s.bg])??ze(n,o.actionSurfaceContrast?c=>o.actionSurfaceContrast(X(d,"color"),c):void 0,o.actionSurfaceSeparation?c=>o.actionSurfaceSeparation(X(d,"color"),c):void 0);H=wt(r,n,o.tones??{})}i[_]={source:y,lightness:H}}}}return i}const Ue={text:{bg:"background",targetLc:75},typeOverline:{bg:"background",targetLc:90},typeLabel:{bg:"background",targetLc:75},typeLead:{bg:"background",targetLc:75},typeCaption:{bg:"background",targetLc:90},dangerText:{bg:"background",targetLc:75},headings:{bg:"background",targetLc:60},headingsHover:{bg:"background",targetLc:60},link:{bg:"background",targetLc:75},linkHover:{bg:"linkHoverBg",targetLc:75},actionText:{bg:"actionBackground",targetLc:75},inputCaret:{bg:"layer2",targetLc:60},inputSelection:{bg:"inputSelectionBg",targetLc:60}},K=["background","layer1","layer2","layer3","layer4","actionBackground","actionText","border","shadow","text","typeOverline","typeLabel","typeLead","typeCaption","dangerText","headings","headingsHover","link","linkHover","linkHoverBg","inputCaret","inputSelection","inputSelectionBg"];function cn(e){return typeof e=="string"&&K.includes(e)}const Lt=["typeOverline","typeLabel","typeLead","typeCaption"],Ae=["primary","analogous-left","analogous-right","complementary","split-complementary-left","split-complementary-right","triadic-left","triadic-right","danger","success","warning","info"],ee=["danger","success","warning","info"],It=["analogous-left","analogous-right","complementary","split-complementary-left","split-complementary-right","triadic-left","triadic-right","danger","success","warning","info"],U=["surface","raised1","raised2","raised3","raised4","accent","muted","text","border","ink","shadow"],Ge="tone:";function Me(e){if(typeof e!="string"||!e.startsWith(Ge))return null;const n=e.slice(Ge.length);return M(n)&&j.test(n)?n:null}function te(e){return typeof e!="string"?!1:U.includes(e)}function Oe(e,n,t){if(te(t))return e[t];const o=Me(t);return o===null?e.surface:n?.[o]??e.surface}const Nt={surface:.99,raised1:.97,raised2:.9,raised3:.8,raised4:.72,accent:.5,muted:.45,text:.35,border:.3,ink:.25,shadow:.2},Ht={surface:.15,raised1:.2,raised2:.3,raised3:.4,raised4:.36,accent:.6,muted:.75,text:.85,border:.7,ink:.95,shadow:.6},Te={background:{source:"primary",lightness:"surface"},layer1:{source:"primary",lightness:"raised1"},layer2:{source:"primary",lightness:"raised2"},layer3:{source:"primary",lightness:"raised3"},layer4:{source:"primary",lightness:"raised4"},actionBackground:{source:"primary",lightness:"raised3"},actionText:{source:"primary",lightness:"ink"},border:{source:"primary",lightness:"border"},shadow:{source:"primary",lightness:"shadow"},text:{source:"primary",lightness:"text"},typeOverline:{source:"primary",lightness:"text"},typeLabel:{source:"primary",lightness:"text"},typeLead:{source:"primary",lightness:"text"},typeCaption:{source:"primary",lightness:"text"},dangerText:{source:"danger",lightness:"text"},headings:{source:"primary",lightness:"muted"},headingsHover:{source:"primary",lightness:"text"},link:{source:"complementary",lightness:"accent"},linkHover:{source:"complementary",lightness:"text"},linkHoverBg:{source:"triadic-left",lightness:"raised2"},inputCaret:{source:"triadic-right",lightness:"ink"},inputSelection:{source:"complementary",lightness:"text"},inputSelectionBg:{source:"triadic-left",lightness:"raised2"}},Y=.4;function Ce(){const e={};for(const n of K)e[n]={min:0,max:Y};return e}const Ve="system-ui, sans-serif",Je="monospace",Ye={seedColor:"oklch(0.7 0.125 216)",fontBody:Ve,fontHeadings:"",fontBrand:"",fontMenu:"",fontMonospace:Je,fontWeightBody:"normal",fontWeightHeadings:"bold",fontWeightBrand:"bold",fontWeightMenu:"bold",fontWeightMonospace:"normal",stylesheets:[],rootFontSize:16,typeRatio:1.25,spaceRatio:1.618,borderRadius:.2,viewportMin:320,viewportMax:1200,angles:{analogous:30,complementary:180,splitComplementary:30,triadic:120},semanticHues:{danger:27,success:150,warning:90,info:244},variantChroma:{},intents:{},tones:{},chroma:Ce(),semanticMappings:{...Te},explicitMappingTokens:[],anchors:{},roles:{},contexts:{},dataPalette:{...be},dataRamps:{}},Re={...Ye,chroma:Ce(),semanticMappings:{...Te},anchors:{},roles:{},contexts:{},tones:{},dataPalette:{...be},dataRamps:{},lightness:{...Nt}},qe={...Ye,chroma:Ce(),semanticMappings:{...Te},anchors:{},roles:{},contexts:{},tones:{},dataPalette:{...be},dataRamps:{},lightness:{...Ht}},le=new WeakMap;le.set(Re,new Set),le.set(qe,new Set);function Pt(e,n){return dt.has(e)?void 0:n}function pe(e){const n=e.explicitMappingTokens;if(!Array.isArray(n)||n.some(o=>typeof o!="string"||!K.includes(o)))return;const t=new Set(n);if(t.size===n.length&&!(t.size>0&&(!L(e.semanticMappings)||[...t].some(o=>!Object.prototype.hasOwnProperty.call(e.semanticMappings,o)))))return t}function Xe(e){return K.filter(n=>e.has(n))}function un(e){return`--esp-color-${e.replace(/([A-Z])/g,"-$1").replace(/(\d)/g,"-$1").toLowerCase()}`}function Dt(e){try{const n=Ze(e),t=JSON.parse(n,Pt);return typeof t!="object"||t===null||Array.isArray(t)?null:t}catch{return null}}const ve="\xEF\xBB\xBF";function Ft(e){if(/^[\u0000-\u007f]*$/.test(e))return btoa(e);const n=new TextEncoder().encode(e);let t=ve;for(const o of n)t+=String.fromCharCode(o);return btoa(t)}function Ze(e){const n=atob(e);if(!n.startsWith(ve))return n;const t=Uint8Array.from(n.slice(ve.length),o=>o.charCodeAt(0));return new TextDecoder("utf-8",{fatal:!0}).decode(t)}function Ee(e){return Ft(JSON.stringify(e))}function Wt(e){const n={};for(const t of ee){const o=e[t];typeof o=="string"&&(n[t]=o.startsWith("anchor:")?o:re(o))}return n}function re(e){if(bt(e))return e;const n=W(e);return n?ce(n):e}function Qe(e,n){const t={};for(const[o,i]of Object.entries(e))M(o)&&(t[o]=i);if(!n)return t;for(const[o,i]of Object.entries(n)){if(i===void 0||!M(o))continue;const a=t[o];if(a!==void 0&&typeof i=="object"&&i!==null){const u={};if(typeof a=="string")u.color=a;else for(const[d,m]of Object.entries(a))M(d)&&(u[d]=m);for(const[d,m]of Object.entries(i))m!==void 0&&M(d)&&(u[d]=m);t[o]=u;continue}t[o]=i}return t}function we(e){const n={};if(!L(e))return n;for(const[t,o]of Object.entries(e))M(t)&&j.test(t)&&!te(t)&&typeof o=="number"&&Number.isFinite(o)&&o>=0&&o<=1&&(n[t]=o);return n}function jt(e,n){return{...we(e),...we(n)}}function zt(e,n){const t={...e};if(!L(n))return t;for(const o of U){const i=n[o];typeof i=="number"&&Number.isFinite(i)&&i>=0&&i<=1&&(t[o]=i)}return t}function et(e){if(typeof e!="object"||e===null||Array.isArray(e))return null;const n=e,t={};for(const o of se){const i=n[o];i!==void 0&&(t[o]=i)}if(typeof n.lightness=="object"&&n.lightness!==null&&!Array.isArray(n.lightness)){const o={};for(const i of U){const a=n.lightness[i];a!==void 0&&(o[i]=a)}t.lightness=o}if(n.tones!==void 0){const o=we(n.tones);Object.keys(o).length>0&&(t.tones=o)}if(typeof n.semanticMappings=="object"&&n.semanticMappings!==null&&!Array.isArray(n.semanticMappings)){const o={};for(const[i,a]of Object.entries(n.semanticMappings)){if(!M(i)||!K.includes(i)||typeof a!="object"||a===null||Array.isArray(a))continue;const{source:u,lightness:d}=a;typeof u=="string"&&(typeof d!="string"||!te(d)&&Me(d)===null||(o[i]={source:u,lightness:d}))}Object.keys(o).length>0&&(t.semanticMappings=o)}return t}function Kt(e,n){const t={};for(const[o,i]of Object.entries(e)){if(!M(o)||!j.test(o))continue;const a=et(i);a&&(t[o]=a)}if(!n)return t;for(const[o,i]of Object.entries(n)){if(!M(o)||!j.test(o)||i===void 0)continue;const a=et(i);if(!a)continue;const u=t[o];t[o]={...u??{},...a,...u?.lightness||a.lightness?{lightness:{...u?.lightness,...a.lightness}}:{},...u?.tones||a.tones?{tones:{...u?.tones,...a.tones}}:{},...u?.semanticMappings||a.semanticMappings?{semanticMappings:{...u?.semanticMappings,...a.semanticMappings}}:{}}}return t}function L(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function F(e){const n={};for(const[t,o]of Object.entries(e))o!==void 0&&M(t)&&(n[t]=o);return n}function tt(e){if(!L(e))return e;const n=F(e);return L(e.lightness)&&(n.lightness=F(e.lightness)),L(e.tones)&&(n.tones=F(e.tones)),n}function Ut(e,n){const t={};for(const[o,i]of Object.entries(e))M(o)&&(t[o]=tt(i));if(!n)return t;for(const[o,i]of Object.entries(n)){if(!M(o)||i===void 0)continue;const a=t[o];if(!L(a)||!L(i)){t[o]=tt(i);continue}const u={...F(a),...F(i)};L(a.lightness)&&L(i.lightness)?u.lightness={...F(a.lightness),...F(i.lightness)}:L(i.lightness)&&(u.lightness=F(i.lightness)),L(a.tones)&&L(i.tones)?u.tones={...F(a.tones),...F(i.tones)}:L(i.tones)&&(u.tones=F(i.tones)),L(a.semanticMappings)&&L(i.semanticMappings)?u.semanticMappings={...F(a.semanticMappings),...F(i.semanticMappings)}:L(i.semanticMappings)&&(u.semanticMappings=F(i.semanticMappings)),t[o]=u}return t}function Gt(e){const n={};for(const[t,o]of Object.entries(e)){if(!M(t))continue;if(typeof o=="string"){n[t]=re(o);continue}const i={};for(const[a,u]of Object.entries(o))M(a)&&(i[a]=typeof u=="string"?re(u):u);n[t]=i}return n}function ie(e){return typeof e!="string"?"":e.startsWith("anchor:")?e:re(e)}function Vt(e){const n={};for(const t of fe)n[t]=ie(e[t]);return n}function nt(e,n){const t={};for(const[o,i]of Object.entries(e))M(o)&&j.test(o)&&i&&typeof i=="object"&&!Array.isArray(i)&&(t[o]={...i});if(!n)return t;for(const[o,i]of Object.entries(n)){if(!M(o)||!j.test(o)||!i||typeof i!="object"||Array.isArray(i))continue;const a=t[o],u=a!==void 0&&i.type!==void 0&&i.type!==a.type;t[o]={...u?{}:a??{},...i}}return t}function Jt(e){const n={};for(const[t,o]of Object.entries(e))if(M(t)){if(o.type==="sequential"&&typeof o.source=="string"){n[t]={...o,source:ie(o.source)};continue}if(o.type==="diverging"&&typeof o.start=="string"&&typeof o.end=="string"){n[t]={...o,start:ie(o.start),end:ie(o.end),...typeof o.neutral=="string"?{neutral:ie(o.neutral)}:{}};continue}n[t]={...o}}return n}function ot(e){const n=W(e.seedColor);if(!n)return;const t=ye(n,e);return(o,i)=>{const a=ue(o,t,e.anchors)??t.primary,u=e.chroma.actionBackground,d=ae(a,e.lightness[i],u.min,u.max),m={l:d.l>.5?0:1,c:0,h:0};return Math.abs(mt(m,d))}}function Yt(e,n,t){if(n?.background)return n.background;const o=X(e.canvas,"color");if(o!==void 0){const i=Se.canvas.color?.find(([a])=>a==="background");if(i)return{source:o,lightness:i[1]}}return t.background}function st(e,n){const t=W(e.seedColor);if(!t||!n)return;const o=ye(t,e),i=ue(n.source,o,e.anchors)??o.primary,a=e.chroma.background,u=ae(i,Oe(e.lightness,e.tones,n.lightness),a.min,a.max);return(d,m)=>{const A=ue(d,o,e.anchors)??o.primary,k=e.chroma.actionBackground,y=ae(A,e.lightness[m],k.min,k.max);return gt(y,u)}}function qt(e){const n=le.get(e);if(n)return new Set(n);const t=pe(e);if(t)return t;const o=new Set,i=Ke(e.roles,e.lightness,e.semanticMappings,{tones:e.tones,actionSurfaceContrast:ot(e),actionSurfaceSeparation:st(e,e.semanticMappings.background)});for(const[a,u]of Object.entries(i)){const d=e.semanticMappings[a];(d.source!==u.source||d.lightness!==u.lightness)&&o.add(a)}return o}function de(e,n){const t={...e.roles,...n.roles},o=Kt(e.contexts,n.contexts),i=zt(e.lightness,n.lightness),a=jt(e.tones,n.tones),u=Gt(Qe(e.anchors,n.anchors)),d=typeof n.seedColor=="string"?re(n.seedColor):e.seedColor,m=n.semanticMappings,A={...e.angles,...n.angles},k={...e.semanticHues,...n.semanticHues},y={...e.variantChroma,...n.variantChroma},T=Wt({...e.intents,...n.intents}),_=n.chroma,z=ne(e.chroma,_),H=Vt(ne(e.dataPalette,n.dataPalette)),s=Jt(nt(e.dataRamps,n.dataRamps)),r=qt(e),c=new Set(r),l=pe(n),p={};for(const x of r)p[x]=e.semanticMappings[x];for(const[x,O]of Object.entries(m??{}))O!==void 0&&(l===void 0||l.has(x)?(c.add(x),p[x]=O):(c.delete(x),delete p[x]));const g=ne(e.semanticMappings,m),f={angles:A,anchors:u,chroma:z,intents:T,lightness:i,tones:a,seedColor:d,semanticHues:k,variantChroma:y},h=ot(f),$=st(f,Yt(t,p,g)),b=Ke(t,i,g,{explicitMappings:p,tones:a,actionSurfaceContrast:h,actionSurfaceSeparation:$}),R={};for(const[x,O]of Object.entries(b))c.has(x)||(R[x]=O);const C={};for(const x of Lt)!c.has(x)&&R[x]===void 0&&(C[x]={source:g.text.source,lightness:g.text.lightness},_?.text!==void 0&&_[x]===void 0&&(z[x]={...z.text}));const w=ne(ne(ne(e.semanticMappings,C),R),m),S={...e,seedColor:d,fontBody:n.fontBody||e.fontBody||Ve,fontHeadings:n.fontHeadings??e.fontHeadings,fontBrand:n.fontBrand??e.fontBrand,fontMenu:n.fontMenu??e.fontMenu,fontMonospace:n.fontMonospace||e.fontMonospace||Je,fontWeightBody:String(n.fontWeightBody??e.fontWeightBody),fontWeightHeadings:String(n.fontWeightHeadings??e.fontWeightHeadings),fontWeightBrand:String(n.fontWeightBrand??e.fontWeightBrand),fontWeightMenu:String(n.fontWeightMenu??e.fontWeightMenu),fontWeightMonospace:String(n.fontWeightMonospace??e.fontWeightMonospace),stylesheets:n.stylesheets??[...e.stylesheets],rootFontSize:n.rootFontSize??e.rootFontSize,typeRatio:n.typeRatio??e.typeRatio,spaceRatio:n.spaceRatio??e.spaceRatio,borderRadius:n.borderRadius??e.borderRadius,viewportMin:n.viewportMin??e.viewportMin,viewportMax:n.viewportMax??e.viewportMax,angles:A,semanticHues:k,variantChroma:y,intents:T,lightness:i,tones:a,chroma:z,semanticMappings:w,explicitMappingTokens:Xe(c),anchors:u,roles:t,contexts:o,dataPalette:H,dataRamps:s};return n.pageBackgroundImage!==void 0&&(S.pageBackgroundImage=n.pageBackgroundImage),n.pageBackgroundImageOpacity!==void 0&&(S.pageBackgroundImageOpacity=n.pageBackgroundImageOpacity),n.boxBackgroundImage!==void 0&&(S.boxBackgroundImage=n.boxBackgroundImage),n.boxBackgroundImageOpacity!==void 0&&(S.boxBackgroundImageOpacity=n.boxBackgroundImageOpacity),n.vellumOpacity!==void 0&&(S.vellumOpacity=n.vellumOpacity),n.vellumBackgroundImage!==void 0&&(S.vellumBackgroundImage=n.vellumBackgroundImage),n.vellumBackgroundImageOpacity!==void 0&&(S.vellumBackgroundImageOpacity=n.vellumBackgroundImageOpacity),le.set(S,new Set(c)),S}const rt=new WeakMap;function it(e,n){const t=e.contexts&&Object.prototype.hasOwnProperty.call(e.contexts,n)?e.contexts[n]:void 0;if(!t)return null;let o=rt.get(e);const i=o?.get(n);if(i)return i;const a={};for(const d of se){const m=t[d];m!==void 0&&(a[d]=m)}const u=de(e,{lightness:t.lightness,tones:t.tones,roles:a,semanticMappings:t.semanticMappings});return o||(o=new Map,rt.set(e,o)),o.set(n,u),u}function ne(e,n){if(!n)return{...e};const t={...e};for(const o of Object.keys(n)){const i=n[o];i!==void 0&&(t[o]=i)}return t}function Be(e){let n;try{n=Ze(e)}catch{return{error:"Failed to decode Base64 string."}}let t;try{t=JSON.parse(n)}catch{return{error:"Decoded string is not valid JSON."}}return typeof t!="object"||t===null||Array.isArray(t)?{error:"Theme must be a JSON object."}:{value:t}}function fn(e){const n=Be(e);return n.error!==void 0?{valid:!1,errors:[n.error],warnings:[]}:_e(n.value)}function _e(e,n=Re){const t=[],o=[];"seedColor"in e&&(typeof e.seedColor!="string"?t.push("seedColor must be a string."):W(e.seedColor)||t.push(`seedColor is not a valid CSS color: "${e.seedColor}". Accepted forms: ${oe}.`));for(const s of["fontBody","fontHeadings","fontBrand","fontMenu","fontMonospace"])s in e&&typeof e[s]!="string"&&t.push(`${s} must be a string.`);const i=["normal","bold","lighter","bolder"],a=["inherit","initial","unset","revert","revert-layer"];for(const s of["fontWeightBody","fontWeightHeadings","fontWeightBrand","fontWeightMenu","fontWeightMonospace"])if(s in e){const r=e[s];if(typeof r=="number")(r<1||r>1e3)&&t.push(`${s} numeric value must be 1\u20131000 (got ${r}).`);else if(typeof r=="string"){const c=i.includes(r)||a.includes(r);if(/^\d+$/.test(r)){const p=Number(r);(p<1||p>1e3)&&t.push(`${s} numeric value must be 1\u20131000 (got "${r}").`)}else c||o.push(`${s} = "${r}" is not a standard font-weight value.`)}else t.push(`${s} must be a string or number.`)}"stylesheets"in e&&(Array.isArray(e.stylesheets)?e.stylesheets.some(s=>typeof s!="string")&&t.push("Every entry in stylesheets must be a string."):t.push("stylesheets must be an array of strings."));const u=[["rootFontSize",1,100],["borderRadius",0,10],["viewportMin",100,1e4],["viewportMax",200,1e4]];for(const[s,r,c]of u)if(s in e)if(typeof e[s]!="number"||!isFinite(e[s]))t.push(`${s} must be a finite number.`);else{const l=e[s];r!==void 0&&l<r&&t.push(`${s} must be \u2265 ${r} (got ${l}).`),c!==void 0&&l>c&&o.push(`${s} = ${l} is unusually high (max ${c}).`)}for(const s of["typeRatio","spaceRatio"])if(s in e)if(typeof e[s]!="number"||!isFinite(e[s]))t.push(`${s} must be a finite number.`);else{const r=e[s];r<=1&&t.push(`${s} must be > 1 (got ${r}).`);const c=s==="typeRatio"?1.3:2;r>c&&o.push(`${s} = ${r} is very high (max ${c}); scales may be extreme.`)}if("viewportMin"in e&&"viewportMax"in e){const s=e.viewportMin,r=e.viewportMax;typeof s=="number"&&typeof r=="number"&&s>=r&&t.push(`viewportMin (${s}) must be less than viewportMax (${r}).`)}if("angles"in e)if(typeof e.angles!="object"||e.angles===null)t.push("angles must be an object.");else{const s=e.angles;for(const r of["analogous","complementary","splitComplementary","triadic"])if(r in s)if(typeof s[r]!="number"||!isFinite(s[r]))t.push(`angles.${r} must be a finite number.`);else{const c=s[r];(c<0||c>360)&&o.push(`angles.${r} = ${c} is outside 0\u2013360.`)}}if("semanticHues"in e)if(typeof e.semanticHues!="object"||e.semanticHues===null)t.push("semanticHues must be an object.");else{const s=e.semanticHues;for(const r of["danger","success","warning","info"])if(r in s)if(typeof s[r]!="number"||!isFinite(s[r]))t.push(`semanticHues.${r} must be a finite number.`);else{const c=s[r];(c<0||c>360)&&o.push(`semanticHues.${r} = ${c} is outside 0\u2013360.`)}}if("variantChroma"in e)if(typeof e.variantChroma!="object"||e.variantChroma===null)t.push("variantChroma must be an object.");else{const s=e.variantChroma;for(const r of It)if(r in s)if(typeof s[r]!="number"||!isFinite(s[r]))t.push(`variantChroma["${r}"] must be a finite number.`);else{const c=s[r];c<0&&t.push(`variantChroma["${r}"] must be \u2265 0 (got ${c}).`),c>Y&&o.push(`variantChroma["${r}"] = ${c} exceeds ${Y}.`)}}function d(s,r){if(typeof s!="object"||s===null||Array.isArray(s)){t.push(`${r} must be an object.`);return}const c=s;for(const l of Object.keys(c))(!M(l)||!te(l))&&t.push(`${r}.${l} is not a built-in lightness stop; expected one of: ${U.join(", ")}.`);for(const l of U)if(l in c)if(typeof c[l]!="number"||!isFinite(c[l]))t.push(`${r}.${l} must be a finite number.`);else{const p=c[l];(p<0||p>1)&&t.push(`${r}.${l} must be 0\u20131 (got ${p}).`)}}"lightness"in e&&d(e.lightness,"lightness");function m(s,r){const c=new Set;if(!L(s))return t.push(`${r} must be an object.`),c;for(const[l,p]of Object.entries(s)){if(!M(l)||!j.test(l)){t.push(`${r}.${l} must be a lowercase slug matching ${j.source}.`);continue}if(te(l)){t.push(`${r}.${l} conflicts with the built-in "${l}" lightness stop; choose a distinct custom tone name.`);continue}c.add(l),typeof p!="number"||!Number.isFinite(p)?t.push(`${r}.${l} must be a finite number.`):(p<0||p>1)&&t.push(`${r}.${l} must be 0\u20131 (got ${p}).`)}return c}const A=new Set(Object.keys(n.tones??{}));if("tones"in e)for(const s of m(e.tones,"tones"))A.add(s);if("chroma"in e)if(typeof e.chroma!="object"||e.chroma===null)t.push("chroma must be an object.");else{const s=e.chroma,r=_t(e,n);for(const c of K)if(c in s){const l=s[c];if(typeof l!="object"||l===null){t.push(`chroma.${c} must be { min, max }.`);continue}const p=l;for(const f of r.get(c)??[])f.chroma!==void 0&&typeof p.min=="number"&&typeof p.max=="number"&&(f.chroma<p.min-1e-9||f.chroma>p.max+1e-9)&&o.push(`chroma.${c} clamps the anchor-sourced token ${c} ("${f.source}", effective in ${f.where}) and moves it off its declared swatch. Remove the band if that is unintended \u2014 anchors otherwise keep their own chroma.`);const g=l;(typeof g.min!="number"||g.min<0)&&t.push(`chroma.${c}.min must be \u2265 0.`),(typeof g.max!="number"||g.max<0||g.max>Y)&&t.push(`chroma.${c}.max must be 0\u2013${Y}.`),typeof g.min=="number"&&typeof g.max=="number"&&g.min>g.max&&t.push(`chroma.${c}.min (${g.min}) must be \u2264 max (${g.max}).`)}}if("anchors"in e)if(typeof e.anchors!="object"||e.anchors===null||Array.isArray(e.anchors))t.push("anchors must be an object of named colors.");else for(const[s,r]of Object.entries(e.anchors))if(M(s)?j.test(s)||t.push(`anchors: "${s}" is not a valid anchor name; use a lowercase slug (letters, digits, hyphens).`):t.push(`anchors: "${s}" is a reserved JavaScript property name and cannot be an anchor name; rename it.`),Ae.includes(s)&&t.push(`anchors: "${s}" collides with a reserved color source name.`),typeof r=="string")W(r)||t.push(`anchors.${s} is not a valid CSS color: "${r}". Accepted forms: ${oe}.`);else if(typeof r=="object"&&r!==null&&!Array.isArray(r)){const c=r;typeof c.color!="string"&&t.push(`anchors.${s} must declare its base "color".`);for(const[l,p]of Object.entries(c))M(l)?l!=="color"&&!j.test(l)&&t.push(`anchors.${s}: "${l}" is not a valid slot name; use a lowercase slug.`):t.push(`anchors.${s}: "${l}" is a reserved JavaScript property name and cannot be a slot name; rename it.`),typeof p!="string"?t.push(`anchors.${s}.${l} must be a CSS color string.`):W(p)||t.push(`anchors.${s}.${l} is not a valid CSS color: "${p}". Accepted forms: ${oe}.`)}else t.push(`anchors.${s} must be a color string or a { color, \u2026slots } object.`);const k=new Map;if("anchors"in e&&typeof e.anchors=="object"&&e.anchors!==null&&!Array.isArray(e.anchors))for(const[s,r]of Object.entries(e.anchors))k.set(s,r);function y(s,r){const c=ke(s);if(!c){t.push(`${r} "${s}" is not valid anchor syntax; use anchor:<name> or anchor:<name>.<slot>.`);return}if(!k.has(c.name)){const l=[...k.keys()];t.push(`${r} references undeclared anchor "${c.name}". Declared anchors: ${l.length>0?l.join(", "):"(none)"}.`);return}if(c.slot!==void 0){const l=k.get(c.name);if(typeof(typeof l=="object"&&l!==null&&!Array.isArray(l)?l[c.slot]:void 0)!="string"){const g=typeof l=="object"&&l!==null?Object.keys(l).filter(f=>f!=="color"):[];t.push(`${r} references unknown slot "${c.slot}" on anchor "${c.name}". Declared slots: ${g.length>0?g.join(", "):"(none)"}.`)}}}function T(s,r){if(s.startsWith("anchor:")){y(s,r);return}Ae.includes(s)||t.push(`${r} must be one of: ${Ae.join(", ")}, or a declared anchor as anchor:<name> / anchor:<name>.<slot>.`)}if("intents"in e)if(typeof e.intents!="object"||e.intents===null||Array.isArray(e.intents))t.push("intents must be an object.");else for(const[s,r]of Object.entries(e.intents)){const c=`intents.${s}`;if(!ee.includes(s)){t.push(`${c} is not a status family; expected one of: ${ee.join(", ")}.`);continue}if(typeof r!="string"){t.push(`${c} must be a string (a CSS color or an anchor: reference).`);continue}if(r.startsWith("anchor:")){y(r,c);continue}W(r)||t.push(`${c} "${r}" is not a supported color form or anchor: reference. Accepted forms: ${oe}, or anchor:<name> / anchor:<name>.<slot>. An override retunes a family with a declared color; it never points one family at another \u2014 retune, never reassign.`)}function _(s,r){if(s.startsWith("anchor:")){y(s,r);return}W(s)||t.push(`${r} is not a valid CSS color: "${s}". Accepted forms: ${oe}, or a declared anchor as anchor:<name> / anchor:<name>.<slot>.`)}if("dataPalette"in e)if(typeof e.dataPalette!="object"||e.dataPalette===null||Array.isArray(e.dataPalette))t.push("dataPalette must be an object with series1\u2013series8 color values.");else{const s=e.dataPalette;for(const[r,c]of Object.entries(s)){if(!fe.includes(r)){t.push(`dataPalette.${r} is not a series slot; expected one of: ${fe.join(", ")}.`);continue}typeof c!="string"?t.push(`dataPalette.${r} must be a CSS color or anchor reference string.`):_(c,`dataPalette.${r}`)}}if("dataRamps"in e)if(typeof e.dataRamps!="object"||e.dataRamps===null||Array.isArray(e.dataRamps))t.push("dataRamps must be an object of named ramp declarations.");else for(const[s,r]of Object.entries(e.dataRamps)){if(M(s)?j.test(s)||t.push(`dataRamps: "${s}" is not a valid ramp name; use a lowercase slug (letters, digits, hyphens).`):t.push(`dataRamps: "${s}" is a reserved JavaScript property name and cannot be a ramp name; rename it.`),typeof r!="object"||r===null||Array.isArray(r)){t.push(`dataRamps.${s} must be a sequential or diverging ramp object.`);continue}const c=r,l=c.steps??Mt;if((typeof l!="number"||!Number.isInteger(l)||l<xe||l>$e)&&t.push(`dataRamps.${s}.steps must be an integer from ${xe} through ${$e}.`),c.type==="sequential"){typeof c.source!="string"?t.push(`dataRamps.${s}.source must be a CSS color or anchor reference string.`):_(c.source,`dataRamps.${s}.source`);const p=c.lightnessStart??.95,g=c.lightnessEnd??.25;for(const[f,h]of[["lightnessStart",p],["lightnessEnd",g]])(typeof h!="number"||!Number.isFinite(h)||h<0||h>1)&&t.push(`dataRamps.${s}.${f} must be a finite number from 0 through 1.`);typeof p=="number"&&typeof g=="number"&&p<=g?t.push(`dataRamps.${s}.lightnessStart must be greater than lightnessEnd.`):typeof p=="number"&&Number.isFinite(p)&&typeof g=="number"&&Number.isFinite(g)&&typeof l=="number"&&Number.isInteger(l)&&l>=xe&&l<=$e&&(p-g)/(l-1)<=We&&t.push(`dataRamps.${s} lightness bounds must leave more than ${We} lightness between serialized stops.`);continue}if(c.type==="diverging"){typeof l=="number"&&Number.isInteger(l)&&l%2===0&&t.push(`dataRamps.${s}.steps must be odd so the neutral is the exact midpoint.`);for(const p of["start","end"])typeof c[p]!="string"?t.push(`dataRamps.${s}.${p} must be a CSS color or anchor reference string.`):_(c[p],`dataRamps.${s}.${p}`);"neutral"in c&&(typeof c.neutral!="string"?t.push(`dataRamps.${s}.neutral must be a CSS color or anchor reference string.`):_(c.neutral,`dataRamps.${s}.neutral`));continue}t.push(`dataRamps.${s}.type must be "sequential" or "diverging".`)}if("dataPalette"in e&&t.length===0){const s=de(Re,e),r={};let c=!0;for(const l of fe){const p=Ot(s.dataPalette[l],s.anchors);if(!p){c=!1;break}r[l]=p}if(c)for(const l of St(r))o.push(At(l))}function z(s,r){if(typeof s!="object"||s===null||Array.isArray(s)){t.push(`${r} must be an object.`);return}const c=s;for(const[l,p]of Object.entries(c)){const g=`${r}.${l}`;if(!se.includes(l)){t.push(`${g} is not a role; expected one of: ${se.join(", ")}. (The status family is reserved and is not a role.)`);continue}const f=l,h=Se[f];if(typeof p=="string"){T(p,g);continue}if(typeof p!="object"||p===null||Array.isArray(p)){t.push(`${g} must be a color source or a { color, \u2026slots } object.`);continue}const $=p;typeof $.color!="string"&&t.push(`${g} must declare its base "color".`);for(const[b,R]of Object.entries($)){if(!Object.prototype.hasOwnProperty.call(h,b)||!M(b)){const C=Object.keys(h).filter(w=>w!=="color");t.push(`${g}.${b} is not a slot of the ${f} role. Declared slots: ${C.length>0?C.join(", "):"(none)"}.`);continue}typeof R!="string"?t.push(`${g}.${b} must be a color source string.`):T(R,`${g}.${b}`)}}}if("roles"in e&&z(e.roles,"roles"),"contexts"in e)if(typeof e.contexts!="object"||e.contexts===null||Array.isArray(e.contexts))t.push("contexts must be an object.");else for(const[s,r]of Object.entries(e.contexts)){if(!M(s)||!j.test(s)){t.push(`contexts.${s} must be a lowercase slug matching ${j.source}.`);continue}if(typeof r!="object"||r===null||Array.isArray(r)){z(r,`contexts.${s}`);continue}const c=r,l=Object.fromEntries(Object.entries(c).filter(([g])=>g!=="lightness"&&g!=="tones"&&g!=="semanticMappings"));z(l,`contexts.${s}`),"lightness"in c&&d(c.lightness,`contexts.${s}.lightness`);const p=new Set(A);if("tones"in c)for(const g of m(c.tones,`contexts.${s}.tones`))p.add(g);"semanticMappings"in c&&H(c.semanticMappings,`contexts.${s}.semanticMappings`,p)}function H(s,r,c){if(typeof s!="object"||s===null||Array.isArray(s)){t.push(`${r} must be an object.`);return}const l=s;for(const p of Object.keys(l))K.includes(p)||t.push(`${r}.${p} is not a semantic token; expected one of: ${K.join(", ")}.`);for(const p of K)if(p in l){const g=l[p];if(typeof g!="object"||g===null){t.push(`${r}.${p} must be { source, lightness }.`);continue}const f=g;if(typeof f.source!="string"?t.push(`${r}.${p}.source must be a string.`):T(f.source,`${r}.${p}.source`),typeof f.lightness!="string")t.push(`${r}.${p}.lightness must be one of: ${U.join(", ")}, or a declared tone:<name>.`);else if(!te(f.lightness)){const h=Me(f.lightness);if(h===null)t.push(`${r}.${p}.lightness must be one of: ${U.join(", ")}, or a declared tone:<name>.`);else if(!c.has(h)){const $=[...c].sort();t.push(`${r}.${p}.lightness references undeclared tone "${h}". Declared tones: ${$.length>0?$.join(", "):"(none)"}.`)}}}}if("semanticMappings"in e&&H(e.semanticMappings,"semanticMappings",A),"explicitMappingTokens"in e)if(!Array.isArray(e.explicitMappingTokens))t.push("explicitMappingTokens must be an array of semantic token names.");else{const s=new Set,r=L(e.semanticMappings)?e.semanticMappings:void 0;for(const c of e.explicitMappingTokens){if(typeof c!="string"||!K.includes(c)){t.push(`explicitMappingTokens entries must be one of: ${K.join(", ")}.`);continue}s.has(c)&&t.push(`explicitMappingTokens contains duplicate token "${c}".`),s.add(c),(!r||!Object.prototype.hasOwnProperty.call(r,c))&&t.push(`explicitMappingTokens names "${c}" without a semanticMappings entry.`)}}for(const s of["pageBackgroundImage","boxBackgroundImage","vellumBackgroundImage"])s in e&&typeof e[s]!="string"&&t.push(`${s} must be a string.`);for(const s of["pageBackgroundImageOpacity","boxBackgroundImageOpacity","vellumOpacity","vellumBackgroundImageOpacity"])if(s in e)if(typeof e[s]!="number"||!isFinite(e[s]))t.push(`${s} must be a finite number.`);else{const r=e[s];(r<0||r>1)&&t.push(`${s} must be 0\u20131 (got ${r}).`)}return o.push(...Xt(e,n)),{valid:t.length===0,errors:t,warnings:o}}const B=.045;function Xt(e,n){try{return Zt(e,n)}catch{return[]}}function Zt(e,n){const t=de(n,e),o=ut(t),i=[...o],a=new Set(o);for(const u of Object.keys(t.contexts)){const d=it(t,u);if(d)for(const m of ut(d))a.has(m)||i.push(`contexts.${u}: ${m}`)}return i}function Qt(e){const n=yt(he(e)),t=$t(n);return ht({r:ge(t.r),g:ge(t.g),b:ge(t.b)})}function Z(e,n){return Math.hypot(e.L-n.L,e.a-n.a,e.b-n.b)}function q(e){return Qt(W(ce(he(e))))}function at(e){return(Math.floor(e*1e4)/1e4).toFixed(4)}const Q=2,ct=1e-4;function ut(e){const n=W(e.seedColor);if(!n)return[];const t=ye(n,e),o=e.semanticMappings.actionBackground,i=e.chroma.actionBackground,a=Oe(e.lightness,e.tones,o.lightness),u=(f,h,$,b)=>he(ae(f,h,$,b)),d=ee.map(f=>({name:f,base:t[f]})),m=[];if(ee.includes(o.source))m.push(`actionBackground is sourced from the "${o.source}" status family: ordinary and ${o.source}-intent action surfaces render identically (their labels may still differ). Remap the action to a non-status source \u2014 retuning "${o.source}" via intents moves both colors together.`);else{const f=ue(o.source,t,e.anchors);f&&d.push({name:"action",base:f})}const A=Fe(d.map(({name:f,base:h})=>[f,ce(u(h,a,i.min,i.max))]),B,["normal"]);if(A.length===0)return m;const k=new Map,y=(f,h)=>{const $=`${f}:${h}`;let b=k.get($);if(!b){b=[];for(let R=0;R<360;R+=Q)b.push(q({l:f,c:h,h:R}));k.set($,b)}return b},T=B-.002,_=(f,h,$,b)=>{const R=Math.hypot(f.a,f.b),C=Math.atan2(f.b,f.a)*180/Math.PI+180;let w=0;for(const S of $===b?[b]:[$,b]){if(S+R<B-1e-4)continue;let x=C,O=Z(q({l:h,c:S,h:C}),f);if(O>=B)return O;const D=y(h,S);for(let E=0;E<D.length;E+=1){const v=Z(D[E],f);if(v>=B)return v;v>O&&(O=v,x=E*Q)}let P=x;for(let E=x-Q;E<=x+Q;E+=.1){const v=Z(q({l:h,c:S,h:E}),f);if(v>=B)return v;v>O&&(O=v,P=E)}if(O>=T)for(let E=P-.1;E<=P+.1;E+=.001){const v=Z(q({l:h,c:S,h:E}),f);if(v>=B)return v;v>O&&(O=v)}O>w&&(w=O)}return w},z=(f,h,$)=>{const b=h===$?[$]:[h,$];let R=0;for(const C of b)for(const w of b){if(C+w<B-1e-4)continue;const S=y(f,C),x=y(f,w);let O=0,D=0,P=-1;for(let N=0;N<S.length;N+=1)for(let G=0;G<x.length;G+=1){const V=Z(S[N],x[G]);if(V>=B)return V;V>P&&(P=V,O=N*Q,D=G*Q)}const E=(N,G,V,Le)=>{const Ie=[];for(let J=G-V;J<=G+V;J+=Le)Ie.push({h:J,lab:q({l:f,c:w,h:J})});let me=-1,Ne=N,He=G;for(let J=N-V;J<=N+V;J+=Le){const pt=q({l:f,c:C,h:J});for(const Pe of Ie){const De=Z(pt,Pe.lab);De>me&&(me=De,Ne=J,He=Pe.h)}}return{distance:me,hueA:Ne,hueB:He}},v=E(O,D,Q,.1);if(v.distance>=B)return v.distance;let I=Math.max(P,v.distance);if(I>=T){const N=E(v.hueA,v.hueB,.1,.001);if(N.distance>I&&(I=N.distance),I>=B)return I}I>R&&(R=I)}return R},H=f=>ee.includes(f),s=(f,h,$,b,R)=>{const C=q(u(f.base,$,b,R)),w=q(u(h.base,$,b,R));if(Z(C,w)>=B)return{outcome:"direct"};const S=H(f.name)&&H(h.name),x=[f,h].filter(P=>H(P.name)),O=S?"one of them":`"${H(f.name)?f.name:h.name}"`;let D;for(const P of x){const E=_(P===f?w:C,$,b,R);if(E>=B)return{outcome:"retune",target:O};E>=B-ct&&(D=D??O)}if(S){const P=z($,b,R);if(P>=B)return{outcome:"retune",target:"both"};P>=B-ct&&(D=D??"both")}return D!==void 0?{outcome:"near",target:D}:{outcome:"no"}},r=f=>f.outcome==="direct"?4:f.outcome==="retune"?f.target==="both"?2:3:f.outcome==="near"?1:0,c=f=>[...f].sort().join("|"),l=new Set(Fe(d.map(({name:f,base:h})=>[f,ce(u(h,a,0,Y))]),B,["normal"]).map(f=>c(f.pair))),p=new Map(d.map(f=>[f.name,f])),g=new Map;for(const{pair:f,distance:h}of A){const $=p.get(f[0]),b=p.get(f[1]),R=H($.name)&&H(b.name),C=s($,b,a,i.min,i.max);if(C.outcome==="direct"||C.outcome==="retune"){const I=C.target??(R?"one of them":`"${H($.name)?$.name:b.name}"`);l.has(c(f))?m.push(`Status colors "${f[0]}" and "${f[1]}" are hard to distinguish under normal vision (distance ${at(h)} < ${B}); status meanings must stay distinguishable \u2014 retune ${I} via intents.`):m.push(`Status colors "${f[0]}" and "${f[1]}" are hard to distinguish as rendered (distance ${at(h)} < ${B}); the actionBackground chroma band ({ min: ${i.min}, max: ${i.max} }) pushes them together \u2014 widen the band, or retune ${I} via intents.`);continue}const w=s($,b,a,0,Y);let S={outcome:"no"};for(let I=1;I<=19&&S.outcome!=="direct";I+=1){const N=I*.05;if(Math.abs(N-a)<.001)continue;const G=s($,b,N,i.min,i.max);r(G)>r(S)&&(S=G)}let x={outcome:"no"};const O=w.outcome==="direct"||w.outcome==="retune",D=S.outcome==="direct"||S.outcome==="retune";if(!O&&!D)for(let I=1;I<=19&&x.outcome!=="direct";I+=1){const N=s($,b,I*.05,0,Y);r(N)>r(x)&&(x=N)}const P=en(w,S,x),E=`${C.outcome}|${P}`;let v=g.get(E);v||(v=[],g.set(E,v)),v.push(f)}for(const[f,h]of g){const $=f.indexOf("|"),b=f.slice(0,$),R=f.slice($+1),C=h.map(([x,O])=>`"${x}"/"${O}"`),w=C.length>1?`${C.slice(0,-1).join(", ")} and ${C[C.length-1]}`:C[0],S=b==="near"?`Status colors ${w} may not separate by retuning as rendered: at the action stop's lightness (${a}) with the actionBackground chroma band ({ min: ${i.min}, max: ${i.max} }), the closest reachable retune found comes within the audit's search margin of the ${B} threshold`:`Status colors ${w} cannot be separated as rendered: at the action stop's lightness (${a}) with the actionBackground chroma band ({ min: ${i.min}, max: ${i.max} }), no intent retuning can pull ${h.length>1?"these pairs":"the pair"} ${B} apart`;m.push(S+R)}return m}function en(e,n,t){if(e.outcome==="direct"&&n.outcome==="direct")return" \u2014 widen the chroma band or move the action lightness stop.";if(e.outcome==="direct")return n.outcome==="no"?"; no other action lightness stop can help while the band holds \u2014 widen the chroma band.":" \u2014 widen the chroma band.";if(n.outcome==="direct")return e.outcome==="no"?"; no wider chroma band can help at this lightness \u2014 move the action lightness stop.":" \u2014 move the action lightness stop.";if(e.outcome==="retune"&&n.outcome==="retune")return` \u2014 widen the chroma band or move the action lightness stop, then retune ${e.target} via intents.`;if(e.outcome==="retune")return n.outcome==="no"?`; no other action lightness stop can help while the band holds \u2014 widen the chroma band, then retune ${e.target} via intents.`:` \u2014 widen the chroma band, then retune ${e.target} via intents.`;if(n.outcome==="retune")return e.outcome==="no"?`; no wider chroma band can help at this lightness \u2014 move the action lightness stop, then retune ${n.target} via intents.`:` \u2014 move the action lightness stop, then retune ${n.target} via intents.`;const o=e.outcome==="no"&&n.outcome==="no"?"; neither a wider chroma band alone nor another stop alone can help":"; neither a wider chroma band alone nor another stop alone provably helps";return t.outcome==="direct"?`${o} \u2014 change the band and the stop together.`:t.outcome==="retune"?`${o} \u2014 change the band and the stop together, then retune ${t.target} via intents.`:"; no explored band or stop change provably separates this pair."}function ln(e,n){const t=Be(e),o=Be(n),i=t.error!==void 0?{valid:!1,errors:[t.error],warnings:[]}:_e(t.value),a=o.error!==void 0?{valid:!1,errors:[o.error],warnings:[]}:_e(o.value,qe),u=[...i.errors.map(m=>`light: ${m}`),...a.errors.map(m=>`dark: ${m}`)],d=[...i.warnings.map(m=>`light: ${m}`),...a.warnings.map(m=>`dark: ${m}`)];if(i.valid&&a.valid){const m=new Set(Object.keys(t.value?.contexts??{})),A=new Set(Object.keys(o.value?.contexts??{})),k=[...A].filter(T=>!m.has(T)).sort(),y=[...m].filter(T=>!A.has(T)).sort();(k.length>0||y.length>0)&&u.push(`contexts must declare the same names in both schemes. Missing from light: ${k.join(", ")||"(none)"}. Missing from dark: ${y.join(", ")||"(none)"}.`)}return{valid:u.length===0,errors:u,warnings:d}}const tn=["anchors","angles","contexts","dataPalette","dataRamps","intents","roles","chroma","lightness","tones","semanticHues","semanticMappings","variantChroma"];function nn(e,n){const t={};for(const[a,u]of Object.entries(e))M(a)&&(t[a]=u);for(const[a,u]of Object.entries(n))u!==void 0&&M(a)&&(t[a]=u);for(const a of tn){const u=e[a],d=n[a];if(u&&typeof u=="object"&&!Array.isArray(u)&&d&&typeof d=="object"&&!Array.isArray(d)){if(a==="anchors"){t[a]=Qe(u,d);continue}if(a==="contexts"){t[a]=Ut(u,d);continue}if(a==="dataRamps"){t[a]=nt(u,d);continue}const m={};for(const[A,k]of Object.entries(u))M(A)&&(m[A]=k);for(const[A,k]of Object.entries(d))k!==void 0&&M(A)&&(m[A]=k);t[a]=m}}const o=pe(e),i=pe(n);if(o!==void 0||i!==void 0){const a=o??new Set(Object.keys(e.semanticMappings??{}).filter(u=>K.includes(u)));for(const u of Object.keys(n.semanticMappings??{}))i===void 0||i.has(u)?a.add(u):a.delete(u);t.explicitMappingTokens=Xe(a)}return t}function pn(...e){let n={};for(const t of e){if(!t)continue;const o=Dt(t);o&&(n=nn(n,o))}return Ee(n)}function ft(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r")}const lt={borderRadius:.1,fontBody:'"Noto Sans", sans-serif',fontWeightBody:"normal",fontHeadings:'"Inika", serif',fontWeightHeadings:"normal",fontBrand:'"Inika", serif',fontWeightBrand:"normal",fontMonospace:'"JetBrains Mono", monospace',fontWeightMonospace:"normal",seedColor:"oklch(.07 0.15 216)"};function dn(e){return Ee({...lt,pageBackgroundImage:`url("${ft(e)}")`,pageBackgroundImageOpacity:.5})}function mn(e){return Ee({...lt,pageBackgroundImage:`url("${ft(e)}")`,pageBackgroundImageOpacity:.55})}export{j as ANCHOR_SLUG_PATTERN,Ae as COLOR_SOURCES,Ve as DEFAULT_BODY_FONT_FAMILY,Ht as DEFAULT_DARK_LIGHTNESS,qe as DEFAULT_DARK_THEME,Nt as DEFAULT_LIGHT_LIGHTNESS,Re as DEFAULT_LIGHT_THEME,Je as DEFAULT_MONOSPACE_FONT_FAMILY,Te as DEFAULT_SEMANTIC_MAPPINGS,U as LIGHTNESS_KEYS,tn as NESTED_THEME_KEYS,se as ROLE_NAMES,Rt as ROLE_PAIRED_INK,Se as ROLE_TOKEN_PLAN,K as SEMANTIC_COLOR_NAMES,ee as STATUS_COLOR_SOURCES,Ue as TOKEN_PAIRINGS,It as VARIANT_COLOR_SOURCES,mn as buildTaprootDarkTheme,dn as buildTaprootLightTheme,Ke as compileRoles,Ee as encodeTheme,qt as explicitMappingTokens,te as isLightnessKey,L as isObjectRecord,cn as isSemanticColorName,pn as layerThemes,nn as mergePartials,de as mergeTheme,ke as parseAnchorSource,Dt as parseTheme,je as resolveAnchorColor,it as resolveContextTheme,Ot as resolveDataColorSource,Oe as resolveLightnessReference,un as semanticToCSS,Me as toneReferenceName,fn as validateTheme,ln as validateThemePair};
|
package/espalier.css-data.json
CHANGED
|
@@ -553,6 +553,10 @@
|
|
|
553
553
|
"name": "--esp-font-headings",
|
|
554
554
|
"description": "Consumer-authored heading family. Emitted only when configured; heading recipes otherwise fall back to `--esp-font-body`."
|
|
555
555
|
},
|
|
556
|
+
{
|
|
557
|
+
"name": "--esp-font-menu",
|
|
558
|
+
"description": "Consumer-authored navigation family. Emitted only when configured; menu items otherwise fall back to `--esp-font-body`, never to headings."
|
|
559
|
+
},
|
|
556
560
|
{
|
|
557
561
|
"name": "--esp-font-monospace",
|
|
558
562
|
"description": "Family for code and monospace text. Defaults to `monospace`."
|
|
@@ -569,6 +573,10 @@
|
|
|
569
573
|
"name": "--esp-font-weight-headings",
|
|
570
574
|
"description": ""
|
|
571
575
|
},
|
|
576
|
+
{
|
|
577
|
+
"name": "--esp-font-weight-menu",
|
|
578
|
+
"description": "Font weight for horizontal navigation menu items. Defaults to `bold`."
|
|
579
|
+
},
|
|
572
580
|
{
|
|
573
581
|
"name": "--esp-font-weight-monospace",
|
|
574
582
|
"description": ""
|
|
@@ -1141,10 +1149,26 @@
|
|
|
1141
1149
|
"name": "--esp-menu-border-color",
|
|
1142
1150
|
"description": "Border color of menu rails and drawers."
|
|
1143
1151
|
},
|
|
1152
|
+
{
|
|
1153
|
+
"name": "--esp-menu-drawer-brand-color",
|
|
1154
|
+
"description": "Text and logo color of the full-screen drawer's brand. Defaults to the mirrored brand color, then `var(--esp-color-headings)`."
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
"name": "--esp-menu-drawer-brand-logo-size",
|
|
1158
|
+
"description": "Logo height of the brand centered in the full-screen drawer. Defaults to `calc(3 * var(--esp-size-medium))`."
|
|
1159
|
+
},
|
|
1160
|
+
{
|
|
1161
|
+
"name": "--esp-menu-drawer-item-font-size",
|
|
1162
|
+
"description": "Item label size in the full-screen drawer. Defaults to `var(--esp-type-large)`."
|
|
1163
|
+
},
|
|
1144
1164
|
{
|
|
1145
1165
|
"name": "--esp-menu-drawer-shadow",
|
|
1146
1166
|
"description": "Box shadow for the drawer overlay."
|
|
1147
1167
|
},
|
|
1168
|
+
{
|
|
1169
|
+
"name": "--esp-menu-drawer-transition-duration",
|
|
1170
|
+
"description": "Duration of the full-screen drawer's transition. Defaults to `0.3s`; reduced motion disables it."
|
|
1171
|
+
},
|
|
1148
1172
|
{
|
|
1149
1173
|
"name": "--esp-menu-drawer-width",
|
|
1150
1174
|
"description": "Drawer width. Defaults to `min(22rem, 86vw)`."
|
|
@@ -1209,6 +1233,10 @@
|
|
|
1209
1233
|
"name": "--esp-menu-item-active-font-weight",
|
|
1210
1234
|
"description": "Font weight of the active item. Defaults to `var(--esp-font-weight-headings)`."
|
|
1211
1235
|
},
|
|
1236
|
+
{
|
|
1237
|
+
"name": "--esp-menu-item-active-indicator-color",
|
|
1238
|
+
"description": "Color of the bar drawn under the active horizontal item. Defaults to `--esp-menu-item-active-color`, then `var(--esp-color-link)`."
|
|
1239
|
+
},
|
|
1212
1240
|
{
|
|
1213
1241
|
"name": "--esp-menu-item-background",
|
|
1214
1242
|
"description": "Background color."
|
|
@@ -1221,6 +1249,18 @@
|
|
|
1221
1249
|
"name": "--esp-menu-item-color",
|
|
1222
1250
|
"description": "Text color."
|
|
1223
1251
|
},
|
|
1252
|
+
{
|
|
1253
|
+
"name": "--esp-menu-item-font-family",
|
|
1254
|
+
"description": "Font family of item labels. Defaults to the theme's `--esp-font-menu`, then `--esp-font-body`."
|
|
1255
|
+
},
|
|
1256
|
+
{
|
|
1257
|
+
"name": "--esp-menu-item-font-size",
|
|
1258
|
+
"description": "Font size of item labels. Defaults to `inherit`."
|
|
1259
|
+
},
|
|
1260
|
+
{
|
|
1261
|
+
"name": "--esp-menu-item-font-weight",
|
|
1262
|
+
"description": "Font weight of horizontal item labels. Defaults to `--esp-font-weight-menu`, then `700`."
|
|
1263
|
+
},
|
|
1224
1264
|
{
|
|
1225
1265
|
"name": "--esp-menu-item-hover-background",
|
|
1226
1266
|
"description": "Hover background color."
|
|
@@ -1229,6 +1269,14 @@
|
|
|
1229
1269
|
"name": "--esp-menu-item-hover-color",
|
|
1230
1270
|
"description": "Hover text color."
|
|
1231
1271
|
},
|
|
1272
|
+
{
|
|
1273
|
+
"name": "--esp-menu-item-hover-decoration",
|
|
1274
|
+
"description": "Text decoration of a hovered link item. Defaults to `none`; set `underline` to restore the former underline."
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
"name": "--esp-menu-item-hover-indicator-color",
|
|
1278
|
+
"description": "Color of the bar drawn under a hovered horizontal item. Defaults to `--esp-menu-item-hover-color`, then `var(--esp-color-headings-hover)`."
|
|
1279
|
+
},
|
|
1232
1280
|
{
|
|
1233
1281
|
"name": "--esp-menu-item-icon-background",
|
|
1234
1282
|
"description": "Icon area background color."
|
|
@@ -1249,6 +1297,10 @@
|
|
|
1249
1297
|
"name": "--esp-menu-item-padding",
|
|
1250
1298
|
"description": "Padding around the item label."
|
|
1251
1299
|
},
|
|
1300
|
+
{
|
|
1301
|
+
"name": "--esp-menu-item-transition-duration",
|
|
1302
|
+
"description": "Duration for color, background, and indicator changes. Defaults to `0.2s`; reduced motion disables the transition."
|
|
1303
|
+
},
|
|
1252
1304
|
{
|
|
1253
1305
|
"name": "--esp-menu-scrim-color",
|
|
1254
1306
|
"description": "Scrim color when the drawer is open."
|