@webority/tokens 0.149.0 → 0.152.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.
Files changed (76) hide show
  1. package/dist/brand.d.ts +39 -25
  2. package/dist/brand.js +2 -2
  3. package/dist/build.d.ts +41 -0
  4. package/dist/build.js +5 -5
  5. package/dist/canvas/webority-phone.json +12 -12
  6. package/dist/canvas/webority-web-390.json +35 -3
  7. package/dist/canvas/webority-web.json +35 -3
  8. package/dist/check.d.ts +37 -0
  9. package/dist/check.js +3 -3
  10. package/dist/cli.d.ts +15 -96
  11. package/dist/cli.js +1 -1
  12. package/dist/emit/canvas.d.ts +8 -0
  13. package/dist/emit/canvas.js +1 -1
  14. package/dist/emit/email.d.ts +32 -0
  15. package/dist/emit/email.js +2 -2
  16. package/dist/emit/meanings.d.ts +3 -0
  17. package/dist/emit/phone.d.ts +26 -0
  18. package/dist/emit/phone.js +3 -3
  19. package/dist/emit/web.d.ts +18 -0
  20. package/dist/emit/web.js +14 -14
  21. package/dist/guards.d.ts +3 -0
  22. package/dist/guards.js +1 -0
  23. package/dist/index.d.ts +7 -7
  24. package/dist/meanings.json +97 -1
  25. package/dist/model/colour.d.ts +8 -0
  26. package/dist/model/colour.js +1 -1
  27. package/dist/model/contrast.d.ts +26 -0
  28. package/dist/model/contrast.js +1 -1
  29. package/dist/model/index.d.ts +52 -0
  30. package/dist/model/length.d.ts +21 -0
  31. package/dist/model/length.js +1 -1
  32. package/dist/model/load.d.ts +32 -0
  33. package/dist/model/load.js +1 -1
  34. package/dist/model/references.d.ts +3 -0
  35. package/dist/model/references.js +1 -1
  36. package/dist/model/resolve.d.ts +4 -0
  37. package/dist/model/resolve.js +2 -2
  38. package/dist/names.d.ts +1 -11
  39. package/dist/names.js +1 -1
  40. package/dist/outputs.d.ts +51 -102
  41. package/dist/present.d.ts +1 -0
  42. package/dist/present.js +1 -0
  43. package/dist/ramp.d.ts +8 -0
  44. package/dist/ramp.js +1 -1
  45. package/dist/source/meaning.tokens.json +144 -0
  46. package/dist/source/palette.tokens.json +9 -9
  47. package/dist/source/scale.tokens.json +39 -2
  48. package/dist/upgrade/classes.d.ts +13 -0
  49. package/dist/upgrade/classes.js +2 -2
  50. package/dist/upgrade/components.d.ts +19 -0
  51. package/dist/upgrade/components.js +3 -3
  52. package/dist/upgrade/css.d.ts +28 -0
  53. package/dist/upgrade/css.js +2 -2
  54. package/dist/upgrade/index.d.ts +64 -0
  55. package/dist/upgrade/index.js +2 -2
  56. package/dist/upgrade/razorAttributes.d.ts +19 -0
  57. package/dist/upgrade/razorAttributes.js +2 -2
  58. package/dist/upgrade/razorTags.d.ts +19 -0
  59. package/dist/upgrade/razorTags.js +2 -2
  60. package/dist/upgrade/razorValueSplits.d.ts +19 -0
  61. package/dist/upgrade/razorValueSplits.js +2 -2
  62. package/dist/upgrade/source.d.ts +19 -0
  63. package/dist/upgrade/source.js +3 -3
  64. package/dist/upgrade/tagScan.d.ts +7 -0
  65. package/dist/upgrade/tagScan.js +1 -1
  66. package/dist/upgrade/themeReads.d.ts +55 -0
  67. package/dist/upgrade/themeReads.js +2 -2
  68. package/dist/upgrade/valueSplits.d.ts +23 -0
  69. package/dist/upgrade/valueSplits.js +3 -3
  70. package/dist/upgrade/wrapperValues.d.ts +71 -0
  71. package/dist/upgrade/wrapperValues.js +1 -1
  72. package/dist/webority.d.ts +1 -0
  73. package/package.json +8 -3
  74. package/renames/0.130.0.json +15 -0
  75. package/renames/0.152.0.json +30 -0
  76. package/renames/renames.d.ts +1 -1
