@riverbankcms/sdk 0.181.0 → 0.183.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 (226) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +49 -3
  3. package/dist/_dts/{BlocksIslandsHydrator-CVCasDPz.d.ts → BlocksIslandsHydrator-X1_G96iN.d.ts} +1 -1
  4. package/dist/_dts/{Page-Dtj2Ui3S.d.ts → Page-CEqZJZEE.d.ts} +7 -7
  5. package/dist/_dts/{SdkPreviewMode-D1f_60WW.d.ts → SdkPreviewMode-DQejfbXL.d.ts} +2 -2
  6. package/dist/_dts/{client-Chr9pNVW.d.ts → client-B_B_amKD.d.ts} +2 -3
  7. package/dist/_dts/{content-types-kjccgopX.d.ts → content-types-Dhx5Ocvx.d.ts} +9 -16
  8. package/dist/_dts/{contracts-BodaiS00.d.ts → contracts-FeOnfoa1.d.ts} +3 -3
  9. package/dist/_dts/{generatePageMetadata-BS6kaJFp.d.ts → generatePageMetadata-m70J6tit.d.ts} +2 -2
  10. package/dist/_dts/{index-Brl6_I2j.d.ts → index-BOpUh8kO.d.ts} +1 -1
  11. package/dist/_dts/{index-CJkefwYh.d.ts → index-Bizdaxji.d.ts} +2 -2
  12. package/dist/_dts/{index-Diqt0PvG.d.ts → index-BxCmCit0.d.ts} +1 -1
  13. package/dist/_dts/{index-DG0OvBs0.d.ts → index-CjAkEWAp.d.ts} +4 -4
  14. package/dist/_dts/{index-D1WpKwQe.d.ts → index-iuFrbIjt.d.ts} +1 -1
  15. package/dist/_dts/{index-Dy50xUMK.d.ts → index-liuhlOX7.d.ts} +2 -2
  16. package/dist/_dts/{loadContent-BgxshKrA.d.ts → loadContent-D4wrTIIw.d.ts} +7 -7
  17. package/dist/_dts/{request-CA0izds5.d.ts → request-Gn0O1blj.d.ts} +25042 -23761
  18. package/dist/_dts/{resolveBlockData-ChQmwEd3.d.ts → resolveBlockData-D5duwuqS.d.ts} +5 -5
  19. package/dist/_dts/{resolvePageContent-BvGyvblj.d.ts → resolvePageContent-xzJ3c9Na.d.ts} +1 -1
  20. package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
  21. package/dist/_dts/sdk/src/client/types.d.ts +2 -2
  22. package/dist/_dts/sdk/src/client.d.ts +7 -7
  23. package/dist/_dts/sdk/src/config/index.d.ts +7 -7
  24. package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
  25. package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
  26. package/dist/_dts/sdk/src/data/dataLoaderContext.d.ts +2 -2
  27. package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +1 -1
  28. package/dist/_dts/sdk/src/data/types.d.ts +2 -2
  29. package/dist/_dts/sdk/src/gifting/client.d.ts +1 -1
  30. package/dist/_dts/sdk/src/index.d.ts +8 -8
  31. package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
  32. package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
  33. package/dist/_dts/sdk/src/navigation/index.d.ts +3 -3
  34. package/dist/_dts/sdk/src/next/index.d.ts +7 -7
  35. package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
  36. package/dist/_dts/sdk/src/page-converter/index.d.ts +3 -3
  37. package/dist/_dts/sdk/src/portal/client.d.ts +1 -1
  38. package/dist/_dts/sdk/src/portal/index.d.ts +1 -1
  39. package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
  40. package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
  41. package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
  42. package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
  43. package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
  44. package/dist/_dts/sdk/src/rendering/components/pageShared.d.ts +1 -1
  45. package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +1 -1
  46. package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +4 -4
  47. package/dist/_dts/sdk/src/rendering/index.d.ts +6 -6
  48. package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
  49. package/dist/_dts/sdk/src/rendering/server.d.ts +2 -2
  50. package/dist/_dts/sdk/src/rendering/themeAdmission.d.ts +1 -1
  51. package/dist/_dts/sdk/src/routing/index.d.ts +6 -6
  52. package/dist/_dts/sdk/src/server.d.ts +5 -5
  53. package/dist/_dts/sdk/src/spam-protection/index.d.ts +2 -2
  54. package/dist/_dts/sdk/src/theme/index.d.ts +91 -2
  55. package/dist/_dts/{serviceBookingOutline-BgFbJQhU.d.ts → serviceBookingOutline-B1gyJon_.d.ts} +7 -7
  56. package/dist/_dts/{types-CgS3xLk8.d.ts → types-BoITy0rA.d.ts} +41 -4
  57. package/dist/_dts/{types-CQrsP1x_.d.ts → types-DBNuMtSk.d.ts} +16 -5
  58. package/dist/_dts/{types-R65DKjPn.d.ts → types-DHMcuoeQ.d.ts} +7 -7
  59. package/dist/_dts/{validation-6LTIbuBA.d.ts → validation-BIPO-XlE.d.ts} +4 -4
  60. package/dist/client/{BlocksIslandsHydrator-DqZPz6oW.mjs → BlocksIslandsHydrator-Ct8slgRk.mjs} +22 -18
  61. package/dist/client/{BookingMailingListNote-uWfR2kaG.mjs → BookingMailingListNote-qqTxGGS4.mjs} +7 -7
  62. package/dist/client/{BookingQuestionFields-CyNIKw6k.mjs → BookingQuestionFields-DCh9MUIF.mjs} +2 -2
  63. package/dist/client/{CalendarAction-D_Glwvz2.mjs → CalendarAction-RcdaStG7.mjs} +1 -1
  64. package/dist/client/{CalendarNavigationChevron-BGCX3zwG.mjs → CalendarNavigationChevron-D7Wt-Oaa.mjs} +27 -10
  65. package/dist/client/{CheckboxChoice-C8i4NraK.mjs → CheckboxChoice-BdGxZWeg.mjs} +1 -1
  66. package/dist/client/{DemoBookingPortalAccess-DFLPyuqe.mjs → DemoBookingPortalAccess-HFVkoOac.mjs} +5 -5
  67. package/dist/client/{EventCalendar.client-zDL4-t-B.mjs → EventCalendar.client-BtkJW8bA.mjs} +10 -10
  68. package/dist/client/{EventCombined.client-uciDKLID.mjs → EventCombined.client-DxaGjFFS.mjs} +9 -9
  69. package/dist/client/{EventEmbeddedCheckoutStep-BGkbUhuw.mjs → EventEmbeddedCheckoutStep-B2c5dR49.mjs} +1 -1
  70. package/dist/client/{EventItem-CwzrjcRw.mjs → EventItem-Fr2qi2C2.mjs} +33 -186
  71. package/dist/client/{EventListWeekNavigation-ChvcnPma.mjs → EventListWeekNavigation-BRMaq0ky.mjs} +1 -1
  72. package/dist/client/{EventListing.client-DA57Qoyx.mjs → EventListing.client-BhGxfbjt.mjs} +3 -3
  73. package/dist/client/{EventListing.view-DZ0qMFF4.mjs → EventListing.view-COuEJzbO.mjs} +8 -8
  74. package/dist/client/{EventRegistrationPayment-DSqCJL8E.mjs → EventRegistrationPayment-BTLYhVxD.mjs} +41 -195
  75. package/dist/client/{Page-C7mygH_f.mjs → Page-CgbQZP5g.mjs} +2947 -1018
  76. package/dist/client/{ProtectedSubmitButton-BNnKuir8.mjs → ProtectedSubmitButton-BG7my0Qf.mjs} +1 -1
  77. package/dist/client/{SiteTermsAgreementField-B4z-e4Wq.mjs → SiteTermsAgreementField-DQNkfNLA.mjs} +3 -3
  78. package/dist/client/{StepIndicator-Dn_DY4oY.mjs → StepIndicator-DvPekKeM.mjs} +1 -1
  79. package/dist/client/{StepIndicator-atfDU82W.mjs → StepIndicator-DyXoI3ob.mjs} +221 -20
  80. package/dist/client/{ThemedButton-PFOhXktM.mjs → ThemedButton-Bc9DBbVp.mjs} +42 -9
  81. package/dist/client/{accessibleSurfaces-n6kS6Hct.mjs → accessibleSurfaces-wj4Rloo5.mjs} +1214 -724
  82. package/dist/client/{accordion-CsW8U3ff.mjs → accordion-BVXfjnh-.mjs} +1 -1
  83. package/dist/client/{booking-form.client-cBWM392H.mjs → booking-form.client-DycPGtke.mjs} +191 -71
  84. package/dist/client/{bookingForm-DgySpp6C.mjs → bookingForm-DrWSUqL3.mjs} +4 -4
  85. package/dist/client/bookings.mjs +5 -5
  86. package/dist/client/{boxStyleClassNames-BpGVdLFD.mjs → boxStyleClassNames-CduDRcIk.mjs} +2 -2
  87. package/dist/client/buttonParts-CJEtVOUy.mjs +1511 -0
  88. package/dist/client/{carousel-DJoleFV3.mjs → carousel-DyCLMP8s.mjs} +2 -2
  89. package/dist/client/{carousel.client-BtLwHefX.mjs → carousel.client-DffP_Nv0.mjs} +1 -1
  90. package/dist/client/{cart-EO5o6uPH.mjs → cart-BuEp_cj4.mjs} +3 -3
  91. package/dist/client/{cart.client-D_gPw45z.mjs → cart.client-CAO39uDG.mjs} +1 -1
  92. package/dist/client/{checkout-NVfZW0kR.mjs → checkout-BoxzT64s.mjs} +3 -3
  93. package/dist/client/{checkout.client-DD3JuqOy.mjs → checkout.client-IGUy7XOx.mjs} +1 -1
  94. package/dist/client/{checkoutUrls-z2gXvlGw.mjs → checkoutUrls-D0UsiFmm.mjs} +1 -1
  95. package/dist/client/client.mjs +466 -94
  96. package/dist/client/{constants-CoOkvw__.mjs → constants-C_8AxMdm.mjs} +1 -1
  97. package/dist/client/{context-CRhn9qzS.mjs → context-D1L0pe__.mjs} +23 -5
  98. package/dist/client/{dateFormatting-BnWB4L1s.mjs → dateFormatting-HvfmS_cH.mjs} +1 -1
  99. package/dist/client/{demoPortalMagicLink-CWDGSTBu.mjs → demoPortalMagicLink-BunFTnIq.mjs} +1 -1
  100. package/dist/client/{enhanceHeaderSection-tdP_-Z9o.mjs → enhanceHeaderSection-CtLAG651.mjs} +4 -4
  101. package/dist/client/{event-registration.client-D7YYKySQ.mjs → event-registration.client-DiSxkBUP.mjs} +15 -15
  102. package/dist/client/{eventCalendar-CsAfu5d0.mjs → eventCalendar-DUnhwZ1o.mjs} +4 -4
  103. package/dist/client/{eventCombined-VXJB5CoS.mjs → eventCombined-BvBQo0nF.mjs} +4 -4
  104. package/dist/client/{eventListing-B3KIZNfY.mjs → eventListing-aTLifOX7.mjs} +4 -4
  105. package/dist/client/{eventRegistration-BP-dEk1c.mjs → eventRegistration-DFd7pr09.mjs} +4 -4
  106. package/dist/client/{form-DM8Zbxbv.mjs → form-Dikmc2AO.mjs} +3 -3
  107. package/dist/client/{form.client-e2z_Tlgk.mjs → form.client-zHaQK5I9.mjs} +5 -5
  108. package/dist/client/{form.parts-Ctljy1a3.mjs → form.parts-BLl9n8TH.mjs} +3 -3
  109. package/dist/client/gifting/client.mjs +16 -9
  110. package/dist/client/{gifting-DWIsqQru.mjs → gifting-CufPM38H.mjs} +4 -4
  111. package/dist/client/{gifting.client-QsSWF0uA.mjs → gifting.client--N1GaSY8.mjs} +155 -84
  112. package/dist/client/gifting.interactive-D9MK4HkV.mjs +157 -0
  113. package/dist/client/gifting.parts-CRtiRzo-.mjs +119 -0
  114. package/dist/client/{headerSection-DAkRkwb-.mjs → headerSection-BIaBpmk3.mjs} +2 -2
  115. package/dist/client/{noop-Dl4mZ-rr.mjs → islands-DJDLGQEm.mjs} +16008 -8676
  116. package/dist/client/{newsletter-form.client-WYja9-WN.mjs → newsletter-form.client-wg_JHTxm.mjs} +6 -6
  117. package/dist/client/{newsletter-form.interactive-RuM86VAv.mjs → newsletter-form.interactive-hzpkW9NQ.mjs} +384 -326
  118. package/dist/client/{newsletter-form.parts-2petDnWv.mjs → newsletter-form.parts-CgzpSv9p.mjs} +2 -2
  119. package/dist/client/{newsletterForm-BUbXdA_e.mjs → newsletterForm-CvxLiEBT.mjs} +3 -3
  120. package/dist/client/portal/client.mjs +291 -101
  121. package/dist/client/{portalOrders-COGn4BKG.mjs → portalOrders-tCxS04g0.mjs} +3 -2
  122. package/dist/client/{portalRoutes-D72yvtDh.mjs → portalRoutes-DTHlWg_F.mjs} +33 -7
  123. package/dist/client/{product-detail.client-pOAryevt.mjs → product-detail.client-22Q7zgjN.mjs} +1 -1
  124. package/dist/client/{product-list.client-CcUpUiud.mjs → product-list.client-DFWYvK8z.mjs} +1 -1
  125. package/dist/client/{productDetail-BZJCfqat.mjs → productDetail-DhZAwo60.mjs} +3 -3
  126. package/dist/client/{productList-CiRs3mNb.mjs → productList-BiVpbZK2.mjs} +3 -3
  127. package/dist/client/{propsDecoder--uHW4tFM.mjs → propsDecoder-DFYqKnLy.mjs} +4 -2
  128. package/dist/client/{registry.server-CDNNd8wC.mjs → registry.server-C3OBRg7x.mjs} +2305 -873
  129. package/dist/client/rendering/client.mjs +29 -26
  130. package/dist/client/rendering/islands.mjs +1 -1
  131. package/dist/client/rendering.mjs +5 -5
  132. package/dist/client/{richText-coerce-CQGE_wHV.mjs → richText-coerce-ms477Z08.mjs} +2 -2
  133. package/dist/client/{routeIslandApiConfig-BtCg87-N.mjs → routeIslandApiConfig-B6nQeqvH.mjs} +1 -1
  134. package/dist/client/{runtimeResponse-Ds9cmBUf.mjs → runtimeResponse-BYqsV1Kb.mjs} +1 -1
  135. package/dist/client/runtimeResponse-CUX_lldL.mjs +3 -0
  136. package/dist/client/{shop-commerce-D8evQnMT.mjs → shop-commerce-DVsIcPaI.mjs} +16 -15
  137. package/dist/client/{shop-commerce-store-C9PcsSTj.mjs → shop-commerce-store-7mO6KY7_.mjs} +1 -1
  138. package/dist/client/{shop-discount-apply.state-D5CtGfJI.mjs → shop-discount-apply.state-L1Vge8tG.mjs} +2 -2
  139. package/dist/client/{shop-Rx_gEMK8.mjs → shop-xt4dQ3HH.mjs} +3 -3
  140. package/dist/client/{shop.client-D4lzQ9oY.mjs → shop.client-DNJfD3VQ.mjs} +28 -17
  141. package/dist/client/{shopShared-BVbq7Nm-.mjs → shopShared-DS8t6749.mjs} +2 -2
  142. package/dist/client/spam-protection.mjs +1 -1
  143. package/dist/client/{src-ZSqRK3dD.mjs → src-Do_s2lqH.mjs} +16 -19
  144. package/dist/client/{timetableModel-BQJrSK0K.mjs → timetableModel-Dy3nNfTG.mjs} +13 -17
  145. package/dist/client/{useAvailableSlots-Dm3lKJKR.mjs → useAvailableSlots-DcjtDpUu.mjs} +2 -2
  146. package/dist/client/{useDiscountCodeUi-klgfGn7f.mjs → useDiscountCodeUi-DvdFFWOT.mjs} +1 -1
  147. package/dist/client/{useEventPagination-Jnjt7_ly.mjs → useEventPagination-Cq-7sU5_.mjs} +8 -8
  148. package/dist/client/{view-CC_yQLSA.mjs → view-4gnPcpWJ.mjs} +24 -9
  149. package/dist/client/{wizardSteps-BliJOzEX.mjs → wizardSteps-DDvL3iza.mjs} +375 -186
  150. package/dist/preview-next/client/{EventEmbeddedCheckoutStep-aRJjq4x8.mjs → EventEmbeddedCheckoutStep-CLqSRUpt.mjs} +1 -1
  151. package/dist/preview-next/client/{LocationPickerEnvironment-BW3dRFIv.mjs → LocationPickerEnvironment-CIdAg-Tm.mjs} +1 -1
  152. package/dist/preview-next/client/{MapLibreEditMap-Db9BHyXh.mjs → MapLibreEditMap-Bm85jX35.mjs} +2 -2
  153. package/dist/preview-next/client/{PageSectionToolbar-BhL0uADo.mjs → PageSectionToolbar-D8srnz9R.mjs} +445 -18
  154. package/dist/preview-next/client/{PreviewEditorSidebar-Ct8eIm0i.mjs → PreviewEditorSidebar-DVpk5cqp.mjs} +3871 -1947
  155. package/dist/preview-next/client/{PreviewEditorUI-BS32G4V9.mjs → PreviewEditorUI-XoTtHSFH.mjs} +11 -36
  156. package/dist/preview-next/client/{PreviewShell-RL0WfZXD.mjs → PreviewShell-VQHsRg2u.mjs} +40 -35
  157. package/dist/preview-next/client/{SdkPreviewModeRuntime-MK_gHeGy.mjs → SdkPreviewModeRuntime-CLdF9f6o.mjs} +51 -20
  158. package/dist/preview-next/client/{ThemedButton-CVYz7h68.mjs → ThemedButton-ORNN4x-3.mjs} +782 -16
  159. package/dist/preview-next/client/{lucide-react-00FF_oar.mjs → lucide-react-eAi3tDAr.mjs} +11 -1
  160. package/dist/preview-next/client/{previewAssistantSlot-CQyS8pcq.mjs → previewAssistantSlot-CqH91EwA.mjs} +20687 -8562
  161. package/dist/preview-next/client/{previewChromeRoot-BSxp3Mfu.mjs → previewChromeRoot-B3ySEu6p.mjs} +3 -90
  162. package/dist/preview-next/client/runtime.mjs +3 -3
  163. package/dist/preview-next/client/{sdk-runtime-DKnTzy74.mjs → sdk-runtime-CdpSupcr.mjs} +2 -2
  164. package/dist/preview-next/client/{siteStyleAccess-BlmbvbLN.mjs → siteStyleAccess-C6eOP6QW.mjs} +35 -6
  165. package/dist/preview-next/client/{useAutosaveStatus-D-7GwZOQ.mjs → useAutosaveStatus-BhPg4e-r.mjs} +49 -3
  166. package/dist/preview-next/client/{useOpenBlockForSetup-BNZtGM5g.mjs → useOpenBlockForSetup-BaWUF9D7.mjs} +2007 -448
  167. package/dist/preview-next/container-responsive.css +320 -0
  168. package/dist/preview-next/editor-chrome.css +23 -2
  169. package/dist/preview-next/keepAlive.mjs +1 -1
  170. package/dist/preview-next/middleware.mjs +1 -1
  171. package/dist/preview-next/{route-contract-R3PcMmax.mjs → route-contract-Ch0X99vE.mjs} +183 -18
  172. package/dist/server/{Block.shared-CniF9tSu.mjs → Block.shared-B2FmczLO.mjs} +5 -5
  173. package/dist/server/{ThemeScopeCore-BQWsnGT6.mjs → ThemeScopeCore-DtAyv9qA.mjs} +51 -29
  174. package/dist/server/{accessibleSurfaces-WPzUAHp4.mjs → accessibleSurfaces-BtPqb76u.mjs} +509 -389
  175. package/dist/server/{accordions-By_0Ykks.mjs → accordions-vzdZ2Wt1.mjs} +1 -1
  176. package/dist/server/{bindings-DxojjtK3.mjs → bindings-B_9JuU66.mjs} +7 -7
  177. package/dist/server/{client-CDndhbYO.mjs → client-DC7cjiSw.mjs} +489 -93
  178. package/dist/server/config-validation.mjs +1 -1
  179. package/dist/server/config.mjs +2 -2
  180. package/dist/server/{constants-VyF5nEhL.mjs → constants-d6nPNJpe.mjs} +33 -6
  181. package/dist/server/{customCss-C9kgPHvr.mjs → customCss-rtIfEYwQ.mjs} +1 -18
  182. package/dist/server/data/resolveBlockData.mjs +1 -1
  183. package/dist/server/{resolveButtonColourStates-B0O1IM16.mjs → expandPalette-DxPrNOAB.mjs} +950 -316
  184. package/dist/server/index.mjs +3 -3
  185. package/dist/server/{loadContent-BKstMBmX.mjs → loadContent-hb27HYic.mjs} +11 -10
  186. package/dist/server/{loadPage-IgNnZaqr.mjs → loadPage-JToD8wDD.mjs} +3 -3
  187. package/dist/server/{lookMediaFrame-TFjgNG61.mjs → lookMediaFrame-CTsycLLK.mjs} +94 -39
  188. package/dist/server/manifest.mjs +2 -2
  189. package/dist/server/{navigation-quBYlSKD.mjs → navigation-B2WhGofA.mjs} +1 -1
  190. package/dist/server/navigation.mjs +1 -1
  191. package/dist/server/next.mjs +8 -8
  192. package/dist/server/{overrideResolution-CCaAPpIa.mjs → overrideResolution-vD5KTClL.mjs} +1 -1
  193. package/dist/server/page-converter.mjs +3 -3
  194. package/dist/server/{pageRenderPlan-B7iULvKe.mjs → pageRenderPlan-CdqJ1NQZ.mjs} +242 -336
  195. package/dist/server/{pageRuntimeSupport-BytMroxn.mjs → pageRuntimeSupport-CAhr4oOf.mjs} +3 -3
  196. package/dist/server/{pageShared-Dcs_XTIO.mjs → pageShared-m80Xu2pd.mjs} +1292 -877
  197. package/dist/server/{parseThemeForPersistence-Bihl4W5K.mjs → parseThemeForPersistence-CRwOZfpa.mjs} +3 -3
  198. package/dist/server/{portal-CMW_b9mG.mjs → portal-B2wCQno_.mjs} +1 -1
  199. package/dist/server/portal.mjs +2 -2
  200. package/dist/server/{prebuild-agaH-vZV.mjs → prebuild-BWIkFaXq.mjs} +1 -1
  201. package/dist/server/prebuild.mjs +1 -1
  202. package/dist/server/{prefetchBlockData-DwpRjqw4.mjs → prefetchBlockData-D1PHU-K9.mjs} +3 -3
  203. package/dist/server/{registry-DM9dHfDC.mjs → registry-KtsOsAzY.mjs} +21703 -10936
  204. package/dist/server/rendering/components/pageShared.mjs +1 -1
  205. package/dist/server/rendering/helpers/loadPage.mjs +1 -1
  206. package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +1 -1
  207. package/dist/server/rendering/server.mjs +4 -4
  208. package/dist/server/rendering.mjs +9 -9
  209. package/dist/server/{resolveBlockData-CinHGf8l.mjs → resolveBlockData-sjIDJYl7.mjs} +1 -1
  210. package/dist/server/{schema-CwfxQjc4.mjs → schema-BBEqquBM.mjs} +44 -28
  211. package/dist/server/server.mjs +3 -3
  212. package/dist/server/{servicePageContent-BBBhOtdE.mjs → servicePageContent-ChEZDRwU.mjs} +38 -15
  213. package/dist/server/theme-bridge.mjs +34 -9
  214. package/dist/server/theme.mjs +2 -2
  215. package/dist/server/{three-pass-converter-DPaUPTfl.mjs → three-pass-converter-DKCIBeb1.mjs} +2 -2
  216. package/dist/server/{titleSourceSchema-NhK6azFS.mjs → titleSourceSchema-DybHErxH.mjs} +4 -4
  217. package/dist/server/{typeGuards-CTW_9AXq.mjs → typeGuards-DZOaGTEv.mjs} +126 -126
  218. package/dist/server/{types-BKaBZFjD.mjs → types-vyz09w64.mjs} +479 -8
  219. package/dist/server/{validation-DG5jX3jH.mjs → validation-Cvi-1TZZ.mjs} +13 -9
  220. package/dist/server/{version-CipbxPHL.mjs → version-B-icAIV1.mjs} +1 -1
  221. package/dist/server/{video-Cdr3wh-q.mjs → video-DBaeSawZ.mjs} +1 -1
  222. package/dist/styles/index.css +2568 -154
  223. package/package.json +1 -1
  224. package/dist/client/gifting.parts-CedLgwa_.mjs +0 -86
  225. package/dist/client/runtimeResponse-DL_ARBpa.mjs +0 -3
  226. package/dist/client/types-BEaKfam_.mjs +0 -778
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { t as stableJsonStringify } from "./stable-json-D0XAEIXc.mjs";
3
- import { C as paletteModeSchema, O as VARIANT_ROLES, T as parseThemeColorToken, _ as hexColorSchema, c as buttonEffectApplicationSchema, h as PALETTE_TOKEN_NAMES, m as parseOpaqueButtonColourToken, n as STANDARD_BUTTON_SURFACE_POLICY, p as opaqueButtonColourTokenSchema, s as unsafeAsOpaqueButtonColourToken, u as buttonSystemSchema, w as parseColorTokenParts, x as paletteColorsFromEntries, y as normalizePaletteHex } from "./types-BEaKfam_.mjs";
3
+ import { A as normalizePaletteHex, C as parseOpaqueButtonColourToken, E as PALETTE_TOKEN_NAMES, F as parseColorTokenParts, I as parseThemeColorToken, M as paletteColorsFromEntries, O as hexColorSchema, P as paletteModeSchema, S as opaqueButtonColourTokenSchema, T as isFreeButtonRadius, _ as buttonEffectApplicationSchema, c as STANDARD_BUTTON_SURFACE_POLICY, d as createStandardButtonSurfacePolicy, g as actionVariablePrefix, h as actionVariableName, i as buttonShadowLayersValue, k as isThemeColorToken, p as unsafeAsOpaqueButtonColourToken, y as buttonSystemSchema, z as VARIANT_ROLES } from "./buttonParts-CJEtVOUy.mjs";
4
4
  import { t as SURFACE_TRANSPORT_KEY } from "./surfaceTransportMarker-BuwkYxsI.mjs";
