@eifi1/ui-kit 0.32.2 → 0.33.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 (363) hide show
  1. package/README.md +16 -8
  2. package/dist/account/delete-account-setting.d.ts +10 -10
  3. package/dist/account/delete-account-setting.js +2 -1
  4. package/dist/account/delete-account-setting.js.map +1 -1
  5. package/dist/account/email-change-setting.d.ts +5 -0
  6. package/dist/account/email-change-setting.js +4 -3
  7. package/dist/account/email-change-setting.js.map +1 -1
  8. package/dist/account/sessions-setting.d.ts +4 -0
  9. package/dist/account/sessions-setting.js +3 -2
  10. package/dist/account/sessions-setting.js.map +1 -1
  11. package/dist/admin/admin-action-confirm.d.ts +10 -10
  12. package/dist/admin/admin-action-confirm.js.map +1 -1
  13. package/dist/admin/invitations-panel.d.ts +10 -10
  14. package/dist/admin/invitations-panel.js +4 -3
  15. package/dist/admin/invitations-panel.js.map +1 -1
  16. package/dist/admin/plan-change.d.ts +100 -0
  17. package/dist/admin/plan-change.js +208 -0
  18. package/dist/admin/plan-change.js.map +1 -0
  19. package/dist/admin/reviewer-scope-editor.d.ts +10 -10
  20. package/dist/admin/reviewer-scope-editor.js.map +1 -1
  21. package/dist/admin/role-select.d.ts +7 -7
  22. package/dist/admin/role-select.js.map +1 -1
  23. package/dist/admin/transfer-ownership-dialog.d.ts +10 -10
  24. package/dist/admin/user-roster.d.ts +7 -7
  25. package/dist/admin/user-roster.js +2 -2
  26. package/dist/admin/user-roster.js.map +1 -1
  27. package/dist/auth/auth-errors.d.ts +13 -2
  28. package/dist/auth/auth-errors.js +5 -1
  29. package/dist/auth/auth-errors.js.map +1 -1
  30. package/dist/auth/complete-name-dialog.d.ts +4 -1
  31. package/dist/auth/complete-name-dialog.js +2 -1
  32. package/dist/auth/complete-name-dialog.js.map +1 -1
  33. package/dist/auth/register-form.d.ts +10 -10
  34. package/dist/billing/billing-banner.d.ts +13 -11
  35. package/dist/billing/billing-banner.js.map +1 -1
  36. package/dist/billing/billing-labels.d.ts +10 -10
  37. package/dist/billing/billing-labels.js +10 -1
  38. package/dist/billing/billing-labels.js.map +1 -1
  39. package/dist/billing/billing-lock.d.ts +39 -12
  40. package/dist/billing/billing-lock.js +9 -3
  41. package/dist/billing/billing-lock.js.map +1 -1
  42. package/dist/billing/billing-overview.d.ts +154 -0
  43. package/dist/billing/billing-overview.js +2 -0
  44. package/dist/billing/billing-overview.js.map +1 -0
  45. package/dist/billing/billing-standing.d.ts +10 -10
  46. package/dist/billing/checkout-processing.d.ts +217 -0
  47. package/dist/billing/checkout-processing.js +198 -0
  48. package/dist/billing/checkout-processing.js.map +1 -0
  49. package/dist/billing/checkout-return.d.ts +51 -0
  50. package/dist/billing/checkout-return.js +43 -0
  51. package/dist/billing/checkout-return.js.map +1 -0
  52. package/dist/billing/pay-page.d.ts +210 -0
  53. package/dist/billing/pay-page.js +113 -0
  54. package/dist/billing/pay-page.js.map +1 -0
  55. package/dist/billing/plan-card.d.ts +10 -10
  56. package/dist/billing/plan-limit-notice.d.ts +10 -10
  57. package/dist/billing/plan-limit-toast.d.ts +143 -0
  58. package/dist/billing/plan-limit-toast.js +40 -0
  59. package/dist/billing/plan-limit-toast.js.map +1 -0
  60. package/dist/billing/subscription-actions.d.ts +38 -15
  61. package/dist/billing/subscription-actions.js +9 -2
  62. package/dist/billing/subscription-actions.js.map +1 -1
  63. package/dist/billing/subscription-status-chip.d.ts +9 -9
  64. package/dist/bin/eifi1-pay-page.mjs +166 -0
  65. package/dist/chart.d.ts +10 -10
  66. package/dist/components/account-chips.d.ts +6 -1
  67. package/dist/components/account-settings.d.ts +4 -1
  68. package/dist/components/account-settings.js +2 -1
  69. package/dist/components/account-settings.js.map +1 -1
  70. package/dist/components/amount-input.d.ts +10 -10
  71. package/dist/components/autocomplete.d.ts +2 -1
  72. package/dist/components/autocomplete.js +3 -1
  73. package/dist/components/autocomplete.js.map +1 -1
  74. package/dist/components/button-group.d.ts +10 -10
  75. package/dist/components/button-group.js +1 -1
  76. package/dist/components/button-group.js.map +1 -1
  77. package/dist/components/calculator.d.ts +10 -10
  78. package/dist/components/calculator.js +3 -3
  79. package/dist/components/calculator.js.map +1 -1
  80. package/dist/components/checkbox-group.d.ts +2 -1
  81. package/dist/components/checkbox-group.js.map +1 -1
  82. package/dist/components/checkbox.d.ts +2 -1
  83. package/dist/components/checkbox.js.map +1 -1
  84. package/dist/components/chip.d.ts +2 -1
  85. package/dist/components/chip.js +19 -17
  86. package/dist/components/chip.js.map +1 -1
  87. package/dist/components/choice-card.d.ts +3 -1
  88. package/dist/components/choice-card.js +1 -1
  89. package/dist/components/choice-card.js.map +1 -1
  90. package/dist/components/combobox.d.ts +4 -3
  91. package/dist/components/combobox.js.map +1 -1
  92. package/dist/components/confirm-dialog.d.ts +10 -10
  93. package/dist/components/confirm-dialog.js +6 -3
  94. package/dist/components/confirm-dialog.js.map +1 -1
  95. package/dist/components/copy-button.d.ts +11 -11
  96. package/dist/components/country-select.d.ts +2 -1
  97. package/dist/components/country-select.js.map +1 -1
  98. package/dist/components/danger-confirm.d.ts +10 -10
  99. package/dist/components/danger-confirm.js.map +1 -1
  100. package/dist/components/data-table-cells.d.ts +12 -1
  101. package/dist/components/data-table-filter-popover.d.ts +12 -1
  102. package/dist/components/data-table-filters.d.ts +12 -1
  103. package/dist/components/data-table-labels.d.ts +12 -1
  104. package/dist/components/data-table-pagination.d.ts +12 -1
  105. package/dist/components/data-table.d.ts +12 -1
  106. package/dist/components/data-table.js +3 -3
  107. package/dist/components/data-table.js.map +1 -1
  108. package/dist/components/date-picker.js +6 -4
  109. package/dist/components/date-picker.js.map +1 -1
  110. package/dist/components/entity-combobox.d.ts +3 -2
  111. package/dist/components/entity-combobox.js.map +1 -1
  112. package/dist/components/facing-pair.d.ts +10 -10
  113. package/dist/components/field-parts.d.ts +32 -4
  114. package/dist/components/field-parts.js +54 -19
  115. package/dist/components/field-parts.js.map +1 -1
  116. package/dist/components/file-button.d.ts +10 -10
  117. package/dist/components/file-button.js +3 -2
  118. package/dist/components/file-button.js.map +1 -1
  119. package/dist/components/file-dropzone.d.ts +11 -11
  120. package/dist/components/file-dropzone.js.map +1 -1
  121. package/dist/components/floating-panel.js +5 -5
  122. package/dist/components/floating-panel.js.map +1 -1
  123. package/dist/components/form-actions.d.ts +9 -9
  124. package/dist/components/form-actions.js +3 -3
  125. package/dist/components/form-actions.js.map +1 -1
  126. package/dist/components/iban-input.d.ts +10 -10
  127. package/dist/components/inline-edit-field.d.ts +2 -1
  128. package/dist/components/inline-edit-field.js +6 -6
  129. package/dist/components/inline-edit-field.js.map +1 -1
  130. package/dist/components/language-select.d.ts +10 -10
  131. package/dist/components/legal-page.d.ts +10 -10
  132. package/dist/components/legal.d.ts +10 -10
  133. package/dist/components/list.d.ts +2 -1
  134. package/dist/components/list.js +4 -5
  135. package/dist/components/list.js.map +1 -1
  136. package/dist/components/money-field.d.ts +10 -10
  137. package/dist/components/month-picker.js +54 -44
  138. package/dist/components/month-picker.js.map +1 -1
  139. package/dist/components/multi-entity-combobox.d.ts +3 -2
  140. package/dist/components/multi-entity-combobox.js.map +1 -1
  141. package/dist/components/number-field.d.ts +10 -10
  142. package/dist/components/number-input.d.ts +10 -10
  143. package/dist/components/numpad-sheet.d.ts +10 -10
  144. package/dist/components/numpad-sheet.js +2 -2
  145. package/dist/components/numpad-sheet.js.map +1 -1
  146. package/dist/components/phone-input.d.ts +10 -10
  147. package/dist/components/row-actions.d.ts +5 -5
  148. package/dist/components/row-actions.js +130 -32
  149. package/dist/components/row-actions.js.map +1 -1
  150. package/dist/components/series-chart.d.ts +10 -10
  151. package/dist/components/settings-fields.d.ts +10 -10
  152. package/dist/components/share-card.d.ts +7 -7
  153. package/dist/components/share-card.js +26 -10
  154. package/dist/components/share-card.js.map +1 -1
  155. package/dist/components/status-dot.d.ts +1 -0
  156. package/dist/components/status-dot.js +2 -2
  157. package/dist/components/status-dot.js.map +1 -1
  158. package/dist/components/swatch-picker.d.ts +2 -1
  159. package/dist/components/swatch-picker.js.map +1 -1
  160. package/dist/components/swipeable-row.d.ts +88 -17
  161. package/dist/components/swipeable-row.js +46 -9
  162. package/dist/components/swipeable-row.js.map +1 -1
  163. package/dist/components/switch.d.ts +2 -1
  164. package/dist/components/switch.js.map +1 -1
  165. package/dist/components/table.d.ts +2 -1
  166. package/dist/components/table.js +6 -0
  167. package/dist/components/table.js.map +1 -1
  168. package/dist/components/text-link.d.ts +9 -9
  169. package/dist/components/time-input.d.ts +10 -10
  170. package/dist/components/toggle-group.d.ts +2 -1
  171. package/dist/components/toggle-group.js +1 -1
  172. package/dist/components/toggle-group.js.map +1 -1
  173. package/dist/components/translation-review-editor.d.ts +4 -0
  174. package/dist/components/translation-review-editor.js +4 -3
  175. package/dist/components/translation-review-editor.js.map +1 -1
  176. package/dist/components/translation-review-parts.d.ts +1 -0
  177. package/dist/components/translation-review.d.ts +1 -0
  178. package/dist/components/translation-review.js +15 -18
  179. package/dist/components/translation-review.js.map +1 -1
  180. package/dist/components/ui.d.ts +9 -9
  181. package/dist/components/ui.js +47 -27
  182. package/dist/components/ui.js.map +1 -1
  183. package/dist/components/use-table-state.d.ts +12 -1
  184. package/dist/components/user-avatar.d.ts +1 -0
  185. package/dist/components/write-lock.d.ts +101 -13
  186. package/dist/components/write-lock.js +37 -13
  187. package/dist/components/write-lock.js.map +1 -1
  188. package/dist/{data-table-labels-kpAAVi6g.d.ts → data-table-labels-BJ5JE_X2.d.ts} +17 -0
  189. package/dist/data-table.d.ts +12 -1
  190. package/dist/{delete-account-setting-Dy4kJgUm.d.ts → delete-account-setting-DiPX4Vue.d.ts} +355 -41
  191. package/dist/feedback/feedback-attachment.d.ts +10 -10
  192. package/dist/feedback/feedback-attachment.js +7 -7
  193. package/dist/feedback/feedback-attachment.js.map +1 -1
  194. package/dist/feedback/feedback-context.d.ts +10 -10
  195. package/dist/feedback/feedback-crash.d.ts +10 -10
  196. package/dist/feedback/feedback-dialog.d.ts +10 -10
  197. package/dist/feedback/feedback-inbox.d.ts +9 -9
  198. package/dist/feedback/feedback-inbox.js +7 -3
  199. package/dist/feedback/feedback-inbox.js.map +1 -1
  200. package/dist/feedback/feedback-labels.d.ts +10 -10
  201. package/dist/feedback/feedback-menu.d.ts +3 -3
  202. package/dist/feedback/feedback-record.d.ts +10 -10
  203. package/dist/feedback/feedback-row-detail.d.ts +10 -10
  204. package/dist/feedback/feedback-row-detail.js.map +1 -1
  205. package/dist/feedback/feedback-status-undo.d.ts +10 -10
  206. package/dist/feedback/feedback-submit.d.ts +10 -10
  207. package/dist/feedback/feedback-swipe.d.ts +10 -10
  208. package/dist/feedback/feedback-swipe.js +3 -6
  209. package/dist/feedback/feedback-swipe.js.map +1 -1
  210. package/dist/feedback/feedback-table.d.ts +10 -10
  211. package/dist/feedback/feedback-table.js.map +1 -1
  212. package/dist/feedback/feedback-thread.d.ts +10 -10
  213. package/dist/feedback.d.ts +10 -10
  214. package/dist/hooks/use-file-drop.d.ts +10 -10
  215. package/dist/i18n/defaults.d.ts +10 -10
  216. package/dist/i18n/defaults.js +2 -0
  217. package/dist/i18n/defaults.js.map +1 -1
  218. package/dist/i18n/german.d.ts +10 -10
  219. package/dist/i18n/german.js +34 -1
  220. package/dist/i18n/german.js.map +1 -1
  221. package/dist/i18n/kit-labels.d.ts +4 -4
  222. package/dist/i18n/kit-labels.js.map +1 -1
  223. package/dist/i18n/languages.d.ts +10 -10
  224. package/dist/i18n/locales/de-CH.d.ts +10 -10
  225. package/dist/i18n/locales/en.d.ts +10 -10
  226. package/dist/i18n/locales/es.d.ts +10 -10
  227. package/dist/i18n/locales/es.js +34 -1
  228. package/dist/i18n/locales/es.js.map +1 -1
  229. package/dist/i18n/locales/fr.d.ts +10 -10
  230. package/dist/i18n/locales/fr.js +35 -1
  231. package/dist/i18n/locales/fr.js.map +1 -1
  232. package/dist/i18n/locales/hu.d.ts +10 -10
  233. package/dist/i18n/locales/hu.js +36 -1
  234. package/dist/i18n/locales/hu.js.map +1 -1
  235. package/dist/i18n/locales/it.d.ts +10 -10
  236. package/dist/i18n/locales/it.js +34 -1
  237. package/dist/i18n/locales/it.js.map +1 -1
  238. package/dist/i18n/locales/zh.d.ts +10 -10
  239. package/dist/i18n/locales/zh.js +34 -1
  240. package/dist/i18n/locales/zh.js.map +1 -1
  241. package/dist/i18n/review.d.ts +10 -10
  242. package/dist/i18n/review.js +8 -1
  243. package/dist/i18n/review.js.map +1 -1
  244. package/dist/index.d.ts +10 -5
  245. package/dist/index.js +40 -2
  246. package/dist/index.js.map +1 -1
  247. package/dist/landing/landing-actions.d.ts +10 -10
  248. package/dist/landing/landing-sections.d.ts +10 -10
  249. package/dist/landing/public-header.d.ts +10 -10
  250. package/dist/landing/routing.d.ts +10 -10
  251. package/dist/pay/.well-known/apple-developer-merchantid-domain-association +1 -0
  252. package/dist/pay/index.html +30 -0
  253. package/dist/pay/pay.css +126 -0
  254. package/dist/pay/pay.js +198 -0
  255. package/dist/rhf/fields.d.ts +10 -10
  256. package/dist/rhf/form.d.ts +10 -10
  257. package/dist/rhf.d.ts +10 -10
  258. package/dist/settings/settings-section.d.ts +10 -10
  259. package/dist/shell/app-shell.d.ts +9 -9
  260. package/dist/shell/top-bar-brand.d.ts +10 -10
  261. package/dist/shell/topbar-action-menu.d.ts +1 -0
  262. package/dist/shell.d.ts +10 -10
  263. package/dist/testing/css-variables.d.ts +74 -0
  264. package/dist/testing/css-variables.generated.d.ts +7 -0
  265. package/dist/testing/css-variables.generated.js +8 -0
  266. package/dist/testing/css-variables.generated.js.map +1 -0
  267. package/dist/testing/css-variables.js +93 -0
  268. package/dist/testing/css-variables.js.map +1 -0
  269. package/dist/testing/index.d.ts +1 -0
  270. package/dist/testing/index.js +12 -0
  271. package/dist/testing/index.js.map +1 -0
  272. package/dist/theme/contrast-tokens.d.ts +44 -1
  273. package/dist/theme/contrast-tokens.js +21 -0
  274. package/dist/theme/contrast-tokens.js.map +1 -1
  275. package/dist/theme/contrast.d.ts +2 -2
  276. package/dist/theme/palette-derive.js +60 -11
  277. package/dist/theme/palette-derive.js.map +1 -1
  278. package/dist/theme/palette-presets.js +45 -43
  279. package/dist/theme/palette-presets.js.map +1 -1
  280. package/dist/wizard/stepper-nav.d.ts +11 -11
  281. package/dist/wizard/stepper-nav.js.map +1 -1
  282. package/dist/wizard.d.ts +10 -10
  283. package/package.json +10 -2
  284. package/src/account/delete-account-setting.tsx +6 -1
  285. package/src/account/email-change-setting.tsx +9 -3
  286. package/src/account/sessions-setting.tsx +7 -2
  287. package/src/admin/admin-action-confirm.tsx +2 -1
  288. package/src/admin/invitations-panel.tsx +9 -3
  289. package/src/admin/plan-change.tsx +459 -0
  290. package/src/admin/reviewer-scope-editor.tsx +2 -1
  291. package/src/admin/role-select.tsx +2 -1
  292. package/src/admin/user-roster.tsx +5 -3
  293. package/src/auth/auth-errors.ts +25 -2
  294. package/src/auth/complete-name-dialog.tsx +6 -2
  295. package/src/billing/billing-banner.tsx +3 -1
  296. package/src/billing/billing-labels.ts +45 -0
  297. package/src/billing/billing-lock.ts +36 -3
  298. package/src/billing/billing-overview.ts +58 -0
  299. package/src/billing/checkout-processing.ts +391 -0
  300. package/src/billing/checkout-return.ts +90 -0
  301. package/src/billing/pay-page.ts +242 -0
  302. package/src/billing/plan-limit-toast.tsx +91 -0
  303. package/src/billing/subscription-actions.tsx +41 -8
  304. package/src/components/account-settings.tsx +6 -2
  305. package/src/components/autocomplete.tsx +5 -2
  306. package/src/components/button-group.tsx +4 -1
  307. package/src/components/calculator.tsx +10 -6
  308. package/src/components/checkbox-group.tsx +2 -2
  309. package/src/components/checkbox.tsx +2 -1
  310. package/src/components/chip.tsx +37 -32
  311. package/src/components/choice-card.tsx +4 -2
  312. package/src/components/combobox.tsx +4 -4
  313. package/src/components/confirm-dialog.tsx +13 -6
  314. package/src/components/country-select.tsx +2 -2
  315. package/src/components/danger-confirm.tsx +2 -2
  316. package/src/components/data-table.tsx +20 -9
  317. package/src/components/date-picker.tsx +10 -7
  318. package/src/components/entity-combobox.tsx +3 -3
  319. package/src/components/field-parts.tsx +61 -14
  320. package/src/components/file-button.tsx +5 -4
  321. package/src/components/file-dropzone.tsx +2 -2
  322. package/src/components/floating-panel.tsx +7 -5
  323. package/src/components/form-actions.tsx +12 -5
  324. package/src/components/inline-edit-field.tsx +13 -13
  325. package/src/components/list.tsx +10 -9
  326. package/src/components/month-picker.tsx +8 -2
  327. package/src/components/multi-entity-combobox.tsx +3 -3
  328. package/src/components/numpad-sheet.tsx +8 -4
  329. package/src/components/row-actions.tsx +208 -58
  330. package/src/components/share-card.tsx +67 -13
  331. package/src/components/status-dot.tsx +7 -7
  332. package/src/components/swatch-picker.tsx +2 -2
  333. package/src/components/swipeable-row.tsx +138 -27
  334. package/src/components/switch.tsx +2 -1
  335. package/src/components/table.tsx +8 -1
  336. package/src/components/toggle-group.tsx +5 -3
  337. package/src/components/translation-review-editor.tsx +8 -3
  338. package/src/components/translation-review.tsx +18 -22
  339. package/src/components/ui.tsx +92 -43
  340. package/src/components/write-lock.tsx +150 -24
  341. package/src/feedback/feedback-attachment.tsx +13 -9
  342. package/src/feedback/feedback-inbox.tsx +10 -6
  343. package/src/feedback/feedback-row-detail.tsx +3 -2
  344. package/src/feedback/feedback-swipe.tsx +6 -11
  345. package/src/feedback/feedback-table.tsx +2 -1
  346. package/src/i18n/defaults.ts +2 -0
  347. package/src/i18n/german.ts +38 -0
  348. package/src/i18n/kit-labels.tsx +4 -0
  349. package/src/i18n/locales/es.ts +34 -0
  350. package/src/i18n/locales/fr.ts +39 -0
  351. package/src/i18n/locales/hu.ts +37 -0
  352. package/src/i18n/locales/it.ts +35 -0
  353. package/src/i18n/locales/zh.ts +33 -0
  354. package/src/i18n/review.ts +7 -0
  355. package/src/index.ts +48 -4
  356. package/src/testing/css-variables.generated.ts +112 -0
  357. package/src/testing/css-variables.ts +191 -0
  358. package/src/testing/index.ts +13 -0
  359. package/src/theme/contrast-tokens.ts +53 -2
  360. package/src/theme/palette-derive.ts +87 -10
  361. package/src/theme/palette-presets.ts +45 -43
  362. package/src/wizard/stepper-nav.tsx +2 -1
  363. package/tokens.css +306 -46