@@ -0,0 +1,8 @@
1
+ import type { Model } from "../model/index.ts";
2
+ import type { ThemeTokensV2 } from "../outputs.ts";
3
+ export interface CanvasDocuments {
4
+ web: ThemeTokensV2;
5
+ web390: ThemeTokensV2;
6
+ phone: ThemeTokensV2;
7
+ }
8
+ export declare function emitCanvas(model: Model): CanvasDocuments;
@@ -1 +1 @@
1
- function e(e){return{web:t(e,`web`,1440),web390:t(e,`web`,390),phone:t(e,`phone`,null)}}function t(e,t,a){let o=n(e,`light`,t,a),s=n(e,`dark`,t,a),c={format:`webority-theme-tokens/2`,source:{package:e.source.package,version:e.source.version,brand:e.source.brand,platform:t,width:a},modes:[`light`,`dark`],colors:{light:{},dark:{}},space:{},radius:{},text:{},typography:{fontWeight:{},leading:{}},fonts:{},shadow:{},components:{}};for(let t of e.tokens.values())t.group===`color`?i(c,e,t,o,s):e.existsIn(t.path,o)&&r(c,e,t,o);return c}function n(e,t,n,r){let i=e.contexts.find(e=>e.mode===t&&e.platform===n&&e.width===r);if(!i){let e=r===null?``:` ${r}`;throw Error(`emitCanvas: the model has no ${t} ${n}${e} context`)}return i}function r(e,t,n,r){let{path:i,name:o}=n;switch(n.group){case`space`:e.space[o]=s(t,i,r);break;case`radius`:e.radius[o]=s(t,i,r);break;case`text`:e.text[o]={size:s(t,i,r)};break;case`weight`:e.typography.fontWeight[o]=c(t,i,r);break;case`leading`:e.typography.leading[o]=c(t,i,r);break;case`font`:e.fonts[o]=l(t,i,r);break;case`shadow`:e.shadow[o]=u(t,i,r);break;case`component`:a(e,t,i,r)}}function i(e,t,n,r,i){let a=t.existsIn(n.path,r);if(a!==t.existsIn(n.path,i))throw Error(`emitCanvas: ${n.path} is present in one mode only`);if(a&&(e.colors.light[n.name]=o(t,n.path,r),e.colors.dark[n.name]=o(t,n.path,i),n.brandOwn)){if(typeof n.description!=`string`||n.description===``)throw Error(`emitCanvas: ${n.path} is a brand colour and needs a description`);e.colorMeanings??={},e.colorMeanings[n.name]=n.description}}function a(e,t,n,r){let i=n.split(`.`);if(i.length!==3&&i.length!==4)throw Error(`emitCanvas: ${n} must be component.<name>.<prop> or component.<name>.<size>.<prop>`);let a=i[1],o=i[i.length-1];e.components[a]??={base:{},sizes:{}};let s=e.components[a].base;i.length===4&&(e.components[a].sizes[i[2]]??={},s=e.components[a].sizes[i[2]]),s[o]=f(t,n,r)}function o(e,t,n){let r=e.resolvedIn(t,n);if(typeof r!=`string`)throw Error(`emitCanvas: ${t} is not a colour string`);return r}function s(e,t,n){let r=e.resolvedIn(t,n);if(typeof r==`number`)return r;if(typeof r==`object`&&r&&r.unit===`px`&&typeof r.value==`number`)return r.value;throw Error(`emitCanvas: ${t} is not a px length`)}function c(e,t,n){let r=e.resolvedIn(t,n);if(typeof r!=`number`)throw Error(`emitCanvas: ${t} is not a number`);return r}function l(e,t,n){let r=e.resolvedIn(t,n);if(!Array.isArray(r)||r.length===0)throw Error(`emitCanvas: ${t} is not a font family list`);return{family:r[0],fallback:r.slice(1).join(`, `)}}function u(e,t,n){let r=e.resolvedIn(t,n);if(r===`none`)return null;if(typeof r!=`object`||!r||typeof r.color!=`string`)throw Error(`emitCanvas: ${t} is not a shadow`);let[i,a,o,s]=[`offsetX`,`offsetY`,`blur`,`spread`].map(e=>d(t,r[e])),c={x:i,y:a,blur:o,spread:s,color:r.color},l=e.tokens.get(t)?.extensions?.elevation;return Number.isFinite(l)&&(c.elevation=l),c}function d(e,t){let n=typeof t==`number`?t:t?.value;if(typeof n!=`number`)throw Error(`emitCanvas: ${e} has a shadow length that is not a number`);return n}function f(e,t,n){let r=e.resolvedIn(t,n);if(typeof r==`string`||typeof r==`number`)return String(r);if(typeof r==`object`&&r&&typeof r.unit==`string`)return`${r.value}${r.unit}`;throw Error(`emitCanvas: ${t} is not a component value`)}export{e as emitCanvas};
1
+ import{isObjectLike as e}from"../guards.js";import{present as t}from"../present.js";function n(e){return{web:r(e,`web`,1440),web390:r(e,`web`,390),phone:r(e,`phone`,null)}}function r(e,t,n){let r=i(e,`light`,t,n),s=i(e,`dark`,t,n),c={format:`webority-theme-tokens/2`,source:{package:e.source.package,version:e.source.version,brand:e.source.brand,platform:t,width:n},modes:[`light`,`dark`],colors:{light:{},dark:{}},space:{},radius:{},text:{},typography:{fontWeight:{},leading:{}},fonts:{},shadow:{},components:{}};for(let t of e.tokens.values())t.group===`color`?o(c,e,t,r,s):e.existsIn(t.path,r)&&a(c,e,t,r);return c}function i(e,t,n,r){let i=e.contexts.find(e=>e.mode===t&&e.platform===n&&e.width===r);if(!i){let e=r===null?``:` ${r}`;throw Error(`emitCanvas: the model has no ${t} ${n}${e} context`)}return i}function a(e,t,n,r){let{path:i,name:a}=n;switch(n.group){case`space`:e.space[a]=l(t,i,r);break;case`radius`:e.radius[a]=l(t,i,r);break;case`text`:e.text[a]={size:l(t,i,r)};break;case`weight`:e.typography.fontWeight[a]=u(t,i,r);break;case`leading`:e.typography.leading[a]=u(t,i,r);break;case`font`:e.fonts[a]=d(t,i,r);break;case`shadow`:e.shadow[a]=f(t,i,r);break;case`component`:s(e,t,i,r)}}function o(e,t,n,r,i){let a=t.existsIn(n.path,r);if(a!==t.existsIn(n.path,i))throw Error(`emitCanvas: ${n.path} is present in one mode only`);if(a&&(e.colors.light[n.name]=c(t,n.path,r),e.colors.dark[n.name]=c(t,n.path,i),n.brandOwn)){if(typeof n.description!=`string`||n.description===``)throw Error(`emitCanvas: ${n.path} is a brand colour and needs a description`);e.colorMeanings??={},e.colorMeanings[n.name]=n.description}}function s(e,n,r,i){let a=r.split(`.`);if(a.length!==3&&a.length!==4)throw Error(`emitCanvas: ${r} must be component.<name>.<prop> or component.<name>.<size>.<prop>`);let o=t(a[1],`the component name`),s=t(a[a.length-1],`the component property`),c=e.components[o];c===void 0&&(c={base:{},sizes:{}},e.components[o]=c);let l=c.base;if(a.length===4){let e=t(a[2],`the component size`),n=c.sizes[e];n===void 0&&(n={},c.sizes[e]=n),l=n}l[s]=m(n,r,i)}function c(e,t,n){let r=e.resolvedIn(t,n);if(typeof r!=`string`)throw Error(`emitCanvas: ${t} is not a colour string`);return r}function l(t,n,r){let i=t.resolvedIn(n,r);if(typeof i==`number`)return i;if(e(i)&&i.unit===`px`&&typeof i.value==`number`)return i.value;throw Error(`emitCanvas: ${n} is not a px length`)}function u(e,t,n){let r=e.resolvedIn(t,n);if(typeof r!=`number`)throw Error(`emitCanvas: ${t} is not a number`);return r}function d(e,t,n){let r=e.resolvedIn(t,n);if(!Array.isArray(r)||!r.every(e=>typeof e==`string`))throw Error(`emitCanvas: ${t} is not a font family list`);let[i,...a]=r;if(i===void 0)throw Error(`emitCanvas: ${t} is not a font family list`);return{family:i,fallback:a.join(`, `)}}function f(t,n,r){let i=t.resolvedIn(n,r);if(i===`none`)return null;if(!e(i)||typeof i.color!=`string`)throw Error(`emitCanvas: ${n} is not a shadow`);let a={x:p(n,i.offsetX),y:p(n,i.offsetY),blur:p(n,i.blur),spread:p(n,i.spread),color:i.color},o=t.tokens.get(n)?.extensions?.elevation;return typeof o==`number`&&Number.isFinite(o)&&(a.elevation=o),a}function p(t,n){let r=typeof n==`number`?n:e(n)?n.value:void 0;if(typeof r!=`number`)throw Error(`emitCanvas: ${t} has a shadow length that is not a number`);return r}function m(t,n,r){let i=t.resolvedIn(n,r);if(typeof i==`string`||typeof i==`number`)return String(i);if(e(i)&&typeof i.unit==`string`)return`${i.value}${i.unit}`;throw Error(`emitCanvas: ${n} is not a component value`)}export{n as emitCanvas};
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The email theme is derived from the brand's two web themes, at 1440 and 390. Email clients render alpha
3
+ * unreliably, so a translucent colour is composited over the card colour of its mode and every colour leaves as
4
+ * opaque #RRGGBB. Sizes and spacing are whole pixels from the token scale, and phone type sizes come from the 390
5
+ * theme. The role tables below are the one home of the email-to-token mapping.
6
+ */
7
+ import type { EmailColorRoleKey, EmailShapeKey, EmailSpaceKey, EmailThemeTokensV1, EmailTypeRoleKey, ThemeTokensV2 } from "../outputs.ts";
8
+ export declare const EMAIL_COLOR_ROLES: Readonly<Record<EmailColorRoleKey, string>>;
9
+ export declare const EMAIL_TYPE_ROLES: Readonly<Record<EmailTypeRoleKey, {
10
+ step: string;
11
+ leading: string;
12
+ }>>;
13
+ export declare const EMAIL_SPACE: Readonly<Record<EmailSpaceKey, string>>;
14
+ export declare const EMAIL_PADDING_ROLES: ReadonlySet<string>;
15
+ export declare const EMAIL_PADDING_PATTERN: RegExp;
16
+ export declare const EMAIL_SHAPE: Readonly<Record<EmailShapeKey, string>>;
17
+ export declare const EMAIL_BUTTON: Readonly<{
18
+ radius: string;
19
+ padding: string;
20
+ }>;
21
+ export interface EmailGroupEntry {
22
+ $value?: unknown;
23
+ $extensions?: Record<string, unknown>;
24
+ }
25
+ export interface EmailGroup {
26
+ color?: Record<string, EmailGroupEntry>;
27
+ type?: Record<string, EmailGroupEntry>;
28
+ space?: Record<string, EmailGroupEntry>;
29
+ shape?: Record<string, EmailGroupEntry>;
30
+ button?: Record<string, EmailGroupEntry>;
31
+ }
32
+ export declare function emitEmail(web: ThemeTokensV2, web390: ThemeTokensV2, email?: EmailGroup | null): EmailThemeTokensV1;
@@ -1,2 +1,2 @@
1
- var e=[`light`,`dark`],t=new Set([`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`,`ui-serif`,`ui-sans-serif`,`ui-monospace`]),n=[[`body`,`ui`],[`display`,`display`],[`mono`,`mono`]],r=Object.freeze({page:`bg`,canvas:`bg`,card:`surface`,panel:`bg-subtle`,"panel-alt":`bg-muted`,surface:`surface`,line:`border`,"line-strong":`border-strong`,"accent-tint-line":`primary-wash-strong`,heading:`text`,strong:`text`,text:`text-body`,secondary:`text-muted`,muted:`text-subtle`,accent:`primary`,"on-accent":`on-primary`,link:`link`,success:`success-text`,warning:`warning-text`,danger:`danger-text`,"accent-tint":`primary-wash`,"success-tint":`success-soft`,"warning-tint":`warning-soft`,"danger-tint":`danger-soft`,"figure-panel":`primary-wash`}),i=Object.freeze({eyebrow:{step:`xs`,leading:`body`},h1:{step:`2xl`,leading:`heading`},lede:{step:`lg`,leading:`body`},body:{step:`base`,leading:`body`},"detail-value":{step:`sm`,leading:`body`},quote:{step:`base`,leading:`body`},"body-large":{step:`lg`,leading:`body`},title:{step:`2xl`,leading:`heading`},item:{step:`base`,leading:`body`},label:{step:`sm`,leading:`body`},note:{step:`sm`,leading:`body`},"note-small":{step:`xs`,leading:`body`},figure:{step:`3xl`,leading:`display`},"figure-hero":{step:`4xl`,leading:`display`},"figure-sub":{step:`sm`,leading:`body`},range:{step:`sm`,leading:`body`},sign:{step:`base`,leading:`body`},foot:{step:`xs`,leading:`body`},num:{step:`base`,leading:`body`},"code-otp":{step:`2xl`,leading:`heading`},"code-id":{step:`base`,leading:`body`},button:{step:`base`,leading:`body`}}),a=Object.freeze({section:`2xl`,"section-phone":`xl`,tight:`md`,item:`sm`,"heading-after":`xl`,"eyebrow-after":`xxs`,"title-after":`md`,"callout-lead-after":`xs`,"paragraph-gap":`sm`,"sign-gap":`2xl`,"sign-gap-phone":`lg`,"signature-gap":`md`,"step-gap":`lg`,"step-gutter":`3xl`,"step-gutter-phone":`2xl`,"step-number-space":`md`,"step-number-space-phone":`sm`,"column-top":`lg`,"column-gap":`lg`,"row-padding":`sm`,"panel-padding":`lg`,"panel-padding-wide":`lg`,"details-padding":`lg`,"details-padding-wide":`lg`,"hero-padding":`xl lg`,"hero-padding-wide":`2xl lg`,"columns-padding":`none lg lg lg`,"columns-padding-wide":`xs lg lg lg`}),o=new Set([`panel-padding`,`panel-padding-wide`,`details-padding`,`details-padding-wide`,`hero-padding`,`hero-padding-wide`,`columns-padding`,`columns-padding-wide`]),s=/^(0|\d+px)( (0|\d+px)){0,3}$/,c=Object.freeze({"panel-radius":`md`,"tint-radius":`md`,"code-radius":`md`,"details-radius":`md`}),l=Object.freeze({radius:`md`,padding:`md sm`});function u(e){return Math.floor(e+.5)}function d(e){if(typeof e!=`string`)return null;let t=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e);if(t===null)return null;let n=t[1];n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=e=>Number.parseInt(n.slice(e,e+2),16);return{r:r(0),g:r(2),b:r(4),a:n.length===8?r(6)/255:1}}function f(e,t,n){return`#${[e,t,n].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`.toUpperCase()}function p(e,t){if(e.a===1)return f(e.r,e.g,e.b);if(t===null)return null;let n=(t,n)=>u(t*e.a+n*(1-e.a));return f(n(e.r,t.r),n(e.g,t.g),n(e.b,t.b))}function m(t,n){let i={},a={light:{},dark:{}};for(let o of e){let e=t.colors?.[o]?.surface;e===void 0&&n(`email role card needs meaning surface in ${o}`);let s=d(e);s!==null&&s.a<1&&n(`email card colour (meaning surface, ${o}) must be opaque`),i[o]=s;for(let[e,s]of Object.entries(r)){let r=t.colors?.[o]?.[s];if(r===void 0){n(`email role ${e} needs meaning ${s} in ${o}`);continue}let c=d(r);c===null?n(`email role ${e} (meaning ${s}, ${o}): cannot read colour ${r}`):a[o][e]=p(c,i[o])}}return Object.fromEntries(Object.keys(r).map(e=>[e,{light:a.light[e],dark:a.dark[e]}]))}function h(e,t,n){let r={};for(let[a,{step:o,leading:s}]of Object.entries(i)){let i=e.text?.[o],c=t.text?.[o],l=e.typography?.leading?.[s],d=t.typography?.leading?.[s];i===void 0&&n(`email type role ${a} needs text step ${o}`),c===void 0&&n(`email type role ${a} needs text step ${o} in the 390 theme`),l===void 0&&n(`email type role ${a} needs leading ${s}`),d===void 0&&n(`email type role ${a} needs leading ${s} in the 390 theme`),i!==void 0&&c!==void 0&&l!==void 0&&d!==void 0&&(r[a]={size:u(i.size),lineHeight:u(i.size*l),phoneSize:u(c.size),phoneLineHeight:u(c.size*d)})}return r}function g(e,t,n,r){let i=[],a=!0;for(let o of t.split(/\s+/))typeof e.space?.[o]==`number`?i.push(e.space[o]):(r(n(o)),a=!1);return a?i.map(e=>`${e}px`).join(` `):null}function _(e,t,n,r){return/\s/.test(n)?(r(`email space role ${t} is a gap and takes one space step, not ${n}`),null):typeof e.space?.[n]==`number`?e.space[n]:(r(`email space role ${t} needs space step ${n}`),null)}function v(e,t){let n={};for(let[r,i]of Object.entries(a)){let a=o.has(r)?g(e,i,e=>`email space role ${r} needs space step ${e}`,t):_(e,r,i,t);a!==null&&(n[r]=a)}return n}function y(e,t){let n={};for(let[r,i]of Object.entries(c)){let a=e.radius?.[i];typeof a==`number`?n[r]=a:t(`email shape role ${r} needs radius step ${i}`)}return n}function b(e,t){let n=e.radius?.[l.radius];return typeof n!=`number`&&t(`email button needs radius step ${l.radius}`),{radius:n,padding:g(e,l.padding,e=>`email button needs space step ${e}`,t)}}function x(e){let t=e.trim();return t.length>=2&&t[0]===t.at(-1)&&(t[0]===`"`||t[0]===`'`)?t.slice(1,-1).trim():t}function S(e){return t.has(e.toLowerCase())||e.startsWith(`-`)?e:e.includes(` `)?`'${e}'`:e}function C(e,t,n){let r=[t.family,...t.fallback.split(`,`)].map(x).filter(e=>e.length>0),i=r.find(e=>/["';<>]/.test(e));return i===void 0?r.map(S).join(`, `):(n(`email font ${e} holds an unsafe character: ${i}`),null)}function w(e,t){let r={};for(let[i,a]of n){let n=e.fonts?.[a];typeof n?.family!=`string`||typeof n?.fallback!=`string`?t(`email fonts need font ${a}`):r[i]=C(a,n,t)}return r}function T(e,t,n){return Number.isInteger(e?.value)&&e.value>=0&&e.unit===`px`?e.value:(n(`${t} needs a whole px value`),null)}function E(e,t,n){return typeof e==`string`&&s.test(e)?e:(n(`${t} needs CSS px padding`),null)}function D(e,t,n,r,i){let a=/^\{color\.([a-z0-9-]+)\}$/.exec(t)?.[1],o=a===void 0?t:e.colors?.[n]?.[a];if(o===void 0)return i(`email group role ${r} needs meaning ${a} in ${n}`),null;let s=d(o);if(s===null)return i(`email group role ${r} (${n}): cannot read colour ${o}`),null;let c=p(s,d(e.colors?.[n]?.surface));return c===null&&i(`email group role ${r} must be opaque in ${n}`),c}function O(e,t,n,s){let{colors:l,type:u,space:d,shape:f,button:p}=n,m=(e,t)=>s(`email group key email.${e}.${t} is not an email role`);for(let[n,i]of Object.entries(e.color??{}))Object.hasOwn(r,n)?l[n]={light:D(t,i.$value,`light`,n,s),dark:D(t,i.$extensions?.[`com.webority`]?.dark??i.$value,`dark`,n,s)}:m(`color`,n);for(let[t,n]of Object.entries(e.type??{})){if(!Object.hasOwn(i,t)){m(`type`,t);continue}let{size:e,lineHeight:r,phoneSize:a,phoneLineHeight:o,narrowSize:c,narrowLineHeight:l}=n.$value??{};[e,r,a,o].every(e=>Number.isInteger(e)&&e>0)||s(`email group role ${t} needs size, lineHeight, phoneSize and phoneLineHeight in whole px`),u[t]=c===void 0?{size:e,lineHeight:r,phoneSize:a,phoneLineHeight:o}:{size:e,lineHeight:r,phoneSize:a,phoneLineHeight:o,narrowSize:c,narrowLineHeight:l}}for(let[t,n]of Object.entries(e.space??{})){if(!Object.hasOwn(a,t)){m(`space`,t);continue}let e=`email group role ${t}`;d[t]=o.has(t)?E(n.$value,e,s):T(n.$value,e,s)}for(let[t,n]of Object.entries(e.shape??{}))Object.hasOwn(c,t)?f[t]=T(n.$value,`email group role ${t}`,s):m(`shape`,t);for(let[t,n]of Object.entries(e.button??{}))t===`radius`?p.radius=T(n.$value,`email group role button radius`,s):t===`padding`?p.padding=E(n.$value,`email group role button padding`,s):m(`button`,t)}function k(e,t,n=null){if(e?.format!==`webority-theme-tokens/2`||e.source?.platform!==`web`)throw Error(`emitEmail: web must be the web theme tokens at width 1440`);if(e.source.width!==1440)throw Error(`emitEmail: web must be the 1440 theme`);if(t?.format!==`webority-theme-tokens/2`||t.source?.platform!==`web`||t.source?.width!==390)throw Error(`emitEmail: web390 must be the web theme tokens at width 390`);let r=[],i=e=>r.push(`emitEmail: ${e}`),a=m(e,i),o=h(e,t,i),s=v(e,i),c=y(e,i),l=b(e,i),u=w(e,i);if(n!==null&&O(n,e,{colors:a,type:o,space:s,shape:c,button:l},i),r.length>0)throw Error(r.join(`
2
- `));return{format:`webority-email-theme/1`,source:{package:e.source.package,version:e.source.version,brand:e.source.brand},colors:a,fonts:u,type:o,space:s,shape:c,button:l}}export{l as EMAIL_BUTTON,r as EMAIL_COLOR_ROLES,s as EMAIL_PADDING_PATTERN,o as EMAIL_PADDING_ROLES,c as EMAIL_SHAPE,a as EMAIL_SPACE,i as EMAIL_TYPE_ROLES,k as emitEmail};
1
+ import{isObjectLike as e}from"../guards.js";import{present as t}from"../present.js";var n=[`light`,`dark`],r=new Set([`serif`,`sans-serif`,`monospace`,`cursive`,`fantasy`,`system-ui`,`ui-serif`,`ui-sans-serif`,`ui-monospace`]),i=[[`body`,`ui`],[`display`,`display`],[`mono`,`mono`]],a=Object.freeze({page:`bg`,canvas:`bg`,card:`surface`,panel:`bg-subtle`,"panel-alt":`bg-muted`,surface:`surface`,line:`border`,"line-strong":`border-strong`,"accent-tint-line":`primary-wash-strong`,heading:`text`,strong:`text`,text:`text-body`,secondary:`text-muted`,muted:`text-subtle`,accent:`primary`,"on-accent":`on-primary`,link:`link`,success:`success-text`,warning:`warning-text`,danger:`danger-text`,"accent-tint":`primary-wash`,"success-tint":`success-soft`,"warning-tint":`warning-soft`,"danger-tint":`danger-soft`,"figure-panel":`primary-wash`}),o=Object.freeze({eyebrow:{step:`xs`,leading:`body`},h1:{step:`2xl`,leading:`heading`},lede:{step:`lg`,leading:`body`},body:{step:`base`,leading:`body`},"detail-value":{step:`sm`,leading:`body`},quote:{step:`base`,leading:`body`},"body-large":{step:`lg`,leading:`body`},title:{step:`2xl`,leading:`heading`},item:{step:`base`,leading:`body`},label:{step:`sm`,leading:`body`},note:{step:`sm`,leading:`body`},"note-small":{step:`xs`,leading:`body`},figure:{step:`3xl`,leading:`display`},"figure-hero":{step:`4xl`,leading:`display`},"figure-sub":{step:`sm`,leading:`body`},range:{step:`sm`,leading:`body`},sign:{step:`base`,leading:`body`},foot:{step:`xs`,leading:`body`},num:{step:`base`,leading:`body`},"code-otp":{step:`2xl`,leading:`heading`},"code-id":{step:`base`,leading:`body`},button:{step:`base`,leading:`body`}}),s=Object.freeze({section:`2xl`,"section-phone":`xl`,tight:`md`,item:`sm`,"heading-after":`xl`,"eyebrow-after":`xxs`,"title-after":`md`,"callout-lead-after":`xs`,"paragraph-gap":`sm`,"sign-gap":`2xl`,"sign-gap-phone":`lg`,"signature-gap":`md`,"step-gap":`lg`,"step-gutter":`3xl`,"step-gutter-phone":`2xl`,"step-number-space":`md`,"step-number-space-phone":`sm`,"column-top":`lg`,"column-gap":`lg`,"row-padding":`sm`,"panel-padding":`lg`,"panel-padding-wide":`lg`,"details-padding":`lg`,"details-padding-wide":`lg`,"hero-padding":`xl lg`,"hero-padding-wide":`2xl lg`,"columns-padding":`none lg lg lg`,"columns-padding-wide":`xs lg lg lg`}),c=new Set([`panel-padding`,`panel-padding-wide`,`details-padding`,`details-padding-wide`,`hero-padding`,`hero-padding-wide`,`columns-padding`,`columns-padding-wide`]),l=/^(0|\d+px)( (0|\d+px)){0,3}$/,u=Object.freeze({"panel-radius":`md`,"tint-radius":`md`,"code-radius":`md`,"details-radius":`md`}),d=Object.freeze({radius:`md`,padding:`md sm`});function f(e){return Object.hasOwn(a,e)}function p(e){return Object.hasOwn(o,e)}function m(e){return Object.hasOwn(s,e)}function h(e){return Object.hasOwn(u,e)}var g=Object.keys(a).filter(f),_=Object.keys(o).filter(p),v=Object.keys(s).filter(m),y=Object.keys(u).filter(h),b=i.map(([e])=>e);function x(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function S(e){return Math.floor(e+.5)}function C(e){if(typeof e!=`string`)return null;let t=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i.exec(e);if(t===null)return null;let n=t[1]??``;n.length===3&&(n=[...n].map(e=>e+e).join(``));let r=e=>Number.parseInt(n.slice(e,e+2),16);return{r:r(0),g:r(2),b:r(4),a:n.length===8?r(6)/255:1}}function w(e,t,n){return`#${[e,t,n].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`.toUpperCase()}function T(e,t){if(e.a===1)return w(e.r,e.g,e.b);if(t===null)return null;let n=(t,n)=>S(t*e.a+n*(1-e.a));return w(n(e.r,t.r),n(e.g,t.g),n(e.b,t.b))}function E(e,t){let r={light:null,dark:null},i={light:{},dark:{}};for(let o of n){let n=e.colors?.[o]?.surface;n===void 0&&t(`email role card needs meaning surface in ${o}`);let s=C(n);s!==null&&s.a<1&&t(`email card colour (meaning surface, ${o}) must be opaque`),r[o]=s;for(let n of g){let s=a[n],c=e.colors?.[o]?.[s];if(c===void 0){t(`email role ${n} needs meaning ${s} in ${o}`);continue}let l=C(c);l===null?t(`email role ${n} (meaning ${s}, ${o}): cannot read colour ${c}`):i[o][n]=T(l,r[o])}}let o={};for(let e of g)o[e]={light:i.light[e]??null,dark:i.dark[e]??null};return o}function D(e,t,n){let r={};for(let i of _){let{step:a,leading:s}=o[i],c=e.text?.[a],l=t.text?.[a],u=e.typography?.leading?.[s],d=t.typography?.leading?.[s];c===void 0&&n(`email type role ${i} needs text step ${a}`),l===void 0&&n(`email type role ${i} needs text step ${a} in the 390 theme`),u===void 0&&n(`email type role ${i} needs leading ${s}`),d===void 0&&n(`email type role ${i} needs leading ${s} in the 390 theme`),c!==void 0&&l!==void 0&&u!==void 0&&d!==void 0&&(r[i]={size:S(c.size),lineHeight:S(c.size*u),phoneSize:S(l.size),phoneLineHeight:S(l.size*d)})}return r}function O(e,t,n,r){let i=[],a=!0;for(let o of t.split(/\s+/)){let t=e.space?.[o];typeof t==`number`?i.push(t):(r(n(o)),a=!1)}return a?i.map(e=>`${e}px`).join(` `):null}function k(e,t,n,r){if(/\s/.test(n))return r(`email space role ${t} is a gap and takes one space step, not ${n}`),null;let i=e.space?.[n];return typeof i==`number`?i:(r(`email space role ${t} needs space step ${n}`),null)}function A(e,t){let n={};for(let r of v){let i=s[r],a=c.has(r)?O(e,i,e=>`email space role ${r} needs space step ${e}`,t):k(e,r,i,t);a!==null&&(n[r]=a)}return n}function j(e,t){let n={};for(let r of y){let i=u[r],a=e.radius?.[i];typeof a==`number`?n[r]=a:t(`email shape role ${r} needs radius step ${i}`)}return n}function M(e,t){let n=e.radius?.[d.radius];return typeof n!=`number`&&t(`email button needs radius step ${d.radius}`),{radius:n,padding:O(e,d.padding,e=>`email button needs space step ${e}`,t)}}function N(e){let t=e.trim();return t.length>=2&&t[0]===t.at(-1)&&(t[0]===`"`||t[0]===`'`)?t.slice(1,-1).trim():t}function P(e){return r.has(e.toLowerCase())||e.startsWith(`-`)?e:e.includes(` `)?`'${e}'`:e}function F(e,t,n){let r=[t.family,...t.fallback.split(`,`)].map(N).filter(e=>e.length>0),i=r.find(e=>/["';<>]/.test(e));return i===void 0?r.map(P).join(`, `):(n(`email font ${e} holds an unsafe character: ${i}`),null)}function I(e,t){let n={};for(let[r,a]of i){let i=e.fonts?.[a];typeof i?.family!=`string`||typeof i?.fallback!=`string`?t(`email fonts need font ${a}`):n[r]=F(a,i,t)}return n}function L(t,n,r){if(e(t)){let e=t.value;if(typeof e==`number`&&Number.isInteger(e)&&e>=0&&t.unit===`px`)return e}return r(`${n} needs a whole px value`),null}function R(e,t,n){return typeof e==`string`&&l.test(e)?e:(n(`${t} needs CSS px padding`),null)}function z(e,t,n,r,i){let a=typeof t==`string`?/^\{color\.([a-z0-9-]+)\}$/.exec(t)?.[1]:void 0,o=a===void 0?t:e.colors?.[n]?.[a];if(o===void 0)return i(`email group role ${r} needs meaning ${a} in ${n}`),null;let s=C(o);if(s===null)return i(`email group role ${r} (${n}): cannot read colour ${o}`),null;let c=T(s,C(e.colors?.[n]?.surface));return c===null&&i(`email group role ${r} must be opaque in ${n}`),c}function B(t){let n=t.$extensions?.[`com.webority`];return(e(n)?n.dark:void 0)??t.$value}function V(t,n,r){let{size:i,lineHeight:a,phoneSize:o,phoneLineHeight:s,narrowSize:c,narrowLineHeight:l}=e(n)?n:{};if(!x(i)||!x(a)||!x(o)||!x(s))return r(`email group role ${t} needs size, lineHeight, phoneSize and phoneLineHeight in whole px`),null;let u={size:i,lineHeight:a,phoneSize:o,phoneLineHeight:s};return c===void 0?u:typeof c!=`number`||typeof l!=`number`?(r(`email group role ${t} needs narrowSize and narrowLineHeight to be numbers`),null):{...u,narrowSize:c,narrowLineHeight:l}}function H(e,t,n,r){let{colors:i,type:a,space:o,shape:s,button:l}=n,u=(e,t)=>r(`email group key email.${e}.${t} is not an email role`);for(let[n,a]of Object.entries(e.color??{}))f(n)?i[n]={light:z(t,a.$value,`light`,n,r),dark:z(t,B(a),`dark`,n,r)}:u(`color`,n);for(let[t,n]of Object.entries(e.type??{})){if(!p(t)){u(`type`,t);continue}let e=V(t,n.$value,r);e!==null&&(a[t]=e)}for(let[t,n]of Object.entries(e.space??{})){if(!m(t)){u(`space`,t);continue}let e=`email group role ${t}`;o[t]=c.has(t)?R(n.$value,e,r):L(n.$value,e,r)}for(let[t,n]of Object.entries(e.shape??{}))h(t)?s[t]=L(n.$value,`email group role ${t}`,r):u(`shape`,t);for(let[t,n]of Object.entries(e.button??{}))t===`radius`?l.radius=L(n.$value,`email group role button radius`,r)??void 0:t===`padding`?l.padding=R(n.$value,`email group role button padding`,r):u(`button`,t)}function U(e,n,r){let i={};for(let a of n)i[a]=t(r(a)??void 0,`${e}.${a}`);if(!W(n,i))throw Error(`emitEmail: ${e} is incomplete`);return i}function W(e,t){return e.every(e=>t[e]!==void 0)}function G(e,n){let{colors:r,fonts:i,type:a,space:o,shape:s,button:c}=n;return{format:`webority-email-theme/1`,source:{package:e.source.package,version:e.source.version,brand:e.source.brand},colors:U(`colors`,g,e=>{let n=r[e];return n===void 0?void 0:{light:t(n.light??void 0,`colors.${e}.light`),dark:t(n.dark??void 0,`colors.${e}.dark`)}}),fonts:U(`fonts`,b,e=>i[e]),type:U(`type`,_,e=>a[e]),space:U(`space`,v,e=>o[e]),shape:U(`shape`,y,e=>s[e]),button:{radius:t(c.radius,`button.radius`),padding:t(c.padding??void 0,`button.padding`)}}}function K(e,t,n=null){if(e?.format!==`webority-theme-tokens/2`||e.source?.platform!==`web`)throw Error(`emitEmail: web must be the web theme tokens at width 1440`);if(e.source.width!==1440)throw Error(`emitEmail: web must be the 1440 theme`);if(t?.format!==`webority-theme-tokens/2`||t.source?.platform!==`web`||t.source?.width!==390)throw Error(`emitEmail: web390 must be the web theme tokens at width 390`);let r=[],i=e=>r.push(`emitEmail: ${e}`),a={colors:E(e,i),type:D(e,t,i),space:A(e,i),shape:j(e,i),button:M(e,i),fonts:I(e,i)};if(n!==null&&H(n,e,a,i),r.length>0)throw Error(r.join(`
2
+ `));return G(e,a)}export{d as EMAIL_BUTTON,a as EMAIL_COLOR_ROLES,l as EMAIL_PADDING_PATTERN,c as EMAIL_PADDING_ROLES,u as EMAIL_SHAPE,s as EMAIL_SPACE,o as EMAIL_TYPE_ROLES,K as emitEmail};
@@ -0,0 +1,3 @@
1
+ import type { Model } from "../model/index.ts";
2
+ import type { MeaningRegistry } from "../outputs.ts";
3
+ export declare function emitMeanings(model: Model): MeaningRegistry;
@@ -0,0 +1,26 @@
1
+ import type { Mode, Model } from "../model/index.ts";
2
+ export interface PhoneToken {
3
+ path: readonly string[];
4
+ type: string;
5
+ value: unknown;
6
+ /** The first alias the token names, "space.lg" for "{space.lg}"; null for a literal. From Model.referenceIn. */
7
+ reference: string | null;
8
+ platforms: readonly ("web" | "phone")[] | null;
9
+ /** The com.webority extension object, or null. */
10
+ extensions: Record<string, unknown> | null;
11
+ }
12
+ export interface PhoneTokenSets {
13
+ light: readonly PhoneToken[];
14
+ dark: readonly PhoneToken[];
15
+ }
16
+ export interface EmittedFile {
17
+ name: string;
18
+ contents: string;
19
+ }
20
+ export declare function phoneSets(model: Model, mode: Mode): readonly PhoneToken[];
21
+ export declare function emitPhoneTheme(sets: PhoneTokenSets): EmittedFile;
22
+ export declare function emitPhoneBrand(library: PhoneTokenSets, branded: PhoneTokenSets, source: {
23
+ package: string;
24
+ version: string;
25
+ brand: string;
26
+ }): EmittedFile;
@@ -1,3 +1,3 @@
1
- var e=/^[A-Za-z_$][A-Za-z0-9_$]*$/,t=/^#([0-9a-fA-F]{6})([0-9a-fA-F]{2})?$/,n=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)$/,r=[`xs`,`sm`,`md`,`lg`,`xl`],i=`must be component.<name>.<prop> or component.<name>.<size>.<prop>`,a=[`light`,`dark`],o={color:`colors`,space:`space`,radius:`radius`,text:`text`,weight:`weight`,leading:`leading`,"letter-spacing":`letter-spacing`,font:`font`,shadow:`shadow`,size:`size`,component:`components`},s=[{key:`colors`,constName:`COLOR_NAMES`,typeName:`ColorName`},{key:`space`,constName:`SPACE_NAMES`,typeName:`SpaceName`},{key:`radius`,constName:`RADIUS_NAMES`,typeName:`RadiusName`},{key:`text`,constName:`TEXT_NAMES`,typeName:`TextName`},{key:`weight`,constName:`WEIGHT_NAMES`,typeName:`WeightName`},{key:`leading`,constName:`LEADING_NAMES`,typeName:`LeadingName`},{key:`letter-spacing`,constName:`LETTER_SPACING_NAMES`,typeName:`LetterSpacingName`},{key:`font`,constName:`FONT_NAMES`,typeName:`FontName`},{key:`shadow`,constName:`SHADOW_NAMES`,typeName:`ShadowName`},{key:`motion.duration`,constName:`DURATION_NAMES`,typeName:`DurationName`},{key:`motion.ease`,constName:`EASE_NAMES`,typeName:`EaseName`},{key:`size`,constName:`SIZE_NAMES`,typeName:`SizeName`}],c={space:`SpaceName`,text:`TextName`,radius:`RadiusName`,px:`number`,number:`number`,ms:`number`},l=[`export type FontWeightValue = "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900";`,`/** Face name per weight; an empty object means the platform system font. */`,`export type FontFaces = Partial<Record<WeightName, string>>;`,`export interface PhoneShadow {`,` shadowColor: string;`,` shadowOffset: { width: number; height: number };`,` shadowOpacity: number;`,` shadowRadius: number;`,` elevation: number;`,`}`,`export type ComponentKind = "space" | "text" | "radius" | "px" | "number" | "ms";`,`type Sized<S extends string, T> = Record<S, T>;`,`type L3 = "sm" | "md" | "lg";`],u=[`export interface TokenSet {`,` mode: "light" | "dark";`,` colors: Record<ColorName, string>;`,` space: Record<SpaceName, number>;`,` radius: Record<RadiusName, number>;`,` text: Record<TextName, { size: number }>;`,` weight: Record<WeightName, FontWeightValue>;`,` leading: Record<LeadingName, number>;`,` "letter-spacing": Record<LetterSpacingName, number>;`,` font: Record<FontName, FontFaces>;`,` shadow: Record<ShadowName, PhoneShadow>;`,` motion: { duration: Record<DurationName, number>; ease: Record<EaseName, readonly [number, number, number, number]> };`,` size: Record<SizeName, number>;`,` components: ComponentTokens;`,`}`];function d(e,t){let n=e.contexts.find(e=>e.platform===`phone`&&e.mode===t);if(!n)throw Error(`phoneSets: the model has no ${t} phone context`);let r=[];for(let t of e.tokens.values()){if(!e.existsIn(t.path,n))continue;let i=e.resolvedIn(t.path,n);r.push({path:t.path.split(`.`),type:t.type,value:t.group===`text`?m(t.path,i):i,reference:e.referenceIn(t.path,n)??null,platforms:t.platforms,extensions:Object.keys(t.extensions).length>0?t.extensions:null})}return r}function f(e){let t=y(e.light),n=y(e.dark);D(t,n);let r=["// Generated by `webority brand --library` from packages/tokens/src/source. Do not edit: run `corepack pnpm --filter @webority/mobile-ui tokens`."];for(let e of s)r.push(...j(e,t.lists.get(e.key)));return r.push(...l),r.push(...I(t.components)),r.push(...L(t.components)),r.push(...u),r.push(...B(`lightTokens`,`light`,t)),r.push(...B(`darkTokens`,`dark`,n)),{name:`tokens.generated.ts`,contents:`${r.join(`
2
- `)}\n`}}function p(e,t,n){let r={colors:{light:{},dark:{}},radius:{},font:{}};for(let n of a){let i=y(e[n]).values,a=y(t[n]).values;for(let e of new Set([...i.keys(),...a.keys()])){let t=i.get(e),o=a.get(e);if(!t&&o&&e.startsWith(`colors.`))continue;if(!t||!o)throw Error(k(e));if(JSON.stringify(t.value)===JSON.stringify(o.value))continue;let s=e.lastIndexOf(`.`),c=e.slice(0,s),l=e.slice(s+1);if(c===`radius`&&(l===`none`||l===`pill`))throw Error(`A brand cannot change radius none or pill`);if(c===`colors`)r.colors[n][l]=o.value;else if(c===`radius`)O(r.radius,l,o.value,e);else if(c===`font`)O(r.font,l,o.value,e);else throw Error(k(e))}}let i=Object.fromEntries(a.filter(e=>Object.keys(r.colors[e]).length>0).map(e=>[e,r.colors[e]])),o={};Object.keys(i).length>0&&(o.colors=i),Object.keys(r.radius).length>0&&(o.radius=r.radius),Object.keys(r.font).length>0&&(o.font=r.font);let s=[`// Generated by \`webority brand\` for ${n.brand} from ${n.package} ${n.version}. Do not edit.`,``,`/** @type {import("@webority/mobile-ui").BrandOverrides} */`];return Object.keys(o).length===0?s.push(`export const brand = {};`):s.push(`export const brand = {`,...Object.entries(o).flatMap(([e,t])=>H(e,t,` `)),`};`),{name:`brand.phone.js`,contents:`${s.join(`
3
- `)}\n`}}function m(e,t){return{size:v(t,e)}}function h(e){return e.extensions?.internal===!0?!1:e.platforms===null||e.platforms.includes(`phone`)}function g(e,t){return Error(`Token group ${e} has no phone mapping; mark it web or add one to emit/phone.js (first: ${t})`)}function _(e){let[t,n]=e.path;if(t===`motion`){if(n===`duration`||n===`ease`)return`motion.${n}`;throw g(t,e.path.join(`.`))}if(!Object.hasOwn(o,t))throw g(t,e.path.join(`.`));return o[t]}function v(e,t){let n=typeof e==`object`&&e?e.value:e;if(!Number.isFinite(n))throw Error(`Token ${t} has no numeric value`);return n}function y(e){let t=new Map(s.map(e=>[e.key,[]])),n=new Map,r=new Map;for(let i of e){if(!h(i))continue;let e=i.path.join(`.`),a=_(i);if(i.value===void 0||i.value===null)throw Error(`Token ${e} has no phone value`);if(a===`components`){T(i,e,n,r);continue}let o=i.path.slice(a.startsWith(`motion.`)?2:1).join(`-`);n.set(`${a}.${o}`,{path:e,value:b(a,o,i,e)}),t.get(a).push(o)}return{lists:t,values:n,components:r}}function b(e,t,n,r){let{value:i}=n;switch(e){case`colors`:return i;case`space`:case`radius`:case`letter-spacing`:case`size`:case`leading`:case`motion.duration`:return v(i,r);case`text`:return{size:v(i.size,r)};case`weight`:return String(v(i,r));case`font`:return x(n,t);case`shadow`:return S(n,t,r);case`motion.ease`:return w(i,r)}}function x(e,t){if(Array.isArray(e.value)&&e.value.length===1&&e.value[0]===`System`)return{};if(!e.extensions?.faces)throw Error(`Font ${t} is not the system font and has no faces`);return e.extensions.faces}function S(e,t,n){let{color:r,offsetX:i,offsetY:a,blur:o}=e.value,{hex:s,opacity:c}=C(r,n),l=e.extensions?.elevation;if(!Number.isFinite(l))throw Error(`Shadow ${t} has no elevation`);return{shadowColor:s,shadowOffset:{width:v(i,n),height:v(a,n)},shadowOpacity:c,shadowRadius:v(o,n),elevation:l}}function C(e,r){let i=t.exec(e);if(i){let e=i[2]===void 0?1:Math.round(parseInt(i[2],16)/255*1e3)/1e3;return{hex:`#${i[1].toLowerCase()}`,opacity:e}}let a=n.exec(e);if(a)return{hex:`#${a.slice(1,4).map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`,opacity:Number(a[4])};throw Error(`Shadow ${r} colour is not #RRGGBB, #RRGGBBAA or rgba(): ${e}`)}function w(e,t){if(!Array.isArray(e)||e.length!==4||!e.every(e=>Number.isFinite(e)))throw Error(`Token ${t} has no phone value`);return[...e]}function T(e,t,n,a){let o=e.path,s=o.length===4;if(o.length!==3&&!s||s&&!r.includes(o[2]))throw Error(`Component token ${t} ${i}`);let c=o[1],l=o[o.length-1],{kind:u,value:d}=E(e,t);a.has(c)||a.set(c,{props:new Map,sizes:new Map,free:new Map});let f=a.get(c);if(f.props.has(l)&&f.props.get(l)!==u)throw Error(`Component ${c} prop ${l} has two kinds`);if(f.props.set(l,u),s){let e=o[2];f.sizes.has(e)||f.sizes.set(e,new Map),f.sizes.get(e).set(l,d),n.set(`components.${c}.${e}.${l}`,{path:t,value:d})}else f.free.set(l,d),n.set(`components.${c}.${l}`,{path:t,value:d})}function E(e,t){let{reference:n}=e;for(let[e,t]of[[`space.`,`space`],[`text.`,`text`],[`radius.`,`radius`]])if(n?.startsWith(e))return{kind:t,value:n.slice(e.length)};if(!n){if(e.type===`dimension`)return{kind:`px`,value:v(e.value,t)};if(e.type===`number`)return{kind:`number`,value:v(e.value,t)};if(e.type===`duration`)return{kind:`ms`,value:v(e.value,t)}}throw Error(`Component token ${t} has an unsupported value`)}function D(e,t){for(let[n,{path:r}]of e.values)if(!t.values.has(n))throw Error(`Token ${r} exists in one mode only`);for(let[n,{path:r}]of t.values)if(!e.values.has(n))throw Error(`Token ${r} exists in one mode only`)}function O(e,t,n,r){if(Object.hasOwn(e,t)&&JSON.stringify(e[t])!==JSON.stringify(n))throw Error(`A brand sets ${r} differently in light and dark`);e[t]=n}function k(e){return`A brand overrides colours, radius and fonts only; ${e} differs`}function A(t){return e.test(t)?t:JSON.stringify(t)}function j(e,t){let n=`export type ${e.typeName} = (typeof ${e.constName})[number];`;return t.length<=12?[`export const ${e.constName} = [${t.map(e=>JSON.stringify(e)).join(`, `)}] as const;`,n]:[`export const ${e.constName} = [`,...t.map(e=>` ${JSON.stringify(e)},`),`] as const;`,n]}var M=140;function N(e,t){return t.map(t=>`${A(t)}: ${c[e.props.get(t)]}`)}function P(e){return e.split(/[^A-Za-z0-9]+/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function F(e,t){return[`export interface ${e} {`,...t.map(e=>` ${e};`),`}`]}function I(e){let t=[],n=[];for(let[i,a]of e){let e=N(a,[...a.free.keys()]),o=N(a,[...new Set([...a.sizes.values()].flatMap(e=>[...e.keys()]))]),s=r.filter(e=>a.sizes.has(e)),c=s.join()===`sm,md,lg`?`L3`:s.map(e=>JSON.stringify(e)).join(` | `),l=e=>`{ ${e.join(`; `)} }`,u=(t,n)=>o.length===0?n:`Sized<${c}, ${t}>${e.length>0?` & ${n}`:``}`,d=` ${A(i)}: ${u(l(o),l(e))};`;if(d.length<=M){n.push(d);continue}let f=P(i);o.length>0&&t.push(...F(`${f}SizeTokens`,o)),e.length>0&&t.push(...F(`${f}Tokens`,e)),n.push(` ${A(i)}: ${u(`${f}SizeTokens`,`${f}Tokens`)};`)}let i=[...t,`export interface ComponentTokens {`,...n];return i.push(`}`,`export type ComponentName = keyof ComponentTokens;`,`type SizeKeysOf<C extends ComponentName> = Extract<keyof ComponentTokens[C], "xs" | "sm" | "md" | "lg" | "xl">;`,`export type ComponentSizeTokens<C extends ComponentName> = ComponentTokens[C][SizeKeysOf<C>];`),i}function L(e){let t=[`export const COMPONENT_KINDS = {`];for(let[n,r]of e){let e=[...r.props].map(([e,t])=>`${A(e)}: ${JSON.stringify(t)}`),i=` ${A(n)}: { ${e.join(`, `)} },`;i.length<=M?t.push(i):t.push(` ${A(n)}: {`,...e.map(e=>` ${e},`),` },`)}return t.push(`} as const satisfies { readonly [C in ComponentName]: Readonly<Record<string, ComponentKind>> };`),t}function R(e){let t={};for(let[n,i]of e){let e={};for(let t of r)i.sizes.has(t)&&(e[t]=Object.fromEntries(i.sizes.get(t)));for(let[t,n]of i.free)e[t]=n;t[n]=e}return t}function z(e,t){let{lists:n}=t,r=(e,n)=>Object.fromEntries(n.map(n=>[n,t.values.get(`${e}.${n}`).value]));return{mode:e,colors:r(`colors`,n.get(`colors`)),space:r(`space`,n.get(`space`)),radius:r(`radius`,n.get(`radius`)),text:r(`text`,n.get(`text`)),weight:r(`weight`,n.get(`weight`)),leading:r(`leading`,n.get(`leading`)),"letter-spacing":r(`letter-spacing`,n.get(`letter-spacing`)),font:r(`font`,n.get(`font`)),shadow:r(`shadow`,n.get(`shadow`)),motion:{duration:r(`motion.duration`,n.get(`motion.duration`)),ease:r(`motion.ease`,n.get(`motion.ease`))},size:r(`size`,n.get(`size`)),components:R(t.components)}}function B(e,t,n){let r=z(t,n);return[`export const ${e}: TokenSet = {`,...Object.entries(r).flatMap(([e,t])=>H(e,t,` `)),`};`]}function V(e){return Array.isArray(e)?`[${e.map(e=>V(e)).join(`, `)}]`:JSON.stringify(e)}function H(e,t,n){let r=`${n}${A(e)}`;if(typeof t==`object`&&t&&!Array.isArray(t)){let e=Object.entries(t);return e.length===0?[`${r}: {},`]:[`${r}: {`,...e.flatMap(([e,t])=>H(e,t,`${n} `)),`${n}},`]}return[`${r}: ${V(t)},`]}export{p as emitPhoneBrand,f as emitPhoneTheme,d as phoneSets};
1
+ import{isObjectLike as e}from"../guards.js";import{present as t}from"../present.js";var n="// Generated by `webority brand --library` from packages/tokens/src/source. Do not edit: run `corepack pnpm --filter @webority/mobile-ui tokens`.",r=/^[A-Za-z_$][A-Za-z0-9_$]*$/,i=/^#([0-9a-fA-F]{6})([0-9a-fA-F]{2})?$/,a=/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)$/,o=[`xs`,`sm`,`md`,`lg`,`xl`],s=`must be component.<name>.<prop> or component.<name>.<size>.<prop>`,c=[`light`,`dark`],l=new Map([[`color`,`colors`],[`space`,`space`],[`radius`,`radius`],[`text`,`text`],[`weight`,`weight`],[`leading`,`leading`],[`letter-spacing`,`letter-spacing`],[`font`,`font`],[`shadow`,`shadow`],[`size`,`size`],[`component`,`components`]]),u=[{key:`colors`,constName:`COLOR_NAMES`,typeName:`ColorName`},{key:`space`,constName:`SPACE_NAMES`,typeName:`SpaceName`},{key:`radius`,constName:`RADIUS_NAMES`,typeName:`RadiusName`},{key:`text`,constName:`TEXT_NAMES`,typeName:`TextName`},{key:`weight`,constName:`WEIGHT_NAMES`,typeName:`WeightName`},{key:`leading`,constName:`LEADING_NAMES`,typeName:`LeadingName`},{key:`letter-spacing`,constName:`LETTER_SPACING_NAMES`,typeName:`LetterSpacingName`},{key:`font`,constName:`FONT_NAMES`,typeName:`FontName`},{key:`shadow`,constName:`SHADOW_NAMES`,typeName:`ShadowName`},{key:`motion.duration`,constName:`DURATION_NAMES`,typeName:`DurationName`},{key:`motion.ease`,constName:`EASE_NAMES`,typeName:`EaseName`},{key:`size`,constName:`SIZE_NAMES`,typeName:`SizeName`}],d={space:`SpaceName`,text:`TextName`,radius:`RadiusName`,px:`number`,number:`number`,ms:`number`},f=[`export type FontWeightValue = "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900";`,`/** Face name per weight; an empty object means the platform system font. */`,`export type FontFaces = Partial<Record<WeightName, string>>;`,`export interface PhoneShadow {`,` shadowColor: string;`,` shadowOffset: { width: number; height: number };`,` shadowOpacity: number;`,` shadowRadius: number;`,` elevation: number;`,`}`,`export type ComponentKind = "space" | "text" | "radius" | "px" | "number" | "ms";`,`type Sized<S extends string, T> = Record<S, T>;`,`type L3 = "sm" | "md" | "lg";`],p=[`export interface TokenSet {`,` mode: "light" | "dark";`,` colors: Record<ColorName, string>;`,` space: Record<SpaceName, number>;`,` radius: Record<RadiusName, number>;`,` text: Record<TextName, { size: number }>;`,` weight: Record<WeightName, FontWeightValue>;`,` leading: Record<LeadingName, number>;`,` "letter-spacing": Record<LetterSpacingName, number>;`,` font: Record<FontName, FontFaces>;`,` shadow: Record<ShadowName, PhoneShadow>;`,` motion: { duration: Record<DurationName, number>; ease: Record<EaseName, readonly [number, number, number, number]> };`,` size: Record<SizeName, number>;`,` components: ComponentTokens;`,`}`];function m(e,t){let n=e.contexts.find(e=>e.platform===`phone`&&e.mode===t);if(!n)throw Error(`phoneSets: the model has no ${t} phone context`);let r=[];for(let t of e.tokens.values()){if(!e.existsIn(t.path,n))continue;let i=e.resolvedIn(t.path,n);r.push({path:t.path.split(`.`),type:t.type,value:t.group===`text`?_(t.path,i):i,reference:e.referenceIn(t.path,n)??null,platforms:t.platforms,extensions:Object.keys(t.extensions).length>0?t.extensions:null})}return r}function h(e){let t=E(e.light),r=E(e.dark);I(t,r);let i=[n];for(let e of u)i.push(...B(e,b(t.lists,e.key)));return i.push(...f),i.push(...G(t.components)),i.push(...K(t.components)),i.push(...p),i.push(...Y(`lightTokens`,`light`,t)),i.push(...Y(`darkTokens`,`dark`,r)),{name:`tokens.generated.ts`,contents:`${i.join(`
2
+ `)}\n`}}function g(e,t,n){let r={colors:{light:{},dark:{}},radius:{},font:{}};for(let n of c){let i=E(e[n]).values,a=E(t[n]).values;for(let e of new Set([...i.keys(),...a.keys()])){let t=i.get(e),o=a.get(e);if(!t&&o&&e.startsWith(`colors.`))continue;if(!t||!o)throw Error(R(e));if(JSON.stringify(t.value)===JSON.stringify(o.value))continue;let s=e.lastIndexOf(`.`),c=e.slice(0,s),l=e.slice(s+1);if(c===`radius`&&(l===`none`||l===`pill`))throw Error(`A brand cannot change radius none or pill`);if(c===`colors`)r.colors[n][l]=o.value;else if(c===`radius`)L(r.radius,l,o.value,e);else if(c===`font`)L(r.font,l,o.value,e);else throw Error(R(e))}}let i=Object.fromEntries(c.filter(e=>Object.keys(r.colors[e]).length>0).map(e=>[e,r.colors[e]])),a={};Object.keys(i).length>0&&(a.colors=i),Object.keys(r.radius).length>0&&(a.radius=r.radius),Object.keys(r.font).length>0&&(a.font=r.font);let o=[`// Generated by \`webority brand\` for ${n.brand} from ${n.package} ${n.version}. Do not edit.`,``,`/** @type {import("@webority/mobile-ui").BrandOverrides} */`];return Object.keys(a).length===0?o.push(`export const brand = {};`):o.push(`export const brand = {`,...Object.entries(a).flatMap(([e,t])=>Z(e,t,` `)),`};`),{name:`brand.phone.js`,contents:`${o.join(`
3
+ `)}\n`}}function _(e,t){return{size:T(t,e)}}function v(t,n){return e(t)?t[n]:void 0}function y(e,n){return t(e[n],`token path segment ${n}`)}function b(e,n){return t(e.get(n),`phone emitter ${n} list`)}function x(e,n){return t(e.get(n),`phone emitter value for ${n}`).value}function S(e){return e.extensions?.internal===!0?!1:e.platforms===null||e.platforms.includes(`phone`)}function C(e,t){return Error(`Token group ${e} has no phone mapping; mark it web or add one to emit/phone.js (first: ${t})`)}function w(e){let[t,n]=e.path;if(t===`motion`){if(n===`duration`||n===`ease`)return`motion.${n}`;throw C(t,e.path.join(`.`))}let r=t===void 0?void 0:l.get(t);if(r===void 0)throw C(t,e.path.join(`.`));return r}function T(t,n){let r=e(t)?t.value:t;if(typeof r!=`number`||!Number.isFinite(r))throw Error(`Token ${n} has no numeric value`);return r}function E(e){let t=new Map(u.map(e=>[e.key,[]])),n=new Map,r=new Map;for(let i of e){if(!S(i))continue;let e=i.path.join(`.`),a=w(i);if(i.value===void 0||i.value===null)throw Error(`Token ${e} has no phone value`);if(a===`components`){P(i,e,n,r);continue}let o=i.path.slice(a.startsWith(`motion.`)?2:1).join(`-`);n.set(`${a}.${o}`,{path:e,value:D(a,o,i,e)}),b(t,a).push(o)}return{lists:t,values:n,components:r}}function D(e,t,n,r){let{value:i}=n;switch(e){case`colors`:return i;case`space`:case`radius`:case`letter-spacing`:case`size`:case`leading`:case`motion.duration`:return T(i,r);case`text`:return{size:T(v(i,`size`),r)};case`weight`:return String(T(i,r));case`font`:return O(n,t);case`shadow`:return k(n,t,r);case`motion.ease`:return j(i,r)}}function O(e,t){if(Array.isArray(e.value)&&e.value.length===1&&e.value[0]===`System`)return{};if(!e.extensions?.faces)throw Error(`Font ${t} is not the system font and has no faces`);return e.extensions.faces}function k(t,n,r){let i=t.value;if(!e(i))throw Error(`Shadow ${n} has no shadow value`);let{hex:a,opacity:o}=A(i.color,r),s=t.extensions?.elevation;if(typeof s!=`number`||!Number.isFinite(s))throw Error(`Shadow ${n} has no elevation`);return{shadowColor:a,shadowOffset:{width:T(i.offsetX,r),height:T(i.offsetY,r)},shadowOpacity:o,shadowRadius:T(i.blur,r),elevation:s}}function A(e,t){let n=typeof e==`string`?i.exec(e):null;if(n){let e=n[1],r=n[2];if(e===void 0)throw Error(`Shadow ${t} colour has no digits`);let i=r===void 0?1:Math.round(parseInt(r,16)/255*1e3)/1e3;return{hex:`#${e.toLowerCase()}`,opacity:i}}let r=typeof e==`string`?a.exec(e):null;if(r)return{hex:`#${r.slice(1,4).map(e=>Number(e).toString(16).padStart(2,`0`)).join(``)}`,opacity:Number(r[4])};throw Error(`Shadow ${t} colour is not #RRGGBB, #RRGGBBAA or rgba(): ${String(e)}`)}function j(e,t){if(!Array.isArray(e)||e.length!==4||!e.every(e=>Number.isFinite(e)))throw Error(`Token ${t} has no phone value`);return[...e]}function M(e){return e!==void 0&&o.includes(e)}function N(e,n){return t(e.props.get(n),`component prop ${n} kind`)}function P(e,t,n,r){let i=e.path,a=i.length===4;if(i.length!==3&&!a||a&&!M(i[2]))throw Error(`Component token ${t} ${s}`);let o=y(i,1),c=y(i,i.length-1),{kind:l,value:u}=F(e,t),d=r.get(o);if(d===void 0&&(d={props:new Map,sizes:new Map,free:new Map},r.set(o,d)),d.props.has(c)&&d.props.get(c)!==l)throw Error(`Component ${o} prop ${c} has two kinds`);if(d.props.set(c,l),a){let e=y(i,2),r=d.sizes.get(e);r===void 0&&(r=new Map,d.sizes.set(e,r)),r.set(c,u),n.set(`components.${o}.${e}.${c}`,{path:t,value:u})}else d.free.set(c,u),n.set(`components.${o}.${c}`,{path:t,value:u})}function F(e,t){let{reference:n}=e;for(let[e,t]of[[`space.`,`space`],[`text.`,`text`],[`radius.`,`radius`]])if(n?.startsWith(e))return{kind:t,value:n.slice(e.length)};if(!n){if(e.type===`dimension`)return{kind:`px`,value:T(e.value,t)};if(e.type===`number`)return{kind:`number`,value:T(e.value,t)};if(e.type===`duration`)return{kind:`ms`,value:T(e.value,t)}}throw Error(`Component token ${t} has an unsupported value`)}function I(e,t){for(let[n,{path:r}]of e.values)if(!t.values.has(n))throw Error(`Token ${r} exists in one mode only`);for(let[n,{path:r}]of t.values)if(!e.values.has(n))throw Error(`Token ${r} exists in one mode only`)}function L(e,t,n,r){if(Object.hasOwn(e,t)&&JSON.stringify(e[t])!==JSON.stringify(n))throw Error(`A brand sets ${r} differently in light and dark`);e[t]=n}function R(e){return`A brand overrides colours, radius and fonts only; ${e} differs`}function z(e){return r.test(e)?e:JSON.stringify(e)}function B(e,t){let n=`export type ${e.typeName} = (typeof ${e.constName})[number];`;return t.length<=12?[`export const ${e.constName} = [${t.map(e=>JSON.stringify(e)).join(`, `)}] as const;`,n]:[`export const ${e.constName} = [`,...t.map(e=>` ${JSON.stringify(e)},`),`] as const;`,n]}var V=140;function H(e,t){return t.map(t=>`${z(t)}: ${d[N(e,t)]}`)}function U(e){return e.split(/[^A-Za-z0-9]+/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function W(e,t){return[`export interface ${e} {`,...t.map(e=>` ${e};`),`}`]}function G(e){let t=[],n=[];for(let[r,i]of e){let e=H(i,[...i.free.keys()]),a=H(i,[...new Set([...i.sizes.values()].flatMap(e=>[...e.keys()]))]),s=o.filter(e=>i.sizes.has(e)),c=s.join()===`sm,md,lg`?`L3`:s.map(e=>JSON.stringify(e)).join(` | `),l=e=>`{ ${e.join(`; `)} }`,u=(t,n)=>a.length===0?n:`Sized<${c}, ${t}>${e.length>0?` & ${n}`:``}`,d=` ${z(r)}: ${u(l(a),l(e))};`;if(d.length<=V){n.push(d);continue}let f=U(r);a.length>0&&t.push(...W(`${f}SizeTokens`,a)),e.length>0&&t.push(...W(`${f}Tokens`,e)),n.push(` ${z(r)}: ${u(`${f}SizeTokens`,`${f}Tokens`)};`)}let r=[...t,`export interface ComponentTokens {`,...n];return r.push(`}`,`export type ComponentName = keyof ComponentTokens;`,`type SizeKeysOf<C extends ComponentName> = Extract<keyof ComponentTokens[C], "xs" | "sm" | "md" | "lg" | "xl">;`,`export type ComponentSizeTokens<C extends ComponentName> = ComponentTokens[C][SizeKeysOf<C>];`),r}function K(e){let t=[`export const COMPONENT_KINDS = {`];for(let[n,r]of e){let e=[...r.props].map(([e,t])=>`${z(e)}: ${JSON.stringify(t)}`),i=` ${z(n)}: { ${e.join(`, `)} },`;i.length<=V?t.push(i):t.push(` ${z(n)}: {`,...e.map(e=>` ${e},`),` },`)}return t.push(`} as const satisfies { readonly [C in ComponentName]: Readonly<Record<string, ComponentKind>> };`),t}function q(e){let t={};for(let[n,r]of e){let e={};for(let t of o){let n=r.sizes.get(t);n!==void 0&&(e[t]=Object.fromEntries(n))}for(let[t,n]of r.free)e[t]=n;t[n]=e}return t}function J(e,t){let{lists:n}=t,r=(e,n)=>Object.fromEntries(n.map(n=>[n,x(t.values,`${e}.${n}`)]));return{mode:e,colors:r(`colors`,b(n,`colors`)),space:r(`space`,b(n,`space`)),radius:r(`radius`,b(n,`radius`)),text:r(`text`,b(n,`text`)),weight:r(`weight`,b(n,`weight`)),leading:r(`leading`,b(n,`leading`)),"letter-spacing":r(`letter-spacing`,b(n,`letter-spacing`)),font:r(`font`,b(n,`font`)),shadow:r(`shadow`,b(n,`shadow`)),motion:{duration:r(`motion.duration`,b(n,`motion.duration`)),ease:r(`motion.ease`,b(n,`motion.ease`))},size:r(`size`,b(n,`size`)),components:q(t.components)}}function Y(e,t,n){let r=J(t,n);return[`export const ${e}: TokenSet = {`,...Object.entries(r).flatMap(([e,t])=>Z(e,t,` `)),`};`]}function X(e){return Array.isArray(e)?`[${e.map(e=>X(e)).join(`, `)}]`:JSON.stringify(e)}function Z(e,t,n){let r=`${n}${z(e)}`;if(typeof t==`object`&&t&&!Array.isArray(t)){let e=Object.entries(t);return e.length===0?[`${r}: {},`]:[`${r}: {`,...e.flatMap(([e,t])=>Z(e,t,`${n} `)),`${n}},`]}return[`${r}: ${X(t)},`]}export{g as emitPhoneBrand,h as emitPhoneTheme,m as phoneSets};
@@ -0,0 +1,18 @@
1
+ import type { Model } from "../model/index.ts";
2
+ /** Library mode: the token SCSS and the Bootstrap variables, references kept as var(). */
3
+ export interface LibraryWebFiles {
4
+ tokens: string;
5
+ bootstrap: string;
6
+ }
7
+ /** Brand mode: only what differs from the library, as brand.css and _brand-variables.scss. */
8
+ export interface BrandWebFiles {
9
+ css: string;
10
+ variables: string;
11
+ }
12
+ /**
13
+ * Library mode returns the tokens and bootstrap SCSS. Brand mode returns the brand CSS and variables that differ from the library.
14
+ */
15
+ export declare function emitWeb(model: Model): LibraryWebFiles;
16
+ export declare function emitWeb(model: Model, options: {
17
+ library: Model;
18
+ }): BrandWebFiles;
package/dist/emit/web.js CHANGED
@@ -1,24 +1,24 @@
1
- import{BREAKPOINT_PX as e,TOUCH_MEDIA as t,breakpointRules as n,fluidLength as r,touchValue as i}from"../model/length.js";import{cssVarOfPath as a}from"../names.js";var o={mode:`light`,platform:`web`,width:1440},s={mode:`dark`,platform:`web`,width:1440},c={mode:`light`,platform:`web`,width:390},l=/\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}/g,u=/^\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}$/,d=/^#[0-9a-f]{6}$/i,f=[[`--bs-body-color`,`text`],[`--bs-emphasis-color`,`text`],[`--bs-secondary-color`,`text-muted`],[`--bs-tertiary-color`,`text-subtle`],[`--bs-heading-color`,`text`],[`--bs-body-bg`,`bg`],[`--bs-border-color`,`border`],[`--bs-secondary-bg`,`surface`],[`--bs-tertiary-bg`,`bg-muted`],[`--bs-primary`,`primary`]],p=[[`--bs-body-bg-rgb`,`bg`],[`--bs-primary-rgb`,`primary`],[`--bs-body-color-rgb`,`text`],[`--bs-emphasis-color-rgb`,`text`],[`--bs-secondary-color-rgb`,`text-muted`],[`--bs-tertiary-color-rgb`,`text-subtle`],[`--bs-secondary-bg-rgb`,`surface`],[`--bs-tertiary-bg-rgb`,`bg-muted`],[`--bs-border-color-rgb`,`border`]],m=[[`--bs-secondary-rgb`,`text-muted`]],h=[[`$body-color`,`color.text-body`],[`$body-secondary-color`,`color.text-muted`],[`$body-tertiary-color`,`color.text-subtle`],[`$body-secondary-bg`,`color.bg-subtle`],[`$body-tertiary-bg`,`color.bg-muted`],[`$border-color`,`color.border`],[`$border-color-translucent`,null],[`$border-radius`,`radius.md`],[`$border-radius-sm`,`radius.sm`],[`$border-radius-lg`,`radius.lg`],[`$border-radius-pill`,`radius.pill`],[`$wui-shadow-overlay`,`shadow.popover`],[`$wui-shadow-overlay-lg`,`shadow.modal`],[`$link-color`,`color.link`],[`$line-height-base`,`leading.body`],[`$headings-line-height`,`leading.heading`],[`$display-line-height`,`leading.display`]],ee=[[`$primary`,`color.primary`]],g={"$border-color-translucent":`rgba(13, 24, 43, 0.08)`},_=[`color.link`,`color.primary-hover`],v=`:root[data-theme="dark"],
2
- :root[data-bs-theme="dark"]`,y=`[data-theme="dark"]:not(:root),
3
- [data-bs-theme="dark"]:not(:root)`,b=`:root[data-theme="auto"]`,x=`:root[data-theme="dark"] [data-theme="light"],
1
+ import{isObjectLike as e}from"../guards.js";import{BREAKPOINT_PX as t,TOUCH_MEDIA as n,breakpointRules as r,fluidLength as i,touchValue as a}from"../model/length.js";import{cssVarOfPath as o}from"../names.js";import{present as s}from"../present.js";var c={mode:`light`,platform:`web`,width:1440},l={mode:`dark`,platform:`web`,width:1440},u={mode:`light`,platform:`web`,width:390},d=/\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}/g,ee=/^\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}$/,te=/^#[0-9a-f]{6}$/i,f=[[`--bs-body-color`,`text`],[`--bs-emphasis-color`,`text`],[`--bs-secondary-color`,`text-muted`],[`--bs-tertiary-color`,`text-subtle`],[`--bs-heading-color`,`text`],[`--bs-body-bg`,`bg`],[`--bs-border-color`,`border`],[`--bs-secondary-bg`,`surface`],[`--bs-tertiary-bg`,`bg-muted`],[`--bs-primary`,`primary`]],p=[[`--bs-body-bg-rgb`,`bg`],[`--bs-primary-rgb`,`primary`],[`--bs-body-color-rgb`,`text`],[`--bs-emphasis-color-rgb`,`text`],[`--bs-secondary-color-rgb`,`text-muted`],[`--bs-tertiary-color-rgb`,`text-subtle`],[`--bs-secondary-bg-rgb`,`surface`],[`--bs-tertiary-bg-rgb`,`bg-muted`],[`--bs-border-color-rgb`,`border`]],ne=[[`--bs-secondary-rgb`,`text-muted`]],m=[[`$body-color`,`color.text-body`],[`$body-secondary-color`,`color.text-muted`],[`$body-tertiary-color`,`color.text-subtle`],[`$body-secondary-bg`,`color.bg-subtle`],[`$body-tertiary-bg`,`color.bg-muted`],[`$border-color`,`color.border`],[`$border-color-translucent`,null],[`$border-radius`,`radius.md`],[`$border-radius-sm`,`radius.sm`],[`$border-radius-lg`,`radius.lg`],[`$border-radius-pill`,`radius.pill`],[`$wui-shadow-overlay`,`shadow.popover`],[`$wui-shadow-overlay-lg`,`shadow.modal`],[`$link-color`,`color.link`],[`$line-height-base`,`leading.body`],[`$headings-line-height`,`leading.heading`],[`$display-line-height`,`leading.display`]],h=[[`$primary`,`color.primary`]],g={"$border-color-translucent":`rgba(13, 24, 43, 0.08)`},_=[`color.link`,`color.primary-hover`],re=`:root[data-theme="dark"],
2
+ :root[data-bs-theme="dark"]`,v=`[data-theme="dark"]:not(:root),
3
+ [data-bs-theme="dark"]:not(:root)`,ie=`:root[data-theme="auto"]`,y=`:root[data-theme="dark"] [data-theme="light"],
4
4
  :root[data-theme="dark"] [data-bs-theme="light"],