5
5
  import { z } from "zod";
6
6
  //#region ../theme-core/src/palette/utils/colorConversion.ts
@@ -231,6 +231,10 @@ function solidPaint(hex, index) {
231
231
  const y = hexLuminance(hex, index);
232
232
  return new Interval(y, y);
233
233
  }
234
+ /** The smallest paint covering every given paint: an ink that clears it clears each of them. */
235
+ function spanningPaint(first, ...rest) {
236
+ return rest.reduce((span, paint) => new Interval(paint.lo < span.lo ? paint.lo : span.lo, paint.hi > span.hi ? paint.hi : span.hi), first);
237
+ }
234
238
  function luminanceRatio(a, b) {
235
239
  return a >= b ? (a + .05) / (b + .05) : (b + .05) / (a + .05);
236
240
  }
@@ -246,8 +250,8 @@ function assertContrastRatio(ratio) {
246
250
  * The one black-or-white rule: literal black or white, whichever contrasts more
247
251
  * with the whole paint (black on a tie). It always returns, even when neither
248
252
  * reaches the ratio a caller wants; callers decide what a shortfall means.
249
- * A style's preferred neutral is a separate input (`neutralInk`) and never
250
- * part of this rule.
253
+ * A style's preferred neutral or the palette's own roles are separate inputs
254
+ * (`neutralInk`, `paletteInk`) that are tried before this rule, never part of it.
251
255
  */
252
256
  function maxContrastBlackOrWhite(paint) {
253
257
  const blackContrast = (paint.lo + .05) / .05;
@@ -260,6 +264,9 @@ function maxContrastBlackOrWhite(paint) {
260
264
  ratio: whiteContrast
261
265
  };
262
266
  }
267
+ function literalInkHex(ink) {
268
+ return ink === "black" ? "#000000" : "#FFFFFF";
269
+ }
263
270
  function contrastRatio(hex1, hex2, index) {
264
271
  const L1 = indexedLuminance(hex1, index);
265
272
  const L2 = indexedLuminance(hex2, index);
@@ -317,6 +324,314 @@ const paletteValueKeySchema = z.string().transform((value, ctx) => {
317
324
  return z.NEVER;
318
325
  });
319
326
  //#endregion
327
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/assertClassBrand.js
328
+ function _assertClassBrand(e, t, n) {
329
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
330
+ throw new TypeError("Private element is not present on this object");
331
+ }
332
+ //#endregion
333
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/classPrivateFieldSet2.js
334
+ function _classPrivateFieldSet2(s, a, r) {
335
+ return s.set(_assertClassBrand(s, a), r), r;
336
+ }
337
+ //#endregion
338
+ //#region \0@oxc-project+runtime@0.137.0/helpers/esm/classPrivateFieldGet2.js
339
+ function _classPrivateFieldGet2(s, a) {
340
+ return s.get(_assertClassBrand(s, a));
341
+ }
342
+ //#endregion
343
+ //#region ../theme-core/src/palette/family.ts
344
+ var _members = /* @__PURE__ */ new WeakMap();
345
+ /**
346
+ * Only `colourFamily` makes one (the class is not exported), so a caller can't
347
+ * swap in its own members and still hand the solver a valid family. That
348
+ * matters because `unpaintable` relies on the members running from black to
349
+ * white.
350
+ */
351
+ var Family = class {
352
+ constructor(seed, members) {
353
+ this.seed = seed;
354
+ _classPrivateFieldInitSpec(this, _members, void 0);
355
+ _classPrivateFieldSet2(_members, this, Object.freeze(members));
356
+ }
357
+ /** Unique by hex, ascending luminance. Includes the exact seed, black and white. */
358
+ get members() {
359
+ return _classPrivateFieldGet2(_members, this);
360
+ }
361
+ };
362
+ const GAMUT_BISECTION_STEPS = 18;
363
+ /** The highest chroma at or below `c` that stays inside sRGB at this lightness and hue. */
364
+ function gamutChroma(l, c, h) {
365
+ if (inLinearSrgbGamut(oklchToLinearSrgb(l, c, h))) return c;
366
+ return Array.from({ length: GAMUT_BISECTION_STEPS }).reduce(({ lo, hi }) => {
367
+ const mid = (lo + hi) / 2;
368
+ return inLinearSrgbGamut(oklchToLinearSrgb(l, mid, h)) ? {
369
+ lo: mid,
370
+ hi
371
+ } : {
372
+ lo,
373
+ hi: mid
374
+ };
375
+ }, {
376
+ lo: 0,
377
+ hi: c
378
+ }).lo;
379
+ }
380
+ function oklabDistance(a, b) {
381
+ return Math.hypot(a.L - b.L, a.a - b.a, a.b - b.b);
382
+ }
383
+ /** OKLab distance between two rendered opaque hex colours. */
384
+ function hexOklabDistance(first, second) {
385
+ const lab = (hex) => {
386
+ const { r, g, b } = hexToRgb(hex);
387
+ return srgbToOklab(r, g, b);
388
+ };
389
+ return oklabDistance(lab(first), lab(second));
390
+ }
391
+ function colourFamily(seedHex) {
392
+ if (!/^#[0-9a-f]{6}$/i.test(seedHex)) throw new Error(`Expected an opaque #rrggbb colour: ${seedHex}`);
393
+ const features = featuresFromHex(seedHex.toLowerCase());
394
+ const seed = member(seedHex.toLowerCase(), {
395
+ l: features.okL,
396
+ c: features.okC,
397
+ h: features.okH
398
+ });
399
+ const seedTaper = Math.max(.001, Math.sin(Math.PI * seed.sample.l));
400
+ const samples = Array.from({ length: 513 }, (_, i) => {
401
+ const l = i / 512;
402
+ return sampleMember({
403
+ l,
404
+ c: gamutChroma(l, seed.sample.c * Math.min(1, Math.sin(Math.PI * l) / seedTaper), seed.sample.h),
405
+ h: seed.sample.h
406
+ });
407
+ });
408
+ return new Family(seed, [...new Map([seed, ...samples].map((candidate) => [candidate.hex, candidate]).reverse()).values()].sort((a, b) => a.y - b.y || (a.hex < b.hex ? -1 : a.hex > b.hex ? 1 : 0)));
409
+ }
410
+ function sampleMember(sample) {
411
+ const { r, g, b } = oklchToLinearSrgb(sample.l, sample.c, sample.h);
412
+ return member(rgbToHex(linearToSrgb(r), linearToSrgb(g), linearToSrgb(b)), sample);
413
+ }
414
+ function member(hex, sample) {
415
+ const { r, g, b } = hexToRgb(hex);
416
+ return {
417
+ hex,
418
+ y: hexLuminance(hex),
419
+ oklab: srgbToOklab(r, g, b),
420
+ sample
421
+ };
422
+ }
423
+ //#endregion
424
+ //#region ../theme-core/src/palette/utils/inkSolver.ts
425
+ /**
426
+ * How far (OKLab ΔE) a brand colour drawn as ink may be nudged along its own
427
+ * family before it stops reading as that colour. Past this the caller uses
428
+ * neutral or palette text instead (Will, 2026-10-14).
429
+ */
430
+ const BRAND_INK_MAX_DELTA_E = .08;
431
+ /**
432
+ * The seed itself when it clears `paint`, otherwise the family member nearest
433
+ * the seed (OKLab ΔE) that clears. On a light ground that is darker, on a dark
434
+ * one lighter. A passing member further than `maxDistance` from the seed is
435
+ * refused as `too-far`, which is distinct from `unpaintable`: the family runs
436
+ * from black to white, so if no member clears, neither does black or white.
437
+ */
438
+ function inkFrom(family, paint, ratio, maxDistance = BRAND_INK_MAX_DELTA_E) {
439
+ assertContrastRatio(ratio);
440
+ if (!Number.isFinite(maxDistance) || maxDistance < 0) throw new RangeError(`Maximum ink distance must be finite and not negative: ${maxDistance}`);
441
+ const seedRatio = worstContrast(family.seed.y, paint);
442
+ if (seedRatio >= ratio) return {
443
+ kind: "ink",
444
+ hex: family.seed.hex,
445
+ ratio: seedRatio,
446
+ source: "exact"
447
+ };
448
+ const nearest = family.members.reduce((best, member) => {
449
+ const achieved = worstContrast(member.y, paint);
450
+ if (achieved < ratio) return best;
451
+ const distance = oklabDistance(member.oklab, family.seed.oklab);
452
+ return best === null || distance < best.distance ? {
453
+ hex: member.hex,
454
+ distance,
455
+ ratio: achieved
456
+ } : best;
457
+ }, null);
458
+ if (nearest === null) return {
459
+ kind: "unpaintable",
460
+ interval: paint,
461
+ ratio
462
+ };
463
+ if (nearest.distance > maxDistance) return {
464
+ kind: "too-far",
465
+ nearest: {
466
+ hex: nearest.hex,
467
+ distance: nearest.distance
468
+ },
469
+ maxDistance
470
+ };
471
+ return {
472
+ kind: "ink",
473
+ hex: nearest.hex,
474
+ ratio: nearest.ratio,
475
+ source: "family"
476
+ };
477
+ }
478
+ /**
479
+ * The one "preferred ink, else black or white" comparison. Of the candidates,
480
+ * the one with the most contrast against the whole paint wins if it reaches
481
+ * `ratio` (the earlier one on a tie); otherwise literal black or white by
482
+ * `maxContrastBlackOrWhite`; otherwise `unpaintable`. It's direction-neutral:
483
+ * a candidate pair of one dark and one light ink needs no light/dark branch.
484
+ */
485
+ function preferredOrLiteralInk(paint, ratio, candidates) {
486
+ assertContrastRatio(ratio);
487
+ const best = candidates.map((candidate) => ({
488
+ ...candidate,
489
+ ratio: worstContrast(hexLuminance(candidate.hex), paint)
490
+ })).reduce((winner, candidate) => winner === null || candidate.ratio > winner.ratio ? candidate : winner, null);
491
+ if (best !== null && best.ratio >= ratio) return {
492
+ kind: "candidate",
493
+ value: best.value,
494
+ ratio: best.ratio
495
+ };
496
+ const literal = maxContrastBlackOrWhite(paint);
497
+ return literal.ratio >= ratio ? {
498
+ kind: "literal",
499
+ ink: literal.ink,
500
+ ratio: literal.ratio
501
+ } : {
502
+ kind: "unpaintable",
503
+ interval: paint,
504
+ ratio
505
+ };
506
+ }
507
+ /**
508
+ * Neutral text for a paint. The style's preferred neutral wins when one of its
509
+ * pair clears (the higher-contrast one, dark on a tie); otherwise literal black
510
+ * or white by `maxContrastBlackOrWhite`; otherwise `unpaintable`.
511
+ */
512
+ function neutralInk(paint, ratio, preferred) {
513
+ const picked = preferredOrLiteralInk(paint, ratio, preferred ? [{
514
+ value: preferred.dark,
515
+ hex: preferred.dark
516
+ }, {
517
+ value: preferred.light,
518
+ hex: preferred.light
519
+ }] : []);
520
+ switch (picked.kind) {
521
+ case "candidate": return {
522
+ kind: "ink",
523
+ hex: picked.value,
524
+ ratio: picked.ratio,
525
+ source: "neutral"
526
+ };
527
+ case "literal": return {
528
+ kind: "ink",
529
+ hex: picked.ink === "black" ? "#000000" : "#ffffff",
530
+ ratio: picked.ratio,
531
+ source: "neutral"
532
+ };
533
+ case "unpaintable": return picked;
534
+ }
535
+ }
536
+ /** The palette's `background` and `text` as an ink pair, or null when either is missing or not a hex colour. */
537
+ function paletteInkRoles(palette) {
538
+ const background = hexColorSchema.safeParse(palette.background?.toLowerCase());
539
+ const text = hexColorSchema.safeParse(palette.text?.toLowerCase());
540
+ return background.success && text.success ? {
541
+ background: background.data,
542
+ text: text.data
543
+ } : null;
544
+ }
545
+ /**
546
+ * Palette text for a paint: of the palette's background and text, the one with
547
+ * more contrast against the whole paint when it reaches `ratio`; otherwise
548
+ * literal black or white; otherwise `unpaintable`. On a dark palette the
549
+ * background is the dark one, so the same rule mirrors with no mode branch.
550
+ */
551
+ function paletteInk(paint, roles, ratio = ORDINARY_TEXT_MIN_CONTRAST_RATIO) {
552
+ const picked = preferredOrLiteralInk(paint, ratio, roles ? ["text", "background"].map((role) => ({
553
+ value: {
554
+ role,
555
+ hex: roles[role]
556
+ },
557
+ hex: roles[role]
558
+ })) : []);
559
+ switch (picked.kind) {
560
+ case "candidate": return {
561
+ kind: "role",
562
+ ...picked.value,
563
+ ratio: picked.ratio
564
+ };
565
+ case "literal": return {
566
+ kind: "literal",
567
+ hex: literalInkHex(picked.ink),
568
+ ratio: picked.ratio
569
+ };
570
+ case "unpaintable": return picked;
571
+ }
572
+ }
573
+ /** Ordinary-text palette ink on one solid ground. Total: black or white always reaches 4.58:1 on a solid. */
574
+ function paletteInkOnSolid(groundHex, roles) {
575
+ const paint = solidPaint(groundHex);
576
+ const ink = paletteInk(paint, roles);
577
+ if (ink.kind !== "unpaintable") return ink;
578
+ const literal = maxContrastBlackOrWhite(paint);
579
+ return {
580
+ kind: "literal",
581
+ hex: literalInkHex(literal.ink),
582
+ ratio: literal.ratio
583
+ };
584
+ }
585
+ /**
586
+ * The ink as token emitters write it: the role's theme token, so CSS follows
587
+ * the palette's variables, or the literal hex.
588
+ */
589
+ function paletteInkToken(ink) {
590
+ if (ink.kind === "literal") return ink.hex;
591
+ if (!isThemeColorToken(ink.role)) throw new Error(`Palette ink role is not a theme token: ${ink.role}`);
592
+ return ink.role;
593
+ }
594
+ /**
595
+ * Secondary text that has to read on several grounds (a surface and the tinted
596
+ * cards laid on it). The full-strength ink is `preferred` when it reaches 4.5:1
597
+ * on every ground, otherwise the palette's ink over the same paint; the muted
598
+ * ink is then the faintest blend from the first ground toward it that still
599
+ * reaches 4.5:1 everywhere. When no ink reaches 4.5:1 on every ground (a light
600
+ * ground and a dark one together), it's `unpaintable` and the caller decides
601
+ * which grounds to give up, rather than receiving a colour that only claims to read.
602
+ */
603
+ function paletteMutedInk(grounds, preferred, roles) {
604
+ const [first, ...rest] = grounds;
605
+ const paint = spanningPaint(solidPaint(first), ...rest.map((ground) => solidPaint(ground)));
606
+ const contrast = (hex) => worstContrast(hexLuminance(hex), paint);
607
+ const passes = (hex) => contrast(hex) >= ORDINARY_TEXT_MIN_CONTRAST_RATIO;
608
+ const endpoint = preferred !== null && passes(preferred) ? {
609
+ kind: "preferred",
610
+ hex: preferred
611
+ } : paletteInk(paint, roles);
612
+ if (endpoint.kind === "unpaintable") return endpoint;
613
+ const start = hexToRgb(first);
614
+ const end = hexToRgb(endpoint.hex);
615
+ const sample = (index) => rgbToHex(mix$1(start.r, end.r, index / 100), mix$1(start.g, end.g, index / 100), mix$1(start.b, end.b, index / 100));
616
+ const firstPassing = (low, high) => {
617
+ if (low >= high) return high;
618
+ const middle = Math.floor((low + high) / 2);
619
+ return passes(sample(middle)) ? firstPassing(low, middle) : firstPassing(middle + 1, high);
620
+ };
621
+ const hex = sample(firstPassing(0, 100));
622
+ return {
623
+ kind: "muted",
624
+ hex,
625
+ ratio: contrast(hex)
626
+ };
627
+ }
628
+ /** The muted ink on one solid ground. Total: black or white always reaches 4.58:1 on a solid. */
629
+ function paletteMutedInkOnSolid(ground, preferred, roles) {
630
+ const ink = paletteMutedInk([ground], preferred, roles);
631
+ if (ink.kind === "unpaintable") throw new Error(`No muted ink reads on the solid ground ${ground}`);
632
+ return ink.hex;
633
+ }
634
+ //#endregion
320
635
  //#region ../theme-core/src/palette/utils/opaqueSurfaceColor.ts
321
636
  /** Resolve an opaque colour, compositing alpha against an explicit underlay. */
322
637
  function resolveOpaqueSurfaceHex(reference, palette, underlayReference) {
@@ -595,121 +910,6 @@ const BUTTON_VISUAL_STATES = [
595
910
  "disabled"
596
911
  ];
597
912
  //#endregion
598
- //#region ../theme-core/src/palette/generateShades.ts
599
- function generateShades(hexColor, name) {
600
- const shadeSteps = [
601
- 50,
602
- 100,
603
- 200,
604
- 300,
605
- 400,
606
- 500,
607
- 600,
608
- 700,
609
- 800,
610
- 900,
611
- 950
612
- ];
613
- const base = featuresFromHex(hexColor);
614
- const hue = base.okH;
615
- const baseChroma = base.okC;
616
- const toneMap = {
617
- 50: .975,
618
- 100: .945,
619
- 200: .89,
620
- 300: .82,
621
- 400: .74,
622
- 500: .66,
623
- 600: .58,
624
- 700: .49,
625
- 800: .4,
626
- 900: .28,
627
- 950: .16
628
- };
629
- const shadeDefs = shadeSteps.map((step, idx) => {
630
- const t = idx / (shadeSteps.length - 1);
631
- const L = toneMap[step];
632
- const C = baseChroma * (.06 + .94 * Math.sin(Math.PI * t));
633
- return {
634
- name: `${name}-${step}`,
635
- hex: oklchToHexGamut(L, C, hue)
636
- };
637
- });
638
- shadeDefs.push({
639
- name,
640
- hex: hexColor
641
- });
642
- return shadeDefs;
643
- }
644
- //#endregion
645
- //#region ../theme-core/src/palette/neutralScale.ts
646
- /**
647
- * A neutral scale from near-white (`neutral-50`) to near-black (`neutral-950`)
648
- * on every palette, light or dark. Readers that want "the ground" or "the
649
- * text" ask the palette for those roles, not a fixed end of this scale.
650
- */
651
- function generateNeutralScale({ steps = 11, warm = false } = {}) {
652
- const shadeNames = [
653
- 50,
654
- 100,
655
- 200,
656
- 300,
657
- 400,
658
- 500,
659
- 600,
660
- 700,
661
- 800,
662
- 900,
663
- 950
664
- ];
665
- const count = Math.min(steps, shadeNames.length);
666
- return shadeNames.slice(0, count).map((shadeName, index) => ({
667
- name: `neutral-${shadeName}`,
668
- hex: oklchToHexGamut(mix(.98, .1, index / (count - 1)), .02, warm ? 85 : 250)
669
- }));
670
- }
671
- function mix(a, b, t) {
672
- return a + (b - a) * Math.max(0, Math.min(1, t));
673
- }
674
- //#endregion
675
- //#region ../theme-core/src/palette/utils/textColor.ts
676
- /**
677
- * Pick the better of black/white text for a given background using actual
678
- * contrast ratios, not a simple luminance cutoff. This is
679
- * `maxContrastBlackOrWhite` for a solid ground.
680
- *
681
- * @param background - Background color in hex or rgb/rgba format (e.g., '#FFFFFF' or 'rgb(255, 255, 255)')
682
- * @param _minContrast - Kept for callers. It cannot change the result: when
683
- * only one of black or white reaches it, that one is also the better of the two.
684
- * @returns '#000000' for light backgrounds, '#FFFFFF' for dark backgrounds
685
- */
686
- function pickBlackOrWhiteTextColor(background, _minContrast = 4.5) {
687
- const { r, g, b } = parseColorToRgb(background);
688
- return maxContrastBlackOrWhite(luminanceInterval(relativeLuminance(r, g, b))).ink === "black" ? "#000000" : "#FFFFFF";
689
- }
690
- /**
691
- * Backwards-compatible alias for callers that want the best black/white text
692
- * color for a background.
693
- */
694
- function getTextColorForBackground(background) {
695
- return pickBlackOrWhiteTextColor(background);
696
- }
697
- function parseColorToRgb(input) {
698
- const trimmed = input.trim();
699
- if (trimmed.startsWith("#")) return hexToRgb(trimmed);
700
- const rgbMatch = trimmed.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(?:0|1|0?\.\d+))?\s*\)$/i);
701
- if (rgbMatch?.[1] && rgbMatch[2] && rgbMatch[3]) return {
702
- r: clamp255(Number(rgbMatch[1])),
703
- g: clamp255(Number(rgbMatch[2])),
704
- b: clamp255(Number(rgbMatch[3]))
705
- };
706
- throw new Error("Unsupported color format");
707
- }
708
- function clamp255(value) {
709
- if (Number.isNaN(value)) return 0;
710
- return Math.max(0, Math.min(255, value));
711
- }
712
- //#endregion
713
913
  //#region ../theme-core/src/palette/utils/onColor.ts
714
914
  const BACKGROUND_ROLE_NAMES = /* @__PURE__ */ new Set([
715
915
  "primary",
@@ -733,122 +933,12 @@ function isOnColorBackgroundCandidateToken(token) {
733
933
  return BACKGROUND_ROLE_NAMES.has(role);
734
934
  }
735
935
  //#endregion
736
- //#region ../theme-core/src/palette/expandPalette.ts
737
- function colorsToMap(palette) {
738
- const map = {};
739
- for (const c of palette.colors) map[c.name] = c.hex;
740
- return map;
741
- }
742
- const nonShadeablePaletteRoleNames = /* @__PURE__ */ new Set([
743
- "success",
744
- "warning",
745
- "destructive"
746
- ]);
747
- /**
748
- * Status role aliases the persisted palette does not carry itself.
749
- *
750
- * Generators reference `--tb-error` (the site-style-owned input error border)
751
- * and `--tb-info` (`.alert-info`, `.status-info`, the field-note rule), but the
752
- * palette schema only defines `destructive` and has no `info` role at all.
753
- * Without these aliases those declarations name variables that are never
754
- * defined and browsers drop them. The SDK bridge resolves the same pair via
755
- * TOKEN_ALIASES, so both runtimes agree on what a status token means.
756
- *
757
- * Runs after the danger → destructive promotion above, so `destructive` is
758
- * already the single source of truth for the error colour.
759
- */
760
- function statusAliasTokens(expanded) {
761
- const aliases = {};
762
- if (expanded.destructive) aliases.error = expanded.destructive;
763
- if (expanded.accent) aliases.info = expanded.accent;
764
- return aliases;
765
- }
766
- function expandPalette(palette, options = {}) {
767
- return {
768
- ...expandBasePalette(palette),
769
- ...arrangementPaletteTokens(colorsToMap(palette), options)
770
- };
771
- }
772
- function expandBasePalette(palette) {
773
- const base = colorsToMap(palette);
774
- const expanded = { ...base };
775
- generateNeutralScale({
776
- steps: 11,
777
- warm: false
778
- }).forEach((n) => {
779
- expanded[n.name] = n.hex;
780
- });
781
- for (const [name, hex] of Object.entries(base)) {
782
- if (nonShadeablePaletteRoleNames.has(name)) continue;
783
- if (hex) generateShades(hex, name).forEach((shade) => {
784
- expanded[shade.name] = shade.hex;
785
- });
786
- }
787
- if (base.text) expanded.body = base.text;
788
- if (base.danger && !base.destructive) expanded.destructive = base.danger;
789
- Object.assign(expanded, statusAliasTokens(expanded));
790
- expanded.mutedText = readableMutedText(expanded["neutral-500"] ?? "#888", base);
791
- for (const [token, hex] of Object.entries({ ...expanded })) {
792
- if (!hex || !isOnColorBackgroundCandidateToken(token)) continue;
793
- const onToken = onColorTokenName(token);
794
- if (expanded[onToken]) continue;
795
- expanded[onToken] = getTextColorForBackground(hex);
796
- }
797
- return expanded;
798
- }
799
- /**
800
- * The neutral step stays when it reads on the ground. Otherwise (a dark palette
801
- * on a mid-tone ground, or a tinted light one) it's the ground-to-text blend
802
- * with a 4.5:1 floor, heading for black or white when the text can't reach it.
803
- */
804
- function readableMutedText(step, base) {
805
- const ground = base.background || base.surface;
806
- if (!ground || contrastRatio(step, ground) >= 4.5) return step;
807
- return deriveSurfaceMutedColor(ground, base.text && contrastRatio(base.text, ground) >= 4.5 ? base.text : getTextColorForBackground(ground));
808
- }
809
- /** Derived decoration colours never become editable palette swatches. */
810
- function deriveSurfaceDecorationColors(ground, text, accent) {
811
- const ink = getTextColorForBackground(ground);
812
- return {
813
- line: firstContrastBlend(ground, text, ground, 1.5),
814
- mark: firstContrastBlend(accent, ink, ground, 3)
815
- };
816
- }
817
- /** Secondary ink is blended toward its ground, with an ordinary-text contrast floor. */
818
- function deriveSurfaceMutedColor(ground, text) {
819
- const start = hexToRgb(ground);
820
- const end = hexToRgb(text);
821
- const sample = (index) => rgbToHex(mix$1(start.r, end.r, index / 100), mix$1(start.g, end.g, index / 100), mix$1(start.b, end.b, index / 100));
822
- return firstSafeMutedSample(sample, ground, 0, 100);
823
- }
824
- /** The blend moves monotonically from the ground toward its validated ink. */
825
- function firstSafeMutedSample(sample, ground, low, high) {
826
- if (low === high) return sample(high);
827
- const middle = Math.floor((low + high) / 2);
828
- return contrastRatio(sample(middle), ground) >= 4.5 ? firstSafeMutedSample(sample, ground, low, middle) : firstSafeMutedSample(sample, ground, middle + 1, high);
829
- }
830
- function firstContrastBlend(from, to, ground, threshold) {
831
- const start = hexToRgb(from);
832
- const end = hexToRgb(to);
833
- return Array.from({ length: 101 }, (_, index) => {
834
- const amount = index / 100;
835
- return rgbToHex(mix$1(start.r, end.r, amount), mix$1(start.g, end.g, amount), mix$1(start.b, end.b, amount));
836
- }).find((hex) => contrastRatio(hex, ground) >= threshold) ?? to;
837
- }
838
- /** `markSource` names the colour surface marks are derived from when a style marks in its brand rather than its accent. */
839
- function arrangementPaletteTokens(base, options) {
840
- if (options.arrangement !== true || !base.text) return {};
841
- return {
842
- onText: getTextColorForBackground(base.text),
843
- ...options.marksFrom === "primary" && base.primary ? { markSource: base.primary } : {}
844
- };
845
- }
846
- //#endregion
847
936
  //#region ../theme-core/src/surfaces/inkCertificate.ts
848
937
  /**
849
938
  * The ink certificate: every colour the site paints text or a mark on is held to
850
939
  * its threshold here, on every backdrop it shows. An ink that misses takes the
851
- * black/white ink that clears all of them; inks that pass are kept as they are,
940
+ * palette ink that clears all of them (the site's background or text colour,
941
+ * else black or white); inks that pass are kept as they are,
852
942
  * so a palette that already passes paints exactly what it declared. It never
853
943
  * throws, because owner palettes are arbitrary.
854
944
  *
@@ -887,10 +977,16 @@ function inkClearsBackdrops(ink, threshold, backdrops, measurement) {
887
977
  return hex !== null && contrastRatio(hex, backdrop, measurement.colourIndex) >= threshold;
888
978
  });
889
979
  }
890
- /** The black/white ink that clears every backdrop at ordinary-text contrast, preferring the best one for the painted end. */
980
+ /** The palette ink that clears every backdrop at ordinary-text contrast, or null when not even black or white does. */
891
981
  function fallbackInk(backdrops, measurement) {
892
- const [endpoint] = backdrops.slice(-1);
893
- return [...endpoint ? [pickBlackOrWhiteTextColor(endpoint)] : [], ...FALLBACK_INKS].find((candidate) => inkClearsBackdrops(candidate, contrastThresholdByPolicy["body-aa"], backdrops, measurement)) ?? null;
982
+ const ys = backdrops.map((backdrop) => hexLuminance(backdrop, measurement.colourIndex));
983
+ if (ys.length === 0) return null;
984
+ const ink = paletteInk(luminanceInterval(Math.min(...ys), Math.max(...ys)), paletteInkRoles(measurement.palette), contrastThresholdByPolicy["body-aa"]);
985
+ return ink.kind === "unpaintable" ? null : paletteInkToken(ink);
986
+ }
987
+ /** One solid backdrop: total, because black or white always clears it. */
988
+ function solidFallbackInk(backdrop, measurement) {
989
+ return paletteInkToken(paletteInkOnSolid(backdrop, paletteInkRoles(measurement.palette)));
894
990
  }
895
991
  function failingInks(inks, backdrops, measurement) {
896
992
  return {
@@ -930,9 +1026,9 @@ function certifySolidSurfaceInks(inks, backdrop, measurement) {
930
1026
  ...inks,
931
1027
  fallback: []
932
1028
  };
933
- return replaceFailing(inks, failing, pickBlackOrWhiteTextColor(backdrop));
1029
+ return replaceFailing(inks, failing, solidFallbackInk(backdrop, measurement));
934
1030
  }
935
- /** Kept when the ink clears the threshold, otherwise the black/white ink, which always clears a solid backdrop. */
1031
+ /** Kept when the ink clears the threshold, otherwise the palette ink, which always clears a solid backdrop. */
936
1032
  function certifyPaint(place, ink, threshold, backdrop, measurement) {
937
1033
  return inkClearsBackdrops(ink, threshold, [backdrop], measurement) ? {
938
1034
  place,
@@ -942,7 +1038,7 @@ function certifyPaint(place, ink, threshold, backdrop, measurement) {
942
1038
  fallback: false
943
1039
  } : {
944
1040
  place,
945
- ink: pickBlackOrWhiteTextColor(backdrop),
1041
+ ink: solidFallbackInk(backdrop, measurement),
946
1042
  backdrop,
947
1043
  threshold,
948
1044
  fallback: true,
@@ -950,214 +1046,65 @@ function certifyPaint(place, ink, threshold, backdrop, measurement) {
950
1046
  };
951
1047
  }
952
1048
  //#endregion
953
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/assertClassBrand.js
954
- function _assertClassBrand(e, t, n) {
955
- if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
956
- throw new TypeError("Private element is not present on this object");
1049
+ //#region ../theme-core/src/palette/utils/textColor.ts
1050
+ /**
1051
+ * Pick the better of black/white text for a given background using actual
1052
+ * contrast ratios, not a simple luminance cutoff. This is
1053
+ * `maxContrastBlackOrWhite` for a solid ground. It is the literal fallback
1054
+ * only: where a palette is in scope, `paletteInkOnSolid` tries the site's own
1055
+ * background and text colours first.
1056
+ *
1057
+ * @param background - Background color in hex or rgb/rgba format (e.g., '#FFFFFF' or 'rgb(255, 255, 255)')
1058
+ * @param _minContrast - Kept for callers. It cannot change the result: when
1059
+ * only one of black or white reaches it, that one is also the better of the two.
1060
+ * @returns '#000000' for light backgrounds, '#FFFFFF' for dark backgrounds
1061
+ */
1062
+ function pickBlackOrWhiteTextColor(background, _minContrast = 4.5) {
1063
+ const { r, g, b } = parseColorToRgb(background);
1064
+ return literalInkHex(maxContrastBlackOrWhite(luminanceInterval(relativeLuminance(r, g, b))).ink);
957
1065
  }
958
- //#endregion
959
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/classPrivateFieldSet2.js
960
- function _classPrivateFieldSet2(s, a, r) {
961
- return s.set(_assertClassBrand(s, a), r), r;
1066
+ function parseColorToRgb(input) {
1067
+ const trimmed = input.trim();
1068
+ if (trimmed.startsWith("#")) return hexToRgb(trimmed);
1069
+ const rgbMatch = trimmed.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(?:0|1|0?\.\d+))?\s*\)$/i);
1070
+ if (rgbMatch?.[1] && rgbMatch[2] && rgbMatch[3]) return {
1071
+ r: clamp255(Number(rgbMatch[1])),
1072
+ g: clamp255(Number(rgbMatch[2])),
1073
+ b: clamp255(Number(rgbMatch[3]))
1074
+ };
1075
+ throw new Error("Unsupported color format");
962
1076
  }
963
- //#endregion
964
- //#region \0@oxc-project+runtime@0.137.0/helpers/esm/classPrivateFieldGet2.js
965
- function _classPrivateFieldGet2(s, a) {
966
- return s.get(_assertClassBrand(s, a));
1077
+ function clamp255(value) {
1078
+ if (Number.isNaN(value)) return 0;
1079
+ return Math.max(0, Math.min(255, value));
967
1080
  }
968
1081
  //#endregion
969
- //#region ../theme-core/src/palette/family.ts
970
- var _members = /* @__PURE__ */ new WeakMap();
1082
+ //#region ../theme-core/src/surfaces/surfaceInks.ts
1083
+ /** Lines and focus rings are graphics: WCAG non-text contrast. */
1084
+ const GRAPHIC_MIN_CONTRAST_RATIO = 3;
971
1085
  /**
972
- * Only `colourFamily` makes one (the class is not exported), so a caller can't
973
- * swap in its own members and still hand the solver a valid family. That
974
- * matters because `unpaintable` relies on the members running from black to
975
- * white.
1086
+ * The palette token the control edge ink is solved from. Input styles whose
1087
+ * border uses another token keep their own colour, since this ink would carry
1088
+ * the wrong hue for them.
976
1089
  */
977
- var Family = class {
978
- constructor(seed, members) {
979
- this.seed = seed;
980
- _classPrivateFieldInitSpec(this, _members, void 0);
981
- _classPrivateFieldSet2(_members, this, Object.freeze(members));
982
- }
983
- /** Unique by hex, ascending luminance. Includes the exact seed, black and white. */
984
- get members() {
985
- return _classPrivateFieldGet2(_members, this);
986
- }
987
- };
988
- const GAMUT_BISECTION_STEPS = 18;
989
- /** The highest chroma at or below `c` that stays inside sRGB at this lightness and hue. */
990
- function gamutChroma(l, c, h) {
991
- if (inLinearSrgbGamut(oklchToLinearSrgb(l, c, h))) return c;
992
- return Array.from({ length: GAMUT_BISECTION_STEPS }).reduce(({ lo, hi }) => {
993
- const mid = (lo + hi) / 2;
994
- return inLinearSrgbGamut(oklchToLinearSrgb(l, mid, h)) ? {
995
- lo: mid,
996
- hi
997
- } : {
998
- lo,
999
- hi: mid
1000
- };
1001
- }, {
1002
- lo: 0,
1003
- hi: c
1004
- }).lo;
1005
- }
1006
- function oklabDistance(a, b) {
1007
- return Math.hypot(a.L - b.L, a.a - b.a, a.b - b.b);
1008
- }
1009
- /** OKLab distance between two rendered opaque hex colours. */
1010
- function hexOklabDistance(first, second) {
1011
- const lab = (hex) => {
1012
- const { r, g, b } = hexToRgb(hex);
1013
- return srgbToOklab(r, g, b);
1014
- };
1015
- return oklabDistance(lab(first), lab(second));
1016
- }
1017
- function colourFamily(seedHex) {
1018
- if (!/^#[0-9a-f]{6}$/i.test(seedHex)) throw new Error(`Expected an opaque #rrggbb colour: ${seedHex}`);
1019
- const features = featuresFromHex(seedHex.toLowerCase());
1020
- const seed = member(seedHex.toLowerCase(), {
1021
- l: features.okL,
1022
- c: features.okC,
1023
- h: features.okH
1024
- });
1025
- const seedTaper = Math.max(.001, Math.sin(Math.PI * seed.sample.l));
1026
- const samples = Array.from({ length: 513 }, (_, i) => {
1027
- const l = i / 512;
1028
- return sampleMember({
1029
- l,
1030
- c: gamutChroma(l, seed.sample.c * Math.min(1, Math.sin(Math.PI * l) / seedTaper), seed.sample.h),
1031
- h: seed.sample.h
1032
- });
1033
- });
1034
- return new Family(seed, [...new Map([seed, ...samples].map((candidate) => [candidate.hex, candidate]).reverse()).values()].sort((a, b) => a.y - b.y || (a.hex < b.hex ? -1 : a.hex > b.hex ? 1 : 0)));
1035
- }
1036
- function sampleMember(sample) {
1037
- const { r, g, b } = oklchToLinearSrgb(sample.l, sample.c, sample.h);
1038
- return member(rgbToHex(linearToSrgb(r), linearToSrgb(g), linearToSrgb(b)), sample);
1039
- }
1040
- function member(hex, sample) {
1041
- const { r, g, b } = hexToRgb(hex);
1042
- return {
1043
- hex,
1044
- y: hexLuminance(hex),
1045
- oklab: srgbToOklab(r, g, b),
1046
- sample
1047
- };
1048
- }
1049
- //#endregion
1050
- //#region ../theme-core/src/palette/utils/inkSolver.ts
1051
- /**
1052
- * How far (OKLab ΔE) a brand colour drawn as ink may be nudged along its own
1053
- * family before it stops reading as that colour. Past this the caller uses
1054
- * neutral or palette text instead (Will, 2026-10-14).
1055
- */
1056
- const BRAND_INK_MAX_DELTA_E = .08;
1057
- /**
1058
- * The seed itself when it clears `paint`, otherwise the family member nearest
1059
- * the seed (OKLab ΔE) that clears. On a light ground that is darker, on a dark
1060
- * one lighter. A passing member further than `maxDistance` from the seed is
1061
- * refused as `too-far`, which is distinct from `unpaintable`: the family runs
1062
- * from black to white, so if no member clears, neither does black or white.
1063
- */
1064
- function inkFrom(family, paint, ratio, maxDistance = BRAND_INK_MAX_DELTA_E) {
1065
- assertContrastRatio(ratio);
1066
- if (!Number.isFinite(maxDistance) || maxDistance < 0) throw new RangeError(`Maximum ink distance must be finite and not negative: ${maxDistance}`);
1067
- const seedRatio = worstContrast(family.seed.y, paint);
1068
- if (seedRatio >= ratio) return {
1069
- kind: "ink",
1070
- hex: family.seed.hex,
1071
- ratio: seedRatio,
1072
- source: "exact"
1073
- };
1074
- const nearest = family.members.reduce((best, member) => {
1075
- const achieved = worstContrast(member.y, paint);
1076
- if (achieved < ratio) return best;
1077
- const distance = oklabDistance(member.oklab, family.seed.oklab);
1078
- return best === null || distance < best.distance ? {
1079
- hex: member.hex,
1080
- distance,
1081
- ratio: achieved
1082
- } : best;
1083
- }, null);
1084
- if (nearest === null) return {
1085
- kind: "unpaintable",
1086
- interval: paint,
1087
- ratio
1088
- };
1089
- if (nearest.distance > maxDistance) return {
1090
- kind: "too-far",
1091
- nearest: {
1092
- hex: nearest.hex,
1093
- distance: nearest.distance
1094
- },
1095
- maxDistance
1096
- };
1097
- return {
1098
- kind: "ink",
1099
- hex: nearest.hex,
1100
- ratio: nearest.ratio,
1101
- source: "family"
1102
- };
1103
- }
1104
- /**
1105
- * Neutral text for a paint. The style's preferred neutral wins when one of its
1106
- * pair clears (the higher-contrast one, dark on a tie); otherwise literal black
1107
- * or white by `maxContrastBlackOrWhite`; otherwise `unpaintable`.
1108
- */
1109
- function neutralInk(paint, ratio, preferred) {
1110
- assertContrastRatio(ratio);
1111
- if (preferred) {
1112
- const dark = worstContrast(hexLuminance(preferred.dark), paint);
1113
- const light = worstContrast(hexLuminance(preferred.light), paint);
1114
- const [hex, achieved] = dark >= light ? [preferred.dark, dark] : [preferred.light, light];
1115
- if (achieved >= ratio) return {
1116
- kind: "ink",
1117
- hex,
1118
- ratio: achieved,
1119
- source: "neutral"
1120
- };
1121
- }
1122
- const literal = maxContrastBlackOrWhite(paint);
1123
- return literal.ratio >= ratio ? {
1124
- kind: "ink",
1125
- hex: literal.ink === "black" ? "#000000" : "#ffffff",
1126
- ratio: literal.ratio,
1127
- source: "neutral"
1128
- } : {
1129
- kind: "unpaintable",
1130
- interval: paint,
1131
- ratio
1132
- };
1133
- }
1134
- //#endregion
1135
- //#region ../theme-core/src/surfaces/surfaceInks.ts
1136
- /** Lines and focus rings are graphics: WCAG non-text contrast. */
1137
- const GRAPHIC_MIN_CONTRAST_RATIO = 3;
1138
- /**
1139
- * The palette token the control edge ink is solved from. Input styles whose
1140
- * border uses another token keep their own colour, since this ink would carry
1141
- * the wrong hue for them.
1142
- */
1143
- const CONTROL_EDGE_SEED_TOKEN = "border";
1144
- const INK_SEEDS = {
1145
- brand: {
1146
- token: "primary",
1147
- ratio: ORDINARY_TEXT_MIN_CONTRAST_RATIO
1148
- },
1149
- accent: {
1150
- token: "accent",
1151
- ratio: ORDINARY_TEXT_MIN_CONTRAST_RATIO
1152
- },
1153
- focus: {
1154
- token: "primary",
1155
- ratio: GRAPHIC_MIN_CONTRAST_RATIO
1156
- },
1157
- control: {
1158
- token: CONTROL_EDGE_SEED_TOKEN,
1159
- ratio: GRAPHIC_MIN_CONTRAST_RATIO,
1160
- maxDistance: 2
1090
+ const CONTROL_EDGE_SEED_TOKEN = "border";
1091
+ const INK_SEEDS = {
1092
+ brand: {
1093
+ token: "primary",
1094
+ ratio: ORDINARY_TEXT_MIN_CONTRAST_RATIO
1095
+ },
1096
+ accent: {
1097
+ token: "accent",
1098
+ ratio: ORDINARY_TEXT_MIN_CONTRAST_RATIO
1099
+ },
1100
+ focus: {
1101
+ token: "primary",
1102
+ ratio: GRAPHIC_MIN_CONTRAST_RATIO
1103
+ },
1104
+ control: {
1105
+ token: CONTROL_EDGE_SEED_TOKEN,
1106
+ ratio: GRAPHIC_MIN_CONTRAST_RATIO,
1107
+ maxDistance: 2
1161
1108
  }
1162
1109
  };
1163
1110
  /**
@@ -1168,7 +1115,7 @@ const INK_SEEDS = {
1168
1115
  */
1169
1116
  function solveSurfaceInks(backdropHex, textInk, palette, candidates = {}) {
1170
1117
  const paint = solidPaint(backdropHex);
1171
- const fallback = literalInk(resolveConcreteColorHex(textInk, palette) ?? pickBlackOrWhiteTextColor(backdropHex));
1118
+ const fallback = literalInk$1(resolveConcreteColorHex(textInk, palette) ?? pickBlackOrWhiteTextColor(backdropHex));
1172
1119
  return {
1173
1120
  brand: solveInk({
1174
1121
  ...INK_SEEDS.brand,
@@ -1194,12 +1141,12 @@ function solveInk(seed, paint, palette, fallback) {
1194
1141
  if (!token || !seedHex.success) return fallback;
1195
1142
  const solved = inkFrom(familyOf(seedHex.data), paint, seed.ratio, seed.maxDistance);
1196
1143
  switch (solved.kind) {
1197
- case "ink": return solved.source === "exact" ? token : literalInk(solved.hex);
1144
+ case "ink": return solved.source === "exact" ? token : literalInk$1(solved.hex);
1198
1145
  case "too-far":
1199
1146
  case "unpaintable": return fallback;
1200
1147
  }
1201
1148
  }
1202
- function literalInk(hex) {
1149
+ function literalInk$1(hex) {
1203
1150
  return hexColorSchema.parse(hex.toLowerCase());
1204
1151
  }
1205
1152
  const FAMILY_CACHE_LIMIT = 64;
@@ -1214,14 +1161,6 @@ function familyOf(seed) {
1214
1161
  }
1215
1162
  //#endregion
1216
1163
  //#region ../theme-core/src/surfaces/resolveSurfaceForeground.ts
1217
- const FALLBACK_TEXT_TOKENS = [
1218
- "text",
1219
- "primaryForeground",
1220
- "secondaryForeground",
1221
- "accentForeground",
1222
- "neutral-950",
1223
- "neutral-50"
1224
- ];
1225
1164
  const CANONICAL_EQUIVALENT_TOKEN_ORDER = [
1226
1165
  "text",
1227
1166
  "primaryForeground",
@@ -1272,11 +1211,7 @@ function resolveDeterministicForeground(backgroundReference, candidates, palette
1272
1211
  function resolveMeasuredForeground(backgroundReference, backgroundHex, candidates, palette) {
1273
1212
  const backgroundToken = paletteToken(backgroundReference);
1274
1213
  const derivedOnToken = backgroundToken ? onColorTokenName(backgroundToken) : null;
1275
- const text = firstSafeToken([
1276
- candidates.text,
1277
- derivedOnToken,
1278
- ...FALLBACK_TEXT_TOKENS
1279
- ], backgroundHex, palette, derivedOnToken ? [derivedOnToken] : []) ?? pickBlackOrWhiteTextColor(backgroundHex);
1214
+ const text = firstSafeToken([candidates.text, derivedOnToken], backgroundHex, palette, derivedOnToken ? [derivedOnToken] : []) ?? paletteTextInk(backgroundHex, palette);
1280
1215
  return certifiedForeground(knownForeground({
1281
1216
  text,
1282
1217
  heading: safeTokenOr(candidates.heading, text, backgroundHex, palette),
@@ -1288,6 +1223,10 @@ function resolveMeasuredForeground(backgroundReference, backgroundHex, candidate
1288
1223
  inks: solveSurfaceInks(backgroundHex, text, palette)
1289
1224
  }, candidates.linkHover, palette), palette);
1290
1225
  }
1226
+ /** The automatic text when neither the authored ink nor the ground's on-colour reads: the palette's own pair, then black or white. */
1227
+ function paletteTextInk(backgroundHex, palette) {
1228
+ return paletteInkToken(paletteInkOnSolid(backgroundHex, paletteInkRoles(palette)));
1229
+ }
1291
1230
  /**
1292
1231
  * Every measured foreground goes through the ink certificate, whoever paints it
1293
1232
  * (sections, cards, header, footer, accordions). The candidates above are chosen
@@ -1310,13 +1249,13 @@ function certifiedForeground(foreground, palette) {
1310
1249
  };
1311
1250
  }
1312
1251
  function resolveTrustedTreatmentForeground(candidates, palette) {
1313
- const text = canonicalToken(candidates.text, palette);
1252
+ const text = canonicalInk(candidates.text, palette);
1314
1253
  if (!text) return { kind: "unmeasured-paint" };
1315
1254
  return knownForeground({
1316
1255
  text,
1317
- heading: canonicalToken(candidates.heading, palette) ?? text,
1318
- link: canonicalToken(candidates.link, palette) ?? text,
1319
- supporting: canonicalToken(candidates.supporting, palette) ?? text
1256
+ heading: canonicalInk(candidates.heading, palette) ?? text,
1257
+ link: canonicalInk(candidates.link, palette) ?? text,
1258
+ supporting: canonicalInk(candidates.supporting, palette) ?? text
1320
1259
  }, { kind: "trusted-treatment" }, candidates.linkHover, palette);
1321
1260
  }
1322
1261
  function knownForeground(roles, provenance, hoverCandidate, palette) {
@@ -1332,7 +1271,7 @@ function knownForeground(roles, provenance, hoverCandidate, palette) {
1332
1271
  roles: {
1333
1272
  ...roles,
1334
1273
  linkHover: hover.token,
1335
- muted: provenance.kind === "measured" ? deriveSurfaceMutedColor(provenance.backdropHex, resolveConcreteColorHex(roles.text, palette) ?? provenance.backdropHex) : roles.text
1274
+ muted: provenance.kind === "measured" ? paletteMutedInkOnSolid(provenance.backdropHex, resolveConcreteColorHex(roles.text, palette), paletteInkRoles(palette)) : roles.text
1336
1275
  },
1337
1276
  hoverDecoration: hover.decoration
1338
1277
  };
@@ -1375,6 +1314,21 @@ function firstSafeToken(candidates, backgroundHex, palette, preferredEquivalentT
1375
1314
  }
1376
1315
  return null;
1377
1316
  }
1317
+ /**
1318
+ * A media treatment's ink as the resolved contract spells it. Nothing measures
1319
+ * the paint, so literal black or white (the photo tint's fallback) stays that
1320
+ * literal colour rather than borrowing whichever palette token shares its value
1321
+ * today, or being dropped when none does. Any other reference is a palette token.
1322
+ * Measured solids keep `firstSafeToken`, whose equivalent on-colour carries the
1323
+ * ground's own hover softening.
1324
+ */
1325
+ function canonicalInk(reference, palette) {
1326
+ return literalInk(reference) ?? canonicalToken(reference, palette);
1327
+ }
1328
+ function literalInk(reference) {
1329
+ const normalized = normalizedReference(reference)?.toUpperCase();
1330
+ return normalized === "#000000" || normalized === "#FFFFFF" ? normalized : null;
1331
+ }
1378
1332
  function canonicalToken(reference, palette, preferredEquivalentTokens = []) {
1379
1333
  const normalized = normalizedReference(reference);
1380
1334
  if (!normalized || normalized === "transparent") return null;
@@ -1392,14 +1346,414 @@ function canonicalToken(reference, palette, preferredEquivalentTokens = []) {
1392
1346
  });
1393
1347
  return equivalent ? parseThemeColorToken(equivalent) : null;
1394
1348
  }
1395
- function paletteToken(reference) {
1396
- const parts = parseColorTokenParts(reference);
1397
- return parts.kind === "token" && parts.opacityPercent === null ? parts.token : null;
1349
+ function paletteToken(reference) {
1350
+ const parts = parseColorTokenParts(reference);
1351
+ return parts.kind === "token" && parts.opacityPercent === null ? parts.token : null;
1352
+ }
1353
+ function normalizedReference(value) {
1354
+ if (typeof value !== "string") return null;
1355
+ const normalized = value.trim();
1356
+ return normalized.length > 0 ? normalized : null;
1357
+ }
1358
+ //#endregion
1359
+ //#region ../theme-core/src/palette/generateShades.ts
1360
+ function generateShades(hexColor, name) {
1361
+ const shadeSteps = [
1362
+ 50,
1363
+ 100,
1364
+ 200,
1365
+ 300,
1366
+ 400,
1367
+ 500,
1368
+ 600,
1369
+ 700,
1370
+ 800,
1371
+ 900,
1372
+ 950
1373
+ ];
1374
+ const base = featuresFromHex(hexColor);
1375
+ const hue = base.okH;
1376
+ const baseChroma = base.okC;
1377
+ const toneMap = {
1378
+ 50: .975,
1379
+ 100: .945,
1380
+ 200: .89,
1381
+ 300: .82,
1382
+ 400: .74,
1383
+ 500: .66,
1384
+ 600: .58,
1385
+ 700: .49,
1386
+ 800: .4,
1387
+ 900: .28,
1388
+ 950: .16
1389
+ };
1390
+ const shadeDefs = shadeSteps.map((step, idx) => {
1391
+ const t = idx / (shadeSteps.length - 1);
1392
+ const L = toneMap[step];
1393
+ const C = baseChroma * (.06 + .94 * Math.sin(Math.PI * t));
1394
+ return {
1395
+ name: `${name}-${step}`,
1396
+ hex: oklchToHexGamut(L, C, hue)
1397
+ };
1398
+ });
1399
+ shadeDefs.push({
1400
+ name,
1401
+ hex: hexColor
1402
+ });
1403
+ return shadeDefs;
1404
+ }
1405
+ //#endregion
1406
+ //#region ../theme-core/src/palette/neutralScale.ts
1407
+ /** The cool slate tint every scale had before #1863, kept for grounds with no hue to lend. */
1408
+ const SLATE_NEUTRAL_TINT = {
1409
+ hue: 250,
1410
+ chroma: .02
1411
+ };
1412
+ /** Below this OKLCH chroma a background reads as plain white, grey or black, so its hue is noise. */
1413
+ const ACHROMATIC_CHROMA = .005;
1414
+ /**
1415
+ * The tint a palette's greys take from its background: the background's own
1416
+ * hue at no more than the slate scale's chroma, so a cream site gets warm greys.
1417
+ * A background with no hue to lend (white, `#fafafa`, a missing or unreadable
1418
+ * value) keeps the slate tint, so those palettes keep their exact neutrals.
1419
+ */
1420
+ function neutralTint(background) {
1421
+ const parsed = hexColorSchema.safeParse(background?.toLowerCase());
1422
+ if (!parsed.success) return SLATE_NEUTRAL_TINT;
1423
+ const { r, g, b } = hexToRgb(parsed.data);
1424
+ const { L, a, b: ob } = srgbToOklab(r, g, b);
1425
+ const { C, h } = oklabToOklch(L, a, ob);
1426
+ return C < ACHROMATIC_CHROMA ? SLATE_NEUTRAL_TINT : {
1427
+ hue: h,
1428
+ chroma: Math.min(C, SLATE_NEUTRAL_TINT.chroma)
1429
+ };
1430
+ }
1431
+ /**
1432
+ * A neutral scale from near-white (`neutral-50`) to near-black (`neutral-950`)
1433
+ * on every palette, light or dark. Readers that want "the ground" or "the
1434
+ * text" ask the palette for those roles, not a fixed end of this scale.
1435
+ */
1436
+ function generateNeutralScale({ steps = 11, tint = SLATE_NEUTRAL_TINT } = {}) {
1437
+ const shadeNames = [
1438
+ 50,
1439
+ 100,
1440
+ 200,
1441
+ 300,
1442
+ 400,
1443
+ 500,
1444
+ 600,
1445
+ 700,
1446
+ 800,
1447
+ 900,
1448
+ 950
1449
+ ];
1450
+ const count = Math.min(steps, shadeNames.length);
1451
+ return shadeNames.slice(0, count).map((shadeName, index) => ({
1452
+ name: `neutral-${shadeName}`,
1453
+ hex: oklchToHexGamut(mix(.98, .1, index / (count - 1)), tint.chroma, tint.hue)
1454
+ }));
1455
+ }
1456
+ function mix(a, b, t) {
1457
+ return a + (b - a) * Math.max(0, Math.min(1, t));
1458
+ }
1459
+ //#endregion
1460
+ //#region ../theme-core/src/palette/utils/scrimContrast.ts
1461
+ const WHITE = "#ffffff";
1462
+ const BLACK = "#000000";
1463
+ /** `top` at `alpha` over opaque `bottom`, blended as CSS paints an overlay. */
1464
+ function compositeHex(topHex, alpha, bottomHex) {
1465
+ const top = hexToRgb(topHex);
1466
+ const bottom = hexToRgb(bottomHex);
1467
+ const mix = (a, b) => Math.round(alpha * a + (1 - alpha) * b);
1468
+ return rgbToHex(mix(top.r, bottom.r), mix(top.g, bottom.g), mix(top.b, bottom.b));
1469
+ }
1470
+ /**
1471
+ * The lowest contrast `foreground` can reach over `scrim` at `alpha` laid on
1472
+ * any pixel. A foreground whose luminance falls inside the range the
1473
+ * composites can take has a worst case of 1:1.
1474
+ */
1475
+ function worstCaseScrimContrast(input) {
1476
+ const overWhite = compositeHex(input.scrimHex, input.alpha, WHITE);
1477
+ const overBlack = compositeHex(input.scrimHex, input.alpha, BLACK);
1478
+ const luminance = (hex) => {
1479
+ const { r, g, b } = hexToRgb(hex);
1480
+ return relativeLuminance(r, g, b);
1481
+ };
1482
+ const foreground = luminance(input.foregroundHex);
1483
+ const low = luminance(overBlack);
1484
+ const high = luminance(overWhite);
1485
+ if (foreground >= low && foreground <= high) return 1;
1486
+ return Math.min(contrastRatio(input.foregroundHex, overWhite), contrastRatio(input.foregroundHex, overBlack));
1487
+ }
1488
+ /**
1489
+ * The smallest scrim opacity, in hundredths, at which every foreground keeps
1490
+ * `threshold` contrast over any pixel. `null` when even an opaque scrim fails,
1491
+ * which means the foreground was never legible on the scrim colour itself.
1492
+ */
1493
+ function minimumScrimOpacity(input) {
1494
+ const passes = (alpha) => input.foregroundHexes.every((foregroundHex) => worstCaseScrimContrast({
1495
+ foregroundHex,
1496
+ scrimHex: input.scrimHex,
1497
+ alpha
1498
+ }) >= input.threshold);
1499
+ return Array.from({ length: 101 }, (_, hundredths) => hundredths / 100).find(passes) ?? null;
1500
+ }
1501
+ /** Shared samples for literal RGB washes and palette-token gradient veils. */
1502
+ function gradientScrimSamples(gradient, alpha, palette) {
1503
+ const literal = [...gradient.matchAll(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/g)].map((stop) => ({
1504
+ hex: rgbToHex(Number(stop[1]), Number(stop[2]), Number(stop[3])),
1505
+ alpha: alpha * (stop[4] === void 0 ? 1 : Number(stop[4]))
1506
+ }));
1507
+ const tokens = [...gradient.matchAll(/var\(--tb-([\w-]+)\)/g)].flatMap((stop) => {
1508
+ const hex = stop[1] ? resolveConcreteColorHex(stop[1], palette) : null;
1509
+ return hex ? [{
1510
+ hex,
1511
+ alpha
1512
+ }] : [];
1513
+ });
1514
+ return [...literal, ...tokens];
1515
+ }
1516
+ /** The ink with the stronger worst-pixel guarantee identifies the veil tone.
1517
+ * No readable samples (or a tie) leaves classification to the foreground owner.
1518
+ */
1519
+ function scrimTone(samples) {
1520
+ if (samples.length === 0) return null;
1521
+ const worst = (foregroundHex) => Math.min(...samples.map((sample) => worstCaseScrimContrast({
1522
+ foregroundHex,
1523
+ scrimHex: sample.hex,
1524
+ alpha: sample.alpha
1525
+ })));
1526
+ const white = worst(WHITE);
1527
+ const black = worst(BLACK);
1528
+ return white === black ? null : white > black ? "dark" : "light";
1529
+ }
1530
+ //#endregion
1531
+ //#region ../theme-core/src/palette/expandPalette.ts
1532
+ function colorsToMap(palette) {
1533
+ const map = {};
1534
+ for (const c of palette.colors) map[c.name] = c.hex;
1535
+ return map;
1536
+ }
1537
+ const nonShadeablePaletteRoleNames = /* @__PURE__ */ new Set([
1538
+ "success",
1539
+ "warning",
1540
+ "destructive"
1541
+ ]);
1542
+ /**
1543
+ * Status role aliases the persisted palette does not carry itself.
1544
+ *
1545
+ * Generators reference `--tb-error` (the site-style-owned input error border)
1546
+ * and `--tb-info` (`.alert-info`, `.status-info`, the field-note rule), but the
1547
+ * palette schema only defines `destructive` and has no `info` role at all.
1548
+ * Without these aliases those declarations name variables that are never
1549
+ * defined and browsers drop them. The SDK bridge resolves the same pair via
1550
+ * TOKEN_ALIASES, so both runtimes agree on what a status token means.
1551
+ *
1552
+ * Runs after the danger → destructive promotion above, so `destructive` is
1553
+ * already the single source of truth for the error colour.
1554
+ */
1555
+ function statusAliasTokens(expanded) {
1556
+ const aliases = {};
1557
+ if (expanded.destructive) aliases.error = expanded.destructive;
1558
+ if (expanded.accent) aliases.info = expanded.accent;
1559
+ return aliases;
1560
+ }
1561
+ function expandPalette(palette, options = {}) {
1562
+ return {
1563
+ ...expandBasePalette(palette),
1564
+ ...arrangementPaletteTokens(colorsToMap(palette), options)
1565
+ };
1566
+ }
1567
+ function expandBasePalette(palette) {
1568
+ const base = colorsToMap(palette);
1569
+ const expanded = { ...base };
1570
+ const roles = paletteInkRoles(base);
1571
+ generateNeutralScale({
1572
+ steps: 11,
1573
+ tint: neutralTint(base.background)
1574
+ }).forEach((n) => {
1575
+ expanded[n.name] = n.hex;
1576
+ });
1577
+ for (const [name, hex] of Object.entries(base)) {
1578
+ if (nonShadeablePaletteRoleNames.has(name)) continue;
1579
+ if (hex) generateShades(hex, name).forEach((shade) => {
1580
+ expanded[shade.name] = shade.hex;
1581
+ });
1582
+ }
1583
+ if (base.text) expanded.body = base.text;
1584
+ if (base.danger && !base.destructive) expanded.destructive = base.danger;
1585
+ Object.assign(expanded, statusAliasTokens(expanded));
1586
+ expanded.mutedText = readableMutedText(expanded["neutral-500"] ?? "#888", base, roles);
1587
+ for (const [token, hex] of Object.entries({ ...expanded })) {
1588
+ if (!hex || !isOnColorBackgroundCandidateToken(token)) continue;
1589
+ const onToken = onColorTokenName(token);
1590
+ if (expanded[onToken]) continue;
1591
+ expanded[onToken] = paletteInkOnSolid(hex, roles).hex;
1592
+ }
1593
+ Object.assign(expanded, groundMutedInkTokens(expanded));
1594
+ return expanded;
1595
+ }
1596
+ /**
1597
+ * The strongest tints booking and registration screens lay over a ground
1598
+ * where secondary text sits: selected option cards, event tiles and summaries
1599
+ * tint `primary` at 5–10% (`blocks/vars/appointment-booking.ts`,
1600
+ * `blocks/vars/event-registration.ts`, `blocks-static/event-registration.css`),
1601
+ * the appointment summary and hover rows tint `text`/`onSurface` at 5%, and the
1602
+ * registration summary lays `muted` at 42%. A weaker tint of the same colour
1603
+ * sits between the ground and these, so solving against the strongest covers it.
1604
+ * A selected card lays its tint over its own ground, so the same list applies
1605
+ * over the surface and over the page background that event option cards paint.
1606
+ * A new tint under secondary text belongs here, and the CSS paints it with
1607
+ * the ground's faded tint token (`groundTintToken`) before the colour itself;
1608
+ * `secondaryTextTints.test.ts` fails if the CSS lays one that isn't covered or
1609
+ * doesn't read that token.
1610
+ */
1611
+ const SURFACE_SECONDARY_TEXT_TINTS = [
1612
+ {
1613
+ token: "primary",
1614
+ alpha: .1
1615
+ },
1616
+ {
1617
+ token: "text",
1618
+ alpha: .05
1619
+ },
1620
+ {
1621
+ token: "onSurface",
1622
+ alpha: .05
1623
+ },
1624
+ {
1625
+ token: "muted",
1626
+ alpha: .42
1627
+ }
1628
+ ];
1629
+ /** The strongest tint alpha per colour, for the CSS that paints those tints. */
1630
+ const SURFACE_SECONDARY_TEXT_TINT_ALPHA = Object.fromEntries(SURFACE_SECONDARY_TEXT_TINTS.map(({ token, alpha }) => [token, alpha]));
1631
+ /**
1632
+ * The grounds booking and registration secondary text sits on, with the token
1633
+ * its solved muted ink is published as: the surface (panels, details) and the
1634
+ * page background (event registration's option, ticket and payment cards).
1635
+ */
1636
+ const MUTED_INK_TOKENS = {
1637
+ surface: "onSurfaceMuted",
1638
+ background: "onBackgroundMuted"
1639
+ };
1640
+ /**
1641
+ * Secondary text on a ground, solved rather than faded from the ground's
1642
+ * on-colour in CSS, against the ground and every tint laid over it.
1643
+ *
1644
+ * Some palettes admit no single ink for all of them: a mid-tone surface with a
1645
+ * dark `primary` tint and a light `muted` one. The plain ground always has one
1646
+ * (black or white reads on any solid), so the ground is kept, each tint is kept
1647
+ * in list order while one ink still reads on everything kept so far, and the
1648
+ * tints that can't join are faded toward the ground until that ink reads on
1649
+ * them too. Fading the tint rather than giving it an ink of its own keeps every
1650
+ * line of text on it (titles and prices as well as secondary text) close to the
1651
+ * ground its colours were chosen for. Hosted palettes and the SDK bridge both
1652
+ * derive it here.
1653
+ */
1654
+ function groundMutedInk(palette, ground) {
1655
+ const groundHex = palette[ground];
1656
+ if (!groundHex) return null;
1657
+ const preferred = palette[onColorTokenName(ground)] ?? null;
1658
+ const roles = paletteInkRoles(palette);
1659
+ const initial = {
1660
+ grounds: [groundHex],
1661
+ hex: paletteMutedInkOnSolid(groundHex, preferred, roles),
1662
+ uncovered: []
1663
+ };
1664
+ const solved = SURFACE_SECONDARY_TEXT_TINTS.reduce((kept, { token, alpha }) => {
1665
+ const tintHex = palette[token];
1666
+ if (!tintHex) return kept;
1667
+ const grounds = [...kept.grounds, compositeHex(tintHex, alpha, groundHex)];
1668
+ const ink = paletteMutedInk(grounds, preferred, roles);
1669
+ return ink.kind === "unpaintable" ? {
1670
+ ...kept,
1671
+ uncovered: [...kept.uncovered, {
1672
+ token,
1673
+ alpha,
1674
+ tintHex
1675
+ }]
1676
+ } : {
1677
+ ...kept,
1678
+ grounds,
1679
+ hex: ink.hex
1680
+ };
1681
+ }, initial);
1682
+ return {
1683
+ hex: solved.hex,
1684
+ fadedTints: solved.uncovered.map(({ token, alpha, tintHex }) => ({
1685
+ token,
1686
+ hex: tintFadedUntilInkReads(tintHex, alpha, groundHex, solved.hex)
1687
+ }))
1688
+ };
1689
+ }
1690
+ /** The tint colour a ground publishes in place of a tint its muted ink can't read on, e.g. `surfaceTintMuted`. */
1691
+ function groundTintToken(ground, tint) {
1692
+ return `${ground}Tint${tint.charAt(0).toUpperCase()}${tint.slice(1)}`;
1693
+ }
1694
+ /**
1695
+ * The tint blended toward the ground in 1% steps, stopping at the first that
1696
+ * the ink reads on when laid at `alpha`. The ground itself always reads, since
1697
+ * the ink was solved on it.
1698
+ */
1699
+ function tintFadedUntilInkReads(tintHex, alpha, groundHex, inkHex) {
1700
+ const tint = hexToRgb(tintHex);
1701
+ const ground = hexToRgb(groundHex);
1702
+ return Array.from({ length: 101 }, (_, index) => {
1703
+ const amount = index / 100;
1704
+ return rgbToHex(mix$1(tint.r, ground.r, amount), mix$1(tint.g, ground.g, amount), mix$1(tint.b, ground.b, amount));
1705
+ }).find((hex) => contrastRatio(inkHex, compositeHex(hex, alpha, groundHex)) >= 4.5) ?? groundHex;
1706
+ }
1707
+ /**
1708
+ * The muted ink tokens a palette doesn't store itself, and the faded tint
1709
+ * colours of each ground whose ink is solved here, as hex.
1710
+ */
1711
+ function groundMutedInkTokens(palette) {
1712
+ return Object.fromEntries(Object.entries(MUTED_INK_TOKENS).flatMap(([ground, token]) => {
1713
+ if (palette[token]) return [];
1714
+ const ink = groundMutedInk(palette, ground);
1715
+ if (!ink) return [];
1716
+ const faded = ink.fadedTints.map(({ token: tint, hex }) => [groundTintToken(ground, tint), hex]);
1717
+ return [[token, ink.hex], ...faded.filter(([name]) => !palette[name])];
1718
+ }));
1719
+ }
1720
+ /**
1721
+ * The neutral step stays when it reads on the ground. Otherwise (a dark palette
1722
+ * on a mid-tone ground, or a tinted light one) it's the ground-to-text blend
1723
+ * with a 4.5:1 floor, heading for the palette's own ink on that ground.
1724
+ */
1725
+ function readableMutedText(step, base, roles) {
1726
+ const ground = base.background || base.surface;
1727
+ if (!ground || contrastRatio(step, ground) >= 4.5) return step;
1728
+ return paletteMutedInkOnSolid(ground, null, roles);
1729
+ }
1730
+ /**
1731
+ * Derived decoration colours never become editable palette swatches. The mark
1732
+ * blends toward literal black or white: it's a graphic endpoint for a 3:1
1733
+ * search, not text, so it stays off the palette ink rule.
1734
+ */
1735
+ function deriveSurfaceDecorationColors(ground, text, accent) {
1736
+ const ink = pickBlackOrWhiteTextColor(ground);
1737
+ return {
1738
+ line: firstContrastBlend(ground, text, ground, 1.5),
1739
+ mark: firstContrastBlend(accent, ink, ground, 3)
1740
+ };
1398
1741
  }
1399
- function normalizedReference(value) {
1400
- if (typeof value !== "string") return null;
1401
- const normalized = value.trim();
1402
- return normalized.length > 0 ? normalized : null;
1742
+ function firstContrastBlend(from, to, ground, threshold) {
1743
+ const start = hexToRgb(from);
1744
+ const end = hexToRgb(to);
1745
+ return Array.from({ length: 101 }, (_, index) => {
1746
+ const amount = index / 100;
1747
+ return rgbToHex(mix$1(start.r, end.r, amount), mix$1(start.g, end.g, amount), mix$1(start.b, end.b, amount));
1748
+ }).find((hex) => contrastRatio(hex, ground) >= threshold) ?? to;
1749
+ }
1750
+ /** `markSource` names the colour surface marks are derived from when a style marks in its brand rather than its accent. */
1751
+ function arrangementPaletteTokens(base, options) {
1752
+ if (options.arrangement !== true || !base.text) return {};
1753
+ return {
1754
+ onText: base.onText ?? paletteInkOnSolid(base.text, paletteInkRoles(base)).hex,
1755
+ ...options.marksFrom === "primary" && base.primary ? { markSource: base.primary } : {}
1756
+ };
1403
1757
  }
1404
1758
  //#endregion
1405
1759
  //#region ../theme-core/src/utils/cssValueSafety.ts
@@ -1673,7 +2027,11 @@ function resolveOnColorForThemeToken(token) {
1673
2027
  //#region ../theme-core/src/buttons/styles/domain.ts
1674
2028
  const PUBLIC_BUTTON_ROLES = VARIANT_ROLES;
1675
2029
  function defineButtonStyleRecipe(recipe) {
1676
- return recipe;
2030
+ const defined = {
2031
+ ...recipe,
2032
+ resolve: (parameters) => resolveButtonStyleRecipe(defined, parameters)
2033
+ };
2034
+ return defined;
1677
2035
  }
1678
2036
  function mapButtonVisualAppearances(states, transform) {
1679
2037
  return {
@@ -1695,6 +2053,98 @@ function mapButtonRoleAppearances(roles, transform) {
1695
2053
  accent: role("accent")
1696
2054
  };
1697
2055
  }
2056
+ function materializeButtonRoles(definitions) {
2057
+ return {
2058
+ primary: materializeCompleteRole("primary", definitions.primary),
2059
+ secondary: materializeCompleteRole("secondary", definitions.secondary),
2060
+ outline: materializeCompleteRole("outline", definitions.outline),
2061
+ ghost: materializeCompleteRole("ghost", definitions.ghost),
2062
+ accent: materializeCompleteRole("accent", definitions.accent)
2063
+ };
2064
+ }
2065
+ function resolveButtonStyleRecipe(recipe, parameters) {
2066
+ const parsedParameters = z.safeParse(recipe.parameterSchema, parameters);
2067
+ if (!parsedParameters.success) return {
2068
+ kind: "error",
2069
+ error: {
2070
+ kind: "invalid-parameters",
2071
+ styleId: recipe.id,
2072
+ issues: parsedParameters.error.issues.map((issue) => issue.message)
2073
+ }
2074
+ };
2075
+ const definition = recipe.defineSystem(parsedParameters.data);
2076
+ const roles = materializeButtonRoles(definition.roles);
2077
+ const buttonSystem = {
2078
+ global: buttonFamilyProjection(roles.primary),
2079
+ sizes: roles.primary.visualStates?.base.sizes,
2080
+ variants: PUBLIC_BUTTON_ROLES.map((role) => roles[role]),
2081
+ surfacePolicy: definition.surfacePolicy ?? createStandardButtonSurfacePolicy()
2082
+ };
2083
+ const parsedButtonSystem = z.safeParse(buttonSystemSchema, buttonSystem);
2084
+ if (!parsedButtonSystem.success) return {
2085
+ kind: "error",
2086
+ error: {
2087
+ kind: "invalid-button-system",
2088
+ styleId: recipe.id,
2089
+ issues: parsedButtonSystem.error.issues.map((issue) => issue.message)
2090
+ }
2091
+ };
2092
+ return {
2093
+ kind: "resolved",
2094
+ buttonSystem: parsedButtonSystem.data
2095
+ };
2096
+ }
2097
+ /** Historical family metadata remains a projection; recipes never read it. */
2098
+ function buttonFamilyProjection(primary) {
2099
+ const base = primary.visualStates.base;
2100
+ const type = base.typography;
2101
+ return {
2102
+ cornerStyle: base.borderRadius === "rounded-none" ? "square" : base.borderRadius === "rounded-full" ? "pill" : "rounded",
2103
+ shadow: base.shadow.elevation,
2104
+ fontWeight: type.fontWeight,
2105
+ textTransform: type.textTransform,
2106
+ typography: type.typography,
2107
+ ...type.fontSize === null ? {} : { fontSize: type.fontSize },
2108
+ ...type.letterSpacing === null || type.letterSpacing === "heading" ? {} : { letterSpacing: type.letterSpacing },
2109
+ ...type.italic ? { italic: true } : {},
2110
+ hoverTransform: "none",
2111
+ hoverColor: "none"
2112
+ };
2113
+ }
2114
+ function materializeCompleteRole(role, appearance) {
2115
+ return {
2116
+ visualStates: appearance.states,
2117
+ background: appearance.states.base.background,
2118
+ borderRadius: appearance.states.base.borderRadius,
2119
+ ...appearance.states.base.border === "none" ? {} : { border: appearance.states.base.border },
2120
+ shadow: appearance.states.base.shadow,
2121
+ sizes: appearance.states.base.sizes,
2122
+ effects: Object.fromEntries([
2123
+ "base",
2124
+ "hover",
2125
+ "focus",
2126
+ "active"
2127
+ ].flatMap((state) => {
2128
+ const effects = appearance.states[state].effects;
2129
+ return effects.length === 0 ? [] : [[state, effects]];
2130
+ })),
2131
+ ...appearance.states.hover.contextualHover ? { contextualHover: appearance.states.hover.contextualHover } : {},
2132
+ ...appearance.affordance ? { affordance: appearance.affordance } : {},
2133
+ ...appearance.keyframes ? { keyframes: appearance.keyframes } : {},
2134
+ id: role,
2135
+ name: roleName(role),
2136
+ enabled: true,
2137
+ priority: rolePriority(role)
2138
+ };
2139
+ }
2140
+ function roleName(role) {
2141
+ return role.charAt(0).toUpperCase() + role.slice(1);
2142
+ }
2143
+ function rolePriority(role) {
2144
+ if (role === "primary") return 1;
2145
+ if (role === "secondary") return 2;
2146
+ return 3;
2147
+ }
1698
2148
  //#endregion
1699
2149
  //#region ../theme-core/src/buttons/constants.ts
1700
2150
  /**
@@ -1948,12 +2398,18 @@ function buttonTypographyDeclarations(type) {
1948
2398
  ...type.textTransform === "none" ? [] : [["text-transform", type.textTransform]]
1949
2399
  ];
1950
2400
  }
2401
+ /** A Tailwind radius token, or a free radius (`46% 54% 58% 42% / 52% 44% 56% 48%`) passed through as written. */
1951
2402
  function buttonRadius(radius) {
1952
- return BORDER_RADIUS_MAP[radius] ?? BORDER_RADIUS_MAP.rounded ?? "0.375rem";
2403
+ return BORDER_RADIUS_MAP[radius] ?? (isFreeButtonRadius(radius) ? radius : BORDER_RADIUS_MAP.rounded ?? "0.375rem");
1953
2404
  }
1954
2405
  function buttonShadow(shadow, tokens) {
1955
2406
  return generateShadowValue(shadow.elevation, shadow.softness, shadow.position, shadow.colorToken ? tokens.getColor(shadow.colorToken) : void 0);
1956
2407
  }
2408
+ /** A state's whole box-shadow: its declared layers when it has them, otherwise its one shadow. */
2409
+ function buttonStateShadow(state, tokens, paint) {
2410
+ if (state.shadow === "focus-indicator") return null;
2411
+ return state.shadowLayers ? buttonShadowLayersValue(state.shadowLayers, paint) : buttonShadow(state.shadow, tokens);
2412
+ }
1957
2413
  function buttonBorder(border, tokens) {
1958
2414
  return border === "none" ? null : `${BORDER_WIDTH_MAP[border.widthClass] || "1px"} solid ${border.boundaryInk ? tokens.getColor(border.boundaryInk) : "currentColor"}`;
1959
2415
  }
@@ -1968,15 +2424,15 @@ function buttonTypographyChanges(base, state) {
1968
2424
  return [...declared, ...resets].filter(([property, value]) => original.get(property) !== value);
1969
2425
  }
1970
2426
  /** Emit only changed declarations; identical states keep historical CSS bytes. */
1971
- function buttonStateAppearanceDeclarations(base, state, tokens, disabled = false) {
2427
+ function buttonStateAppearanceDeclarations(base, state, tokens, paint, disabled = false) {
1972
2428
  const border = buttonBorder(state.border, tokens);
1973
2429
  const radius = buttonRadius(state.borderRadius);
1974
- const shadow = !disabled && state.shadow !== "focus-indicator" ? buttonShadow(state.shadow, tokens) : null;
2430
+ const shadow = disabled ? null : buttonStateShadow(state, tokens, paint);
1975
2431
  return [
1976
2432
  ...buttonTypographyChanges(base.typography, state.typography),
1977
2433
  ...buttonRadius(base.borderRadius) === radius ? [] : [["border-radius", radius]],
1978
2434
  ...buttonBorder(base.border, tokens) === border ? [] : [["border", border ?? "none"]],
1979
- ...shadow === null || base.shadow === "focus-indicator" || buttonShadow(base.shadow, tokens) === shadow ? [] : [["box-shadow", shadow]]
2435
+ ...shadow === null || buttonStateShadow(base, tokens, paint) === shadow ? [] : [["box-shadow", shadow]]
1980
2436
  ];
1981
2437
  }
1982
2438
  /** Surface paint is a context for the recipe, checked by the same colour owner. */
@@ -2370,15 +2826,42 @@ function unknownEffect(input, effect) {
2370
2826
  }
2371
2827
  //#endregion
2372
2828
  //#region ../theme-core/src/buttons/contextualHover.ts
2829
+ /**
2830
+ * The smallest OKLab move that reads as a hover. Neighbouring steps of a
2831
+ * palette scale are about 0.06 to 0.08 apart.
2832
+ */
2833
+ const MINIMUM_VISIBLE_STEP = .04;
2834
+ /**
2835
+ * The contrast at which a fill reads as a fill rather than a shadow on its
2836
+ * ground. It applies when the recipe names the ink to fill with
2837
+ * (`preferredToken`): those buttons rest as an outline and fill only on hover,
2838
+ * so the fill has to read against the ground on its own. A button edge can keep
2839
+ * a darker fill distinct, but it then looks like a hole in the panel.
2840
+ */
2841
+ const FILL_CLEARS_GROUND = 1.5;
2842
+ /** Two label inks closer than this read as the same ink (a near-black for black); a light label against a dark one is far above it. */
2843
+ const SAME_LABEL_INK = 3;
2844
+ /** A step a filled button can change its label for: one or two neighbouring shades of its scale. */
2845
+ const NEAR_STEP = .2;
2846
+ /**
2847
+ * The ends of a scale are often close to neutral black or white. A shade below
2848
+ * the dark end or above the light end (OKLab lightness) that has under this
2849
+ * share of the seed's chroma reads as grey, black or white, not as the button.
2850
+ */
2851
+ const HUELESS_DARK_END = .2;
2852
+ const HUELESS_LIGHT_END = .94;
2853
+ const HUE_KEPT_SHARE = .5;
2854
+ /** The recipe's own hover ink wins when it holds; otherwise the shade shift decides. */
2373
2855
  function resolveContextualHoverPreference(input) {
2374
2856
  const preferred = input.instruction.preferredToken;
2375
- if (preferred && isSafeCandidate(preferred, input.palette, input.surface, input.colourIndex, input.border)) return {
2857
+ if (preferred && preferredInkHolds(preferred, input)) return {
2376
2858
  kind: "resolved",
2377
2859
  token: preferred,
2378
2860
  repair: null
2379
2861
  };
2380
2862
  const contextual = resolveContextualHover(input);
2381
- return contextual.kind === "resolved" ? {
2863
+ if (contextual.kind === "unavailable") return contextual;
2864
+ return {
2382
2865
  kind: "resolved",
2383
2866
  token: contextual.token,
2384
2867
  repair: preferred ? {
@@ -2386,112 +2869,154 @@ function resolveContextualHoverPreference(input) {
2386
2869
  preferredToken: preferred,
2387
2870
  contextualToken: contextual.token
2388
2871
  } : null
2389
- } : contextual;
2872
+ };
2390
2873
  }
2391
2874
  /**
2392
- * Resolves semantic shade movement from real palette steps. The persisted
2393
- * instruction owns the colour family and deterministic unknown-surface
2394
- * fallback; a proven surface may select the opposite direction when it gives
2395
- * the button stronger separation while retaining the shared contrast contract.
2875
+ * Chooses the hover fill from the seed's own shade family, so the hue stays.
2876
+ *
2877
+ * A hover should read as the same button, stronger. The choice is made on the
2878
+ * colours themselves, not on shade numbers (a brand colour is rarely the 500
2879
+ * step of its scale). Hard limits come first: the label stays readable, the
2880
+ * hover stands apart from a known surface, and a button that rests filled
2881
+ * stays recognisably itself. `HOVER_PREFERENCE` then ranks what's left.
2882
+ *
2883
+ * The ground is the proven surface, or the palette's page colour when the
2884
+ * surface is unknown. With neither, the instruction's fallback direction
2885
+ * stands in for "stronger".
2396
2886
  */
2397
2887
  function resolveContextualHover(input) {
2398
- const candidates = shadeCandidates(input.instruction.seedToken, input.palette);
2399
- if (candidates.length === 0) return {
2888
+ const shades = shadeCandidates(input);
2889
+ if (shades.length === 0) return {
2400
2890
  kind: "unavailable",
2401
2891
  reason: "no-distinct-shade"
2402
2892
  };
2403
- const textSafe = candidates.filter((candidate) => hasSafeTextContrast(candidate.token, input.palette, input.colourIndex));
2404
- if (textSafe.length === 0) return {
2893
+ const readable = shades.filter((shade) => labelReadable(shade.hex, shade.labelInk, input.colourIndex));
2894
+ if (readable.length === 0) return {
2405
2895
  kind: "unavailable",
2406
2896
  reason: "no-text-safe-candidate"
2407
2897
  };
2408
- if (!input.surface) {
2409
- const selected = textSafe.find((candidate) => candidate.direction === input.instruction.fallbackDirection) ?? textSafe[0];
2410
- return selected ? {
2411
- kind: "resolved",
2412
- token: selected.token,
2413
- direction: selected.direction,
2414
- evidence: "fallback-direction"
2415
- } : {
2416
- kind: "unavailable",
2417
- reason: "no-text-safe-candidate"
2418
- };
2419
- }
2420
- const selected = selectSurfaceSafeHover(textSafe, {
2421
- palette: input.palette,
2422
- surface: input.surface,
2423
- colourIndex: input.colourIndex,
2424
- fallbackDirection: input.instruction.fallbackDirection,
2425
- border: input.border
2426
- });
2427
- return selected ? {
2898
+ const restLabel = seedFilledRestLabel(input.rest, input.instruction.seedToken);
2899
+ const selected = pickHover(readable.filter((shade) => standsApartFromSurface(shade.hex, shade.labelInk, input) && (restLabel === void 0 || staysTheSameFilledButton(shade, restLabel))));
2900
+ const surfaceKnown = input.surface !== void 0;
2901
+ if (!selected) return {
2902
+ kind: "unavailable",
2903
+ reason: surfaceKnown ? "no-surface-safe-candidate" : "no-text-safe-candidate"
2904
+ };
2905
+ return {
2428
2906
  kind: "resolved",
2429
2907
  token: selected.token,
2430
2908
  direction: selected.direction,
2431
- evidence: "known-surface"
2432
- } : {
2433
- kind: "unavailable",
2434
- reason: "no-surface-safe-candidate"
2909
+ evidence: surfaceKnown ? "known-surface" : "fallback-direction"
2435
2910
  };
2436
2911
  }
2437
- /** Rank the proven-surface candidates without mixing selection with fallback policy. */
2438
- function selectSurfaceSafeHover(candidates, input) {
2439
- return candidates.flatMap((candidate) => {
2440
- const separation = buttonSurfaceSeparation(input.palette[candidate.token] ?? "", input.surface, {
2441
- border: input.border,
2442
- palette: input.palette,
2443
- labelInk: input.palette[solidForegroundToken(candidate.token)] ?? ""
2444
- });
2445
- return separation.distinct ? [{
2446
- ...candidate,
2447
- surfaceDistance: separation.deltaE
2448
- }] : [];
2449
- }).sort((left, right) => {
2450
- const distanceDifference = left.distance - right.distance;
2451
- if (distanceDifference !== 0) return distanceDifference;
2452
- const contrastDifference = (right.surfaceDistance ?? 0) - (left.surfaceDistance ?? 0);
2453
- if (contrastDifference !== 0) return contrastDifference;
2454
- if (left.direction === right.direction) return left.token.localeCompare(right.token);
2455
- return left.direction === input.fallbackDirection ? -1 : 1;
2456
- })[0];
2457
- }
2458
- function shadeCandidates(seedToken, palette) {
2459
- const match = String(seedToken).match(/^(.*?)(?:-(\d{2,3}))?$/);
2460
- const family = match?.[1] ?? String(seedToken);
2461
- const currentShade = match?.[2] ? Number(match[2]) : 500;
2462
- const seedHex = palette[seedToken];
2463
- const shades = Object.keys(palette).flatMap((token) => {
2464
- const shade = token.match(new RegExp(`^${escapeRegExp(family)}-(\\d{2,3})$`));
2465
- return shade?.[1] ? [Number(shade[1])] : [];
2466
- }).filter((shade) => Number.isFinite(shade)).sort((left, right) => left - right);
2467
- const lower = [...shades].filter((shade) => shade < currentShade).sort((left, right) => right - left);
2468
- const higher = shades.filter((shade) => shade > currentShade);
2469
- return [...lower.map((shade) => candidate(family, shade, currentShade, "lighter", seedHex, palette)), ...higher.map((shade) => candidate(family, shade, currentShade, "darker", seedHex, palette))].filter((value) => value !== null);
2470
- }
2471
- function candidate(family, shade, currentShade, direction, seedHex, palette) {
2472
- const token = parseOpaqueButtonColourToken(`${family}-${shade}`);
2473
- if (token === null) return null;
2474
- const candidateHex = palette[token];
2475
- if (!candidateHex || candidateHex === seedHex) return null;
2912
+ const visible = (shade) => shade.distance >= MINIMUM_VISIBLE_STEP;
2913
+ /**
2914
+ * Where the hover is looked for, in order. The first group with a shade wins,
2915
+ * and within it the nearest visible step (or, with none visible, the furthest).
2916
+ *
2917
+ * 1. Stronger, keeping the hue, and clearing the ground when the recipe names a fill ink.
2918
+ * 2. Stronger, keeping the hue.
2919
+ * 3. The other way, keeping the hue: a visible hover beats a hue-less or invisible one.
2920
+ * 4. Any stronger shade.
2921
+ * 5. Any shade the other way.
2922
+ */
2923
+ const HOVER_PREFERENCE = [
2924
+ (shade) => shade.stronger && shade.keepsHue && visible(shade) && shade.fillClearsGround,
2925
+ (shade) => shade.stronger && shade.keepsHue && visible(shade),
2926
+ (shade) => !shade.stronger && shade.keepsHue && visible(shade),
2927
+ (shade) => shade.stronger,
2928
+ () => true
2929
+ ];
2930
+ function pickHover(allowed) {
2931
+ for (const inGroup of HOVER_PREFERENCE) {
2932
+ const group = allowed.filter(inGroup);
2933
+ if (group.length > 0) return nearestVisibleStep(group);
2934
+ }
2935
+ }
2936
+ function nearestVisibleStep(shades) {
2937
+ const byDistance = [...shades].sort((left, right) => left.distance - right.distance || left.token.localeCompare(right.token));
2938
+ return byDistance.find(visible) ?? byDistance[byDistance.length - 1];
2939
+ }
2940
+ /** The label ink of a button that rests filled with the seed; undefined when it rests some other way (it fills only on hover). */
2941
+ function seedFilledRestLabel(rest, seed) {
2942
+ return rest.kind === "solid" && rest.colorToken === seed ? rest.labelInk : void 0;
2943
+ }
2944
+ /**
2945
+ * A button that rests filled with the seed should still read as itself on
2946
+ * hover. A shade that needs the other label ink is only allowed a near step
2947
+ * away (a jump across the scale with the label flipped looks like another
2948
+ * button), and a shade the other way has to keep the hue. A button that fills
2949
+ * only on hover changes its label anyway, so this doesn't apply to it.
2950
+ */
2951
+ function staysTheSameFilledButton(shade, restLabel) {
2952
+ return (contrastRatio(shade.labelInk, restLabel) < SAME_LABEL_INK || shade.distance <= NEAR_STEP) && (shade.stronger || shade.keepsHue);
2953
+ }
2954
+ function labelReadable(hex, labelInk, colourIndex) {
2955
+ return labelInk !== void 0 && contrastRatio(hex, labelInk, colourIndex) >= BUTTON_CONTRAST_POLICY.textMinimumRatio;
2956
+ }
2957
+ /** On a proven surface, the fill stands apart from it by colour or by a declared edge. */
2958
+ function standsApartFromSurface(hex, labelInk, input) {
2959
+ return input.surface === void 0 || buttonSurfaceSeparation(hex, input.surface, {
2960
+ border: input.border,
2961
+ palette: input.palette,
2962
+ labelInk
2963
+ }).distinct;
2964
+ }
2965
+ /** The recipe's own hover ink holds when its label reads and, on a proven surface, it stands apart and clears the surface as a fill. */
2966
+ function preferredInkHolds(token, input) {
2967
+ const hex = input.palette[token];
2968
+ const labelInk = input.palette[solidForegroundToken(token)];
2969
+ if (hex === void 0 || !labelReadable(hex, labelInk, input.colourIndex)) return false;
2970
+ return input.surface === void 0 || standsApartFromSurface(hex, labelInk, input) && contrastRatio(hex, input.surface.backgroundHex, input.colourIndex) >= FILL_CLEARS_GROUND;
2971
+ }
2972
+ /** The other steps of the seed's scale (`primary-100` … `primary-950`), measured against the seed and the ground. */
2973
+ function shadeCandidates(input) {
2974
+ const { instruction, palette, colourIndex } = input;
2975
+ const seedHex = palette[instruction.seedToken];
2976
+ if (seedHex === void 0) return [];
2977
+ const family = String(instruction.seedToken).match(/^(.*?)(?:-\d{2,3})?$/)?.[1] ?? String(instruction.seedToken);
2978
+ const step = new RegExp(`^${escapeRegExp(family)}-\\d{2,3}$`);
2979
+ const ground = input.surface?.backgroundHex ?? palette.background;
2980
+ const seed = {
2981
+ hex: seedHex,
2982
+ lightness: contrastRatio(seedHex, "#000000"),
2983
+ chroma: oklab(seedHex).chroma,
2984
+ ground: ground === void 0 ? void 0 : {
2985
+ contrast: (hex) => contrastRatio(hex, ground, colourIndex),
2986
+ restContrast: contrastRatio(seedHex, ground, colourIndex)
2987
+ }
2988
+ };
2989
+ return Object.keys(palette).flatMap((name) => {
2990
+ const token = step.test(name) ? parseOpaqueButtonColourToken(name) : null;
2991
+ const hex = token === null ? void 0 : palette[token];
2992
+ return token === null || hex === void 0 || hex === seedHex ? [] : [describeShade(token, hex, seed, input)];
2993
+ });
2994
+ }
2995
+ function describeShade(token, hex, seed, input) {
2996
+ const { instruction, palette } = input;
2997
+ const direction = contrastRatio(hex, "#000000") > seed.lightness ? "lighter" : "darker";
2998
+ const groundContrast = seed.ground?.contrast(hex);
2476
2999
  return {
2477
3000
  token,
3001
+ hex,
2478
3002
  direction,
2479
- distance: Math.abs(shade - currentShade),
2480
- surfaceDistance: null
3003
+ labelInk: palette[solidForegroundToken(token)],
3004
+ distance: hexOklabDistance(seed.hex, hex),
3005
+ stronger: seed.ground === void 0 ? direction === instruction.fallbackDirection : seed.ground.contrast(hex) >= seed.ground.restContrast,
3006
+ keepsHue: keepsHue(oklab(hex), seed.chroma),
3007
+ fillClearsGround: instruction.preferredToken !== void 0 && groundContrast !== void 0 && groundContrast >= FILL_CLEARS_GROUND
2481
3008
  };
2482
3009
  }
2483
- function hasSafeTextContrast(token, palette, colourIndex) {
2484
- const background = palette[token];
2485
- const foreground = palette[solidForegroundToken(token)];
2486
- return typeof background === "string" && typeof foreground === "string" && contrastRatio(background, foreground, colourIndex) >= BUTTON_CONTRAST_POLICY.textMinimumRatio;
3010
+ function keepsHue(shade, seedChroma) {
3011
+ return !(shade.lightness < HUELESS_DARK_END || shade.lightness > HUELESS_LIGHT_END) || shade.chroma >= seedChroma * HUE_KEPT_SHARE;
2487
3012
  }
2488
- function isSafeCandidate(token, palette, surface, colourIndex, border) {
2489
- if (!hasSafeTextContrast(token, palette, colourIndex)) return false;
2490
- return surface ? buttonSurfaceSeparation(palette[token] ?? "", surface, {
2491
- border,
2492
- palette,
2493
- labelInk: palette[solidForegroundToken(token)] ?? ""
2494
- }).distinct : true;
3013
+ function oklab(hex) {
3014
+ const { r, g, b } = hexToRgb(hex);
3015
+ const lab = srgbToOklab(r, g, b);
3016
+ return {
3017
+ lightness: lab.L,
3018
+ chroma: Math.hypot(lab.a, lab.b)
3019
+ };
2495
3020
  }
2496
3021
  function escapeRegExp(value) {
2497
3022
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -2505,7 +3030,8 @@ function resolveButtonHoverTreatment(input) {
2505
3030
  palette: input.palette,
2506
3031
  colourIndex: input.colourIndex,
2507
3032
  surface: input.surface,
2508
- border: input.variant.border
3033
+ border: input.variant.border,
3034
+ rest: input.rest
2509
3035
  });
2510
3036
  if (contextual.kind === "resolved") return {
2511
3037
  treatment: {
@@ -2555,6 +3081,11 @@ function compileButtonColourStates(input) {
2555
3081
  variant: input.variant,
2556
3082
  global: input.global,
2557
3083
  fallback: base.treatment,
3084
+ rest: restingFill({
3085
+ ...input,
3086
+ variantId: input.variant.id,
3087
+ state: "base"
3088
+ }, base.treatment),
2558
3089
  palette: input.palette,
2559
3090
  surface: input.surface,
2560
3091
  colourIndex: input.colourIndex
@@ -2579,7 +3110,12 @@ function compileDeclaredVisualStates(input, states) {
2579
3110
  hoverColor: "none",
2580
3111
  hoverColorToken: void 0
2581
3112
  },
2582
- fallback: states.hover.background
3113
+ fallback: states.hover.background,
3114
+ rest: restingFill({
3115
+ ...input,
3116
+ variantId: input.variant.id,
3117
+ state: "base"
3118
+ }, states.base.background)
2583
3119
  });
2584
3120
  const colours = collectStateColours(mapVisualStates((state) => compileDeclaredVisualState(input, states, state, state === "hover" ? hover.treatment : states[state].background)));
2585
3121
  return colours.ok ? {
@@ -2740,13 +3276,25 @@ function resolveSolid(input, backgroundToken, preferredForeground) {
2740
3276
  function resolveSolidButtonColour(input, backgroundToken, preferredForeground) {
2741
3277
  return resolveSolid(input, backgroundToken, preferredForeground);
2742
3278
  }
2743
- /** Preserve checked on-colours (a requested label colour first); a solid state's last resort belongs to its actual fill. */
3279
+ /** A solid rest fill with the label ink resolveSolidInk gives it, so a contextual hover compares against the ink visitors see. */
3280
+ function restingFill(input, treatment) {
3281
+ if (treatment.type !== "solid") return { kind: "not-solid" };
3282
+ const hex = input.palette[treatment.colorToken];
3283
+ if (hex === void 0) return { kind: "not-solid" };
3284
+ const ink = resolveSolidInk(input, treatment.colorToken, hex, treatment.foregroundToken);
3285
+ return {
3286
+ kind: "solid",
3287
+ colorToken: treatment.colorToken,
3288
+ labelInk: ink.foregroundHex
3289
+ };
3290
+ }
3291
+ /** Preserve checked on-colours (a requested label colour first); a solid state's last resort is the palette ink for its actual fill. */
2744
3292
  function resolveSolidInk(input, backgroundToken, backgroundHex, preferredForeground) {
2745
3293
  if (preferredForeground !== void 0) {
2746
3294
  const preferred = checkedSolidInk(input, backgroundToken, backgroundHex, preferredForeground);
2747
3295
  if (preferred) return preferred;
2748
3296
  }
2749
- return checkedSolidInk(input, backgroundToken, backgroundHex, unsafeAsOpaqueButtonColourToken(solidForegroundToken(backgroundToken))) ?? blackOrWhiteSolidInk(backgroundToken, backgroundHex);
3297
+ return checkedSolidInk(input, backgroundToken, backgroundHex, unsafeAsOpaqueButtonColourToken(solidForegroundToken(backgroundToken))) ?? paletteSolidInk(input, backgroundToken, backgroundHex);
2750
3298
  }
2751
3299
  function checkedSolidInk(input, backgroundToken, backgroundHex, foregroundToken) {
2752
3300
  const candidate = input.palette[foregroundToken];
@@ -2768,14 +3316,18 @@ function checkedSolidInk(input, backgroundToken, backgroundHex, foregroundToken)
2768
3316
  };
2769
3317
  return null;
2770
3318
  }
2771
- function blackOrWhiteSolidInk(backgroundToken, backgroundHex) {
2772
- const foregroundHex = pickBlackOrWhiteTextColor(backgroundHex);
3319
+ /** The palette's own background or text as the label where it reads (as a checked token), else literal black or white. */
3320
+ function paletteSolidInk(input, backgroundToken, backgroundHex) {
3321
+ const ink = paletteInkOnSolid(backgroundHex, paletteInkRoles(input.palette));
3322
+ const role = ink.kind === "role" ? checkedSolidInk(input, backgroundToken, backgroundHex, unsafeAsOpaqueButtonColourToken(ink.role)) : null;
3323
+ if (role) return role;
3324
+ const literal = pickBlackOrWhiteTextColor(backgroundHex);
2773
3325
  return {
2774
- foregroundHex,
3326
+ foregroundHex: literal,
2775
3327
  colour: {
2776
3328
  kind: "known-solid",
2777
3329
  backgroundCss: tokenCss(backgroundToken),
2778
- foregroundCss: foregroundHex
3330
+ foregroundCss: literal
2779
3331
  }
2780
3332
  };
2781
3333
  }
@@ -2854,7 +3406,7 @@ function interpolateHex(startHex, endHex, position) {
2854
3406
  }
2855
3407
  //#endregion
2856
3408
  //#region ../theme-core/src/buttons/buttonSurfaceContext.ts
2857
- /** The last resort, chosen by `maxContrastBlackOrWhite`. */
3409
+ /** The last resort, when neither palette role reads (`paletteInkOnSolid`). */
2858
3410
  const LITERAL_NEUTRALS = {
2859
3411
  black: {
2860
3412
  hex: "#000000",
@@ -2875,7 +3427,7 @@ function deriveButtonSurfaceContext(input, palette, fallbackToken, colourIndex)
2875
3427
  const background = deriveKnownBackground(input, palette, fallbackToken);
2876
3428
  if (background.kind === "unknown") return background;
2877
3429
  const explicitForeground = resolveKnownColour(input.kind === "solid" || input.kind === "inherit" ? input.foreground ?? "" : "", palette);
2878
- const foreground = explicitForeground && contrastRatio(background.colour.hex, explicitForeground.hex, colourIndex) >= 4.5 ? explicitForeground : LITERAL_NEUTRALS[maxContrastBlackOrWhite(solidPaint(background.colour.hex, colourIndex)).ink];
3430
+ const foreground = explicitForeground && contrastRatio(background.colour.hex, explicitForeground.hex, colourIndex) >= 4.5 ? explicitForeground : automaticForeground(background.colour.hex, palette);
2879
3431
  return {
2880
3432
  kind: "known-solid",
2881
3433
  source: background.source,
@@ -3050,7 +3602,7 @@ function resolveFallbackButtonRole(input, requested, fallbacks, rejected) {
3050
3602
  kind: "repaired",
3051
3603
  requestedRole: input.role,
3052
3604
  candidate: candidate.name,
3053
- states: candidate.name === "surface-outline" ? withSurfaceInversion(compiled.states, input.surface) : compiled.states,
3605
+ states: surfaceFallbackStates(fallback, compiled.states, input.surface),
3054
3606
  focusIndicator: compiled.focusIndicator,
3055
3607
  boundary: candidate.boundary,
3056
3608
  rejectedCandidates: rejected
@@ -3101,26 +3653,39 @@ function resetActionVariables(role) {
3101
3653
  ]) styles[actionVariableName(role, state, property)] = "initial";
3102
3654
  return styles;
3103
3655
  }
3104
- function withSurfaceInversion(states, surface) {
3105
- const inverted = {
3106
- kind: "known-solid",
3107
- backgroundCss: surface.foregroundCss,
3108
- foregroundCss: surface.backgroundCss
3109
- };
3110
- return {
3656
+ /**
3657
+ * Both surface fallbacks paint with the surface's own checked pair. The outline
3658
+ * fills with the ground's ink on hover. The solid is filled with it from the
3659
+ * start, and on hover either stays so or takes the ground's colour, as an
3660
+ * opaque paint so a part can draw with it.
3661
+ */
3662
+ function surfaceFallbackStates(fallback, states, surface) {
3663
+ const inverted = surfaceInkFill(surface);
3664
+ if (fallback.kind === "surface-outline") return {
3111
3665
  ...states,
3112
3666
  hover: inverted,
3113
3667
  active: inverted
3114
3668
  };
3115
- }
3116
- function actionVariableName(role, state, property) {
3117
- return `--rb-action-${role}-${state}-${property}`;
3118
- }
3119
- function actionVariableFallback(role, state, property, fallback) {
3120
- return `var(${actionVariableName(role, state, property)}, ${fallback})`;
3121
- }
3122
- function actionVariablePrefix(role, state) {
3123
- return `--rb-action-${role}-${state}`;
3669
+ if (fallback.kind !== "surface-solid") return states;
3670
+ if (fallback.hover === "steady") return {
3671
+ base: inverted,
3672
+ hover: inverted,
3673
+ focus: inverted,
3674
+ active: inverted,
3675
+ disabled: inverted
3676
+ };
3677
+ const ground = {
3678
+ kind: "known-solid",
3679
+ backgroundCss: surface.backgroundCss,
3680
+ foregroundCss: surface.foregroundCss
3681
+ };
3682
+ return {
3683
+ base: inverted,
3684
+ hover: ground,
3685
+ focus: inverted,
3686
+ active: ground,
3687
+ disabled: inverted
3688
+ };
3124
3689
  }
3125
3690
  function compileCandidate(variant, context) {
3126
3691
  return compileButtonColourStates({
@@ -3131,6 +3696,13 @@ function compileCandidate(variant, context) {
3131
3696
  colourIndex: context.colourIndex
3132
3697
  });
3133
3698
  }
3699
+ function surfaceInkFill(surface) {
3700
+ return {
3701
+ kind: "known-solid",
3702
+ backgroundCss: surface.foregroundCss,
3703
+ foregroundCss: surface.backgroundCss
3704
+ };
3705
+ }
3134
3706
  function candidateVariant(fallback, requested, system) {
3135
3707
  if (fallback.kind === "variant") {
3136
3708
  const variant = findVariant(system, fallback.role);
@@ -3142,7 +3714,7 @@ function candidateVariant(fallback, requested, system) {
3142
3714
  }
3143
3715
  const width = BORDER_WIDTH_MAP.border ?? "1px";
3144
3716
  return {
3145
- name: "surface-outline",
3717
+ name: fallback.kind,
3146
3718
  variant: {
3147
3719
  ...requested,
3148
3720
  visualStates: void 0,
@@ -3150,12 +3722,15 @@ function candidateVariant(fallback, requested, system) {
3150
3722
  type: "surface",
3151
3723
  role: "link"
3152
3724
  },
3153
- border: { widthClass: "border" },
3725
+ border: fallback.kind === "surface-solid" && fallback.hover === "swap" ? {
3726
+ widthClass: "border",
3727
+ marksBoundary: true
3728
+ } : { widthClass: "border" },
3154
3729
  hoverBackgroundToken: void 0,
3155
3730
  contextualHover: void 0,
3156
3731
  effects: void 0
3157
3732
  },
3158
- boundary: {
3733
+ boundary: fallback.kind === "surface-solid" && requested.border?.ring ? boundaryForVariant(requested) : {
3159
3734
  width,
3160
3735
  color: "currentColor"
3161
3736
  }
@@ -3180,6 +3755,16 @@ function boundaryForVariant(variant) {
3180
3755
  function findVariant(system, role) {
3181
3756
  return system.variants.find((variant) => variant.enabled && variant.id === role);
3182
3757
  }
3758
+ /** The surface's automatic text: the palette's own background or text where it reads, else black or white. */
3759
+ function automaticForeground(backgroundHex, palette) {
3760
+ const ink = paletteInkOnSolid(backgroundHex, paletteInkRoles(palette));
3761
+ if (ink.kind === "literal") return LITERAL_NEUTRALS[ink.hex === "#000000" ? "black" : "white"];
3762
+ return resolveKnownColour(ink.role, palette) ?? {
3763
+ hex: ink.hex,
3764
+ css: ink.hex,
3765
+ source: "literal-css"
3766
+ };
3767
+ }
3183
3768
  function resolveKnownColour(value, palette) {
3184
3769
  const reference = parseThemeColorReference(value, { palette });
3185
3770
  if (reference.kind !== "literal-css") {
@@ -3270,100 +3855,17 @@ function contextualBoundaryStyles(boundary) {
3270
3855
  };
3271
3856
  }
3272
3857
  //#endregion
3273
- //#region ../theme-core/src/palette/utils/scrimContrast.ts
3274
- const WHITE = "#ffffff";
3275
- const BLACK = "#000000";
3276
- /** `top` at `alpha` over opaque `bottom`, blended as CSS paints an overlay. */
3277
- function compositeHex(topHex, alpha, bottomHex) {
3278
- const top = hexToRgb(topHex);
3279
- const bottom = hexToRgb(bottomHex);
3280
- const mix = (a, b) => Math.round(alpha * a + (1 - alpha) * b);
3281
- return rgbToHex(mix(top.r, bottom.r), mix(top.g, bottom.g), mix(top.b, bottom.b));
3282
- }
3283
- /**
3284
- * The lowest contrast `foreground` can reach over `scrim` at `alpha` laid on
3285
- * any pixel. A foreground whose luminance falls inside the range the
3286
- * composites can take has a worst case of 1:1.
3287
- */
3288
- function worstCaseScrimContrast(input) {
3289
- const overWhite = compositeHex(input.scrimHex, input.alpha, WHITE);
3290
- const overBlack = compositeHex(input.scrimHex, input.alpha, BLACK);
3291
- const luminance = (hex) => {
3292
- const { r, g, b } = hexToRgb(hex);
3293
- return relativeLuminance(r, g, b);
3294
- };
3295
- const foreground = luminance(input.foregroundHex);
3296
- const low = luminance(overBlack);
3297
- const high = luminance(overWhite);
3298
- if (foreground >= low && foreground <= high) return 1;
3299
- return Math.min(contrastRatio(input.foregroundHex, overWhite), contrastRatio(input.foregroundHex, overBlack));
3300
- }
3301
- /**
3302
- * The smallest scrim opacity, in hundredths, at which every foreground keeps
3303
- * `threshold` contrast over any pixel. `null` when even an opaque scrim fails,
3304
- * which means the foreground was never legible on the scrim colour itself.
3305
- */
3306
- function minimumScrimOpacity(input) {
3307
- const passes = (alpha) => input.foregroundHexes.every((foregroundHex) => worstCaseScrimContrast({
3308
- foregroundHex,
3309
- scrimHex: input.scrimHex,
3310
- alpha
3311
- }) >= input.threshold);
3312
- return Array.from({ length: 101 }, (_, hundredths) => hundredths / 100).find(passes) ?? null;
3313
- }
3314
- /** Shared samples for literal RGB washes and palette-token gradient veils. */
3315
- function gradientScrimSamples(gradient, alpha, palette) {
3316
- const literal = [...gradient.matchAll(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+))?\s*\)/g)].map((stop) => ({
3317
- hex: rgbToHex(Number(stop[1]), Number(stop[2]), Number(stop[3])),
3318
- alpha: alpha * (stop[4] === void 0 ? 1 : Number(stop[4]))
3319
- }));
3320
- const tokens = [...gradient.matchAll(/var\(--tb-([\w-]+)\)/g)].flatMap((stop) => {
3321
- const hex = stop[1] ? resolveConcreteColorHex(stop[1], palette) : null;
3322
- return hex ? [{
3323
- hex,
3324
- alpha
3325
- }] : [];
3326
- });
3327
- return [...literal, ...tokens];
3328
- }
3329
- /** The ink with the stronger worst-pixel guarantee identifies the veil tone.
3330
- * No readable samples (or a tie) leaves classification to the foreground owner.
3331
- */
3332
- function scrimTone(samples) {
3333
- if (samples.length === 0) return null;
3334
- const worst = (foregroundHex) => Math.min(...samples.map((sample) => worstCaseScrimContrast({
3335
- foregroundHex,
3336
- scrimHex: sample.hex,
3337
- alpha: sample.alpha
3338
- })));
3339
- const white = worst(WHITE);
3340
- const black = worst(BLACK);
3341
- return white === black ? null : white > black ? "dark" : "light";
3342
- }
3343
- //#endregion
3344
3858
  //#region ../theme-core/src/site-styles/accessibleSurfaces.ts
3345
3859
  const ON_BACKGROUND = { kind: "on-background" };
3346
3860
  const surfaceRecipes = {
3347
3861
  base: {
3348
3862
  backgroundCandidates: ["background", "surface"],
3349
- headingCandidates: [
3350
- "text",
3351
- ON_BACKGROUND,
3352
- "neutral-950",
3353
- "neutral-50"
3354
- ],
3355
- textCandidates: [
3356
- "text",
3357
- ON_BACKGROUND,
3358
- "neutral-950",
3359
- "neutral-50"
3360
- ],
3863
+ headingCandidates: ["text", ON_BACKGROUND],
3864
+ textCandidates: ["text", ON_BACKGROUND],
3361
3865
  linkCandidates: [
3362
3866
  "primary",
3363
3867
  "text",
3364
- ON_BACKGROUND,
3365
- "neutral-950",
3366
- "neutral-50"
3868
+ ON_BACKGROUND
3367
3869
  ],
3368
3870
  supportingCandidates: ["mutedText"],
3369
3871
  inheritedBackground: true
@@ -3375,24 +3877,12 @@ const surfaceRecipes = {
3375
3877
  "surface",
3376
3878
  "background"
3377
3879
  ],
3378
- headingCandidates: [
3379
- ON_BACKGROUND,
3380
- "text",
3381
- "neutral-950",
3382
- "neutral-50"
3383
- ],
3384
- textCandidates: [
3385
- ON_BACKGROUND,
3386
- "text",
3387
- "neutral-950",
3388
- "neutral-50"
3389
- ],
3880
+ headingCandidates: [ON_BACKGROUND, "text"],
3881
+ textCandidates: [ON_BACKGROUND, "text"],
3390
3882
  linkCandidates: [
3391
3883
  "primary",
3392
3884
  ON_BACKGROUND,
3393
- "text",
3394
- "neutral-950",
3395
- "neutral-50"
3885
+ "text"
3396
3886
  ],
3397
3887
  supportingCandidates: [
3398
3888
  "mutedText",
@@ -3411,25 +3901,19 @@ const surfaceRecipes = {
3411
3901
  ON_BACKGROUND,
3412
3902
  "primaryForeground",
3413
3903
  "background",
3414
- "surface",
3415
- "neutral-50",
3416
- "neutral-950"
3904
+ "surface"
3417
3905
  ],
3418
3906
  textCandidates: [
3419
3907
  ON_BACKGROUND,
3420
3908
  "primaryForeground",
3421
3909
  "background",
3422
- "surface",
3423
- "neutral-50",
3424
- "neutral-950"
3910
+ "surface"
3425
3911
  ],
3426
3912
  linkCandidates: [
3427
3913
  ON_BACKGROUND,
3428
3914
  "primaryForeground",
3429
3915
  "background",
3430
- "surface",
3431
- "neutral-50",
3432
- "neutral-950"
3916
+ "surface"
3433
3917
  ],
3434
3918
  supportingCandidates: [
3435
3919
  ON_BACKGROUND,
@@ -3450,25 +3934,19 @@ const surfaceRecipes = {
3450
3934
  ON_BACKGROUND,
3451
3935
  "primaryForeground",
3452
3936
  "background",
3453
- "surface",
3454
- "neutral-50",
3455
- "neutral-950"
3937
+ "surface"
3456
3938
  ],
3457
3939
  textCandidates: [
3458
3940
  ON_BACKGROUND,
3459
3941
  "primaryForeground",
3460
3942
  "background",
3461
- "surface",
3462
- "neutral-50",
3463
- "neutral-950"
3943
+ "surface"
3464
3944
  ],
3465
3945
  linkCandidates: [
3466
3946
  ON_BACKGROUND,
3467
3947
  "primaryForeground",
3468
3948
  "background",
3469
- "surface",
3470
- "neutral-50",
3471
- "neutral-950"
3949
+ "surface"
3472
3950
  ],
3473
3951
  supportingCandidates: [
3474
3952
  ON_BACKGROUND,
@@ -3493,7 +3971,11 @@ function toAccessibleColorSurfaceIntent(surface) {
3493
3971
  default: return assertNeverSurface(surface);
3494
3972
  }
3495
3973
  }
3496
- /** Keep every successful legacy recipe; only exhausted candidates need neutral ink. */
3974
+ /**
3975
+ * Keep every successful recipe. When no ground has a passing ink, the first
3976
+ * ground present takes the palette's own ink there (the shared owner), which
3977
+ * always reaches ordinary-text contrast on a solid.
3978
+ */
3497
3979
  function resolveAccessibleSurfaceRecipe(input) {
3498
3980
  const result = tryAccessibleSurfaceRecipe(input);
3499
3981
  if (result.kind === "resolved-accessible-surface") return result;
@@ -3501,13 +3983,13 @@ function resolveAccessibleSurfaceRecipe(input) {
3501
3983
  const token = recipe.backgroundCandidates.find((candidate) => resolveConcreteColorHex(candidate, input.palette) !== null);
3502
3984
  const hex = token ? resolveConcreteColorHex(token, input.palette) : null;
3503
3985
  if (!token || !hex) return result;
3504
- const ink = pickBlackOrWhiteTextColor(hex);
3986
+ const ink = paletteInkOnSolid(hex, paletteInkRoles(input.palette));
3505
3987
  const foreground = (role) => ({
3506
3988
  kind: "safe-token",
3507
3989
  role,
3508
- token: asAccessibleSurfaceToken(ink),
3509
- hex: ink,
3510
- contrastRatio: contrastRatio(ink, hex)
3990
+ token: asAccessibleSurfaceToken(paletteInkToken(ink)),
3991
+ hex: ink.hex,
3992
+ contrastRatio: ink.ratio
3511
3993
  });
3512
3994
  return {
3513
3995
  kind: "resolved-accessible-surface",
@@ -3606,16 +4088,24 @@ function tryAccessibleSurfaceRecipe(input) {
3606
4088
  rejectedCandidates
3607
4089
  };
3608
4090
  }
4091
+ /**
4092
+ * The recipe's explicit candidates first; when none reads, the palette's own
4093
+ * ink on this ground at the recipe's threshold (the shared owner, which tries
4094
+ * the palette's text and background before black or white). Null only when
4095
+ * even black or white misses the threshold, so the recipe tries its next ground.
4096
+ */
3609
4097
  function resolveRequiredForeground(input) {
3610
- return resolveSafeToken({
4098
+ const explicit = resolveSafeToken(input);
4099
+ if (explicit) return explicit;
4100
+ const ink = paletteInk(solidPaint(input.backgroundHex), paletteInkRoles(input.palette), input.threshold);
4101
+ if (ink.kind === "unpaintable") return null;
4102
+ return {
4103
+ kind: "safe-token",
3611
4104
  role: input.role,
3612
- candidates: input.candidates,
3613
- backgroundToken: input.backgroundToken,
3614
- backgroundHex: input.backgroundHex,
3615
- palette: input.palette,
3616
- threshold: input.threshold,
3617
- rejectedCandidates: input.rejectedCandidates
3618
- });
4105
+ token: asAccessibleSurfaceToken(paletteInkToken(ink)),
4106
+ hex: ink.hex,
4107
+ contrastRatio: ink.ratio
4108
+ };
3619
4109
  }
3620
4110
  function resolveSupportingForeground(input) {
3621
4111
  const resolved = resolveSafeToken({
@@ -3758,14 +4248,14 @@ function ownSurfaceRevision(context) {
3758
4248
  revisionOwners.set(palette, revisions);
3759
4249
  return revision;
3760
4250
  }
3761
- /** Local computation keeps its colour index; transport references only the owning revision inputs. */
4251
+ /** Keep the derived colour index for local computation, but never repeat it on the wire. */
3762
4252
  function surfaceTransportContext(context) {
3763
4253
  const revision = ownSurfaceRevision(context);
3764
- const result = Object.freeze({
4254
+ const result = Object.freeze(Object.defineProperty({
3765
4255
  ...revision,
3766
4256
  colourIndex: context.colourIndex,
3767
4257
  solvedInks: context.solvedInks
3768
- });
4258
+ }, "colourIndex", { enumerable: false }));
3769
4259
  const preparedSurfaces = matchingPreparedSurfaceIndex(preparedSurfaceIndexFor(context), result);
3770
4260
  surfaceRevisionOwners.set(result, {
3771
4261
  revision,
@@ -4473,4 +4963,4 @@ function mapSurfaceTreeChildren(value, map) {
4473
4963
  return isSurfaceTreeRecord(value) ? Object.fromEntries(Object.entries(value).map(([key, item]) => [key, map(item)])) : value;
4474
4964
  }
4475
4965
  //#endregion
4476
- export { surfaceInkPublication as $, DEFAULT_BUTTON_SIZES as A, ORDINARY_TEXT_MIN_CONTRAST_RATIO as At, resolveThemeColorReferenceValue as B, rgbToHex as Bt, buttonRadius as C, freezeOwnedThemeValue as Ct, materializeRuntimeButtonAppearance as D, paletteValueKey as Dt, buttonTypographyDeclarations as E, resolveOpaqueSurfaceHex as Et, defineButtonStyleRecipe as F, featuresFromHex as Ft, mergeStyles as G, backgroundColorStyle as H, mapButtonRoleAppearances as I, hexToRgb as It, textColorValue as J, rgbColorValue as K, mapButtonVisualAppearances as L, oklabToOklch as Lt, FONT_SIZE_MAP as M, preparePaletteColourIndex as Mt, generateShadowValue as N, solidPaint as Nt, paddingDeclarations as O, paletteValueKeySchema as Ot, PUBLIC_BUTTON_ROLES as P, _classPrivateFieldInitSpec as Pt, safeTokenOr as Q, isCssColorLiteral as R, oklabToSrgb as Rt, buttonBorder as S, surfaceInkValue as St, buttonStateAppearanceDeclarations as T, resolveConcreteColorHex as Tt, borderColorStyle as U, resolveTokenOrCssColorValue as V, srgbToOklab as Vt, cssVarValue as W, staysInsideDeclaration as X, callsCssLoadingFunction as Y, resolveSurfaceForeground as Z, contextualButtonSurfaceResetStyles as _, surfaceForegroundStyle as _t, requireResolvedSurface as a, HOVER_TEXT_THRESHOLD as at, BUTTON_CONTRAST_POLICY as b, surfaceInkDeclarations as bt, surfaceButtonRequest as c, inkReference as ct, toAccessibleColorSurfaceIntent as d, planForegroundHover as dt, CONTROL_EDGE_SEED_TOKEN as et, compositeHex as f, DEFAULT_SURFACE_TEXT_COLOR as ft, actionVariableFallback as g, surfaceForegroundInputFromResolved as gt, scrimTone as h, surfaceForegroundDeclarations as ht, prepareThemeSurfaceRevision as i, _classPrivateFieldSet2 as it, ELEVATION_OFFSET as j, contrastRatio as jt, BORDER_WIDTH_MAP as k, requirePaletteColorsFromEntries as kt, surfaceDecorationColors as l, expandPalette as lt, minimumScrimOpacity as m, SURFACE_INK_CSS_VARS as mt, parseSurfaceTree as n, neutralInk as nt, resolveSurface as o, certifyPaint as ot, gradientScrimSamples as p, SURFACE_FOREGROUND_CSS_VARS as pt, textColorStyle as q, prepareSurfaceIndex as r, _classPrivateFieldGet2 as rt, serializeSurfaceTree as s, contrastThresholdByPolicy as st, parseResolvedSurface as t, solveSurfaceInks as tt, surfaceTransportContext as u, getTextColorForBackground as ut, compileButtonColourStates as v, surfaceForegroundValue as vt, buttonShadow as w, ownedThemeSnapshot as wt, formatButtonColourContractError as x, surfaceInkStyle as xt, resolveSolidButtonColour as y, surfaceForegroundValueWithOpacity as yt, resolveOnColorForThemeToken as z, oklchToHexGamut as zt };
4966
+ export { safeTokenOr as $, defineButtonStyleRecipe as A, paletteValueKey as At, mergeStyles as B, featuresFromHex as Bt, paddingDeclarations as C, resolveOpaqueSurfaceHex as Ct, FONT_SIZE_MAP as D, paletteInkToken as Dt, ELEVATION_OFFSET as E, paletteInkRoles as Et, resolveThemeColorReferenceValue as F, hexLuminance as Ft, staysInsideDeclaration as G, rgbToHex as Gt, textColorStyle as H, oklabToOklch as Ht, resolveTokenOrCssColorValue as I, luminanceInterval as It, compositeHex as J, SURFACE_SECONDARY_TEXT_TINT_ALPHA as K, srgbToOklab as Kt, backgroundColorStyle as L, preparePaletteColourIndex as Lt, mapButtonVisualAppearances as M, requirePaletteColorsFromEntries as Mt, isCssColorLiteral as N, ORDINARY_TEXT_MIN_CONTRAST_RATIO as Nt, generateShadowValue as O, _classPrivateFieldGet2 as Ot, resolveOnColorForThemeToken as P, contrastRatio as Pt, resolveSurfaceForeground as Q, borderColorStyle as R, solidPaint as Rt, materializeRuntimeButtonAppearance as S, resolveConcreteColorHex as St, DEFAULT_BUTTON_SIZES as T, paletteInk as Tt, textColorValue as U, oklabToSrgb as Ut, rgbColorValue as V, hexToRgb as Vt, callsCssLoadingFunction as W, oklchToHexGamut as Wt, minimumScrimOpacity as X, gradientScrimSamples as Y, scrimTone as Z, buttonBorder as _, surfaceInkDeclarations as _t, requireResolvedSurface as a, certifyPaint as at, buttonStateShadow as b, freezeOwnedThemeValue as bt, surfaceButtonRequest as c, planForegroundHover as ct, toAccessibleColorSurfaceIntent as d, SURFACE_INK_CSS_VARS as dt, surfaceInkPublication as et, contextualButtonSurfaceResetStyles as f, surfaceForegroundDeclarations as ft, formatButtonColourContractError as g, surfaceForegroundValueWithOpacity as gt, BUTTON_CONTRAST_POLICY as h, surfaceForegroundValue as ht, prepareThemeSurfaceRevision as i, HOVER_TEXT_THRESHOLD as it, mapButtonRoleAppearances as j, paletteValueKeySchema as jt, PUBLIC_BUTTON_ROLES as k, _classPrivateFieldSet2 as kt, surfaceDecorationColors as l, DEFAULT_SURFACE_TEXT_COLOR as lt, resolveSolidButtonColour as m, surfaceForegroundStyle as mt, parseSurfaceTree as n, solveSurfaceInks as nt, resolveSurface as o, contrastThresholdByPolicy as ot, compileButtonColourStates as p, surfaceForegroundInputFromResolved as pt, expandPalette as q, prepareSurfaceIndex as r, pickBlackOrWhiteTextColor as rt, serializeSurfaceTree as s, inkReference as st, parseResolvedSurface as t, CONTROL_EDGE_SEED_TOKEN as tt, surfaceTransportContext as u, SURFACE_FOREGROUND_CSS_VARS as ut, buttonRadius as v, surfaceInkStyle as vt, BORDER_WIDTH_MAP as w, neutralInk as wt, buttonTypographyDeclarations as x, ownedThemeSnapshot as xt, buttonStateAppearanceDeclarations as y, surfaceInkValue as yt, cssVarValue as z, _classPrivateFieldInitSpec as zt };