@@ -10,6 +10,7 @@ import {
10
10
  simulateCvd,
11
11
  solveLightness
12
12
  } from "./color.js";
13
+ import { brandSoft, hoverFill } from "./contrast-tokens.js";
13
14
  const HUE_HOME = {
14
15
  danger: { hue: 27, slack: 14 },
15
16
  warning: { hue: 75, slack: 16 },
@@ -36,7 +37,14 @@ function placeHue(home, slack, taken) {
36
37
  const SURFACE_L = {
37
38
  // Light: the PAGE is slightly darker than the cards on it, so a card reads as raised
38
39
  // without needing a shadow to say so. Matches the shipped presets' relationship.
39
- light: { page: 0.912, surface: 0.945, surface2: 0.929 },
40
+ //
41
+ // The light WELL is the page itself (0.33, docs/colour-roles-harmonization.md §5.3,
42
+ // k26). Between the card and the page it sat 1.02–1.05:1 from the card it is inset
43
+ // in, which is no well at all; at the page's lightness it stands out from the card
44
+ // exactly as far as the card does from the page, and nothing re-solves, because the
45
+ // page is already the surface every text role is solved against. Dark keeps its
46
+ // well a step lighter than the card (1.11–1.13:1).
47
+ light: { page: 0.912, surface: 0.945, surface2: 0.912 },
40
48
  dark: { page: 0.158, surface: 0.206, surface2: 0.249 }
41
49
  };
42
50
  const BORDER_CONTRAST = 1.5;
@@ -102,21 +110,44 @@ function derivePalette({
102
110
  const textPrimary = solveAgainst(brand.h, textChroma, targets.primary, worstSurface, mode);
103
111
  const textSecondary = solveAgainst(brand.h, textChroma, targets.secondary, worstSurface, mode);
104
112
  const textMuted = solveAgainst(brand.h, textChroma, targets.muted, worstSurface, mode);
113
+ const hover = hoverFill({ textPrimary, bgSurface: surfaces.bgSurface });
114
+ const worstText = [worstSurface, hover].reduce(
115
+ (a, b) => contrast(a, mode === "light" ? "#000000" : "#ffffff") < contrast(b, mode === "light" ? "#000000" : "#ffffff") ? a : b
116
+ );
105
117
  const brandChroma = Math.max(brand.c, 0.06);
106
118
  const brandRatio = contrast(anchors.brand, worstSurface);
107
- const brandHex = brandRatio >= 3 ? toHex(parseHex(anchors.brand)) : solveAgainst(brand.h, brandChroma, 3, worstSurface, mode);
119
+ let brandHex = brandRatio >= 3 ? toHex(parseHex(anchors.brand)) : solveAgainst(brand.h, brandChroma, 3, worstSurface, mode);
108
120
  if (brandRatio < 3) {
109
121
  warnings.push(
110
122
  `brand ${anchors.brand} sits at ${brandRatio.toFixed(2)}:1 against the ${mode} surfaces, below the 3:1 WCAG 1.4.11 asks of a control boundary. Lightness was adjusted to ${brandHex}; hue and chroma are unchanged.`
111
123
  );
112
124
  }
125
+ const brandMutedWorst = (hex) => {
126
+ const soft = brandSoft({ brand: hex, textPrimary, bgSurface: surfaces.bgSurface });
127
+ return Math.min(
128
+ contrast(soft.brandMuted, worstText),
129
+ contrast(soft.brandMuted, soft.brandBg),
130
+ contrast(soft.brandMuted, soft.brandBgHover)
131
+ );
132
+ };
133
+ for (let i = 0; i < 40 && brandMutedWorst(brandHex) < 4.5; i++) {
134
+ const lch = hexToOklch(brandHex);
135
+ brandHex = oklchToHex({ ...lch, l: mode === "light" ? lch.l - 5e-3 : lch.l + 5e-3 });
136
+ }
137
+ if (brandMutedWorst(brandHex) < 4.5) {
138
+ warnings.push(
139
+ `the brand as text (--brand-muted) reaches only ${brandMutedWorst(brandHex).toFixed(2)}:1 against the ${mode} surfaces (needs 4.5:1).`
140
+ );
141
+ }
113
142
  const brandLch = hexToOklch(brandHex);
143
+ const brandContrast = contrastOn(brandHex);
114
144
  const brandHover = oklchToHex({
115
145
  ...brandLch,
116
- // Hover moves AWAY from the page in both themes: darker on light, lighter on dark.
117
- l: mode === "light" ? brandLch.l - 0.06 : brandLch.l + 0.06
146
+ // Hover moves AWAY from the colour of the text on it (0.33, §5.5): darker under
147
+ // white, lighter under a dark ink. It used to move away from the page, which in dark
148
+ // lightened a fill that carries WHITE text, toward its own label: 4.07:1.
149
+ l: brandContrast === "#ffffff" ? brandLch.l - 0.06 : brandLch.l + 0.06
118
150
  });
119
- const brandContrast = contrastOn(brandHex);
120
151
  const onBrand = contrast(brandHex, brandContrast);
121
152
  if (onBrand < 4.5) {
122
153
  warnings.push(
@@ -156,7 +187,7 @@ function derivePalette({
156
187
  const bg = tintOn(hue, chroma, surfaces.bgSurface, mode);
157
188
  const onSurface = solveLightness(
158
189
  4.5,
159
- parseHex(worstSurface),
190
+ parseHex(worstText),
160
191
  hue,
161
192
  chroma,
162
193
  mode === "light" ? "darker" : "lighter"
@@ -221,11 +252,16 @@ function derivePalette({
221
252
  semantic.accentContrast = contrastOn(accent);
222
253
  semantic.accentBg = tintOn(accentLch.h, Math.max(accentLch.c, 0.06), surfaces.bgSurface, mode);
223
254
  }
224
- const money = (hue, target) => solveAgainst(hue, 0.12, target, worstSurface, mode);
255
+ const money = (hue, target) => solveAgainst(hue, 0.12, target, worstText, mode);
225
256
  const moneyIncome = money(175, 4.5);
226
257
  const moneyExpense = money(70, 4.5);
227
258
  const moneyNet = money(300, 4.5);
228
- const moneyNeutral = oklchToHex({ l: mode === "light" ? 0.52 : 0.72, c: 0.012, h: brand.h });
259
+ const neutralFloor = solveLightness(4.5, parseHex(worstText), brand.h, 0.012, mode === "light" ? "darker" : "lighter");
260
+ const moneyNeutral = oklchToHex({
261
+ l: mode === "light" ? Math.min(0.52, neutralFloor) : Math.max(0.72, neutralFloor),
262
+ c: 0.012,
263
+ h: brand.h
264
+ });
229
265
  const tokens = {
230
266
  ...surfaces,
231
267
  textPrimary,
@@ -269,25 +305,37 @@ function auditPalette(t, semantic) {
269
305
  ["bgSurface", t.bgSurface],
270
306
  ["bgSurface2", t.bgSurface2]
271
307
  ];
308
+ const hover = hoverFill(t);
309
+ const textGrounds = [...surfaces, ["bgHover", hover]];
310
+ const { brandMuted, brandBg, brandBgHover } = brandSoft(t);
272
311
  const add = (pair, fg, bg, required, rule) => {
273
312
  const ratio = contrast(fg, bg);
274
313
  checks.push({ pair, ratio, required, rule, passes: ratio >= required - 0.05 });
275
314
  };
276
315
  for (const [name, bg] of surfaces) {
316
+ add(`brand on ${name}`, t.brand, bg, 3, "WCAG 1.4.11 graphical object");
317
+ add(`border on ${name}`, t.border, bg, 1.1, "house rule: a hairline must be findable");
318
+ }
319
+ for (const [name, bg] of textGrounds) {
277
320
  add(`textPrimary on ${name}`, t.textPrimary, bg, 7, "WCAG 1.4.6 AAA body text");
278
321
  add(`textSecondary on ${name}`, t.textSecondary, bg, 4.5, "WCAG 1.4.3 AA body text");
279
322
  add(`textMuted on ${name}`, t.textMuted, bg, 4.5, "WCAG 1.4.3 AA body text");
280
- add(`brand on ${name}`, t.brand, bg, 3, "WCAG 1.4.11 graphical object");
281
- add(`border on ${name}`, t.border, bg, 1.1, "house rule: a hairline must be findable");
323
+ add(`brandMuted on ${name}`, brandMuted, bg, 4.5, "WCAG 1.4.3 \u2014 the brand as text");
282
324
  for (const [key, hex] of [
283
325
  ["moneyIncome", t.moneyIncome],
284
326
  ["moneyExpense", t.moneyExpense],
285
- ["moneyNet", t.moneyNet]
327
+ ["moneyNet", t.moneyNet],
328
+ // Not a figure's colour but still printed as one (the numpad's sign, a future
329
+ // row's amount) — measured since 0.33, when it was found at 4.24:1.
330
+ ["moneyNeutral", t.moneyNeutral]
286
331
  ]) {
287
332
  add(`${key} on ${name}`, hex, bg, 4.5, "WCAG 1.4.3 \u2014 these are rendered as TEXT");
288
333
  }
289
334
  }
290
335
  add("brandContrast on brand", t.brandContrast, t.brand, 4.5, "WCAG 1.4.3 AA body text");
336
+ add("brandContrast on brandHover", t.brandContrast, t.brandHover, 4.5, "WCAG 1.4.3 AA body text");
337
+ add("brandMuted on brandBg", brandMuted, brandBg, 4.5, "WCAG 1.4.3 \u2014 a soft brand chip's label");
338
+ add("brandMuted on brandBgHover", brandMuted, brandBgHover, 4.5, "WCAG 1.4.3 \u2014 a hovered soft brand chip's label");
291
339
  if (semantic) {
292
340
  for (const [name, fg] of [
293
341
  ["danger", semantic.danger],
@@ -296,6 +344,7 @@ function auditPalette(t, semantic) {
296
344
  ["success", semantic.success]
297
345
  ]) {
298
346
  add(`${name} on bgSurface`, fg, t.bgSurface, 4.5, "WCAG 1.4.3 \u2014 rendered as text");
347
+ add(`${name} on bgHover`, fg, hover, 4.5, "WCAG 1.4.3 \u2014 rendered as text, on a hovered row");
299
348
  }
300
349
  add("danger on dangerBg", semantic.danger, semantic.dangerBg, 4.5, "WCAG 1.4.3 \u2014 badge text");
301
350
  add("warning on warningBg", semantic.warning, semantic.warningBg, 4.5, "WCAG 1.4.3 \u2014 badge text");
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theme/palette-derive.ts"],"sourcesContent":["import type { ThemeMode } from \"./theme-store\";\nimport type { TokenSet } from \"./palette-presets\";\nimport type { HeatStops } from \"./chart-palette\";\nimport {\n contrast,\n deltaE,\n toHex,\n hexToOklch,\n oklchToHex,\n parseHex,\n rgbToOklch,\n simulateCvd,\n solveLightness,\n} from \"./color\";\nimport type { CvdType, Oklch } from \"./color\";\n\n/**\n * Build a whole palette from one brand colour, plus any number of colours pinned by\n * hand, with every contrast ratio SOLVED rather than chosen and then hoped for.\n *\n * The presets this package shipped were assembled by eye and annotated with the ratios\n * they were believed to hold — `tokens.css` records \"7.0:1 and 4.8:1\", and\n * `palette-presets.ts` records \"2.67:1 … lifted they clear it at 3.30:1\". Nothing\n * computed any of them, and the audit found four of the nine default light chart hues\n * below the 3:1 that WCAG 1.4.11 requires of a graphical object. A comment is not a\n * test. Everything here is derived to a target and then measured, and\n * {@link auditPalette} returns the measurements so a caller can refuse a palette that\n * does not hold up.\n *\n * WHAT IS DERIVED AND WHAT IS NOT. The UI palette and the CATEGORICAL CHART RAMP solve\n * different problems and are deliberately kept apart. A UI colour needs contrast against\n * one known surface and carries a fixed meaning; a chart colour needs to stay separable\n * from eight unknown siblings, at roughly equal salience, with no implied order.\n * Optimising a set for one makes it worse at the other, which is why `deriveTokenSet`\n * leaves `chart` alone unless you explicitly ask for {@link deriveChartRamp}.\n */\n\n/* ── Inputs ───────────────────────────────────────────────────────────────── */\n\n/** A role whose hue may be pinned by the caller instead of chosen by the deriver. */\nexport type AnchorRole = \"brand\" | \"accent\" | \"danger\" | \"warning\" | \"success\" | \"info\";\n\nexport type PaletteAnchors = { brand: string } & Partial<Record<Exclude<AnchorRole, \"brand\">, string>>;\n\nexport interface DeriveOptions {\n anchors: PaletteAnchors;\n mode: ThemeMode;\n /**\n * How strongly the surfaces carry the brand's hue, 0–1 of the maximum useful tint.\n * 0 gives neutral greys; the shipped default is a visible warmth, because a page that\n * is very slightly the brand's hue reads as considered where a pure grey reads as\n * unstyled. Above ~0.5 the surfaces start competing with the content.\n */\n surfaceTint?: number;\n /** Contrast targets for the three text roles against the WORST surface. */\n textContrast?: { primary?: number; secondary?: number; muted?: number };\n}\n\n/* ── Outputs ──────────────────────────────────────────────────────────────── */\n\n/** The semantic layer, which lives in tokens.css rather than in `TokenSet`. */\nexport interface SemanticTokens {\n danger: string;\n dangerHover: string;\n dangerContrast: string;\n dangerBorder: string;\n /** The error line (invalid field, danger banner, destructive focus ring): as loud as\n * `dangerBorder` was before 0.15.5, so it keeps 3:1 against the surface. */\n dangerBorderStrong: string;\n dangerBg: string;\n warning: string;\n warningBorder: string;\n warningBg: string;\n info: string;\n infoBorder: string;\n infoBg: string;\n success: string;\n successBorder: string;\n successBg: string;\n /** Present only when a `accent` (secondary brand) anchor was supplied. */\n accent?: string;\n accentContrast?: string;\n accentBg?: string;\n}\n\nexport interface ContrastCheck {\n /** e.g. \"textMuted on bgPage\". */\n pair: string;\n ratio: number;\n /** What WCAG asks of this pair. */\n required: number;\n /** Which rule the requirement comes from, for a reader who wants to argue with it. */\n rule: string;\n passes: boolean;\n}\n\nexport interface ContrastReport {\n checks: ContrastCheck[];\n failures: ContrastCheck[];\n passes: boolean;\n}\n\nexport interface DerivedPalette {\n tokens: TokenSet;\n semantic: SemanticTokens;\n audit: ContrastReport;\n /** Compromises the deriver had to make, in plain words. Never silent. */\n warnings: string[];\n}\n\n/* ── The hue homes ────────────────────────────────────────────────────────── */\n\n/**\n * Where each semantic role wants to sit, and how far it may be pushed.\n *\n * A semantic colour is a convention before it is an aesthetic: danger is red because\n * every other interface the user has ever used made it red, and a \"danger\" button in\n * the brand's teal is a worse button however well it matches. So each role has a home\n * hue and a narrow licence to move — enough to get out of the brand's way when the\n * brand happens to live in the same neighbourhood, not enough to stop meaning what it\n * means. If it cannot get far enough, that is a warning, not a silent compromise.\n */\nconst HUE_HOME: Record<Exclude<AnchorRole, \"brand\" | \"accent\">, { hue: number; slack: number }> = {\n danger: { hue: 27, slack: 14 },\n warning: { hue: 75, slack: 16 },\n success: { hue: 150, slack: 20 },\n info: { hue: 240, slack: 22 },\n};\n\n/** Circular distance between two hue angles, 0–180. */\nfunction hueGap(a: number, b: number): number {\n const d = Math.abs(((a - b) % 360) + 360) % 360;\n return d > 180 ? 360 - d : d;\n}\n\n/**\n * Nudge `home` within `slack` to maximise the distance from every taken hue.\n *\n * Sampled rather than solved: the objective is a min-of-distances over a handful of\n * points on a short arc, which is piecewise-linear with kinks wherever the nearest\n * neighbour changes. Gradient methods stall on those kinks; 2° steps over a ±22° arc is\n * 23 evaluations of some trigonometry and cannot stall.\n */\nfunction placeHue(home: number, slack: number, taken: number[]): number {\n let best = home;\n let bestGap = Math.min(...taken.map((t) => hueGap(home, t)), 360);\n for (let d = -slack; d <= slack; d += 2) {\n const h = (home + d + 360) % 360;\n const gap = Math.min(...taken.map((t) => hueGap(h, t)), 360);\n // Ties go to the hue nearest home: a role should move only as far as it must.\n if (gap > bestGap + 1e-9) {\n best = h;\n bestGap = gap;\n }\n }\n return best;\n}\n\n/* ── Derivation ───────────────────────────────────────────────────────────── */\n\nconst SURFACE_L = {\n // Light: the PAGE is slightly darker than the cards on it, so a card reads as raised\n // without needing a shadow to say so. Matches the shipped presets' relationship.\n light: { page: 0.912, surface: 0.945, surface2: 0.929 },\n dark: { page: 0.158, surface: 0.206, surface2: 0.249 },\n} as const;\n\n/**\n * What a hairline has to clear against the surface it divides.\n *\n * WCAG has nothing to say here — a decorative border is not a graphical object that\n * conveys information — so this is a house rule, and it is deliberately low. A border\n * that clears 3:1 is a RULE, not a hairline: it draws the eye to the box instead of to\n * what is in it. 1.5:1 is the point at which the edge is reliably findable without\n * becoming part of the composition.\n */\nconst BORDER_CONTRAST = 1.5;\n\n/** The most tint a surface can carry before it stops reading as a neutral ground. */\nconst MAX_SURFACE_CHROMA = 0.034;\n\nfunction surfaceSet(hue: number, mode: ThemeMode, tint: number) {\n const c = MAX_SURFACE_CHROMA * Math.max(0, Math.min(1, tint));\n const L = SURFACE_L[mode];\n const bgPage = oklchToHex({ l: L.page, c, h: hue });\n const bgSurface = oklchToHex({ l: L.surface, c, h: hue });\n const bgSurface2 = oklchToHex({ l: L.surface2, c, h: hue });\n // Solved, not guessed: a fixed lightness that looks right against a pale warm ground\n // disappears against a deep cold one, and both are reachable from the same `hue`\n // input. The border carries a little more chroma than the surfaces because at these\n // lightnesses a perfectly neutral hairline on a tinted ground reads as a wrong grey.\n const borderChroma = c * 1.6;\n // Solved against the surface the hairline is HARDEST to see on, not against one of\n // the three. Solving against `bgSurface` alone left it at 1.36:1 on `bgPage`, so the\n // target and the audit disagreed about the same border.\n const hardest = [bgPage, bgSurface, bgSurface2].reduce((a, b) =>\n contrast(a, mode === \"light\" ? \"#000000\" : \"#ffffff\") <\n contrast(b, mode === \"light\" ? \"#000000\" : \"#ffffff\")\n ? a\n : b,\n );\n const borderL = solveLightness(\n BORDER_CONTRAST,\n parseHex(hardest)!,\n hue,\n borderChroma,\n mode === \"light\" ? \"darker\" : \"lighter\",\n );\n return {\n bgPage,\n bgSurface,\n bgSurface2,\n border: oklchToHex({ l: borderL, c: borderChroma, h: hue }),\n };\n}\n\n/** Solve a colour at this hue that clears `target` against `against`, keeping chroma. */\nfunction solveAgainst(hue: number, chroma: number, target: number, against: string, mode: ThemeMode): string {\n const bg = parseHex(against)!;\n const l = solveLightness(target, bg, hue, chroma, mode === \"light\" ? \"darker\" : \"lighter\");\n return oklchToHex({ l, c: chroma, h: hue });\n}\n\n/** Whichever of near-white / near-black reads better ON `fill`. */\nfunction contrastOn(fill: string): string {\n const light = \"#ffffff\";\n const dark = \"#12100e\";\n return contrast(fill, light) >= contrast(fill, dark) ? light : dark;\n}\n\n/** A soft tint of `hue` sitting on the surface — a badge fill, not a button fill. */\nfunction tintOn(hue: number, chroma: number, surface: string, mode: ThemeMode): string {\n const s = hexToOklch(surface)!;\n // Toward the colour, but only far enough to be seen: these back TEXT of the same hue,\n // and a strong tint leaves the text nowhere to go.\n const l = mode === \"light\" ? s.l - 0.055 : s.l + 0.055;\n return oklchToHex({ l, c: Math.min(chroma * 0.45, 0.06), h: hue });\n}\n\nexport function derivePalette({\n anchors,\n mode,\n surfaceTint = 0.55,\n textContrast,\n}: DeriveOptions): DerivedPalette {\n const warnings: string[] = [];\n const brand = hexToOklch(anchors.brand);\n if (!brand) {\n throw new Error(\n `derivePalette: brand \"${anchors.brand}\" is not a #rgb or #rrggbb colour. ` +\n `Anchors must be hex — a named colour or an rgba() string cannot be converted.`,\n );\n }\n\n const targets = { primary: 10, secondary: 7, muted: 4.6, ...textContrast };\n\n // ── Surfaces, from the brand's hue.\n const surfaces = surfaceSet(brand.h, mode, surfaceTint);\n // Every text role is solved against the WORST of the three, so a token is legible\n // wherever it lands. Solving against `bgSurface` alone is the mistake that makes a\n // muted label fail on the page background it also sits on.\n const worstSurface = [surfaces.bgPage, surfaces.bgSurface, surfaces.bgSurface2].reduce((a, b) =>\n contrast(a, mode === \"light\" ? \"#000000\" : \"#ffffff\") <\n contrast(b, mode === \"light\" ? \"#000000\" : \"#ffffff\")\n ? a\n : b,\n );\n\n // ── Text. A trace of the brand hue keeps the greys from reading cold on a warm page.\n const textChroma = 0.014;\n const textPrimary = solveAgainst(brand.h, textChroma, targets.primary, worstSurface, mode);\n const textSecondary = solveAgainst(brand.h, textChroma, targets.secondary, worstSurface, mode);\n const textMuted = solveAgainst(brand.h, textChroma, targets.muted, worstSurface, mode);\n\n // ── Brand. Keep the hue the caller asked for; move only the lightness, and only as\n // far as 3:1 against the worst surface — WCAG 1.4.11, since a brand-filled control is\n // a graphical object whose boundary has to be perceivable.\n const brandChroma = Math.max(brand.c, 0.06);\n const brandRatio = contrast(anchors.brand, worstSurface);\n // NORMALISED, never the caller's raw string. `parseHex` accepts \"4f46e5\" and \"#abc\",\n // and passing either through unchanged put a value in the TokenSet that is not a CSS\n // colour — it then fails silently at paint time, three layers from here.\n const brandHex =\n brandRatio >= 3\n ? toHex(parseHex(anchors.brand)!)\n : solveAgainst(brand.h, brandChroma, 3, worstSurface, mode);\n if (brandRatio < 3) {\n warnings.push(\n `brand ${anchors.brand} sits at ${brandRatio.toFixed(2)}:1 against the ${mode} surfaces, ` +\n `below the 3:1 WCAG 1.4.11 asks of a control boundary. Lightness was adjusted to ` +\n `${brandHex}; hue and chroma are unchanged.`,\n );\n }\n const brandLch = hexToOklch(brandHex)!;\n const brandHover = oklchToHex({\n ...brandLch,\n // Hover moves AWAY from the page in both themes: darker on light, lighter on dark.\n l: mode === \"light\" ? brandLch.l - 0.06 : brandLch.l + 0.06,\n });\n const brandContrast = contrastOn(brandHex);\n const onBrand = contrast(brandHex, brandContrast);\n if (onBrand < 4.5) {\n warnings.push(\n `text on the brand fill reaches only ${onBrand.toFixed(2)}:1 (needs 4.5:1). ` +\n `A mid-lightness, high-chroma brand cannot carry legible text at any ink; ` +\n `use it as an accent and keep primary buttons on a darker or lighter variant.`,\n );\n }\n\n // ── Semantic roles. Anchors are honoured exactly; the rest are placed away from the\n // brand and from each other, within each role's licence to move.\n const taken: number[] = [brandLch.h];\n const accentLch = anchors.accent ? hexToOklch(anchors.accent) : null;\n if (anchors.accent && !accentLch) {\n warnings.push(`accent \"${anchors.accent}\" is not a hex colour and was ignored.`);\n }\n if (accentLch) taken.push(accentLch.h);\n\n const semanticHue = {} as Record<Exclude<AnchorRole, \"brand\" | \"accent\">, number>;\n const semanticChroma = {} as Record<Exclude<AnchorRole, \"brand\" | \"accent\">, number>;\n for (const role of [\"danger\", \"warning\", \"success\", \"info\"] as const) {\n const pinned = anchors[role] ? hexToOklch(anchors[role]!) : null;\n if (anchors[role] && !pinned) {\n warnings.push(`${role} \"${anchors[role]}\" is not a hex colour and was ignored.`);\n }\n const home = HUE_HOME[role];\n const hue = pinned ? pinned.h : placeHue(home.hue, home.slack, taken);\n if (!pinned) {\n const gap = Math.min(...taken.map((t) => hueGap(hue, t)));\n if (gap < 20) {\n warnings.push(\n `${role} could only reach ${gap.toFixed(0)}° from the nearest pinned hue, which is ` +\n `too close to tell apart at a glance. Pin ${role} explicitly, or move the brand.`,\n );\n }\n }\n semanticHue[role] = hue;\n semanticChroma[role] = pinned ? Math.max(pinned.c, 0.08) : 0.13;\n taken.push(hue);\n }\n\n /**\n * A semantic colour has two jobs and therefore two backgrounds: plain text on the\n * page, and the label inside its own tinted badge. The badge is the harder of the\n * two — it is a step toward the colour — so solving only against the surface produced\n * a badge at 4.1:1 while the loose text passed, which is the failure mode that is\n * hardest to notice because nine tenths of the uses look fine.\n */\n const sem = (role: Exclude<AnchorRole, \"brand\" | \"accent\">) => {\n const hue = semanticHue[role];\n const chroma = semanticChroma[role];\n const bg = tintOn(hue, chroma, surfaces.bgSurface, mode);\n const onSurface = solveLightness(\n 4.5,\n parseHex(worstSurface)!,\n hue,\n chroma,\n mode === \"light\" ? \"darker\" : \"lighter\",\n );\n const onTint = solveLightness(\n 4.5,\n parseHex(bg)!,\n hue,\n chroma,\n mode === \"light\" ? \"darker\" : \"lighter\",\n );\n const l = mode === \"light\" ? Math.min(onSurface, onTint) : Math.max(onSurface, onTint);\n return oklchToHex({ l, c: chroma, h: hue });\n };\n\n const danger = sem(\"danger\");\n const dangerLch = hexToOklch(danger)!;\n const semantic: SemanticTokens = {\n danger,\n dangerHover: oklchToHex({\n ...dangerLch,\n l: mode === \"light\" ? dangerLch.l - 0.06 : dangerLch.l + 0.06,\n }),\n dangerContrast: contrastOn(danger),\n // The tone border follows its siblings' lightness in dark mode (warning 0.44, info\n // and success 0.45) — a soft frame; the strong line keeps the old, louder recipe.\n dangerBorder: oklchToHex({\n l: mode === \"light\" ? dangerLch.l + 0.22 : 0.45,\n c: semanticChroma.danger,\n h: semanticHue.danger,\n }),\n dangerBorderStrong: oklchToHex({\n l: mode === \"light\" ? dangerLch.l + 0.22 : dangerLch.l - 0.22,\n c: semanticChroma.danger,\n h: semanticHue.danger,\n }),\n dangerBg: tintOn(semanticHue.danger, semanticChroma.danger, surfaces.bgSurface, mode),\n warning: sem(\"warning\"),\n warningBorder: oklchToHex({\n l: mode === \"light\" ? 0.82 : 0.44,\n c: semanticChroma.warning,\n h: semanticHue.warning,\n }),\n warningBg: tintOn(semanticHue.warning, semanticChroma.warning, surfaces.bgSurface, mode),\n info: sem(\"info\"),\n infoBorder: oklchToHex({\n l: mode === \"light\" ? 0.8 : 0.45,\n c: semanticChroma.info,\n h: semanticHue.info,\n }),\n infoBg: tintOn(semanticHue.info, semanticChroma.info, surfaces.bgSurface, mode),\n success: sem(\"success\"),\n successBorder: oklchToHex({\n l: mode === \"light\" ? 0.81 : 0.45,\n c: semanticChroma.success,\n h: semanticHue.success,\n }),\n successBg: tintOn(semanticHue.success, semanticChroma.success, surfaces.bgSurface, mode),\n };\n\n if (accentLch) {\n const accent = solveAgainst(accentLch.h, Math.max(accentLch.c, 0.06), 3, worstSurface, mode);\n semantic.accent = accent;\n semantic.accentContrast = contrastOn(accent);\n semantic.accentBg = tintOn(accentLch.h, Math.max(accentLch.c, 0.06), surfaces.bgSurface, mode);\n }\n\n // ── Money. A THIRD system again: these are data colours with fixed meanings, and the\n // one rule that outranks everything is that income and expense must never be the\n // red/green pair — which is why the shipped presets use teal/amber/violet. Derived\n // here at fixed hues rather than from the brand, for the same reason `--danger` is:\n // a consumer who rebrands does not thereby change what \"money out\" looks like.\n const money = (hue: number, target: number) => solveAgainst(hue, 0.12, target, worstSurface, mode);\n const moneyIncome = money(175, 4.5);\n const moneyExpense = money(70, 4.5);\n const moneyNet = money(300, 4.5);\n const moneyNeutral = oklchToHex({ l: mode === \"light\" ? 0.52 : 0.72, c: 0.012, h: brand.h });\n\n const tokens: TokenSet = {\n ...surfaces,\n textPrimary,\n textSecondary,\n textMuted,\n brand: brandHex,\n brandHover,\n brandContrast,\n moneyIncome,\n moneyExpense,\n moneyNet,\n moneyNeutral,\n // Left alone. See the note at the top of this file about why the categorical ramp is\n // not derived from the brand unless the caller asks.\n //\n // ⚠️ EMPTY, not absent: a caller who hands this straight to `applyTokenSet` keeps\n // whatever `--chart-1…9` were already on the element. That is deliberate — the ramp\n // is a separate decision and clearing it would leave charts unpainted — but it means\n // a derived palette applied over another preset is a MIX until you also supply a\n // ramp. `deriveChartRamp` is how you supply one.\n chart: [],\n heat: deriveHeat(moneyIncome, moneyExpense, surfaces, mode),\n };\n\n return { tokens, semantic, audit: auditPalette(tokens, semantic), warnings };\n}\n\n/**\n * Heatmap stops, reusing the money pair.\n *\n * `under` is the good direction and `over` the bad one, at the SAME hues as\n * `moneyIncome`/`moneyExpense` — so a heatmap cell and the figure printed beside it\n * agree about which way is which, rather than each inventing its own convention.\n */\nfunction deriveHeat(\n income: string,\n expense: string,\n surfaces: { bgSurface2: string },\n mode: ThemeMode,\n): HeatStops {\n const exp = hexToOklch(expense)!;\n return {\n neutral: surfaces.bgSurface2,\n under: income,\n over: expense,\n seqLow: oklchToHex({ l: mode === \"light\" ? 0.93 : 0.26, c: 0.05, h: exp.h }),\n seqHigh: expense,\n empty: mode === \"light\" ? \"rgba(120,110,95,0.14)\" : \"rgba(160,170,190,0.10)\",\n };\n}\n\n/* ── Audit ────────────────────────────────────────────────────────────────── */\n\n/**\n * Measure every pair that has a requirement, and say which ones fail.\n *\n * This is the part the shipped presets were missing. `derivePalette` runs it on the way\n * out, and the preset test runs it over everything the package ships, so a palette that\n * does not hold up cannot be merged with a comment claiming that it does.\n */\nexport function auditPalette(t: TokenSet, semantic?: SemanticTokens): ContrastReport {\n const checks: ContrastCheck[] = [];\n const surfaces: Array<[string, string]> = [\n [\"bgPage\", t.bgPage],\n [\"bgSurface\", t.bgSurface],\n [\"bgSurface2\", t.bgSurface2],\n ];\n\n const add = (pair: string, fg: string, bg: string, required: number, rule: string) => {\n const ratio = contrast(fg, bg);\n checks.push({ pair, ratio, required, rule, passes: ratio >= required - 0.05 });\n };\n\n for (const [name, bg] of surfaces) {\n add(`textPrimary on ${name}`, t.textPrimary, bg, 7, \"WCAG 1.4.6 AAA body text\");\n add(`textSecondary on ${name}`, t.textSecondary, bg, 4.5, \"WCAG 1.4.3 AA body text\");\n add(`textMuted on ${name}`, t.textMuted, bg, 4.5, \"WCAG 1.4.3 AA body text\");\n add(`brand on ${name}`, t.brand, bg, 3, \"WCAG 1.4.11 graphical object\");\n add(`border on ${name}`, t.border, bg, 1.1, \"house rule: a hairline must be findable\");\n for (const [key, hex] of [\n [\"moneyIncome\", t.moneyIncome],\n [\"moneyExpense\", t.moneyExpense],\n [\"moneyNet\", t.moneyNet],\n ] as const) {\n add(`${key} on ${name}`, hex, bg, 4.5, \"WCAG 1.4.3 — these are rendered as TEXT\");\n }\n }\n\n add(\"brandContrast on brand\", t.brandContrast, t.brand, 4.5, \"WCAG 1.4.3 AA body text\");\n\n if (semantic) {\n for (const [name, fg] of [\n [\"danger\", semantic.danger],\n [\"warning\", semantic.warning],\n [\"info\", semantic.info],\n [\"success\", semantic.success],\n ] as const) {\n add(`${name} on bgSurface`, fg, t.bgSurface, 4.5, \"WCAG 1.4.3 — rendered as text\");\n }\n add(\"danger on dangerBg\", semantic.danger, semantic.dangerBg, 4.5, \"WCAG 1.4.3 — badge text\");\n add(\"warning on warningBg\", semantic.warning, semantic.warningBg, 4.5, \"WCAG 1.4.3 — badge text\");\n add(\"info on infoBg\", semantic.info, semantic.infoBg, 4.5, \"WCAG 1.4.3 — badge text\");\n add(\"success on successBg\", semantic.success, semantic.successBg, 4.5, \"WCAG 1.4.3 — badge text\");\n add(\n \"dangerContrast on danger\",\n semantic.dangerContrast,\n semantic.danger,\n 4.5,\n \"WCAG 1.4.3 AA body text\",\n );\n }\n\n const failures = checks.filter((c) => !c.passes);\n return { checks, failures, passes: failures.length === 0 };\n}\n\n/* ── Categorical chart ramp ───────────────────────────────────────────────── */\n\nexport interface ChartRampReport {\n colors: string[];\n /** Series pairs that are too close under normal vision or any simulated CVD. */\n collisions: Array<{ a: number; b: number; under: \"normal\" | CvdType; distance: number }>;\n /** Series that do not clear 3:1 against a surface they may be drawn on. */\n lowContrast: Array<{ index: number; surface: string; ratio: number }>;\n /** The worst pairwise separation, across normal vision and all three dichromacies. */\n minSeparation: number;\n /** The worst contrast any series reaches against any surface it was measured on. */\n minContrast: number;\n passes: boolean;\n}\n\n/**\n * The floor for pairwise separation in OKLab, across normal vision and each dichromacy.\n *\n * CALIBRATED, not chosen. Paul Tol's \"Muted\" set — which this package ships and which is\n * a well-regarded CVD-safe palette — bottoms out at 0.059 in its light variant and 0.032\n * in the lightened dark one. A threshold above 0.059 would fail a palette that is known\n * to work, which is worse than having no check at all: an audit that cries wolf gets\n * switched off. 0.05 sits just under the known-good case.\n */\nconst MIN_SEPARATION = 0.05;\n\n/**\n * **The categorical trade-off, measured.** At a SINGLE lightness, the most series that\n * can satisfy both the 3:1 fill contrast of WCAG 1.4.11 and {@link MIN_SEPARATION} under\n * dichromacy is FOUR. Searched exhaustively over starting hue and lightness:\n *\n * n=4 best separation 0.065 — both satisfiable\n * n=5 best separation 0.041 — not satisfiable\n * n=9 best separation 0.015 — not satisfiable\n *\n * The reason is structural: dichromacy collapses the red-green axis, so hue alone stops\n * distinguishing colours once you need more than a handful, and the remaining channel is\n * LIGHTNESS — the very thing a uniform-contrast ramp holds constant. Paul Tol's set\n * varies lightness deliberately and pays for it in contrast; that is not an oversight in\n * their palette, it is the only currency left.\n *\n * So above four series this deriver varies lightness too, and reports what it gave up\n * rather than pretending both constraints were met.\n *\n * NOTE ON WHAT THIS BOUND IS. It describes the PROBLEM, not a guarantee about\n * {@link deriveChartRamp}. That function fixes lightness and starts the hue wheel at the\n * brand's own hue rather than searching for the best start, so it reaches the bound only\n * where the brand happens to sit well: sweeping 72 brand hues against the default light\n * surfaces, 7 of 72 produced a passing 4-series ramp (12 of 72 on dark), and none passed\n * at 5 or 9. Read the report it returns; do not assume a pass.\n */\nconst SINGLE_LIGHTNESS_MAX_SERIES = 4;\n\n/**\n * A categorical ramp of `count` hues, evenly spaced and equal in perceived lightness,\n * then MEASURED for separability — including under each dichromacy.\n *\n * Offered but not used by default, and the distinction matters. Evenly spaced hues at\n * one lightness are a reasonable generic answer; Paul Tol's \"Muted\" set, which this\n * package ships, is a better specific one, because it was optimised against real\n * confusion lines rather than derived from a formula. So this exists for a consumer who\n * wants their charts to follow their brand and is willing to read the report — not as\n * a silent upgrade to the default.\n */\nexport function deriveChartRamp(\n brandHex: string,\n mode: ThemeMode,\n surfaces: string[],\n count = 9,\n): ChartRampReport {\n const brand = hexToOklch(brandHex) ?? { l: 0.6, c: 0.12, h: 264 };\n const base = mode === \"light\" ? 0.58 : 0.74;\n const c = Math.max(0.09, Math.min(brand.c, 0.15));\n // Up to four series, one lightness: a scale that varies lightness implies rank, and a\n // categorical one must not. Beyond four, lightness is the only channel left that\n // survives dichromacy — see SINGLE_LIGHTNESS_MAX_SERIES — so it alternates in a\n // three-step cycle, which keeps ADJACENT series (the ones a legend puts side by side)\n // at different lightnesses as well as different hues.\n const vary = count > SINGLE_LIGHTNESS_MAX_SERIES;\n const offsets = [0, mode === \"light\" ? -0.1 : 0.1, mode === \"light\" ? 0.08 : -0.08];\n const colors = Array.from({ length: count }, (_, i) =>\n oklchToHex({\n l: vary ? base + offsets[i % offsets.length] : base,\n c,\n h: (brand.h + (360 / count) * i) % 360,\n }),\n );\n\n return measureRamp(colors, surfaces);\n}\n\n/** Audit a ramp somebody else chose — the shipped Paul Tol set, say. */\nexport function auditChartRamp(colors: string[], surfaces: string[]): ChartRampReport {\n return measureRamp(colors, surfaces);\n}\n\nfunction measureRamp(colors: string[], surfaces: string[]): ChartRampReport {\n const collisions: ChartRampReport[\"collisions\"] = [];\n const rgbs = colors.map((hex) => parseHex(hex)).filter((v): v is NonNullable<typeof v> => !!v);\n let minSeparation = Infinity;\n for (let i = 0; i < rgbs.length; i++) {\n for (let j = i + 1; j < rgbs.length; j++) {\n const normal = deltaE(rgbs[i], rgbs[j]);\n minSeparation = Math.min(minSeparation, normal);\n if (normal < MIN_SEPARATION) {\n collisions.push({ a: i, b: j, under: \"normal\", distance: normal });\n }\n for (const type of [\"protanopia\", \"deuteranopia\", \"tritanopia\"] as const) {\n const d = deltaE(simulateCvd(rgbs[i], type), simulateCvd(rgbs[j], type));\n minSeparation = Math.min(minSeparation, d);\n if (d < MIN_SEPARATION) collisions.push({ a: i, b: j, under: type, distance: d });\n }\n }\n }\n\n const lowContrast: ChartRampReport[\"lowContrast\"] = [];\n let minContrast = Infinity;\n colors.forEach((hex, index) => {\n for (const surface of surfaces) {\n const ratio = contrast(hex, surface);\n minContrast = Math.min(minContrast, ratio);\n // WCAG 1.4.11: a graphical object carrying meaning needs 3:1 against what is\n // adjacent to it. A bar the same value as the card behind it has no boundary.\n if (ratio < 3) lowContrast.push({ index, surface, ratio });\n }\n });\n\n return {\n colors,\n collisions,\n lowContrast,\n minSeparation: Number.isFinite(minSeparation) ? minSeparation : 0,\n minContrast: Number.isFinite(minContrast) ? minContrast : 0,\n passes: collisions.length === 0 && lowContrast.length === 0,\n };\n}\n\n/** Convenience: the OKLCH of a hex, for a caller inspecting an anchor. */\nexport function describe(hex: string): Oklch | null {\n const rgb = parseHex(hex);\n return rgb ? rgbToOklch(rgb) : null;\n}\n"],"mappings":";AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA6GP,MAAM,WAA4F;AAAA,EAChG,QAAQ,EAAE,KAAK,IAAI,OAAO,GAAG;AAAA,EAC7B,SAAS,EAAE,KAAK,IAAI,OAAO,GAAG;AAAA,EAC9B,SAAS,EAAE,K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,GAAG,GAAG,GAAG,GAAG,OAAO,MAAM,UAAU,EAAE,CAAC;AAAA,MAClF;AAAA,IACF;AAAA,EACF;AAEA,QAAM,cAA8C,CAAC;AACrD,MAAI,cAAc;AAClB,SAAO,QAAQ,CAAC,KAAK,UAAU;AAC7B,eAAW,WAAW,UAAU;AAC9B,YAAM,QAAQ,SAAS,KAAK,OAAO;AACnC,oBAAc,KAAK,IAAI,aAAa,KAAK;AAGzC,UAAI,QAAQ,EAAG,aAAY,KAAK,EAAE,OAAO,SAAS,MAAM,CAAC;AAAA,IAC3D;AAAA,EACF,CAAC;AAED,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe,OAAO,SAAS,aAAa,IAAI,gBAAgB;AAAA,IAChE,aAAa,OAAO,SAAS,WAAW,IAAI,cAAc;AAAA,IAC1D,QAAQ,WAAW,WAAW,KAAK,YAAY,WAAW;AAAA,EAC5D;AACF;AAGO,SAAS,SAAS,KAA2B;AAClD,QAAM,MAAM,SAAS,GAAG;AACxB,SAAO,MAAM,WAAW,GAAG,IAAI;AACjC;","names":[]}
1
+ {"version":3,"sources":["../../src/theme/palette-derive.ts"],"sourcesContent":["import type { ThemeMode } from \"./theme-store\";\nimport type { TokenSet } from \"./palette-presets\";\nimport type { HeatStops } from \"./chart-palette\";\nimport {\n contrast,\n deltaE,\n toHex,\n hexToOklch,\n oklchToHex,\n parseHex,\n rgbToOklch,\n simulateCvd,\n solveLightness,\n} from \"./color\";\nimport type { CvdType, Oklch } from \"./color\";\nimport { brandSoft, hoverFill } from \"./contrast-tokens\";\n\n/**\n * Build a whole palette from one brand colour, plus any number of colours pinned by\n * hand, with every contrast ratio SOLVED rather than chosen and then hoped for.\n *\n * The presets this package shipped were assembled by eye and annotated with the ratios\n * they were believed to hold — `tokens.css` records \"7.0:1 and 4.8:1\", and\n * `palette-presets.ts` records \"2.67:1 … lifted they clear it at 3.30:1\". Nothing\n * computed any of them, and the audit found four of the nine default light chart hues\n * below the 3:1 that WCAG 1.4.11 requires of a graphical object. A comment is not a\n * test. Everything here is derived to a target and then measured, and\n * {@link auditPalette} returns the measurements so a caller can refuse a palette that\n * does not hold up.\n *\n * WHAT IS DERIVED AND WHAT IS NOT. The UI palette and the CATEGORICAL CHART RAMP solve\n * different problems and are deliberately kept apart. A UI colour needs contrast against\n * one known surface and carries a fixed meaning; a chart colour needs to stay separable\n * from eight unknown siblings, at roughly equal salience, with no implied order.\n * Optimising a set for one makes it worse at the other, which is why `deriveTokenSet`\n * leaves `chart` alone unless you explicitly ask for {@link deriveChartRamp}.\n */\n\n/* ── Inputs ───────────────────────────────────────────────────────────────── */\n\n/** A role whose hue may be pinned by the caller instead of chosen by the deriver. */\nexport type AnchorRole = \"brand\" | \"accent\" | \"danger\" | \"warning\" | \"success\" | \"info\";\n\nexport type PaletteAnchors = { brand: string } & Partial<Record<Exclude<AnchorRole, \"brand\">, string>>;\n\nexport interface DeriveOptions {\n anchors: PaletteAnchors;\n mode: ThemeMode;\n /**\n * How strongly the surfaces carry the brand's hue, 0–1 of the maximum useful tint.\n * 0 gives neutral greys; the shipped default is a visible warmth, because a page that\n * is very slightly the brand's hue reads as considered where a pure grey reads as\n * unstyled. Above ~0.5 the surfaces start competing with the content.\n */\n surfaceTint?: number;\n /** Contrast targets for the three text roles against the WORST surface. */\n textContrast?: { primary?: number; secondary?: number; muted?: number };\n}\n\n/* ── Outputs ──────────────────────────────────────────────────────────────── */\n\n/** The semantic layer, which lives in tokens.css rather than in `TokenSet`. */\nexport interface SemanticTokens {\n danger: string;\n dangerHover: string;\n dangerContrast: string;\n dangerBorder: string;\n /** The error line (invalid field, danger banner, destructive focus ring): as loud as\n * `dangerBorder` was before 0.15.5, so it keeps 3:1 against the surface. */\n dangerBorderStrong: string;\n dangerBg: string;\n warning: string;\n warningBorder: string;\n warningBg: string;\n info: string;\n infoBorder: string;\n infoBg: string;\n success: string;\n successBorder: string;\n successBg: string;\n /** Present only when a `accent` (secondary brand) anchor was supplied. */\n accent?: string;\n accentContrast?: string;\n accentBg?: string;\n}\n\nexport interface ContrastCheck {\n /** e.g. \"textMuted on bgPage\". */\n pair: string;\n ratio: number;\n /** What WCAG asks of this pair. */\n required: number;\n /** Which rule the requirement comes from, for a reader who wants to argue with it. */\n rule: string;\n passes: boolean;\n}\n\nexport interface ContrastReport {\n checks: ContrastCheck[];\n failures: ContrastCheck[];\n passes: boolean;\n}\n\nexport interface DerivedPalette {\n tokens: TokenSet;\n semantic: SemanticTokens;\n audit: ContrastReport;\n /** Compromises the deriver had to make, in plain words. Never silent. */\n warnings: string[];\n}\n\n/* ── The hue homes ────────────────────────────────────────────────────────── */\n\n/**\n * Where each semantic role wants to sit, and how far it may be pushed.\n *\n * A semantic colour is a convention before it is an aesthetic: danger is red because\n * every other interface the user has ever used made it red, and a \"danger\" button in\n * the brand's teal is a worse button however well it matches. So each role has a home\n * hue and a narrow licence to move — enough to get out of the brand's way when the\n * brand happens to live in the same neighbourhood, not enough to stop meaning what it\n * means. If it cannot get far enough, that is a warning, not a silent compromise.\n */\nconst HUE_HOME: Record<Exclude<AnchorRole, \"brand\" | \"accent\">, { hue: number; slack: number }> = {\n danger: { hue: 27, slack: 14 },\n warning: { hue: 75, slack: 16 },\n success: { hue: 150, slack: 20 },\n info: { hue: 240, slack: 22 },\n};\n\n/** Circular distance between two hue angles, 0–180. */\nfunction hueGap(a: number, b: number): number {\n const d = Math.abs(((a - b) % 360) + 360) % 360;\n return d > 180 ? 360 - d : d;\n}\n\n/**\n * Nudge `home` within `slack` to maximise the distance from every taken hue.\n *\n * Sampled rather than solved: the objective is a min-of-distances over a handful of\n * points on a short arc, which is piecewise-linear with kinks wherever the nearest\n * neighbour changes. Gradient methods stall on those kinks; 2° steps over a ±22° arc is\n * 23 evaluations of some trigonometry and cannot stall.\n */\nfunction placeHue(home: number, slack: number, taken: number[]): number {\n let best = home;\n let bestGap = Math.min(...taken.map((t) => hueGap(home, t)), 360);\n for (let d = -slack; d <= slack; d += 2) {\n const h = (home + d + 360) % 360;\n const gap = Math.min(...taken.map((t) => hueGap(h, t)), 360);\n // Ties go to the hue nearest home: a role should move only as far as it must.\n if (gap > bestGap + 1e-9) {\n best = h;\n bestGap = gap;\n }\n }\n return best;\n}\n\n/* ── Derivation ───────────────────────────────────────────────────────────── */\n\nconst SURFACE_L = {\n // Light: the PAGE is slightly darker than the cards on it, so a card reads as raised\n // without needing a shadow to say so. Matches the shipped presets' relationship.\n //\n // The light WELL is the page itself (0.33, docs/colour-roles-harmonization.md §5.3,\n // k26). Between the card and the page it sat 1.02–1.05:1 from the card it is inset\n // in, which is no well at all; at the page's lightness it stands out from the card\n // exactly as far as the card does from the page, and nothing re-solves, because the\n // page is already the surface every text role is solved against. Dark keeps its\n // well a step lighter than the card (1.11–1.13:1).\n light: { page: 0.912, surface: 0.945, surface2: 0.912 },\n dark: { page: 0.158, surface: 0.206, surface2: 0.249 },\n} as const;\n\n/**\n * What a hairline has to clear against the surface it divides.\n *\n * WCAG has nothing to say here — a decorative border is not a graphical object that\n * conveys information — so this is a house rule, and it is deliberately low. A border\n * that clears 3:1 is a RULE, not a hairline: it draws the eye to the box instead of to\n * what is in it. 1.5:1 is the point at which the edge is reliably findable without\n * becoming part of the composition.\n */\nconst BORDER_CONTRAST = 1.5;\n\n/** The most tint a surface can carry before it stops reading as a neutral ground. */\nconst MAX_SURFACE_CHROMA = 0.034;\n\nfunction surfaceSet(hue: number, mode: ThemeMode, tint: number) {\n const c = MAX_SURFACE_CHROMA * Math.max(0, Math.min(1, tint));\n const L = SURFACE_L[mode];\n const bgPage = oklchToHex({ l: L.page, c, h: hue });\n const bgSurface = oklchToHex({ l: L.surface, c, h: hue });\n const bgSurface2 = oklchToHex({ l: L.surface2, c, h: hue });\n // Solved, not guessed: a fixed lightness that looks right against a pale warm ground\n // disappears against a deep cold one, and both are reachable from the same `hue`\n // input. The border carries a little more chroma than the surfaces because at these\n // lightnesses a perfectly neutral hairline on a tinted ground reads as a wrong grey.\n const borderChroma = c * 1.6;\n // Solved against the surface the hairline is HARDEST to see on, not against one of\n // the three. Solving against `bgSurface` alone left it at 1.36:1 on `bgPage`, so the\n // target and the audit disagreed about the same border.\n const hardest = [bgPage, bgSurface, bgSurface2].reduce((a, b) =>\n contrast(a, mode === \"light\" ? \"#000000\" : \"#ffffff\") <\n contrast(b, mode === \"light\" ? \"#000000\" : \"#ffffff\")\n ? a\n : b,\n );\n const borderL = solveLightness(\n BORDER_CONTRAST,\n parseHex(hardest)!,\n hue,\n borderChroma,\n mode === \"light\" ? \"darker\" : \"lighter\",\n );\n return {\n bgPage,\n bgSurface,\n bgSurface2,\n border: oklchToHex({ l: borderL, c: borderChroma, h: hue }),\n };\n}\n\n/** Solve a colour at this hue that clears `target` against `against`, keeping chroma. */\nfunction solveAgainst(hue: number, chroma: number, target: number, against: string, mode: ThemeMode): string {\n const bg = parseHex(against)!;\n const l = solveLightness(target, bg, hue, chroma, mode === \"light\" ? \"darker\" : \"lighter\");\n return oklchToHex({ l, c: chroma, h: hue });\n}\n\n/** Whichever of near-white / near-black reads better ON `fill`. */\nfunction contrastOn(fill: string): string {\n const light = \"#ffffff\";\n const dark = \"#12100e\";\n return contrast(fill, light) >= contrast(fill, dark) ? light : dark;\n}\n\n/** A soft tint of `hue` sitting on the surface — a badge fill, not a button fill. */\nfunction tintOn(hue: number, chroma: number, surface: string, mode: ThemeMode): string {\n const s = hexToOklch(surface)!;\n // Toward the colour, but only far enough to be seen: these back TEXT of the same hue,\n // and a strong tint leaves the text nowhere to go.\n const l = mode === \"light\" ? s.l - 0.055 : s.l + 0.055;\n return oklchToHex({ l, c: Math.min(chroma * 0.45, 0.06), h: hue });\n}\n\nexport function derivePalette({\n anchors,\n mode,\n surfaceTint = 0.55,\n textContrast,\n}: DeriveOptions): DerivedPalette {\n const warnings: string[] = [];\n const brand = hexToOklch(anchors.brand);\n if (!brand) {\n throw new Error(\n `derivePalette: brand \"${anchors.brand}\" is not a #rgb or #rrggbb colour. ` +\n `Anchors must be hex — a named colour or an rgba() string cannot be converted.`,\n );\n }\n\n const targets = { primary: 10, secondary: 7, muted: 4.6, ...textContrast };\n\n // ── Surfaces, from the brand's hue.\n const surfaces = surfaceSet(brand.h, mode, surfaceTint);\n // Every text role is solved against the WORST of the three, so a token is legible\n // wherever it lands. Solving against `bgSurface` alone is the mistake that makes a\n // muted label fail on the page background it also sits on.\n const worstSurface = [surfaces.bgPage, surfaces.bgSurface, surfaces.bgSurface2].reduce((a, b) =>\n contrast(a, mode === \"light\" ? \"#000000\" : \"#ffffff\") <\n contrast(b, mode === \"light\" ? \"#000000\" : \"#ffffff\")\n ? a\n : b,\n );\n\n // ── Text. A trace of the brand hue keeps the greys from reading cold on a warm page.\n const textChroma = 0.014;\n const textPrimary = solveAgainst(brand.h, textChroma, targets.primary, worstSurface, mode);\n const textSecondary = solveAgainst(brand.h, textChroma, targets.secondary, worstSurface, mode);\n const textMuted = solveAgainst(brand.h, textChroma, targets.muted, worstSurface, mode);\n\n // The darkest fill text sits on (the lightest, in dark): the worst surface, or a\n // hovered row on the card (`--bg-hover`), which in light is a shade darker than the\n // page. The colours that are solved exactly to 4.5:1 — money, the semantic text — are\n // solved against this, so they hold on a hovered row too (0.33, §12.10). The text\n // roles above keep their margin (4.6:1 and up) and need no second solve.\n const hover = hoverFill({ textPrimary, bgSurface: surfaces.bgSurface });\n const worstText = [worstSurface, hover].reduce((a, b) =>\n contrast(a, mode === \"light\" ? \"#000000\" : \"#ffffff\") <\n contrast(b, mode === \"light\" ? \"#000000\" : \"#ffffff\")\n ? a\n : b,\n );\n\n // ── Brand. Keep the hue the caller asked for; move only the lightness, and only as\n // far as 3:1 against the worst surface — WCAG 1.4.11, since a brand-filled control is\n // a graphical object whose boundary has to be perceivable.\n const brandChroma = Math.max(brand.c, 0.06);\n const brandRatio = contrast(anchors.brand, worstSurface);\n // NORMALISED, never the caller's raw string. `parseHex` accepts \"4f46e5\" and \"#abc\",\n // and passing either through unchanged put a value in the TokenSet that is not a CSS\n // colour — it then fails silently at paint time, three layers from here.\n let brandHex =\n brandRatio >= 3\n ? toHex(parseHex(anchors.brand)!)\n : solveAgainst(brand.h, brandChroma, 3, worstSurface, mode);\n if (brandRatio < 3) {\n warnings.push(\n `brand ${anchors.brand} sits at ${brandRatio.toFixed(2)}:1 against the ${mode} surfaces, ` +\n `below the 3:1 WCAG 1.4.11 asks of a control boundary. Lightness was adjusted to ` +\n `${brandHex}; hue and chroma are unchanged.`,\n );\n }\n // `--brand-muted` is the brand AS TEXT — a soft brand chip's label, an outline chip, a\n // current link — and tokens.css derives it: 62 % brand into the ink. A brand solved\n // to 3:1 left it at 4.43–4.51:1 in three dark presets (0.33, §5.5), so it gets the\n // text floor here: the brand moves away from the surfaces, a step at a time, until its\n // muted form clears 4.5:1 on the worst fill and on its own soft chip, at rest\n // (`--brand-bg`) and hovered (`--brand-bg-hover`, the harder of the two: §12.11).\n const brandMutedWorst = (hex: string) => {\n const soft = brandSoft({ brand: hex, textPrimary, bgSurface: surfaces.bgSurface });\n return Math.min(\n contrast(soft.brandMuted, worstText),\n contrast(soft.brandMuted, soft.brandBg),\n contrast(soft.brandMuted, soft.brandBgHover),\n );\n };\n for (let i = 0; i < 40 && brandMutedWorst(brandHex) < 4.5; i++) {\n const lch = hexToOklch(brandHex)!;\n brandHex = oklchToHex({ ...lch, l: mode === \"light\" ? lch.l - 0.005 : lch.l + 0.005 });\n }\n if (brandMutedWorst(brandHex) < 4.5) {\n warnings.push(\n `the brand as text (--brand-muted) reaches only ${brandMutedWorst(brandHex).toFixed(2)}:1 ` +\n `against the ${mode} surfaces (needs 4.5:1).`,\n );\n }\n const brandLch = hexToOklch(brandHex)!;\n const brandContrast = contrastOn(brandHex);\n const brandHover = oklchToHex({\n ...brandLch,\n // Hover moves AWAY from the colour of the text on it (0.33, §5.5): darker under\n // white, lighter under a dark ink. It used to move away from the page, which in dark\n // lightened a fill that carries WHITE text, toward its own label: 4.07:1.\n l: brandContrast === \"#ffffff\" ? brandLch.l - 0.06 : brandLch.l + 0.06,\n });\n const onBrand = contrast(brandHex, brandContrast);\n if (onBrand < 4.5) {\n warnings.push(\n `text on the brand fill reaches only ${onBrand.toFixed(2)}:1 (needs 4.5:1). ` +\n `A mid-lightness, high-chroma brand cannot carry legible text at any ink; ` +\n `use it as an accent and keep primary buttons on a darker or lighter variant.`,\n );\n }\n\n // ── Semantic roles. Anchors are honoured exactly; the rest are placed away from the\n // brand and from each other, within each role's licence to move.\n const taken: number[] = [brandLch.h];\n const accentLch = anchors.accent ? hexToOklch(anchors.accent) : null;\n if (anchors.accent && !accentLch) {\n warnings.push(`accent \"${anchors.accent}\" is not a hex colour and was ignored.`);\n }\n if (accentLch) taken.push(accentLch.h);\n\n const semanticHue = {} as Record<Exclude<AnchorRole, \"brand\" | \"accent\">, number>;\n const semanticChroma = {} as Record<Exclude<AnchorRole, \"brand\" | \"accent\">, number>;\n for (const role of [\"danger\", \"warning\", \"success\", \"info\"] as const) {\n const pinned = anchors[role] ? hexToOklch(anchors[role]!) : null;\n if (anchors[role] && !pinned) {\n warnings.push(`${role} \"${anchors[role]}\" is not a hex colour and was ignored.`);\n }\n const home = HUE_HOME[role];\n const hue = pinned ? pinned.h : placeHue(home.hue, home.slack, taken);\n if (!pinned) {\n const gap = Math.min(...taken.map((t) => hueGap(hue, t)));\n if (gap < 20) {\n warnings.push(\n `${role} could only reach ${gap.toFixed(0)}° from the nearest pinned hue, which is ` +\n `too close to tell apart at a glance. Pin ${role} explicitly, or move the brand.`,\n );\n }\n }\n semanticHue[role] = hue;\n semanticChroma[role] = pinned ? Math.max(pinned.c, 0.08) : 0.13;\n taken.push(hue);\n }\n\n /**\n * A semantic colour has two jobs and therefore two backgrounds: plain text on the\n * page, and the label inside its own tinted badge. The badge is the harder of the\n * two — it is a step toward the colour — so solving only against the surface produced\n * a badge at 4.1:1 while the loose text passed, which is the failure mode that is\n * hardest to notice because nine tenths of the uses look fine.\n */\n const sem = (role: Exclude<AnchorRole, \"brand\" | \"accent\">) => {\n const hue = semanticHue[role];\n const chroma = semanticChroma[role];\n const bg = tintOn(hue, chroma, surfaces.bgSurface, mode);\n const onSurface = solveLightness(\n 4.5,\n parseHex(worstText)!,\n hue,\n chroma,\n mode === \"light\" ? \"darker\" : \"lighter\",\n );\n const onTint = solveLightness(\n 4.5,\n parseHex(bg)!,\n hue,\n chroma,\n mode === \"light\" ? \"darker\" : \"lighter\",\n );\n const l = mode === \"light\" ? Math.min(onSurface, onTint) : Math.max(onSurface, onTint);\n return oklchToHex({ l, c: chroma, h: hue });\n };\n\n const danger = sem(\"danger\");\n const dangerLch = hexToOklch(danger)!;\n const semantic: SemanticTokens = {\n danger,\n dangerHover: oklchToHex({\n ...dangerLch,\n l: mode === \"light\" ? dangerLch.l - 0.06 : dangerLch.l + 0.06,\n }),\n dangerContrast: contrastOn(danger),\n // The tone border follows its siblings' lightness in dark mode (warning 0.44, info\n // and success 0.45) — a soft frame; the strong line keeps the old, louder recipe.\n dangerBorder: oklchToHex({\n l: mode === \"light\" ? dangerLch.l + 0.22 : 0.45,\n c: semanticChroma.danger,\n h: semanticHue.danger,\n }),\n dangerBorderStrong: oklchToHex({\n l: mode === \"light\" ? dangerLch.l + 0.22 : dangerLch.l - 0.22,\n c: semanticChroma.danger,\n h: semanticHue.danger,\n }),\n dangerBg: tintOn(semanticHue.danger, semanticChroma.danger, surfaces.bgSurface, mode),\n warning: sem(\"warning\"),\n warningBorder: oklchToHex({\n l: mode === \"light\" ? 0.82 : 0.44,\n c: semanticChroma.warning,\n h: semanticHue.warning,\n }),\n warningBg: tintOn(semanticHue.warning, semanticChroma.warning, surfaces.bgSurface, mode),\n info: sem(\"info\"),\n infoBorder: oklchToHex({\n l: mode === \"light\" ? 0.8 : 0.45,\n c: semanticChroma.info,\n h: semanticHue.info,\n }),\n infoBg: tintOn(semanticHue.info, semanticChroma.info, surfaces.bgSurface, mode),\n success: sem(\"success\"),\n successBorder: oklchToHex({\n l: mode === \"light\" ? 0.81 : 0.45,\n c: semanticChroma.success,\n h: semanticHue.success,\n }),\n successBg: tintOn(semanticHue.success, semanticChroma.success, surfaces.bgSurface, mode),\n };\n\n if (accentLch) {\n const accent = solveAgainst(accentLch.h, Math.max(accentLch.c, 0.06), 3, worstSurface, mode);\n semantic.accent = accent;\n semantic.accentContrast = contrastOn(accent);\n semantic.accentBg = tintOn(accentLch.h, Math.max(accentLch.c, 0.06), surfaces.bgSurface, mode);\n }\n\n // ── Money. A THIRD system again: these are data colours with fixed meanings, and the\n // one rule that outranks everything is that income and expense must never be the\n // red/green pair — which is why the shipped presets use teal/amber/violet. Derived\n // here at fixed hues rather than from the brand, for the same reason `--danger` is:\n // a consumer who rebrands does not thereby change what \"money out\" looks like.\n const money = (hue: number, target: number) => solveAgainst(hue, 0.12, target, worstText, mode);\n const moneyIncome = money(175, 4.5);\n const moneyExpense = money(70, 4.5);\n const moneyNet = money(300, 4.5);\n // \"No money has moved\": a quiet grey at a fixed lightness, but printed as TEXT (the\n // numpad's sign, a future row's figure), so it gets the text floor too (0.33). The\n // fixed lightness left it at 4.24:1 on four light pages.\n const neutralFloor = solveLightness(4.5, parseHex(worstText)!, brand.h, 0.012, mode === \"light\" ? \"darker\" : \"lighter\");\n const moneyNeutral = oklchToHex({\n l: mode === \"light\" ? Math.min(0.52, neutralFloor) : Math.max(0.72, neutralFloor),\n c: 0.012,\n h: brand.h,\n });\n\n const tokens: TokenSet = {\n ...surfaces,\n textPrimary,\n textSecondary,\n textMuted,\n brand: brandHex,\n brandHover,\n brandContrast,\n moneyIncome,\n moneyExpense,\n moneyNet,\n moneyNeutral,\n // Left alone. See the note at the top of this file about why the categorical ramp is\n // not derived from the brand unless the caller asks.\n //\n // ⚠️ EMPTY, not absent: a caller who hands this straight to `applyTokenSet` keeps\n // whatever `--chart-1…9` were already on the element. That is deliberate — the ramp\n // is a separate decision and clearing it would leave charts unpainted — but it means\n // a derived palette applied over another preset is a MIX until you also supply a\n // ramp. `deriveChartRamp` is how you supply one.\n chart: [],\n heat: deriveHeat(moneyIncome, moneyExpense, surfaces, mode),\n };\n\n return { tokens, semantic, audit: auditPalette(tokens, semantic), warnings };\n}\n\n/**\n * Heatmap stops, reusing the money pair.\n *\n * `under` is the good direction and `over` the bad one, at the SAME hues as\n * `moneyIncome`/`moneyExpense` — so a heatmap cell and the figure printed beside it\n * agree about which way is which, rather than each inventing its own convention.\n */\nfunction deriveHeat(\n income: string,\n expense: string,\n surfaces: { bgSurface2: string },\n mode: ThemeMode,\n): HeatStops {\n const exp = hexToOklch(expense)!;\n return {\n neutral: surfaces.bgSurface2,\n under: income,\n over: expense,\n seqLow: oklchToHex({ l: mode === \"light\" ? 0.93 : 0.26, c: 0.05, h: exp.h }),\n seqHigh: expense,\n empty: mode === \"light\" ? \"rgba(120,110,95,0.14)\" : \"rgba(160,170,190,0.10)\",\n };\n}\n\n/* ── Audit ────────────────────────────────────────────────────────────────── */\n\n/**\n * Measure every pair that has a requirement, and say which ones fail.\n *\n * This is the part the shipped presets were missing. `derivePalette` runs it on the way\n * out, and the preset test runs it over everything the package ships, so a palette that\n * does not hold up cannot be merged with a comment claiming that it does.\n */\nexport function auditPalette(t: TokenSet, semantic?: SemanticTokens): ContrastReport {\n const checks: ContrastCheck[] = [];\n const surfaces: Array<[string, string]> = [\n [\"bgPage\", t.bgPage],\n [\"bgSurface\", t.bgSurface],\n [\"bgSurface2\", t.bgSurface2],\n ];\n // A hovered row on the card (`--bg-hover`) carries the same text as the card, and in\n // light it is the darkest fill that text sits on (0.33, §12.10). Text is measured on\n // it; the brand fill and the hairline, which are not text, are not.\n const hover = hoverFill(t);\n const textGrounds: Array<[string, string]> = [...surfaces, [\"bgHover\", hover]];\n // `--brand-muted`, `--brand-bg` and `--brand-bg-hover`, mixed as tokens.css mixes them.\n const { brandMuted, brandBg, brandBgHover } = brandSoft(t);\n\n const add = (pair: string, fg: string, bg: string, required: number, rule: string) => {\n const ratio = contrast(fg, bg);\n checks.push({ pair, ratio, required, rule, passes: ratio >= required - 0.05 });\n };\n\n for (const [name, bg] of surfaces) {\n add(`brand on ${name}`, t.brand, bg, 3, \"WCAG 1.4.11 graphical object\");\n add(`border on ${name}`, t.border, bg, 1.1, \"house rule: a hairline must be findable\");\n }\n for (const [name, bg] of textGrounds) {\n add(`textPrimary on ${name}`, t.textPrimary, bg, 7, \"WCAG 1.4.6 AAA body text\");\n add(`textSecondary on ${name}`, t.textSecondary, bg, 4.5, \"WCAG 1.4.3 AA body text\");\n add(`textMuted on ${name}`, t.textMuted, bg, 4.5, \"WCAG 1.4.3 AA body text\");\n add(`brandMuted on ${name}`, brandMuted, bg, 4.5, \"WCAG 1.4.3 — the brand as text\");\n for (const [key, hex] of [\n [\"moneyIncome\", t.moneyIncome],\n [\"moneyExpense\", t.moneyExpense],\n [\"moneyNet\", t.moneyNet],\n // Not a figure's colour but still printed as one (the numpad's sign, a future\n // row's amount) — measured since 0.33, when it was found at 4.24:1.\n [\"moneyNeutral\", t.moneyNeutral],\n ] as const) {\n add(`${key} on ${name}`, hex, bg, 4.5, \"WCAG 1.4.3 — these are rendered as TEXT\");\n }\n }\n\n add(\"brandContrast on brand\", t.brandContrast, t.brand, 4.5, \"WCAG 1.4.3 AA body text\");\n // A hovered brand button carries the same label (0.33): the derived dark presets\n // lightened the hover toward their white label and left it at 4.07:1.\n add(\"brandContrast on brandHover\", t.brandContrast, t.brandHover, 4.5, \"WCAG 1.4.3 AA body text\");\n add(\"brandMuted on brandBg\", brandMuted, brandBg, 4.5, \"WCAG 1.4.3 — a soft brand chip's label\");\n // The same label on the chip hovered (§12.11): a current link, a selected day. At 70 %\n // brand the muted text read 4.08–4.42:1 here (Default and Moss light; Ink, Moss, Plum\n // and Contrast dark).\n add(\"brandMuted on brandBgHover\", brandMuted, brandBgHover, 4.5, \"WCAG 1.4.3 — a hovered soft brand chip's label\");\n\n if (semantic) {\n for (const [name, fg] of [\n [\"danger\", semantic.danger],\n [\"warning\", semantic.warning],\n [\"info\", semantic.info],\n [\"success\", semantic.success],\n ] as const) {\n add(`${name} on bgSurface`, fg, t.bgSurface, 4.5, \"WCAG 1.4.3 — rendered as text\");\n add(`${name} on bgHover`, fg, hover, 4.5, \"WCAG 1.4.3 — rendered as text, on a hovered row\");\n }\n add(\"danger on dangerBg\", semantic.danger, semantic.dangerBg, 4.5, \"WCAG 1.4.3 — badge text\");\n add(\"warning on warningBg\", semantic.warning, semantic.warningBg, 4.5, \"WCAG 1.4.3 — badge text\");\n add(\"info on infoBg\", semantic.info, semantic.infoBg, 4.5, \"WCAG 1.4.3 — badge text\");\n add(\"success on successBg\", semantic.success, semantic.successBg, 4.5, \"WCAG 1.4.3 — badge text\");\n add(\n \"dangerContrast on danger\",\n semantic.dangerContrast,\n semantic.danger,\n 4.5,\n \"WCAG 1.4.3 AA body text\",\n );\n }\n\n const failures = checks.filter((c) => !c.passes);\n return { checks, failures, passes: failures.length === 0 };\n}\n\n/* ── Categorical chart ramp ───────────────────────────────────────────────── */\n\nexport interface ChartRampReport {\n colors: string[];\n /** Series pairs that are too close under normal vision or any simulated CVD. */\n collisions: Array<{ a: number; b: number; under: \"normal\" | CvdType; distance: number }>;\n /** Series that do not clear 3:1 against a surface they may be drawn on. */\n lowContrast: Array<{ index: number; surface: string; ratio: number }>;\n /** The worst pairwise separation, across normal vision and all three dichromacies. */\n minSeparation: number;\n /** The worst contrast any series reaches against any surface it was measured on. */\n minContrast: number;\n passes: boolean;\n}\n\n/**\n * The floor for pairwise separation in OKLab, across normal vision and each dichromacy.\n *\n * CALIBRATED, not chosen. Paul Tol's \"Muted\" set — which this package ships and which is\n * a well-regarded CVD-safe palette — bottoms out at 0.059 in its light variant and 0.032\n * in the lightened dark one. A threshold above 0.059 would fail a palette that is known\n * to work, which is worse than having no check at all: an audit that cries wolf gets\n * switched off. 0.05 sits just under the known-good case.\n */\nconst MIN_SEPARATION = 0.05;\n\n/**\n * **The categorical trade-off, measured.** At a SINGLE lightness, the most series that\n * can satisfy both the 3:1 fill contrast of WCAG 1.4.11 and {@link MIN_SEPARATION} under\n * dichromacy is FOUR. Searched exhaustively over starting hue and lightness:\n *\n * n=4 best separation 0.065 — both satisfiable\n * n=5 best separation 0.041 — not satisfiable\n * n=9 best separation 0.015 — not satisfiable\n *\n * The reason is structural: dichromacy collapses the red-green axis, so hue alone stops\n * distinguishing colours once you need more than a handful, and the remaining channel is\n * LIGHTNESS — the very thing a uniform-contrast ramp holds constant. Paul Tol's set\n * varies lightness deliberately and pays for it in contrast; that is not an oversight in\n * their palette, it is the only currency left.\n *\n * So above four series this deriver varies lightness too, and reports what it gave up\n * rather than pretending both constraints were met.\n *\n * NOTE ON WHAT THIS BOUND IS. It describes the PROBLEM, not a guarantee about\n * {@link deriveChartRamp}. That function fixes lightness and starts the hue wheel at the\n * brand's own hue rather than searching for the best start, so it reaches the bound only\n * where the brand happens to sit well: sweeping 72 brand hues against the default light\n * surfaces, 7 of 72 produced a passing 4-series ramp (12 of 72 on dark), and none passed\n * at 5 or 9. Read the report it returns; do not assume a pass.\n */\nconst SINGLE_LIGHTNESS_MAX_SERIES = 4;\n\n/**\n * A categorical ramp of `count` hues, evenly spaced and equal in perceived lightness,\n * then MEASURED for separability — including under each dichromacy.\n *\n * Offered but not used by default, and the distinction matters. Evenly spaced hues at\n * one lightness are a reasonable generic answer; Paul Tol's \"Muted\" set, which this\n * package ships, is a better specific one, because it was optimised against real\n * confusion lines rather than derived from a formula. So this exists for a consumer who\n * wants their charts to follow their brand and is willing to read the report — not as\n * a silent upgrade to the default.\n */\nexport function deriveChartRamp(\n brandHex: string,\n mode: ThemeMode,\n surfaces: string[],\n count = 9,\n): ChartRampReport {\n const brand = hexToOklch(brandHex) ?? { l: 0.6, c: 0.12, h: 264 };\n const base = mode === \"light\" ? 0.58 : 0.74;\n const c = Math.max(0.09, Math.min(brand.c, 0.15));\n // Up to four series, one lightness: a scale that varies lightness implies rank, and a\n // categorical one must not. Beyond four, lightness is the only channel left that\n // survives dichromacy — see SINGLE_LIGHTNESS_MAX_SERIES — so it alternates in a\n // three-step cycle, which keeps ADJACENT series (the ones a legend puts side by side)\n // at different lightnesses as well as different hues.\n const vary = count > SINGLE_LIGHTNESS_MAX_SERIES;\n const offsets = [0, mode === \"light\" ? -0.1 : 0.1, mode === \"light\" ? 0.08 : -0.08];\n const colors = Array.from({ length: count }, (_, i) =>\n oklchToHex({\n l: vary ? base + offsets[i % offsets.length] : base,\n c,\n h: (brand.h + (360 / count) * i) % 360,\n }),\n );\n\n return measureRamp(colors, surfaces);\n}\n\n/** Audit a ramp somebody else chose — the shipped Paul Tol set, say. */\nexport function auditChartRamp(colors: string[], surfaces: string[]): ChartRampReport {\n return measureRamp(colors, surfaces);\n}\n\nfunction measureRamp(colors: string[], surfaces: string[]): ChartRampReport {\n const collisions: ChartRampReport[\"collisions\"] = [];\n const rgbs = colors.map((hex) => parseHex(hex)).filter((v): v is NonNullable<typeof v> => !!v);\n let minSeparation = Infinity;\n for (let i = 0; i < rgbs.length; i++) {\n for (let j = i + 1; j < rgbs.length; j++) {\n const normal = deltaE(rgbs[i], rgbs[j]);\n minSeparation = Math.min(minSeparation, normal);\n if (normal < MIN_SEPARATION) {\n collisions.push({ a: i, b: j, under: \"normal\", distance: normal });\n }\n for (const type of [\"protanopia\", \"deuteranopia\", \"tritanopia\"] as const) {\n const d = deltaE(simulateCvd(rgbs[i], type), simulateCvd(rgbs[j], type));\n minSeparation = Math.min(minSeparation, d);\n if (d < MIN_SEPARATION) collisions.push({ a: i, b: j, under: type, distance: d });\n }\n }\n }\n\n const lowContrast: ChartRampReport[\"lowContrast\"] = [];\n let minContrast = Infinity;\n colors.forEach((hex, index) => {\n for (const surface of surfaces) {\n const ratio = contrast(hex, surface);\n minContrast = Math.min(minContrast, ratio);\n // WCAG 1.4.11: a graphical object carrying meaning needs 3:1 against what is\n // adjacent to it. A bar the same value as the card behind it has no boundary.\n if (ratio < 3) lowContrast.push({ index, surface, ratio });\n }\n });\n\n return {\n colors,\n collisions,\n lowContrast,\n minSeparation: Number.isFinite(minSeparation) ? minSeparation : 0,\n minContrast: Number.isFinite(minContrast) ? minContrast : 0,\n passes: collisions.length === 0 && lowContrast.length === 0,\n };\n}\n\n/** Convenience: the OKLCH of a hex, for a caller inspecting an anchor. */\nexport function describe(hex: string): Oklch | null {\n const rgb = parseHex(hex);\n return rgb ? rgbToOklch(rgb) : null;\n}\n"],"mappings":";AAGA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,WAAW,iBAAiB;AA4GrC,MAAM,WAA4F;AAAA,EAChG,QAAQ,EAAE,KAAK,IAAI,OAAO,GAAG;AAAA,EAC7B,SAAS,EAAE,KAAK,IAAI,OAAO,GAAG;AAAA,EAC9B,SAAS,EAAE,KAAK,KAAK,OAAO,GAAG;AAAA,EAC/B,MAAM,EAAE,KAAK,KAAK,OAAO,GAAG;AAC9B;AAGA,SAAS,OAAO,GAAW,GAAmB;AAC5C,QAAM,IAAI,KAAK,KAAM,IAAI,KAAK,MAAO,GAAG,IAAI;AAC5C,SAAO,IAAI,MAAM,MAAM,IAAI;AAC7B;AAUA,SAAS,SAAS,MAAc,OAAe,OAAyB;AACtE,MAAI,OAAO;AACX,MAAI,UAAU,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC,GAAG,GAAG;AAChE,WAAS,IAAI,CAAC,OAAO,KAAK,OAAO,KAAK,GAAG;AACvC,UAAM,KAAK,OAAO,IAAI,OAAO;AAC7B,UAAM,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC,GAAG,GAAG;AAE3D,QAAI,MAAM,UAAU,MAAM;AACxB,aAAO;AACP,gBAAU;AAAA,IACZ;AAAA,EACF;AACA,SAAO;AACT;AAIA,MAAM,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUhB,OAAO,EAAE,M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;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA,eAAe,OAAO,SAAS,aAAa,IAAI,gBAAgB;AAAA,IAChE,aAAa,OAAO,SAAS,WAAW,IAAI,cAAc;AAAA,IAC1D,QAAQ,WAAW,WAAW,KAAK,YAAY,WAAW;AAAA,EAC5D;AACF;AAGO,SAAS,SAAS,KAA2B;AAClD,QAAM,MAAM,SAAS,GAAG;AACxB,SAAO,MAAM,WAAW,GAAG,IAAI;AACjC;","names":[]}
@@ -8,7 +8,9 @@ const DEFAULT_PRESET = {
8
8
  // Solar Dusk (light) surfaces, with the brand unified to indigo (see above).
9
9
  bgPage: "#ede3cf",
10
10
  bgSurface: "#f6ecd9",
11
- bgSurface2: "#f3ead6",
11
+ // The well is the page in light (0.33, k26): #f3ead6 stood 1.02:1 from the card it
12
+ // is inset in. Every light preset does the same; see SURFACE_L in palette-derive.ts.
13
+ bgSurface2: "#ede3cf",
12
14
  border: "#e2d6bd",
13
15
  textPrimary: "#463f33",
14
16
  textSecondary: "#50493c",
@@ -70,7 +72,7 @@ const ALTERNATIVE_PRESETS = [
70
72
  light: {
71
73
  bgPage: "#ece5d6",
72
74
  bgSurface: "#f5efe3",
73
- bgSurface2: "#efe9dc",
75
+ bgSurface2: "#ece5d6",
74
76
  border: "#e2dcce",
75
77
  textPrimary: "#2b2622",
76
78
  textSecondary: "#4f4a44",
@@ -125,7 +127,7 @@ const ALTERNATIVE_PRESETS = [
125
127
  light: {
126
128
  bgPage: "#e2e7ef",
127
129
  bgSurface: "#f0f3f8",
128
- bgSurface2: "#e1e6ee",
130
+ bgSurface2: "#e2e7ef",
129
131
  border: "#d3dae6",
130
132
  textPrimary: "#2e3440",
131
133
  textSecondary: "#454b56",
@@ -180,7 +182,7 @@ const ALTERNATIVE_PRESETS = [
180
182
  light: {
181
183
  bgPage: "#e8eaf2",
182
184
  bgSurface: "#f6f7fb",
183
- bgSurface2: "#eef1f8",
185
+ bgSurface2: "#e8eaf2",
184
186
  border: "#dadfeb",
185
187
  textPrimary: "#1b1f2e",
186
188
  textSecondary: "#494d5a",
@@ -236,7 +238,7 @@ const ALTERNATIVE_PRESETS = [
236
238
  light: {
237
239
  bgPage: "#ede3cf",
238
240
  bgSurface: "#f6ecd9",
239
- bgSurface2: "#f3ead6",
241
+ bgSurface2: "#ede3cf",
240
242
  border: "#e2d6bd",
241
243
  textPrimary: "#463f33",
242
244
  textSecondary: "#50493c",
@@ -291,7 +293,7 @@ const ALTERNATIVE_PRESETS = [
291
293
  light: {
292
294
  bgPage: "#ececec",
293
295
  bgSurface: "#f7f7f7",
294
- bgSurface2: "#f4f4f5",
296
+ bgSurface2: "#ececec",
295
297
  border: "#e4e4e7",
296
298
  textPrimary: "#18181b",
297
299
  textSecondary: "#4e4e50",
@@ -392,7 +394,7 @@ const DERIVED_PRESETS = [
392
394
  light: {
393
395
  bgPage: "#dce2ef",
394
396
  bgSurface: "#e6edfa",
395
- bgSurface2: "#e1e8f5",
397
+ bgSurface2: "#dce2ef",
396
398
  border: "#b0bace",
397
399
  textPrimary: "#2e3139",
398
400
  textSecondary: "#454950",
@@ -400,14 +402,14 @@ const DERIVED_PRESETS = [
400
402
  brand: "#2f5fd0",
401
403
  brandHover: "#1f4cbc",
402
404
  brandContrast: "#ffffff",
403
- moneyIncome: "#00735f",
405
+ moneyIncome: "#00725e",
404
406
  moneyExpense: "#8e5900",
405
407
  moneyNet: "#7356a2",
406
- moneyNeutral: "#656970",
408
+ moneyNeutral: "#61656c",
407
409
  chart: PAUL_TOL.light,
408
410
  heat: {
409
- neutral: "#e1e8f5",
410
- under: "#00735f",
411
+ neutral: "#dce2ef",
412
+ under: "#00725e",
411
413
  over: "#8e5900",
412
414
  seqLow: "#fee3c5",
413
415
  seqHigh: "#8e5900",
@@ -422,8 +424,8 @@ const DERIVED_PRESETS = [
422
424
  textPrimary: "#c7ccd5",
423
425
  textSecondary: "#a7abb4",
424
426
  textMuted: "#858992",
425
- brand: "#3364d5",
426
- brandHover: "#4477ea",
427
+ brand: "#3466d7",
428
+ brandHover: "#2353c3",
427
429
  brandContrast: "#ffffff",
428
430
  moneyIncome: "#00997f",
429
431
  moneyExpense: "#b77b29",
@@ -447,7 +449,7 @@ const DERIVED_PRESETS = [
447
449
  light: {
448
450
  bgPage: "#d8e6dd",
449
451
  bgSurface: "#e3f1e8",
450
- bgSurface2: "#deece3",
452
+ bgSurface2: "#d8e6dd",
451
453
  border: "#abbfb2",
452
454
  textPrimary: "#2c342e",
453
455
  textSecondary: "#434b45",
@@ -456,16 +458,16 @@ const DERIVED_PRESETS = [
456
458
  brandHover: "#196842",
457
459
  brandContrast: "#ffffff",
458
460
  moneyIncome: "#00735f",
459
- moneyExpense: "#8f5a00",
460
- moneyNet: "#7457a3",
461
- moneyNeutral: "#646b66",
461
+ moneyExpense: "#8e5900",
462
+ moneyNet: "#7356a2",
463
+ moneyNeutral: "#5f6762",
462
464
  chart: PAUL_TOL.light,
463
465
  heat: {
464
- neutral: "#deece3",
466
+ neutral: "#d8e6dd",
465
467
  under: "#00735f",
466
- over: "#8f5a00",
467
- seqLow: "#fee3c4",
468
- seqHigh: "#8f5a00",
468
+ over: "#8e5900",
469
+ seqLow: "#fee3c5",
470
+ seqHigh: "#8e5900",
469
471
  empty: "rgba(120,110,95,0.14)"
470
472
  }
471
473
  },
@@ -477,8 +479,8 @@ const DERIVED_PRESETS = [
477
479
  textPrimary: "#c5cfc9",
478
480
  textSecondary: "#a4aea8",
479
481
  textMuted: "#838c86",
480
- brand: "#2f7a52",
481
- brandHover: "#428c63",
482
+ brand: "#317b53",
483
+ brandHover: "#1c6943",
482
484
  brandContrast: "#ffffff",
483
485
  moneyIncome: "#009a80",
484
486
  moneyExpense: "#b87b2a",
@@ -502,7 +504,7 @@ const DERIVED_PRESETS = [
502
504
  light: {
503
505
  bgPage: "#e7dfea",
504
506
  bgSurface: "#f2e9f5",
505
- bgSurface2: "#ece4ef",
507
+ bgSurface2: "#e7dfea",
506
508
  border: "#c2b6c6",
507
509
  textPrimary: "#342f36",
508
510
  textSecondary: "#4c474e",
@@ -511,16 +513,16 @@ const DERIVED_PRESETS = [
511
513
  brandHover: "#692d7d",
512
514
  brandContrast: "#ffffff",
513
515
  moneyIncome: "#00725e",
514
- moneyExpense: "#8e5900",
515
- moneyNet: "#7356a2",
516
- moneyNeutral: "#6c676e",
516
+ moneyExpense: "#8d5900",
517
+ moneyNet: "#7355a2",
518
+ moneyNeutral: "#676369",
517
519
  chart: PAUL_TOL.light,
518
520
  heat: {
519
- neutral: "#ece4ef",
521
+ neutral: "#e7dfea",
520
522
  under: "#00725e",
521
- over: "#8e5900",
522
- seqLow: "#fee3c5",
523
- seqHigh: "#8e5900",
523
+ over: "#8d5900",
524
+ seqLow: "#fee3c4",
525
+ seqHigh: "#8d5900",
524
526
  empty: "rgba(120,110,95,0.14)"
525
527
  }
526
528
  },
@@ -532,8 +534,8 @@ const DERIVED_PRESETS = [
532
534
  textPrimary: "#d0cad3",
533
535
  textSecondary: "#afa9b1",
534
536
  textMuted: "#8d878f",
535
- brand: "#8f52a4",
536
- brandHover: "#a264b7",
537
+ brand: "#9153a6",
538
+ brandHover: "#7f4193",
537
539
  brandContrast: "#ffffff",
538
540
  moneyIncome: "#00997f",
539
541
  moneyExpense: "#b77b29",
@@ -557,7 +559,7 @@ const DERIVED_PRESETS = [
557
559
  light: {
558
560
  bgPage: "#e0e2e5",
559
561
  bgSurface: "#ebedef",
560
- bgSurface2: "#e6e8ea",
562
+ bgSurface2: "#e0e2e5",
561
563
  border: "#b7babe",
562
564
  textPrimary: "#191d24",
563
565
  textSecondary: "#373c44",
@@ -565,17 +567,17 @@ const DERIVED_PRESETS = [
565
567
  brand: "#1f2937",
566
568
  brandHover: "#111b28",
567
569
  brandContrast: "#ffffff",
568
- moneyIncome: "#00735f",
569
- moneyExpense: "#8e5900",
570
- moneyNet: "#7456a2",
571
- moneyNeutral: "#656970",
570
+ moneyIncome: "#00715d",
571
+ moneyExpense: "#8d5800",
572
+ moneyNet: "#7255a1",
573
+ moneyNeutral: "#5f646b",
572
574
  chart: PAUL_TOL.light,
573
575
  heat: {
574
- neutral: "#e6e8ea",
575
- under: "#00735f",
576
- over: "#8e5900",
576
+ neutral: "#e0e2e5",
577
+ under: "#00715d",
578
+ over: "#8d5800",
577
579
  seqLow: "#fee3c5",
578
- seqHigh: "#8e5900",
580
+ seqHigh: "#8d5800",
579
581
  empty: "rgba(120,110,95,0.14)"
580
582
  }
581
583
  },
@@ -588,7 +590,7 @@ const DERIVED_PRESETS = [
588
590
  textSecondary: "#b7bdc5",
589
591
  textMuted: "#9197a0",
590
592
  brand: "#546c8d",
591
- brandHover: "#657e9f",
593
+ brandHover: "#445b7b",
592
594
  brandContrast: "#ffffff",
593
595
  moneyIncome: "#00997f",
594
596
  moneyExpense: "#b77b29",