5
5
  :root[data-bs-theme="dark"] [data-theme="light"],
6
- :root[data-bs-theme="dark"] [data-bs-theme="light"]`,S=`:root[data-theme="auto"] [data-theme="light"],
7
- :root[data-theme="auto"] [data-bs-theme="light"]`,C=`[data-theme="dark"]:not(:root) [data-theme="light"],
6
+ :root[data-bs-theme="dark"] [data-bs-theme="light"]`,b=`:root[data-theme="auto"] [data-theme="light"],
7
+ :root[data-theme="auto"] [data-bs-theme="light"]`,x=`[data-theme="dark"]:not(:root) [data-theme="light"],
8
8
  [data-theme="dark"]:not(:root) [data-bs-theme="light"],
9
9
  [data-bs-theme="dark"]:not(:root) [data-theme="light"],
10
- [data-bs-theme="dark"]:not(:root) [data-bs-theme="light"]`,te=`// var() resolves where a name is declared, so the html copies keep the light values for a light box.`,w=`/* var() resolves where a name is declared, so the html copies keep the light values for a light box. */`,T=`// Zero specificity, so a component's own class on a themed section or inside it keeps its colour.`,E=`/* Zero specificity, so a component's own class on a themed section or inside it keeps its colour. */`,D=`// A light box under a dark page root takes literal light values: var() would resolve against the dark root.`,ne=`/* A light box under a dark page root takes literal light values: var() would resolve against the dark root. */`;function O(e){return String(Number(e.toFixed(4)))}function k(e,t){if(typeof t==`string`)return t.replace(l,(e,t)=>`var(${a(t)})`);if(typeof t==`number`)return O(t);if(Array.isArray(t)){if(e.type===`cubicBezier`&&t.length===4&&t.every(e=>typeof e==`number`))return`cubic-bezier(${t.map(e=>O(e)).join(`, `)})`;if(e.type===`fontFamily`&&t.every(e=>typeof e==`string`))return t.map(e=>/\s/.test(e)?`"${e}"`:e).join(`, `)}else if(t&&typeof t==`object`){if(`unit`in t&&typeof t.value==`number`)return`${O(t.value)}${t.unit}`;if(`color`in t)return[t.offsetX,t.offsetY,t.blur,t.spread,t.color].map(t=>k(e,t)).join(` `)}throw Error(`emitWeb: ${e.path}: cannot write a ${e.type} value as CSS.`)}function A(e,t,n){return k(e.tokens.get(t),e.valueIn(t,n))}function j(e,t){if(t&&typeof t==`object`&&t.unit===`px`&&typeof t.value==`number`)return t.value;throw Error(`emitWeb: ${e}: a text size must be a px dimension.`)}function M(e,t){let i=e.tokens.get(t),s=a(t);if(i.group===`text`){if(n(i).length>0)throw Error(`emitWeb: ${t}: a text size cannot carry breakpoints.`);let a=j(t,e.valueIn(t,c)),l=j(t,e.valueIn(t,o)),u=i.extensions?.fluidUntil;if(a!==l&&u===void 0)throw Error(`emitWeb: ${t}: the 390 and 1440 sizes differ but no fluidUntil is recorded.`);return{path:t,name:s,root:r(a,l,u??1440),tiers:[]}}let l=n(i);return l.length>0?{path:t,name:s,root:A(e,t,c),tiers:l.map(e=>({tier:e.tier,text:k(i,e.value)}))}:{path:t,name:s,root:A(e,t,o),tiers:[]}}function N(e){let t=[];for(let n of e.tokens.keys())e.existsIn(n,o)&&t.push(M(e,n));return t}function re(e,t){let r=[];for(let[i,c]of e.tokens){if(!e.existsIn(i,s)||!e.existsIn(i,o)||n(c).length>0)continue;let l=A(e,i,s);if(c.group===`text`){if(l!==A(e,i,o))throw Error(`emitWeb: ${i}: a text size cannot change with the mode.`)}else t(i,l)&&r.push({path:i,name:a(i),text:l,light:A(e,i,o)})}return r}function P(e){let t=Number.parseInt(e.slice(1),16);return`${t>>16&255}, ${t>>8&255}, ${t&255}`}function F(e,t){let n=[],r=(r,i)=>{for(let[a,c]of r){let r=`color.${c}`,l=e.resolvedIn(r,s);if(!d.test(l))throw Error(`emitWeb: ${r}: a Bootstrap rgb triplet needs an opaque colour.`);if(t(r,l)){let t=i?P(V(e,r,o)):null;n.push({name:a,text:P(l),light:t})}}};return r(p,!0),r(m,!1),n}function I(e,t,n){return!e.tokens.has(`color.primary`)||!t.tokens.has(`color.primary`)||e.resolvedIn(`color.primary`,n)===t.resolvedIn(`color.primary`,n)?[]:L(e,n)}function L(e,t){let n=V(e,`color.primary`,t);return[{name:`--bs-primary`,text:n},{name:`--bs-primary-rgb`,text:P(n)}]}function R(e,t,n){return!_.every(n=>e.tokens.has(n)&&t.tokens.has(n))||e.resolvedIn(`color.link`,n)===t.resolvedIn(`color.link`,n)?[]:z(e,n)}function z(e,t){let n=V(e,`color.link`,t),r=V(e,`color.primary-hover`,t);return[{name:`--bs-link-color`,text:n},{name:`--bs-link-color-rgb`,text:P(n)},{name:`--bs-link-hover-color`,text:r},{name:`--bs-link-hover-color-rgb`,text:P(r)}]}function B(e){return _.every(t=>e.tokens.has(t))?[{name:`--bs-link-color`,text:`var(--color-link)`,light:`var(--color-link)`},{name:`--bs-link-color-rgb`,text:P(V(e,`color.link`,s)),light:P(V(e,`color.link`,o))},{name:`--bs-link-hover-color`,text:`var(--color-primary-hover)`,light:`var(--color-primary-hover)`},{name:`--bs-link-hover-color-rgb`,text:P(V(e,`color.primary-hover`,s)),light:P(V(e,`color.primary-hover`,o))}]:[]}function V(e,t,n){let r=e.resolvedIn(t,n);if(!d.test(r))throw Error(`emitWeb: ${t}: a Bootstrap rgb triplet needs an opaque colour.`);return r}function H(e,t){let n=re(e,t?(e,n)=>!t.tokens.has(e)||!t.existsIn(e,s)||n!==A(t,e,s):(t,n)=>n!==A(e,t,o)),r=F(e,t?(e,n)=>n!==t.resolvedIn(e,s):()=>!0);if(t){let i=R(e,t,o).length>0?z(e,s):R(e,t,s);return[...n,...r,...i]}let i=f.map(([e,t])=>{let n=`var(${a(`color.${t}`)})`;return{name:e,text:n,light:n}});return[...n,...i,...r,...B(e)]}function U(e,t,n){return e.tokens.has(n)&&t.tokens.has(n)&&e.resolvedIn(n,o)!==t.resolvedIn(n,o)}function W(e,t){let n=f.filter(([n,r])=>n!==`--bs-primary`&&U(e,t,`color.${r}`)).map(([e,t])=>({name:e,text:`var(${a(`color.${t}`)})`})),r=p.filter(([n,r])=>n!==`--bs-primary-rgb`&&U(e,t,`color.${r}`)).map(([t,n])=>({name:t,text:P(V(e,`color.${n}`,o))}));return[...n,...r]}function G(e,t){return`${e} {\n${t.join(`
10
+ [data-bs-theme="dark"]:not(:root) [data-bs-theme="light"]`,S=`// var() resolves where a name is declared, so the html copies keep the light values for a light box.`,C=`/* var() resolves where a name is declared, so the html copies keep the light values for a light box. */`,w=`// Zero specificity, so a component's own class on a themed section or inside it keeps its colour.`,T=`/* Zero specificity, so a component's own class on a themed section or inside it keeps its colour. */`,E=`// A light box under a dark page root takes literal light values: var() would resolve against the dark root.`,D=`/* A light box under a dark page root takes literal light values: var() would resolve against the dark root. */`;function O(e){return String(Number(e.toFixed(4)))}function k(e,t){return s(e.tokens.get(t),`token ${t}`)}function ae(e){if(e==null)return 1440;if(typeof e==`number`)return e;throw Error(`emitWeb: fluidUntil must be a number`)}function A(t,n){if(typeof n==`string`)return n.replace(d,(e,t)=>`var(${o(t)})`);if(typeof n==`number`)return O(n);if(Array.isArray(n)){if(t.type===`cubicBezier`&&n.length===4&&n.every(e=>typeof e==`number`))return`cubic-bezier(${n.map(e=>O(e)).join(`, `)})`;if(t.type===`fontFamily`&&n.every(e=>typeof e==`string`))return n.map(e=>/\s/.test(e)?`"${e}"`:e).join(`, `)}else if(e(n)){if(`unit`in n&&typeof n.value==`number`)return`${O(n.value)}${String(n.unit)}`;if(`color`in n)return[n.offsetX,n.offsetY,n.blur,n.spread,n.color].map(e=>A(t,e)).join(` `)}throw Error(`emitWeb: ${t.path}: cannot write a ${t.type} value as CSS.`)}function j(e,t,n){return A(k(e,t),e.valueIn(t,n))}function M(t,n){if(e(n)&&n.unit===`px`&&typeof n.value==`number`)return n.value;throw Error(`emitWeb: ${t}: a text size must be a px dimension.`)}function N(e,t){let n=k(e,t),a=o(t);if(n.group===`text`){if(r(n).length>0)throw Error(`emitWeb: ${t}: a text size cannot carry breakpoints.`);let o=M(t,e.valueIn(t,u)),s=M(t,e.valueIn(t,c)),l=n.extensions?.fluidUntil;if(o!==s&&l===void 0)throw Error(`emitWeb: ${t}: the 390 and 1440 sizes differ but no fluidUntil is recorded.`);return{path:t,name:a,root:i(o,s,ae(l)),tiers:[]}}let s=r(n);return s.length>0?{path:t,name:a,root:j(e,t,u),tiers:s.map(e=>({tier:e.tier,text:A(n,e.value)}))}:{path:t,name:a,root:j(e,t,c),tiers:[]}}function P(e){let t=[];for(let n of e.tokens.keys())e.existsIn(n,c)&&t.push(N(e,n));return t}function F(e,t){let n=[];for(let[i,a]of e.tokens){if(!e.existsIn(i,l)||!e.existsIn(i,c)||r(a).length>0)continue;let s=j(e,i,l);if(a.group===`text`){if(s!==j(e,i,c))throw Error(`emitWeb: ${i}: a text size cannot change with the mode.`)}else t(i,s)&&n.push({path:i,name:o(i),text:s,light:j(e,i,c)})}return n}function I(e){let t=Number.parseInt(e.slice(1),16);return`${t>>16&255}, ${t>>8&255}, ${t&255}`}function L(e,t){let n=[],r=(r,i)=>{for(let[a,o]of r){let r=`color.${o}`,s=U(e,r,l);if(t(r,s)){let t=i?I(U(e,r,c)):null;n.push({name:a,text:I(s),light:t})}}};return r(p,!0),r(ne,!1),n}function R(e,t,n){return!e.tokens.has(`color.primary`)||!t.tokens.has(`color.primary`)||e.resolvedIn(`color.primary`,n)===t.resolvedIn(`color.primary`,n)?[]:z(e,n)}function z(e,t){let n=U(e,`color.primary`,t);return[{name:`--bs-primary`,text:n},{name:`--bs-primary-rgb`,text:I(n)}]}function B(e,t,n){return!_.every(n=>e.tokens.has(n)&&t.tokens.has(n))||e.resolvedIn(`color.link`,n)===t.resolvedIn(`color.link`,n)?[]:V(e,n)}function V(e,t){let n=U(e,`color.link`,t),r=U(e,`color.primary-hover`,t);return[{name:`--bs-link-color`,text:n},{name:`--bs-link-color-rgb`,text:I(n)},{name:`--bs-link-hover-color`,text:r},{name:`--bs-link-hover-color-rgb`,text:I(r)}]}function H(e){return _.every(t=>e.tokens.has(t))?[{name:`--bs-link-color`,text:`var(--color-link)`,light:`var(--color-link)`},{name:`--bs-link-color-rgb`,text:I(U(e,`color.link`,l)),light:I(U(e,`color.link`,c))},{name:`--bs-link-hover-color`,text:`var(--color-primary-hover)`,light:`var(--color-primary-hover)`},{name:`--bs-link-hover-color-rgb`,text:I(U(e,`color.primary-hover`,l)),light:I(U(e,`color.primary-hover`,c))}]:[]}function U(e,t,n){let r=e.resolvedIn(t,n);if(typeof r!=`string`||!te.test(r))throw Error(`emitWeb: ${t}: a Bootstrap rgb triplet needs an opaque colour.`);return r}function W(e,t){let n=F(e,t?(e,n)=>!t.tokens.has(e)||!t.existsIn(e,l)||n!==j(t,e,l):(t,n)=>n!==j(e,t,c)),r=L(e,t?(e,n)=>n!==t.resolvedIn(e,l):()=>!0);if(t){let i=B(e,t,c).length>0?V(e,l):B(e,t,l);return[...n,...r,...i]}let i=f.map(([e,t])=>{let n=`var(${o(`color.${t}`)})`;return{name:e,text:n,light:n}});return[...n,...i,...r,...H(e)]}function G(e,t,n){return e.tokens.has(n)&&t.tokens.has(n)&&e.resolvedIn(n,c)!==t.resolvedIn(n,c)}function K(e,t){let n=f.filter(([n,r])=>n!==`--bs-primary`&&G(e,t,`color.${r}`)).map(([e,t])=>({name:e,text:`var(${o(`color.${t}`)})`})),r=p.filter(([n,r])=>n!==`--bs-primary-rgb`&&G(e,t,`color.${r}`)).map(([t,n])=>({name:t,text:I(U(e,`color.${n}`,c))}));return[...n,...r]}function q(e,t){return`${e} {\n${t.join(`
11
11
  `).split(`
12
12
  `).map(e=>e===``?e:` ${e}`).join(`
13
- `)}\n}`}function K(e){return e.split(`,
13
+ `)}\n}`}function J(e){return e.split(`,
14
14
  `).map(e=>`:where(${e})`).join(`,
15
- `)}function q(e,t){let n=H(e,null).filter(e=>e.light!=null);if(!t)return n;let r=new Map(H(t,null).filter(e=>e.light!=null).map(e=>[e.name,e.light]));return n.filter(e=>r.get(e.name)!==e.light)}function J(e,t){if(e.length===0)return[];let n=e.map(e=>`${e.name}: ${e.light};`);return[t?ne:D,G(x,n),G(K(x),[`color-scheme: light;`,`color: var(--color-text);`]),G(`@media (prefers-color-scheme: dark)`,[G(S,n),G(K(S),[`color-scheme: light;`,`color: var(--color-text);`])])]}function Y(e){let t=[];for(let n=0;n<e.length;n+=6)t.push(e.slice(n,n+6).join(`, `));return[`$wui-dark-layer-names: (\n${t.map((e,n)=>` ${e}${n<t.length-1?`,`:``}`).join(`
16
- `)}\n);`,te,G(`html`,[`@each $name in $wui-dark-layer-names {`,` --wui-light-#{$name}: var(--#{$name});`,`}`]),G(C,[`@each $name in $wui-dark-layer-names {`,` --#{$name}: var(--wui-light-#{$name});`,`}`]),G(K(C),[`color-scheme: light;`,`color: var(--color-text);`])].join(`
15
+ `)}function oe(e,t){let n=W(e,null).filter(e=>e.light!=null);if(!t)return n;let r=new Map(W(t,null).filter(e=>e.light!=null).map(e=>[e.name,e.light]));return n.filter(e=>r.get(e.name)!==e.light)}function se(e,t){if(e.length===0)return[];let n=e.map(e=>`${e.name}: ${String(e.light)};`);return[t?D:E,q(y,n),q(J(y),[`color-scheme: light;`,`color: var(--color-text);`]),q(`@media (prefers-color-scheme: dark)`,[q(b,n),q(J(b),[`color-scheme: light;`,`color: var(--color-text);`])])]}function ce(e){let t=[];for(let n=0;n<e.length;n+=6)t.push(e.slice(n,n+6).join(`, `));return[`$wui-dark-layer-names: (\n${t.map((e,n)=>` ${e}${n<t.length-1?`,`:``}`).join(`
16
+ `)}\n);`,S,q(`html`,[`@each $name in $wui-dark-layer-names {`,` --wui-light-#{$name}: var(--#{$name});`,`}`]),q(x,[`@each $name in $wui-dark-layer-names {`,` --#{$name}: var(--wui-light-#{$name});`,`}`]),q(J(x),[`color-scheme: light;`,`color: var(--color-text);`])].join(`
17
17
 
18
- `)}function ie(e){return[w,G(`html`,e.map(e=>`--wui-light-${e}: var(--${e});`)),G(C,e.map(e=>`--${e}: var(--wui-light-${e});`)),G(K(C),[`color-scheme: light;`,`color: var(--color-text);`])].join(`
18
+ `)}function le(e){return[C,q(`html`,e.map(e=>`--wui-light-${e}: var(--${e});`)),q(x,e.map(e=>`--${e}: var(--wui-light-${e});`)),q(J(x),[`color-scheme: light;`,`color: var(--color-text);`])].join(`
19
19
 
20
- `)}function X(e,t,n=!1){let{package:r,version:i,brand:a}=e.source,o=t?`Generated by ${r} ${i} for the ${a} brand. Do not edit; run webority brand.`:`Generated by ${r} ${i} from its token source. Do not edit; run webority brand --library.`;return n?`/* ${o} */`:`// ${o}`}function Z(n,r){let a=N(n),s=new Map((r?N(r):[]).map(e=>[e.path,e])),c=[],l=a.filter(e=>s.get(e.path)?.root!==e.root).map(e=>`${e.name}: ${e.root};`);r&&(l.push(...I(n,r,o).map(e=>`${e.name}: ${e.text};`)),l.push(...R(n,r,o).map(e=>`${e.name}: ${e.text};`)),l.push(...W(n,r).map(e=>`${e.name}: ${e.text};`))),l.length>0&&c.push(G(`:root`,l));for(let[t,n]of Object.entries(e)){let e=[];for(let n of a)for(let r of n.tiers)r.tier===t&&s.get(n.path)?.tiers.find(e=>e.tier===t)?.text!==r.text&&e.push(`${n.name}: ${r.text};`);e.length>0&&c.push(G(`@media (min-width: ${n}px)`,[G(`:root`,e)]))}let u=[];for(let e of a){let t=n.tokens.get(e.path),a=i(t);if(a===null)continue;let o=k(t,a),s=r?.tokens.get(e.path),c=s?i(s):null;(c===null||k(s,c)!==o)&&u.push(`${e.name}: ${o};`)}u.length>0&&c.push(G(`@media ${t}`,[G(`:root`,u)]));let d=H(n,r);if(d.length>0){let e=d.map(e=>`${e.name}: ${e.text};`),t=r?E:T;c.push(G(v,[...e,`color-scheme: dark;`]),G(y,e),`${t}\n${G(K(y),[`color-scheme: dark;`,`color: var(--color-text);`])}`);let i=d.map(e=>e.name.slice(2));if(r){let e=new Set(H(r,null).map(e=>e.name.slice(2))),t=i.filter(t=>!e.has(t));t.length>0&&c.push(ie(t))}else c.push(Y(i));c.push(G(`@media (prefers-color-scheme: dark)`,[G(b,[...e,`color-scheme: dark;`])])),c.push(...J(q(n,r),r!==null))}return`${[X(n,r!==null,r!==null),...c].join(`
20
+ `)}function Y(e,t,n=!1){let{package:r,version:i,brand:a}=e.source,o=t?`Generated by ${r} ${i} for the ${a} brand. Do not edit; run webority brand.`:`Generated by ${r} ${i} from its token source. Do not edit; run webority brand --library.`;return n?`/* ${o} */`:`// ${o}`}function X(e,r){let i=P(e),o=new Map((r?P(r):[]).map(e=>[e.path,e])),s=[],l=i.filter(e=>o.get(e.path)?.root!==e.root).map(e=>`${e.name}: ${e.root};`);r&&(l.push(...R(e,r,c).map(e=>`${e.name}: ${e.text};`)),l.push(...B(e,r,c).map(e=>`${e.name}: ${e.text};`)),l.push(...K(e,r).map(e=>`${e.name}: ${e.text};`))),l.length>0&&s.push(q(`:root`,l));for(let[e,n]of Object.entries(t)){let t=[];for(let n of i)for(let r of n.tiers)r.tier===e&&o.get(n.path)?.tiers.find(t=>t.tier===e)?.text!==r.text&&t.push(`${n.name}: ${r.text};`);t.length>0&&s.push(q(`@media (min-width: ${n}px)`,[q(`:root`,t)]))}let u=[];for(let t of i){let n=k(e,t.path),i=a(n);if(i===null)continue;let o=A(n,i),s=r?.tokens.get(t.path),c=s?a(s):null;s&&c!==null&&A(s,c)===o||u.push(`${t.name}: ${o};`)}u.length>0&&s.push(q(`@media ${n}`,[q(`:root`,u)]));let d=W(e,r);if(d.length>0){let t=d.map(e=>`${e.name}: ${e.text};`),n=r?T:w;s.push(q(re,[...t,`color-scheme: dark;`]),q(v,t),`${n}\n${q(J(v),[`color-scheme: dark;`,`color: var(--color-text);`])}`);let i=d.map(e=>e.name.slice(2));if(r){let e=new Set(W(r,null).map(e=>e.name.slice(2))),t=i.filter(t=>!e.has(t));t.length>0&&s.push(le(t))}else s.push(ce(i));s.push(q(`@media (prefers-color-scheme: dark)`,[q(ie,[...t,`color-scheme: dark;`])])),s.push(...se(oe(e,r),r!==null))}return`${[Y(e,r!==null,r!==null),...s].join(`
21
21
 
22
- `)}\n`}function Q(e,t){let n=e.tokens.get(t);if(n.type===`color`)return e.resolvedIn(t,o);let r=e.valueIn(t,o),i=typeof r==`string`?u.exec(r):null;if(i)return Q(e,i[1]);let a=k(n,r);if(a.includes(`var(`))throw Error(`emitWeb: ${t}: a Bootstrap variable needs a literal.`);return a}function $(e,t,n){return n===null?g[t]:Q(e,n)}function ae(e){let t=h.map(([t,n])=>`${t}: ${$(e,t,n)} !default;`);return`${[X(e,!1),...t].join(`
23
- `)}\n`}function oe(e,t){let n=[...ee,...h].filter(([n,r])=>$(e,n,r)!==$(t,n,r)).map(([t,n])=>`${t}: ${$(e,t,n)};`);return`${[X(e,!0),...n].join(`
24
- `)}\n`}function se(e,t){return t===void 0?{tokens:Z(e,null),bootstrap:ae(e)}:{css:Z(e,t.library),variables:oe(e,t.library)}}export{se as emitWeb};
22
+ `)}\n`}function Z(e,t){let n=k(e,t);if(n.type===`color`)return String(e.resolvedIn(t,c));let r=e.valueIn(t,c),i=(typeof r==`string`?ee.exec(r):null)?.[1];if(i!==void 0)return Z(e,i);let a=A(n,r);if(a.includes(`var(`))throw Error(`emitWeb: ${t}: a Bootstrap variable needs a literal.`);return a}function Q(e,t,n){return n===null?g[t]:Z(e,n)}function $(e){let t=m.map(([t,n])=>`${t}: ${String(Q(e,t,n))} !default;`);return`${[Y(e,!1),...t].join(`
23
+ `)}\n`}function ue(e,t){let n=[...h,...m].filter(([n,r])=>Q(e,n,r)!==Q(t,n,r)).map(([t,n])=>`${t}: ${String(Q(e,t,n))};`);return`${[Y(e,!0),...n].join(`
24
+ `)}\n`}function de(e,t){return t===void 0?{tokens:X(e,null),bootstrap:$(e)}:{css:X(e,t.library),variables:ue(e,t.library)}}export{de as emitWeb};
@@ -0,0 +1,3 @@
1
+ export declare function messageOf(error: unknown): string;
2
+ export declare function isObjectLike(value: unknown): value is Record<string, unknown>;
3
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
package/dist/guards.js ADDED
@@ -0,0 +1 @@
1
+ function e(e){return e instanceof Error?e.message:String(e)}function t(e){return typeof e==`object`&&!!e}function n(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}export{t as isObjectLike,n as isRecord,e as messageOf};
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export type { RenameTable, RetiredThemeRead } from "../renames/renames";
2
- export type { BrandLayer, Deviations, LibrarySources } from "./brand";
3
- export { BRAND_OUTPUT_FILES, HEAD_FOLDER, loadBrand } from "./brand";
4
- export type * from "./cli";
5
- export { brand, check, run, upgrade } from "./cli";
6
- export type * from "./outputs";
7
- export { cssVar } from "./outputs";
1
+ export type { RenameTable, RetiredThemeRead } from "../renames/renames.d.ts";
2
+ export type { BrandLayer, Deviations, LibrarySources } from "./brand.ts";
3
+ export { BRAND_OUTPUT_FILES, HEAD_FOLDER, loadBrand } from "./brand.ts";
4
+ export type * from "./cli.ts";
5
+ export { brand, check, run, upgrade } from "./cli.ts";
6
+ export { cssVar } from "./names.ts";
7
+ export type * from "./outputs.ts";
@@ -2,7 +2,7 @@
2
2
  "format": "webority-meanings/1",
3
3
  "source": {
4
4
  "package": "@webority/tokens",
5
- "version": "0.149.0"
5
+ "version": "0.152.0"
6
6
  },
7
7
  "color": {
8
8
  "bg": {
@@ -959,6 +959,102 @@
959
959
  "platforms": [
960
960
  "phone"
961
961
  ]
962
+ },
963
+ "shell-bg": {
964
+ "description": "Dark navigation shell background, the sidebar behind the nav items and the workspace switcher.",
965
+ "platforms": [
966
+ "web"
967
+ ]
968
+ },
969
+ "shell-bg-deep": {
970
+ "description": "Deepest shell tone, the ink on an accent mark or an avatar in the shell.",
971
+ "platforms": [
972
+ "web"
973
+ ]
974
+ },
975
+ "shell-bg-raised": {
976
+ "description": "Raised shell band, the fill of the active page row inside an open group.",
977
+ "platforms": [
978
+ "web"
979
+ ]
980
+ },
981
+ "shell-text": {
982
+ "description": "Body text and nav item labels on the dark shell.",
983
+ "platforms": [
984
+ "web"
985
+ ]
986
+ },
987
+ "shell-text-strong": {
988
+ "description": "Emphasis text on the dark shell: the brand name, hovered and open rows, the switcher label.",
989
+ "platforms": [
990
+ "web"
991
+ ]
992
+ },
993
+ "shell-text-muted": {
994
+ "description": "Quiet text on the dark shell: group labels, nav icons, carets and the sidebar toggle.",
995
+ "platforms": [
996
+ "web"
997
+ ]
998
+ },
999
+ "shell-accent": {
1000
+ "description": "Warm accent on the dark shell that marks where the user is: the active icon, the open group's guide line, the focus outline and the avatar.",
1001
+ "platforms": [
1002
+ "web"
1003
+ ]
1004
+ },
1005
+ "shell-accent-ring": {
1006
+ "description": "Translucent accent halo on the dark shell, for a selection or focus ring.",
1007
+ "platforms": [
1008
+ "web"
1009
+ ]
1010
+ },
1011
+ "shell-hover": {
1012
+ "description": "Hover fill for a nav row or the sidebar toggle on the dark shell.",
1013
+ "platforms": [
1014
+ "web"
1015
+ ]
1016
+ },
1017
+ "shell-active": {
1018
+ "description": "Fill of the active nav row on the dark shell.",
1019
+ "platforms": [
1020
+ "web"
1021
+ ]
1022
+ },
1023
+ "shell-rule": {
1024
+ "description": "Hairline divider between shell groups and under the shell brand.",
1025
+ "platforms": [
1026
+ "web"
1027
+ ]
1028
+ },
1029
+ "shell-fill-subtle": {
1030
+ "description": "Faint translucent fill on the dark shell, for the open group band and the workspace switcher pill.",
1031
+ "platforms": [
1032
+ "web"
1033
+ ]
1034
+ },
1035
+ "shell-fill": {
1036
+ "description": "Translucent fill for a badge and a focused or open switcher on the dark shell.",
1037
+ "platforms": [
1038
+ "web"
1039
+ ]
1040
+ },
1041
+ "shell-fill-strong": {
1042
+ "description": "Strongest translucent fill on the dark shell, for a control that is held.",
1043
+ "platforms": [
1044
+ "web"
1045
+ ]
1046
+ },
1047
+ "shell-border": {
1048
+ "description": "Border of a control on the dark shell, shown on hover.",
1049
+ "platforms": [
1050
+ "web"
1051
+ ]
1052
+ },
1053
+ "shell-border-strong": {
1054
+ "description": "Border of a focused or open control on the dark shell.",
1055
+ "platforms": [
1056
+ "web"
1057
+ ]
962
1058
  }
963
1059
  }
964
1060
  }
@@ -0,0 +1,8 @@
1
+ type Lookup = (name: string) => string | undefined;
2
+ /**
3
+ * @param value
4
+ * @param lookup returns the raw value of a custom property name such as "--wui-blue-500", or undefined
5
+ * @returns #rrggbb, or #rrggbbaa when the alpha is below 1
6
+ */
7
+ export declare function resolveColour(value: string, lookup: Lookup): string;
8
+ export {};
@@ -1 +1 @@
1
- function e(e,t){let n=[],r=0,i=null,a=0;for(let o=0;o<e.length;o++){let s=e[o];i?s===`\\`?o++:s===i&&(i=null):s===`"`||s===`'`?i=s:s===`(`||s===`[`?r++:s===`)`||s===`]`?r--:s===t&&r===0&&(n.push(e.slice(a,o)),a=o+1)}return n.push(e.slice(a)),n}var t=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,n=/^rgba?\(([\s\S]*)\)$/i,r=/^color-mix\(([\s\S]*)\)$/i,i=/^var\(([\s\S]*)\)$/i;function a(s,c,u=0){if(u>10)return null;let d=s.trim(),f=i.exec(d);if(f){let t=e(f[1],`,`),n=t[0].trim();if(!/^--[a-z0-9-]+$/i.test(n))return null;let r=c(n);if(r!==void 0)return a(r,c,u+1);let i=t.slice(1).join(`,`).trim();return i?a(i,c,u+1):null}let p=t.exec(d);if(p){let e=p[1];e.length<=4&&(e=[...e].map(e=>e+e).join(``)),e.length===6&&(e+=`ff`);let t=t=>Number.parseInt(e.slice(t,t+2),16);return[t(0),t(2),t(4),t(6)/255]}let m=n.exec(d);if(m)return o(m[1]);let h=r.exec(d);if(h)return l(h[1],c,u);let g=d.toLowerCase();return g===`white`?[255,255,255,1]:g===`black`?[0,0,0,1]:g===`transparent`?[0,0,0,0]:null}function o(t){let n=t.trim(),r,i=e(n,`/`);if(i.length>2)return null;i.length===2&&(n=i[0].trim(),r=i[1].trim());let a=e(n,`,`).flatMap(e=>e.trim().split(/\s+/)).filter(Boolean);if(a.length!==3&&a.length!==4)return null;let o=a.slice(0,3).map(e=>/^-?\d*\.?\d+$/.test(e)?Math.min(255,Math.max(0,Number(e))):null);if(o.some(e=>e===null))return null;if(a.length===4){if(r!==void 0)return null;r=a[3]}let c=r===void 0?1:s(r);return c===null?null:[...o,c]}function s(e){let t=e.trim(),n=/^(-?\d*\.?\d+)%$/.exec(t);return n?Math.min(1,Math.max(0,Number(n[1])/100)):/^-?\d*\.?\d+$/.test(t)?Math.min(1,Math.max(0,Number(t))):null}function c(e){let t=e.trim(),n=/\s+(-?\d*\.?\d+)%$/.exec(t);if(!n)return{colour:t};let r=t.slice(0,n.index).trim();return r?{colour:r,percent:Number(n[1])}:null}function l(t,n,r){let i=e(t,`,`);if(i.length!==3||!/^in\s+srgb$/i.test(i[0].trim()))return null;let o=c(i[1]),s=c(i[2]);if(!o||!s)return null;let l=a(o.colour,n,r+1),u=a(s.colour,n,r+1);if(!l||!u)return null;let d=o.percent,f=s.percent,p=1;if(d===void 0&&f===void 0)d=50,f=50;else if(f===void 0)f=100-d;else if(d===void 0)d=100-f;else if(d+f!==100){let e=d+f;e>0?(e<100&&(p=e/100),d=d*100/e,f=f*100/e):(d=0,f=0)}let m=d/100,h=f/100,g=l[3]*m+u[3]*h;return[...[0,1,2].map(e=>g===0?0:(l[e]*l[3]*m+u[e]*u[3]*h)/g),g*p]}function u(e){let t=e.slice(0,3).map(e=>Math.round(Math.min(255,Math.max(0,e))).toString(16).padStart(2,`0`)).join(``),n=Math.round(Math.min(1,Math.max(0,e[3]))*255);return`#${t}${n<255?n.toString(16).padStart(2,`0`):``}`}function d(e,t){let n=a(e,t,0);if(n===null)throw Error(`colour "${e}" does not resolve to a colour.`);return u(n)}export{d as resolveColour};
1
+ import{present as e}from"../present.js";function t(e,t){let n=[],r=0,i=null,a=0;for(let o=0;o<e.length;o++){let s=e[o];i?s===`\\`?o++:s===i&&(i=null):s===`"`||s===`'`?i=s:s===`(`||s===`[`?r++:s===`)`||s===`]`?r--:s===t&&r===0&&(n.push(e.slice(a,o)),a=o+1)}return n.push(e.slice(a)),n}var n=10,r=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,i=/^rgba?\(([\s\S]*)\)$/i,a=/^color-mix\(([\s\S]*)\)$/i,o=/^var\(([\s\S]*)\)$/i;function s(l,u,f=0){if(f>n)return null;let p=l.trim(),m=o.exec(p);if(m){let n=t(e(m[1],`the var() arguments`),`,`),r=e(n[0],`the var() name`).trim();if(!/^--[a-z0-9-]+$/i.test(r))return null;let i=u(r);if(i!==void 0)return s(i,u,f+1);let a=n.slice(1).join(`,`).trim();return a?s(a,u,f+1):null}let h=r.exec(p);if(h){let t=e(h[1],`the hex colour digits`);t.length<=4&&(t=[...t].map(e=>e+e).join(``)),t.length===6&&(t+=`ff`);let n=e=>Number.parseInt(t.slice(e,e+2),16);return[n(0),n(2),n(4),n(6)/255]}let g=i.exec(p);if(g)return c(e(g[1],`the rgb() arguments`));let _=a.exec(p);if(_)return d(e(_[1],`the color-mix() arguments`),u,f);let v=p.toLowerCase();return v===`white`?[255,255,255,1]:v===`black`?[0,0,0,1]:v===`transparent`?[0,0,0,0]:null}function c(n){let r=n.trim(),i,a=t(r,`/`);if(a.length>2)return null;a.length===2&&(r=e(a[0],`the colour before the alpha slash`).trim(),i=e(a[1],`the alpha after the slash`).trim());let o=t(r,`,`).flatMap(e=>e.trim().split(/\s+/)).filter(Boolean);if(o.length!==3&&o.length!==4)return null;let s=o.slice(0,3).map(e=>/^-?\d*\.?\d+$/.test(e)?Math.min(255,Math.max(0,Number(e))):null).filter(e=>e!==null);if(s.length!==3)return null;if(o.length===4){if(i!==void 0)return null;i=e(o[3],`the alpha channel`)}let c=i===void 0?1:l(i);return c===null?null:[e(s[0],`the red channel`),e(s[1],`the green channel`),e(s[2],`the blue channel`),c]}function l(e){let t=e.trim(),n=/^(-?\d*\.?\d+)%$/.exec(t);return n?Math.min(1,Math.max(0,Number(n[1])/100)):/^-?\d*\.?\d+$/.test(t)?Math.min(1,Math.max(0,Number(t))):null}function u(t){let n=t.trim(),r=/\s+(-?\d*\.?\d+)%$/.exec(n);if(!r)return{colour:n};let i=n.slice(0,r.index).trim();return i?{colour:i,percent:Number(e(r[1],`the mix percentage`))}:null}function d(n,r,i){let a=t(n,`,`);if(a.length!==3||!/^in\s+srgb$/i.test(e(a[0],`the colour-space argument`).trim()))return null;let o=u(e(a[1],`the first mix argument`)),c=u(e(a[2],`the second mix argument`));if(!o||!c)return null;let l=s(o.colour,r,i+1),d=s(c.colour,r,i+1);if(!l||!d)return null;let f=o.percent,p=c.percent,m,h,g=1;if(f===void 0&&p===void 0)m=50,h=50;else if(p===void 0)m=f??0,h=100-m;else if(f===void 0)h=p,m=100-h;else if(m=f,h=p,m+h!==100){let e=m+h;e>0?(e<100&&(g=e/100),m=m*100/e,h=h*100/e):(m=0,h=0)}let _=m/100,v=h/100,y=l[3]*_+d[3]*v,b=e=>y===0?0:(l[e]*l[3]*_+d[e]*d[3]*v)/y;return[b(0),b(1),b(2),y*g]}function f(e){let t=e.slice(0,3).map(e=>Math.round(Math.min(255,Math.max(0,e))).toString(16).padStart(2,`0`)).join(``),n=Math.round(Math.min(1,Math.max(0,e[3]))*255);return`#${t}${n<255?n.toString(16).padStart(2,`0`):``}`}function p(e,t){let n=s(e,t,0);if(n===null)throw Error(`colour "${e}" does not resolve to a colour.`);return f(n)}export{p as resolveColour};
@@ -0,0 +1,26 @@
1
+ import type { JsonObject } from "../brand.ts";
2
+ import type { Model } from "./index.ts";
3
+ /** Margin over WCAG AA 4.5:1, so rounding to a hex never lands under it; equal to mobile-ui's TARGET. */
4
+ export declare const READABLE_TARGET: number;
5
+ /**
6
+ * @param a opaque #rrggbb
7
+ * @param b opaque #rrggbb
8
+ */
9
+ export declare function contrastRatio(a: string, b: string): number;
10
+ /**
11
+ * The fill as a solid under its label at READABLE_TARGET: unchanged when the pair reads or either value is not #rrggbb;
12
+ * otherwise its HSL lightness moves away from the label in 0.0025 steps, hue and saturation kept.
13
+ * @returns lowercase #rrggbb, or fill as given when it is not #rrggbb
14
+ */
15
+ export declare function deriveSolidFill(fill: string, on: string): string;
16
+ /**
17
+ * The phone-only brand layer that makes each mode's primary fill read under its label. A mode whose fill and label
18
+ * equal the library's, or whose pair already reads, gets nothing.
19
+ * @param model the branded model
20
+ * @param library the library model
21
+ * @returns DTCG trees, each {} or { color: { primary: { $type: "color", $value } } }
22
+ */
23
+ export declare function phonePairLayer(model: Model, library: Model): {
24
+ light: JsonObject;
25
+ dark: JsonObject;
26
+ };
@@ -1 +1 @@
1
- var e=4.55,t=/^#[0-9a-f]{6}$/i,n=.0025,r=e=>{let t=Number.parseInt(e.slice(1,7),16);return[t>>16&255,t>>8&255,t&255]},i=e=>{let[t,n,i]=r(e).map(e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*i},a=e=>{let[t,n,i]=r(e).map(e=>e/255),a=Math.max(t,n,i),o=Math.min(t,n,i),s=a-o,c=(a+o)/2;if(s===0)return[0,0,c];let l=c>.5?s/(2-a-o):s/(a+o);return[(a===t?((n-i)/s+6)%6:a===n?(i-t)/s+2:(t-n)/s+4)*60,l,c]},o=([e,t,n])=>{let r=t*Math.min(n,1-n),i=t=>{let i=(t+e/30)%12,a=n-r*Math.max(-1,Math.min(i-3,9-i,1));return Math.round(a*255).toString(16).padStart(2,`0`)};return`#${i(0)}${i(8)}${i(4)}`.toUpperCase()},s=(e,t,r)=>{let[i,s,c]=a(e),l=e;for(let e=c+t*n;e>=0&&e<=1;e+=t*n)if(l=o([i,s,e]),r(l))return l;return l};function c(e,t){let[n,r]=[i(e),i(t)].sort((e,t)=>t-e);return(n+.05)/(r+.05)}function l(n,r){if(!t.test(n)||!t.test(r))return n;let a=t=>c(t,r)>=e;return a(n)?n.toLowerCase():s(n,i(r)>i(n)?-1:1,a).toLowerCase()}function u(e,t){let n={};for(let r of[`light`,`dark`]){let i={mode:r,platform:`phone`,width:null};if(![`color.primary`,`color.on-primary`].every(n=>e.existsIn(n,i)&&t.existsIn(n,i)))continue;let a=e.resolvedIn(`color.primary`,i),o=e.resolvedIn(`color.on-primary`,i);if(a===t.resolvedIn(`color.primary`,i)&&o===t.resolvedIn(`color.on-primary`,i))continue;let s=l(a,o);s!==String(a).toLowerCase()&&(n[r]={color:{primary:{$type:`color`,$value:s}}})}return{light:n.light??{},dark:n.dark??{}}}export{e as READABLE_TARGET,c as contrastRatio,l as deriveSolidFill,u as phonePairLayer};
1
+ var e=4.55,t=/^#[0-9a-f]{6}$/i,n=.0025,r=e=>{let t=Number.parseInt(e.slice(1,7),16);return[t>>16&255,t>>8&255,t&255]},i=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},a=e=>{let[t,n,a]=r(e);return .2126*i(t)+.7152*i(n)+.0722*i(a)},o=e=>{let[t,n,i]=r(e),a=t/255,o=n/255,s=i/255,c=Math.max(a,o,s),l=Math.min(a,o,s),u=c-l,d=(c+l)/2;if(u===0)return[0,0,d];let f=d>.5?u/(2-c-l):u/(c+l);return[(c===a?((o-s)/u+6)%6:c===o?(s-a)/u+2:(a-o)/u+4)*60,f,d]},s=([e,t,n])=>{let r=t*Math.min(n,1-n),i=t=>{let i=(t+e/30)%12,a=n-r*Math.max(-1,Math.min(i-3,9-i,1));return Math.round(a*255).toString(16).padStart(2,`0`)};return`#${i(0)}${i(8)}${i(4)}`.toUpperCase()},c=(e,t,r)=>{let[i,a,c]=o(e),l=e;for(let e=c+t*n;e>=0&&e<=1;e+=t*n)if(l=s([i,a,e]),r(l))return l;return l};function l(e,t){let n=a(e),r=a(t),i=Math.max(n,r),o=Math.min(n,r);return(i+.05)/(o+.05)}function u(n,r){if(!t.test(n)||!t.test(r))return n;let i=t=>l(t,r)>=e;return i(n)?n.toLowerCase():c(n,a(r)>a(n)?-1:1,i).toLowerCase()}function d(e,t){let n={};for(let r of[`light`,`dark`]){let i={mode:r,platform:`phone`,width:null};if(![`color.primary`,`color.on-primary`].every(n=>e.existsIn(n,i)&&t.existsIn(n,i)))continue;let a=String(e.resolvedIn(`color.primary`,i)),o=String(e.resolvedIn(`color.on-primary`,i));if(a===t.resolvedIn(`color.primary`,i)&&o===t.resolvedIn(`color.on-primary`,i))continue;let s=u(a,o);s!==a.toLowerCase()&&(n[r]={color:{primary:{$type:`color`,$value:s}}})}return{light:n.light??{},dark:n.dark??{}}}export{e as READABLE_TARGET,l as contrastRatio,u as deriveSolidFill,d as phonePairLayer};