@riverbankcms/sdk 0.183.0 → 0.185.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -1
- package/dist/_dts/{BlocksIslandsHydrator-X1_G96iN.d.ts → BlocksIslandsHydrator-Bu0O7l4p.d.ts} +1 -1
- package/dist/_dts/{Page-CEqZJZEE.d.ts → Page-DYoL0IWL.d.ts} +7 -7
- package/dist/_dts/{SdkPreviewMode-DQejfbXL.d.ts → SdkPreviewMode-DgFAiR8r.d.ts} +2 -2
- package/dist/_dts/{client-B_B_amKD.d.ts → client-BKdjJ7A0.d.ts} +35 -4
- package/dist/_dts/{content-types-Dhx5Ocvx.d.ts → content-types-6K7zlJuF.d.ts} +2 -2
- package/dist/_dts/{contracts-FeOnfoa1.d.ts → contracts-CUR8ccnX.d.ts} +3 -3
- package/dist/_dts/{generatePageMetadata-m70J6tit.d.ts → generatePageMetadata-CveWSMew.d.ts} +2 -2
- package/dist/_dts/{index-CjAkEWAp.d.ts → index-6WypKfbu.d.ts} +4 -4
- package/dist/_dts/{index-iuFrbIjt.d.ts → index-BMwrFX_K.d.ts} +1 -1
- package/dist/_dts/{index-BxCmCit0.d.ts → index-Bp5lk6I8.d.ts} +1 -1
- package/dist/_dts/{index-BOpUh8kO.d.ts → index-DTKn1H8g.d.ts} +3 -3
- package/dist/_dts/{index-Bizdaxji.d.ts → index-DX-Xe54X.d.ts} +2 -2
- package/dist/_dts/{index-liuhlOX7.d.ts → index-SD1fTP_7.d.ts} +2 -2
- package/dist/_dts/{loadContent-D4wrTIIw.d.ts → loadContent-BN8GtRsL.d.ts} +7 -7
- package/dist/_dts/{request-Gn0O1blj.d.ts → request-BwYvMqLf.d.ts} +78461 -77905
- package/dist/_dts/{resolveBlockData-D5duwuqS.d.ts → resolveBlockData-CYy0VlSK.d.ts} +5 -5
- package/dist/_dts/{resolvePageContent-xzJ3c9Na.d.ts → resolvePageContent-BwUDLi_W.d.ts} +1 -1
- package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
- package/dist/_dts/sdk/src/client/types.d.ts +2 -2
- package/dist/_dts/sdk/src/client.d.ts +7 -7
- package/dist/_dts/sdk/src/config/index.d.ts +6 -6
- package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
- package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
- package/dist/_dts/sdk/src/data/dataLoaderContext.d.ts +2 -2
- package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +1 -1
- package/dist/_dts/sdk/src/data/types.d.ts +2 -2
- package/dist/_dts/sdk/src/gifting/client.d.ts +1 -1
- package/dist/_dts/sdk/src/index.d.ts +7 -7
- package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
- package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
- package/dist/_dts/sdk/src/navigation/index.d.ts +3 -3
- package/dist/_dts/sdk/src/next/index.d.ts +7 -7
- package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
- package/dist/_dts/sdk/src/page-converter/index.d.ts +3 -3
- package/dist/_dts/sdk/src/portal/client.d.ts +1 -1
- package/dist/_dts/sdk/src/portal/index.d.ts +10 -2
- package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
- package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
- package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
- package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
- package/dist/_dts/sdk/src/rendering/components/pageShared.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +4 -4
- package/dist/_dts/sdk/src/rendering/index.d.ts +6 -6
- package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
- package/dist/_dts/sdk/src/rendering/server.d.ts +2 -2
- package/dist/_dts/sdk/src/rendering/themeAdmission.d.ts +1 -1
- package/dist/_dts/sdk/src/routing/index.d.ts +6 -6
- package/dist/_dts/sdk/src/server.d.ts +5 -5
- package/dist/_dts/sdk/src/spam-protection/index.d.ts +2 -2
- package/dist/_dts/sdk/src/theme/index.d.ts +36 -1
- package/dist/_dts/{serviceBookingOutline-B1gyJon_.d.ts → serviceBookingOutline-CMNev0gz.d.ts} +19 -8
- package/dist/_dts/{types-DBNuMtSk.d.ts → types-BBazdRQf.d.ts} +9 -10
- package/dist/_dts/{types-DHMcuoeQ.d.ts → types-BwngWRQ8.d.ts} +13 -15
- package/dist/_dts/{types-BoITy0rA.d.ts → types-C9_amrul.d.ts} +6 -2
- package/dist/_dts/{validation-BIPO-XlE.d.ts → validation-B58kUTuV.d.ts} +4 -4
- package/dist/client/{BlocksIslandsHydrator-Ct8slgRk.mjs → BlocksIslandsHydrator-CooOPhs3.mjs} +17 -17
- package/dist/client/{BookingMailingListNote-qqTxGGS4.mjs → BookingMailingListNote-D_khdttF.mjs} +61 -62
- package/dist/client/{BookingQuestionFields-DCh9MUIF.mjs → BookingQuestionFields-Bia1E7Cj.mjs} +49 -36
- package/dist/client/{CalendarAction-RcdaStG7.mjs → CalendarAction-C-AbMmct.mjs} +2 -2
- package/dist/client/{CalendarNavigationChevron-D7Wt-Oaa.mjs → CalendarNavigationChevron-oaHxRbUO.mjs} +7 -7
- package/dist/client/{CheckboxChoice-BdGxZWeg.mjs → CheckboxChoice-CTMIII37.mjs} +1 -1
- package/dist/client/{DemoBookingPortalAccess-HFVkoOac.mjs → DemoBookingPortalAccess-M2xKYQjX.mjs} +7 -5
- package/dist/client/{EventCalendar.client-BtkJW8bA.mjs → EventCalendar.client-By7e9nyF.mjs} +11 -11
- package/dist/client/{EventCombined.client-DxaGjFFS.mjs → EventCombined.client-BdRZXB14.mjs} +10 -10
- package/dist/client/EventEmbeddedCheckoutStep-CJoxbx2Y.mjs +147 -0
- package/dist/client/{EventItem-Fr2qi2C2.mjs → EventItem-CDMa9zOX.mjs} +5 -5
- package/dist/client/{EventListWeekNavigation-BRMaq0ky.mjs → EventListWeekNavigation-B8WKaCrN.mjs} +1 -1
- package/dist/client/{EventListing.client-BhGxfbjt.mjs → EventListing.client-BEGiiFnO.mjs} +3 -3
- package/dist/client/{EventListing.view-COuEJzbO.mjs → EventListing.view-B6LOK-z4.mjs} +84 -7
- package/dist/client/{EventRegistrationPayment-BTLYhVxD.mjs → EventRegistrationPayment-CARdr15t.mjs} +140 -68
- package/dist/client/{Page-CgbQZP5g.mjs → Page-uP7AKSyp.mjs} +1762 -521
- package/dist/client/{ProtectedSubmitButton-BG7my0Qf.mjs → ProtectedSubmitButton-CY6u5sQa.mjs} +1 -1
- package/dist/client/SiteChoiceGroup-BZ5I0Vhy.mjs +96 -0
- package/dist/client/{SiteTermsAgreementField-DQNkfNLA.mjs → SiteTermsAgreementField-BDqRo2C5.mjs} +3 -3
- package/dist/client/{StepIndicator-DvPekKeM.mjs → StepIndicator-BWrXAKvs.mjs} +1 -1
- package/dist/client/{StepIndicator-DyXoI3ob.mjs → StepIndicator-Cb3NMw-Y.mjs} +30 -18
- package/dist/client/{ThemedButton-Bc9DBbVp.mjs → ThemedButton-C4rCsPCt.mjs} +11 -2
- package/dist/client/{accessibleSurfaces-wj4Rloo5.mjs → accessibleSurfaces-q-dDOwsW.mjs} +750 -560
- package/dist/client/{accordion-BVXfjnh-.mjs → accordion-BYW2YSUN.mjs} +1 -1
- package/dist/client/{booking-form.client-DycPGtke.mjs → booking-form.client-DAlWWWjV.mjs} +110 -72
- package/dist/client/{bookingCalendar--aWnqFDn.mjs → bookingCalendar-9nFa_do4.mjs} +6 -2
- package/dist/client/{bookingForm-DrWSUqL3.mjs → bookingForm-DtVk9p5l.mjs} +7 -6
- package/dist/client/bookings.mjs +5 -5
- package/dist/client/{boxStyleClassNames-CduDRcIk.mjs → boxStyleClassNames-CaSq3-r-.mjs} +2 -2
- package/dist/client/{EventEmbeddedCheckoutStep-B2c5dR49.mjs → browserStripe-Dh-LcDoW.mjs} +36 -142
- package/dist/client/{buttonParts-CJEtVOUy.mjs → buttonParts-C39GC0kz.mjs} +9 -2
- package/dist/client/{carousel-DyCLMP8s.mjs → carousel-msur7fxW.mjs} +2 -2
- package/dist/client/{carousel.client-DffP_Nv0.mjs → carousel.client-DKWqVHHh.mjs} +1 -1
- package/dist/client/{cart-BuEp_cj4.mjs → cart-Bx-JuY2n.mjs} +3 -3
- package/dist/client/{cart.client-CAO39uDG.mjs → cart.client-hB_9MimN.mjs} +1 -1
- package/dist/client/{checkout-BoxzT64s.mjs → checkout-BVWZn5Qu.mjs} +3 -3
- package/dist/client/{checkout.client-IGUy7XOx.mjs → checkout.client-Bt_GtHW9.mjs} +1 -1
- package/dist/client/{checkoutUrls-D0UsiFmm.mjs → checkoutUrls-CP-rQOZV.mjs} +1 -1
- package/dist/client/client.mjs +61 -48
- package/dist/client/{constants-C_8AxMdm.mjs → constants-yA1RJGXD.mjs} +1 -1
- package/dist/client/{context-D1L0pe__.mjs → context-CG77Keax.mjs} +43 -6
- package/dist/client/{dateFormatting-HvfmS_cH.mjs → dateFormatting-DIRIgfYr.mjs} +1 -1
- package/dist/client/{demoPortalMagicLink-BunFTnIq.mjs → demoPortalMagicLink-CgzNiOQ0.mjs} +1 -1
- package/dist/client/{enhanceHeaderSection-CtLAG651.mjs → enhanceHeaderSection-DgzZNM2M.mjs} +4 -4
- package/dist/client/{event-registration.client-DiSxkBUP.mjs → event-registration.client-Ckb4aDE9.mjs} +118 -74
- package/dist/client/{eventCalendar-DUnhwZ1o.mjs → eventCalendar-lqqQSzBQ.mjs} +4 -4
- package/dist/client/{eventCombined-BvBQo0nF.mjs → eventCombined-BIMyHrd-.mjs} +4 -4
- package/dist/client/{eventListing-aTLifOX7.mjs → eventListing-CBYxfvNf.mjs} +4 -4
- package/dist/client/{eventRegistration-DFd7pr09.mjs → eventRegistration-BhAqvkCb.mjs} +7 -6
- package/dist/client/{form-Dikmc2AO.mjs → form-CkOfk-Eb.mjs} +3 -3
- package/dist/client/{form.client-zHaQK5I9.mjs → form.client-Whi43oio.mjs} +5 -5
- package/dist/client/{form.parts-BLl9n8TH.mjs → form.parts-BgsWo2Me.mjs} +3 -3
- package/dist/client/gifting/client.mjs +8 -8
- package/dist/client/{gifting-CufPM38H.mjs → gifting-XtNpLcFI.mjs} +4 -4
- package/dist/client/{gifting.client--N1GaSY8.mjs → gifting.client-CraWj4I4.mjs} +174 -73
- package/dist/client/{gifting.interactive-D9MK4HkV.mjs → gifting.interactive-DiPDObN0.mjs} +61 -10
- package/dist/client/{gifting.parts-CRtiRzo-.mjs → gifting.parts-_mgGOcbA.mjs} +17 -43
- package/dist/client/{headerSection-BIaBpmk3.mjs → headerSection-CPIN3VSU.mjs} +2 -2
- package/dist/client/{islands-DJDLGQEm.mjs → islands-C95FyxUF.mjs} +1996 -1178
- package/dist/client/{newsletter-form.client-wg_JHTxm.mjs → newsletter-form.client-BgVJdKVe.mjs} +7 -7
- package/dist/client/{newsletter-form.interactive-hzpkW9NQ.mjs → newsletter-form.interactive-DpcfRbI_.mjs} +39 -18
- package/dist/client/{newsletter-form.parts-CgzpSv9p.mjs → newsletter-form.parts-poPgHrUh.mjs} +2 -2
- package/dist/client/{newsletterForm-CvxLiEBT.mjs → newsletterForm-Dt6wFjTe.mjs} +3 -3
- package/dist/client/portal/client.mjs +999 -81
- package/dist/client/{portalOrders-tCxS04g0.mjs → portalOrders-CAfjTyV9.mjs} +1 -1
- package/dist/client/{portalRoutes-DTHlWg_F.mjs → portalRoutes-D3Ttfv5x.mjs} +54 -12
- package/dist/client/portalSession-0XhXyTxT.mjs +41 -0
- package/dist/client/presentation-CudSUZ6Q.mjs +169 -0
- package/dist/client/{product-detail.client-22Q7zgjN.mjs → product-detail.client-BrBNT7Mq.mjs} +1 -1
- package/dist/client/{product-list.client-DFWYvK8z.mjs → product-list.client-CftTl7n6.mjs} +1 -1
- package/dist/client/{productDetail-DhZAwo60.mjs → productDetail-b1tpt585.mjs} +3 -3
- package/dist/client/{productList-BiVpbZK2.mjs → productList-DRT5sabi.mjs} +3 -3
- package/dist/client/{propsDecoder-DFYqKnLy.mjs → propsDecoder-Co1VXFaW.mjs} +4 -4
- package/dist/client/{registry.server-C3OBRg7x.mjs → registry.server-0UDNY7dO.mjs} +796 -715
- package/dist/client/rendering/client.mjs +28 -27
- package/dist/client/rendering/islands.mjs +1 -1
- package/dist/client/rendering.mjs +5 -5
- package/dist/client/{richText-coerce-ms477Z08.mjs → richText-coerce-BFDEPZZA.mjs} +2 -2
- package/dist/client/{routeIslandApiConfig-B6nQeqvH.mjs → routeIslandApiConfig-DtqRutuX.mjs} +1 -1
- package/dist/client/{runtimeResponse-BYqsV1Kb.mjs → runtimeResponse-DBVXbcuz.mjs} +1 -1
- package/dist/client/runtimeResponse-LQnQdtNI.mjs +3 -0
- package/dist/client/{shop-xt4dQ3HH.mjs → shop-DL3CYR7i.mjs} +3 -3
- package/dist/client/{shop-commerce-DVsIcPaI.mjs → shop-commerce-CDth2_qq.mjs} +45 -27
- package/dist/client/{shop-commerce-store-7mO6KY7_.mjs → shop-commerce-store-CE0aaSHJ.mjs} +1 -1
- package/dist/client/{shop-discount-apply.state-L1Vge8tG.mjs → shop-discount-apply.state-p4aXtVsF.mjs} +2 -2
- package/dist/client/{shop.client-DNJfD3VQ.mjs → shop.client-BI2iw6Z3.mjs} +83 -29
- package/dist/client/{shopShared-DS8t6749.mjs → shopShared-BNWzgWAC.mjs} +2 -2
- package/dist/client/spam-protection.mjs +1 -1
- package/dist/client/{src-Do_s2lqH.mjs → src-CJf3u16T.mjs} +1 -1
- package/dist/{preview-next/client/src-lX6heoDA.mjs → client/src-CMuv8vSO.mjs} +5 -1
- package/dist/client/src-CXOxpNtj.mjs +3 -0
- package/dist/client/{timetableModel-Dy3nNfTG.mjs → timetableModel-DZzGD6rS.mjs} +9 -9
- package/dist/client/{urlParams-C2QHo1Pa.mjs → useAutomaticDiscountPreview-CJDylOUe.mjs} +44 -1
- package/dist/client/{useAvailableSlots-DcjtDpUu.mjs → useAvailableSlots-nD6nuvSW.mjs} +2 -2
- package/dist/client/{useDiscountCodeUi-DvdFFWOT.mjs → useDiscountCodeUi-DMtTHqex.mjs} +6 -2
- package/dist/client/{useEventPagination-Cq-7sU5_.mjs → useEventPagination-CM-DCokc.mjs} +14 -16
- package/dist/client/{view-4gnPcpWJ.mjs → view-CHOhliHv.mjs} +4 -4
- package/dist/client/{wizardSteps-DDvL3iza.mjs → wizardSteps-BbroaNkT.mjs} +277 -87
- package/dist/preview-next/client/{EventEmbeddedCheckoutStep-CLqSRUpt.mjs → EventEmbeddedCheckoutStep-CVy9oapv.mjs} +1 -1
- package/dist/preview-next/client/{LocationPickerEnvironment-CIdAg-Tm.mjs → LocationPickerEnvironment-DuRUwUrK.mjs} +1 -1
- package/dist/preview-next/client/{MapLibreEditMap-Bm85jX35.mjs → MapLibreEditMap-CdSDYBq9.mjs} +2 -2
- package/dist/preview-next/client/{PageSectionToolbar-D8srnz9R.mjs → PageSectionToolbar-CR99z8BL.mjs} +582 -195
- package/dist/preview-next/client/{PreviewEditorSidebar-DVpk5cqp.mjs → PreviewEditorSidebar-BaKS6H8F.mjs} +1096 -283
- package/dist/preview-next/client/{PreviewEditorUI-XoTtHSFH.mjs → PreviewEditorUI-D6IG119o.mjs} +65 -16
- package/dist/preview-next/client/{PreviewShell-VQHsRg2u.mjs → PreviewShell-CKjkFOZS.mjs} +39 -12
- package/dist/preview-next/client/{SdkPreviewModeRuntime-CLdF9f6o.mjs → SdkPreviewModeRuntime-BexDQWGj.mjs} +128 -27
- package/dist/preview-next/client/{ThemedButton-ORNN4x-3.mjs → ThemedButton-CRgbU75r.mjs} +18 -2
- package/dist/preview-next/client/{lucide-react-eAi3tDAr.mjs → lucide-react-B4c6U3ZU.mjs} +1 -1
- package/dist/preview-next/client/{previewAssistantSlot-CqH91EwA.mjs → previewAssistantSlot-DcEwU9l_.mjs} +7192 -3039
- package/dist/preview-next/client/{previewChromeRoot-B3ySEu6p.mjs → previewChromeRoot-VqseF0yf.mjs} +1 -1
- package/dist/preview-next/client/runtime.mjs +3 -3
- package/dist/preview-next/client/{sdk-runtime-CdpSupcr.mjs → sdk-runtime-DcoVpKUf.mjs} +2 -2
- package/dist/preview-next/client/{siteStyleAccess-C6eOP6QW.mjs → siteStyleAccess-BL1fZnUD.mjs} +16 -10
- package/dist/{client/src-uwCpbHXG.mjs → preview-next/client/src-B5x3r4cg.mjs} +5 -1
- package/dist/preview-next/client/src-CrT7h--V.mjs +3 -0
- package/dist/preview-next/client/{useAutosaveStatus-BhPg4e-r.mjs → useAutosaveStatus-CdFnzKac.mjs} +3 -3
- package/dist/preview-next/client/{useOpenBlockForSetup-BaWUF9D7.mjs → useOpenBlockForSetup-B62h7dhR.mjs} +4 -3
- package/dist/preview-next/container-responsive.css +158 -3
- package/dist/preview-next/keepAlive.mjs +1 -1
- package/dist/preview-next/middleware.mjs +1 -1
- package/dist/preview-next/{route-contract-Ch0X99vE.mjs → route-contract-CQfEvfbg.mjs} +54 -41
- package/dist/server/{Block.shared-B2FmczLO.mjs → Block.shared-CbGnxkWX.mjs} +5 -5
- package/dist/server/{ThemeScopeCore-DtAyv9qA.mjs → ThemeScopeCore-BjxlpVaV.mjs} +34 -8
- package/dist/server/{accessibleSurfaces-BtPqb76u.mjs → accessibleSurfaces-CZ7pLuJ7.mjs} +317 -148
- package/dist/server/{accordions-vzdZ2Wt1.mjs → accordions-C_C52VkS.mjs} +1 -1
- package/dist/server/{bindings-B_9JuU66.mjs → bindings-D-n66Oqc.mjs} +68 -247
- package/dist/server/{client-DC7cjiSw.mjs → client-BGGlrkft.mjs} +64 -47
- package/dist/server/config-validation.mjs +1 -1
- package/dist/server/config.mjs +2 -2
- package/dist/server/{constants-d6nPNJpe.mjs → constants-TkO9Uxma.mjs} +51 -9
- package/dist/server/data/resolveBlockData.mjs +1 -1
- package/dist/server/index.mjs +3 -3
- package/dist/server/{loadContent-hb27HYic.mjs → loadContent-8H1hHdXo.mjs} +4 -4
- package/dist/server/{loadPage-JToD8wDD.mjs → loadPage-BZyqF_g3.mjs} +3 -3
- package/dist/server/lookMediaFrame-Dw6R9B0L.mjs +31837 -0
- package/dist/server/manifest.mjs +2 -2
- package/dist/server/{navigation-B2WhGofA.mjs → navigation-9TOyY5Zf.mjs} +1 -1
- package/dist/server/navigation.mjs +1 -1
- package/dist/server/next.mjs +9 -9
- package/dist/server/{overrideResolution-vD5KTClL.mjs → overrideResolution-CuduOS6V.mjs} +1 -1
- package/dist/server/page-converter.mjs +17 -4
- package/dist/server/{pageRenderPlan-CdqJ1NQZ.mjs → pageRenderPlan-DmP0HVMu.mjs} +618 -209
- package/dist/server/{pageRuntimeSupport-CAhr4oOf.mjs → pageRuntimeSupport-BQ1dWs1V.mjs} +12 -5
- package/dist/server/{pageShared-m80Xu2pd.mjs → pageShared-ALu7y5Dq.mjs} +836 -516
- package/dist/server/{parseThemeForPersistence-CRwOZfpa.mjs → parseThemeForPersistence-D_8I28BB.mjs} +3 -3
- package/dist/server/{portal-B2wCQno_.mjs → portal-P4oHSRho.mjs} +23 -2
- package/dist/server/portal.mjs +3 -3
- package/dist/server/{prebuild-BWIkFaXq.mjs → prebuild-BLL6RhjS.mjs} +1 -1
- package/dist/server/prebuild.mjs +1 -1
- package/dist/server/{prefetchBlockData-D1PHU-K9.mjs → prefetchBlockData-aR5W1dVF.mjs} +3 -3
- package/dist/server/{registry-KtsOsAzY.mjs → registry-DD_s7l3Y.mjs} +1575 -28658
- package/dist/server/rendering/components/pageShared.mjs +1 -1
- package/dist/server/rendering/helpers/loadPage.mjs +1 -1
- package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +1 -1
- package/dist/server/rendering/server.mjs +4 -4
- package/dist/server/rendering.mjs +9 -9
- package/dist/server/{resolveBlockData-sjIDJYl7.mjs → resolveBlockData-DnQ2N0lI.mjs} +2 -2
- package/dist/server/{expandPalette-DxPrNOAB.mjs → resolveButtonColourStates-ChlP4NJ9.mjs} +1662 -1430
- package/dist/server/{responseMedia-IfH65QAH.mjs → responseMedia-D6F1tvIm.mjs} +1 -1
- package/dist/server/{schema-BBEqquBM.mjs → schema-ClDfFtz2.mjs} +261 -6
- package/dist/server/server.mjs +3 -3
- package/dist/server/{servicePageContent-ChEZDRwU.mjs → servicePageContent-CsUerbJ1.mjs} +15 -12
- package/dist/server/theme-bridge.mjs +5 -4
- package/dist/server/theme.mjs +2 -2
- package/dist/server/{three-pass-converter-DKCIBeb1.mjs → three-pass-converter-CLJrZb7s.mjs} +1 -1
- package/dist/server/{titleSourceSchema-DybHErxH.mjs → titleSourceSchema-DA_iErtG.mjs} +2 -3
- package/dist/server/{types-vyz09w64.mjs → types-CcKy8_tj.mjs} +14 -5
- package/dist/server/{validation-Cvi-1TZZ.mjs → validation-BbImAsVs.mjs} +5 -5
- package/dist/server/{version-B-icAIV1.mjs → version-BY48jPoe.mjs} +1 -1
- package/dist/styles/index.css +684 -181
- package/package.json +1 -1
- package/dist/client/appointment-service-categories-Cl2pqw-z.mjs +0 -70
- package/dist/client/runtimeResponse-CUX_lldL.mjs +0 -3
- package/dist/client/src-DqMbCjI1.mjs +0 -3
- package/dist/preview-next/client/src-EO5QoRlU.mjs +0 -3
- package/dist/server/customCss-rtIfEYwQ.mjs +0 -230
- package/dist/server/lookMediaFrame-CTsycLLK.mjs +0 -2756
- package/dist/server/media-gvfIw3z8.mjs +0 -216
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { t as stableJsonStringify } from "./stable-json-D0XAEIXc.mjs";
|
|
3
|
-
import { A as
|
|
3
|
+
import { A as isThemeColorToken, B as VARIANT_ROLES, C as parseOpaqueButtonColourToken, D as absoluteInkColors, E as PALETTE_TOKEN_NAMES, F as paletteModeSchema, I as parseColorTokenParts, L as parseThemeColorToken, N as paletteColorsFromEntries, 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, j as normalizePaletteHex, k as hexColorSchema, p as unsafeAsOpaqueButtonColourToken, y as buttonSystemSchema } from "./buttonParts-C39GC0kz.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
|
|
@@ -584,12 +584,12 @@ function paletteInkOnSolid(groundHex, roles) {
|
|
|
584
584
|
}
|
|
585
585
|
/**
|
|
586
586
|
* The ink as token emitters write it: the role's theme token, so CSS follows
|
|
587
|
-
* the palette's variables, or
|
|
587
|
+
* the palette's variables, or a fixed absolute black/white token.
|
|
588
588
|
*/
|
|
589
589
|
function paletteInkToken(ink) {
|
|
590
|
-
|
|
591
|
-
if (!isThemeColorToken(
|
|
592
|
-
return
|
|
590
|
+
const token = ink.kind === "role" ? ink.role : ink.hex === "#000000" ? "absoluteBlack" : "absoluteWhite";
|
|
591
|
+
if (!isThemeColorToken(token)) throw new Error(`Palette ink is not a theme token: ${token}`);
|
|
592
|
+
return token;
|
|
593
593
|
}
|
|
594
594
|
/**
|
|
595
595
|
* Secondary text that has to read on several grounds (a surface and the tinted
|
|
@@ -642,7 +642,7 @@ function resolveOpaqueSurfaceHex(reference, palette, underlayReference) {
|
|
|
642
642
|
if (!underlayHex) return null;
|
|
643
643
|
const parts = parseColorTokenParts(reference);
|
|
644
644
|
if (parts.kind === "token" && parts.opacityPercent !== null) {
|
|
645
|
-
const foregroundHex =
|
|
645
|
+
const foregroundHex = resolveConcreteColorHex(parts.token, palette);
|
|
646
646
|
return foregroundHex ? compositeHex$1(foregroundHex, underlayHex, parts.opacityPercent / 100) : null;
|
|
647
647
|
}
|
|
648
648
|
const rgba = parseRgba(parts.kind === "raw" ? parts.value : reference);
|
|
@@ -655,7 +655,7 @@ function resolveConcreteColorHex(reference, palette) {
|
|
|
655
655
|
const parts = parseColorTokenParts(reference);
|
|
656
656
|
if (parts.kind === "token") {
|
|
657
657
|
if (parts.opacityPercent !== null) return null;
|
|
658
|
-
return normalizePaletteHex(palette[parts.token] ?? "");
|
|
658
|
+
return normalizePaletteHex((parts.token === "absoluteBlack" || parts.token === "absoluteWhite" ? absoluteInkColors[parts.token] : palette[parts.token]) ?? "");
|
|
659
659
|
}
|
|
660
660
|
const literal = parts.kind === "raw" ? parts.value : reference;
|
|
661
661
|
if (literal.toLowerCase() === "black") return "#000000";
|
|
@@ -744,13 +744,14 @@ function requireSurfaceColorValue(role, value) {
|
|
|
744
744
|
function completeSurfaceForegrounds(input) {
|
|
745
745
|
const text = requireSurfaceColorValue("text", input.text);
|
|
746
746
|
const link = input.link === void 0 ? text : requireSurfaceColorValue("link", input.link);
|
|
747
|
+
const supporting = input.supporting === void 0 ? text : requireSurfaceColorValue("supporting", input.supporting);
|
|
747
748
|
return {
|
|
748
749
|
text,
|
|
749
750
|
heading: input.heading === void 0 ? text : requireSurfaceColorValue("heading", input.heading),
|
|
750
751
|
link,
|
|
751
752
|
linkHover: input.linkHover === void 0 ? link : requireSurfaceColorValue("linkHover", input.linkHover),
|
|
752
|
-
muted: input.muted === void 0 ?
|
|
753
|
-
supporting
|
|
753
|
+
muted: input.muted === void 0 ? supporting : requireSurfaceColorValue("muted", input.muted),
|
|
754
|
+
supporting
|
|
754
755
|
};
|
|
755
756
|
}
|
|
756
757
|
function surfaceForegroundValue(role, outsideProviderFallback = DEFAULT_ROLE_FALLBACKS[role]) {
|
|
@@ -816,7 +817,7 @@ function surfaceForegroundStyle(input) {
|
|
|
816
817
|
[SURFACE_FOREGROUND_CSS_VARS.link]: foregrounds.link,
|
|
817
818
|
[SURFACE_FOREGROUND_CSS_VARS.linkHover]: foregrounds.linkHover,
|
|
818
819
|
[SURFACE_FOREGROUND_CSS_VARS.supporting]: foregrounds.supporting,
|
|
819
|
-
|
|
820
|
+
[SURFACE_FOREGROUND_CSS_VARS.muted]: foregrounds.muted,
|
|
820
821
|
"--rb-surface-link-hover-decoration": hoverDecoration(input)
|
|
821
822
|
};
|
|
822
823
|
}
|
|
@@ -835,103 +836,13 @@ function surfaceForegroundInputFromResolved(foreground, color) {
|
|
|
835
836
|
link: value(roles.link),
|
|
836
837
|
linkHover: value(roles.linkHover),
|
|
837
838
|
supporting: value(roles.supporting),
|
|
839
|
+
muted: value(roles.muted),
|
|
838
840
|
hoverDecoration: foreground.hoverDecoration
|
|
839
841
|
};
|
|
840
842
|
}
|
|
841
843
|
function hoverDecoration(input) {
|
|
842
844
|
return input.hoverDecoration ?? "underline";
|
|
843
845
|
}
|
|
844
|
-
/**
|
|
845
|
-
* Derive the hover foreground that belongs with a resolved resting foreground.
|
|
846
|
-
*
|
|
847
|
-
* A resting foreground is chosen to be legible against a known surface. A hover
|
|
848
|
-
* state derived from it stays within a bounded distance of that colour, so it
|
|
849
|
-
* inherits most of the resting colour's contrast margin instead of asserting
|
|
850
|
-
* an unrelated brand colour that no one checked against the surface.
|
|
851
|
-
*
|
|
852
|
-
* That bounded-distance property is what lets this be used on a transparent
|
|
853
|
-
* overlay header, where the backdrop is only partly knowable: the scrolled
|
|
854
|
-
* state composites a 60% glass tint over arbitrary page content, so no
|
|
855
|
-
* compile-time contrast proof is available there. Staying near a colour that
|
|
856
|
-
* is already trusted in both states is a weaker claim than a contrast proof,
|
|
857
|
-
* and it is one this function can actually keep.
|
|
858
|
-
*
|
|
859
|
-
* Returns `null` when the resting token is not a plain palette token — an
|
|
860
|
-
* already-faded or raw value has no well-defined softening, and the caller
|
|
861
|
-
* should leave hover alone rather than guess.
|
|
862
|
-
*/
|
|
863
|
-
function deriveForegroundHoverToken(restingToken) {
|
|
864
|
-
const parts = parseColorTokenParts(restingToken);
|
|
865
|
-
if (parts.kind !== "token") return null;
|
|
866
|
-
if (parts.opacityPercent !== null) return null;
|
|
867
|
-
return parseThemeColorToken(`${parts.token}/85`);
|
|
868
|
-
}
|
|
869
|
-
/**
|
|
870
|
-
* Prefer an authored hover that survives every measured backdrop, then a
|
|
871
|
-
* checked softening of the resting colour. A null backdrop set represents a
|
|
872
|
-
* trusted treatment: only an explicit authored hover may change the colour.
|
|
873
|
-
* When neither option works, retain the resting colour and underline it.
|
|
874
|
-
*/
|
|
875
|
-
function planForegroundHover(input) {
|
|
876
|
-
const { restingToken, candidate, palette, backdrops } = input;
|
|
877
|
-
if (candidate && String(candidate) !== String(restingToken)) {
|
|
878
|
-
if (backdrops === null || survivesEveryBackdrop(candidate, palette, backdrops)) return {
|
|
879
|
-
kind: "candidate",
|
|
880
|
-
token: candidate,
|
|
881
|
-
decoration: "initial"
|
|
882
|
-
};
|
|
883
|
-
}
|
|
884
|
-
const resting = parseThemeColorToken(restingToken);
|
|
885
|
-
const softened = resting ? deriveForegroundHoverToken(resting) : null;
|
|
886
|
-
if (softened && backdrops && survivesEveryBackdrop(softened, palette, backdrops)) return {
|
|
887
|
-
kind: "softened",
|
|
888
|
-
token: softened,
|
|
889
|
-
decoration: "initial"
|
|
890
|
-
};
|
|
891
|
-
return {
|
|
892
|
-
kind: "resting",
|
|
893
|
-
token: restingToken,
|
|
894
|
-
decoration: "underline"
|
|
895
|
-
};
|
|
896
|
-
}
|
|
897
|
-
function survivesEveryBackdrop(token, palette, backdrops) {
|
|
898
|
-
return backdrops.length > 0 && backdrops.every((backdrop) => {
|
|
899
|
-
const foreground = resolveOpaqueSurfaceHex(token, palette, backdrop);
|
|
900
|
-
return foreground !== null && contrastRatio(foreground, backdrop) >= 4.5;
|
|
901
|
-
});
|
|
902
|
-
}
|
|
903
|
-
//#endregion
|
|
904
|
-
//#region ../site-contracts/src/renderResults/buttonTypes.ts
|
|
905
|
-
const BUTTON_VISUAL_STATES = [
|
|
906
|
-
"base",
|
|
907
|
-
"hover",
|
|
908
|
-
"focus",
|
|
909
|
-
"active",
|
|
910
|
-
"disabled"
|
|
911
|
-
];
|
|
912
|
-
//#endregion
|
|
913
|
-
//#region ../theme-core/src/palette/utils/onColor.ts
|
|
914
|
-
const BACKGROUND_ROLE_NAMES = /* @__PURE__ */ new Set([
|
|
915
|
-
"primary",
|
|
916
|
-
"secondary",
|
|
917
|
-
"accent",
|
|
918
|
-
"success",
|
|
919
|
-
"warning",
|
|
920
|
-
"destructive",
|
|
921
|
-
"info",
|
|
922
|
-
"background",
|
|
923
|
-
"surface",
|
|
924
|
-
"surfaceAlt",
|
|
925
|
-
"muted",
|
|
926
|
-
"neutral"
|
|
927
|
-
]);
|
|
928
|
-
function onColorTokenName(backgroundToken) {
|
|
929
|
-
return `on${backgroundToken.split("-").filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("")}`;
|
|
930
|
-
}
|
|
931
|
-
function isOnColorBackgroundCandidateToken(token) {
|
|
932
|
-
const role = token.match(/^(.*?)(?:-\d{2,3})?$/)?.[1] ?? token;
|
|
933
|
-
return BACKGROUND_ROLE_NAMES.has(role);
|
|
934
|
-
}
|
|
935
846
|
//#endregion
|
|
936
847
|
//#region ../theme-core/src/surfaces/inkCertificate.ts
|
|
937
848
|
/**
|
|
@@ -965,17 +876,20 @@ const surfaceTextPolicy = Object.freeze({
|
|
|
965
876
|
* the current-page link) keep the text threshold.
|
|
966
877
|
*/
|
|
967
878
|
const HOVER_TEXT_THRESHOLD = contrastThresholdByPolicy["large-text-aa"];
|
|
968
|
-
|
|
969
|
-
const isFallbackInk = (ink) => FALLBACK_INKS.includes(ink);
|
|
970
|
-
function inkReference(ink) {
|
|
971
|
-
return isFallbackInk(ink) ? `raw:${ink}` : ink;
|
|
972
|
-
}
|
|
973
|
-
/** A token, `rgba()` or literal, composited over each backdrop, clears the threshold on all of them. */
|
|
879
|
+
/** A sampled paint is continuous: also reject an ink whose luminance lies between its bounds. */
|
|
974
880
|
function inkClearsBackdrops(ink, threshold, backdrops, measurement) {
|
|
975
|
-
|
|
881
|
+
if (backdrops.length === 0) return true;
|
|
882
|
+
const readings = backdrops.flatMap((backdrop) => {
|
|
976
883
|
const hex = resolveOpaqueSurfaceHex(ink, measurement.palette, backdrop);
|
|
977
|
-
return hex
|
|
884
|
+
return hex === null ? [] : [{
|
|
885
|
+
ink: hexLuminance(hex, measurement.colourIndex),
|
|
886
|
+
ground: hexLuminance(backdrop, measurement.colourIndex)
|
|
887
|
+
}];
|
|
978
888
|
});
|
|
889
|
+
if (readings.length !== backdrops.length) return false;
|
|
890
|
+
const ground = luminanceInterval(Math.min(...readings.map((value) => value.ground)), Math.max(...readings.map((value) => value.ground)));
|
|
891
|
+
const inks = luminanceInterval(Math.min(...readings.map((value) => value.ink)), Math.max(...readings.map((value) => value.ink)));
|
|
892
|
+
return (inks.hi < ground.lo ? worstContrast(inks.hi, ground) : inks.lo > ground.hi ? worstContrast(inks.lo, ground) : 1) >= threshold;
|
|
979
893
|
}
|
|
980
894
|
/** The palette ink that clears every backdrop at ordinary-text contrast, or null when not even black or white does. */
|
|
981
895
|
function fallbackInk(backdrops, measurement) {
|
|
@@ -1045,316 +959,72 @@ function certifyPaint(place, ink, threshold, backdrop, measurement) {
|
|
|
1045
959
|
declared: ink
|
|
1046
960
|
};
|
|
1047
961
|
}
|
|
1048
|
-
//#endregion
|
|
1049
|
-
//#region ../theme-core/src/palette/utils/textColor.ts
|
|
1050
962
|
/**
|
|
1051
|
-
*
|
|
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.
|
|
963
|
+
* Derive the hover foreground that belongs with a resolved resting foreground.
|
|
1056
964
|
*
|
|
1057
|
-
*
|
|
1058
|
-
*
|
|
1059
|
-
*
|
|
1060
|
-
*
|
|
965
|
+
* A resting foreground is chosen to be legible against a known surface. A hover
|
|
966
|
+
* state derived from it stays within a bounded distance of that colour, so it
|
|
967
|
+
* inherits most of the resting colour's contrast margin instead of asserting
|
|
968
|
+
* an unrelated brand colour that no one checked against the surface.
|
|
969
|
+
*
|
|
970
|
+
* That bounded-distance property is what lets this be used on a transparent
|
|
971
|
+
* overlay header, where the backdrop is only partly knowable: the scrolled
|
|
972
|
+
* state composites a 60% glass tint over arbitrary page content, so no
|
|
973
|
+
* compile-time contrast proof is available there. Staying near a colour that
|
|
974
|
+
* is already trusted in both states is a weaker claim than a contrast proof,
|
|
975
|
+
* and it is one this function can actually keep.
|
|
976
|
+
*
|
|
977
|
+
* Returns `null` when the resting token is not a plain palette token — an
|
|
978
|
+
* already-faded or raw value has no well-defined softening, and the caller
|
|
979
|
+
* should leave hover alone rather than guess.
|
|
1061
980
|
*/
|
|
1062
|
-
function
|
|
1063
|
-
const
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
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");
|
|
1076
|
-
}
|
|
1077
|
-
function clamp255(value) {
|
|
1078
|
-
if (Number.isNaN(value)) return 0;
|
|
1079
|
-
return Math.max(0, Math.min(255, value));
|
|
981
|
+
function deriveForegroundHoverToken(restingToken) {
|
|
982
|
+
const parts = parseColorTokenParts(restingToken);
|
|
983
|
+
if (parts.kind !== "token") return null;
|
|
984
|
+
if (parts.opacityPercent !== null) return null;
|
|
985
|
+
if (parts.token === "absoluteBlack" || parts.token === "absoluteWhite") return null;
|
|
986
|
+
return parseThemeColorToken(`${parts.token}/85`);
|
|
1080
987
|
}
|
|
1081
|
-
//#endregion
|
|
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;
|
|
1085
988
|
/**
|
|
1086
|
-
*
|
|
1087
|
-
*
|
|
1088
|
-
*
|
|
989
|
+
* Prefer an authored hover that survives every measured backdrop, then a
|
|
990
|
+
* checked softening of the resting colour. A null backdrop set represents a
|
|
991
|
+
* trusted treatment: only an explicit authored hover may change the colour.
|
|
992
|
+
* When neither option works, retain the resting colour and underline it.
|
|
1089
993
|
*/
|
|
1090
|
-
|
|
1091
|
-
const
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
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
|
|
994
|
+
function planForegroundHover(input) {
|
|
995
|
+
const { restingToken, candidate, palette, backdrops } = input;
|
|
996
|
+
if (candidate && String(candidate) !== String(restingToken)) {
|
|
997
|
+
if (backdrops === null || survivesEveryBackdrop(candidate, palette, backdrops)) return {
|
|
998
|
+
kind: "candidate",
|
|
999
|
+
token: candidate,
|
|
1000
|
+
decoration: "initial"
|
|
1001
|
+
};
|
|
1108
1002
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
function solveSurfaceInks(backdropHex, textInk, palette, candidates = {}) {
|
|
1117
|
-
const paint = solidPaint(backdropHex);
|
|
1118
|
-
const fallback = literalInk$1(resolveConcreteColorHex(textInk, palette) ?? pickBlackOrWhiteTextColor(backdropHex));
|
|
1003
|
+
const resting = parseThemeColorToken(restingToken);
|
|
1004
|
+
const softened = resting ? deriveForegroundHoverToken(resting) : null;
|
|
1005
|
+
if (softened && backdrops && survivesEveryBackdrop(softened, palette, backdrops)) return {
|
|
1006
|
+
kind: "softened",
|
|
1007
|
+
token: softened,
|
|
1008
|
+
decoration: "initial"
|
|
1009
|
+
};
|
|
1119
1010
|
return {
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
}, paint, palette, fallback),
|
|
1124
|
-
accent: solveInk({
|
|
1125
|
-
...INK_SEEDS.accent,
|
|
1126
|
-
token: candidates.accent ?? INK_SEEDS.accent.token
|
|
1127
|
-
}, paint, palette, fallback),
|
|
1128
|
-
focus: solveInk({
|
|
1129
|
-
...INK_SEEDS.focus,
|
|
1130
|
-
token: candidates.focus ?? INK_SEEDS.focus.token
|
|
1131
|
-
}, paint, palette, fallback),
|
|
1132
|
-
control: solveInk({
|
|
1133
|
-
...INK_SEEDS.control,
|
|
1134
|
-
token: candidates.control ?? INK_SEEDS.control.token
|
|
1135
|
-
}, paint, palette, fallback)
|
|
1011
|
+
kind: "resting",
|
|
1012
|
+
token: restingToken,
|
|
1013
|
+
decoration: "underline"
|
|
1136
1014
|
};
|
|
1137
1015
|
}
|
|
1138
|
-
function
|
|
1139
|
-
|
|
1140
|
-
const seedHex = hexColorSchema.safeParse(resolveConcreteColorHex(seed.token, palette));
|
|
1141
|
-
if (!token || !seedHex.success) return fallback;
|
|
1142
|
-
const solved = inkFrom(familyOf(seedHex.data), paint, seed.ratio, seed.maxDistance);
|
|
1143
|
-
switch (solved.kind) {
|
|
1144
|
-
case "ink": return solved.source === "exact" ? token : literalInk$1(solved.hex);
|
|
1145
|
-
case "too-far":
|
|
1146
|
-
case "unpaintable": return fallback;
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
function literalInk$1(hex) {
|
|
1150
|
-
return hexColorSchema.parse(hex.toLowerCase());
|
|
1151
|
-
}
|
|
1152
|
-
const FAMILY_CACHE_LIMIT = 64;
|
|
1153
|
-
const families = /* @__PURE__ */ new Map();
|
|
1154
|
-
function familyOf(seed) {
|
|
1155
|
-
const cached = families.get(seed);
|
|
1156
|
-
if (cached) return cached;
|
|
1157
|
-
if (families.size >= FAMILY_CACHE_LIMIT) families.clear();
|
|
1158
|
-
const family = colourFamily(seed);
|
|
1159
|
-
families.set(seed, family);
|
|
1160
|
-
return family;
|
|
1016
|
+
function survivesEveryBackdrop(token, palette, backdrops) {
|
|
1017
|
+
return backdrops.length > 0 && inkClearsBackdrops(token, 4.5, backdrops, { palette });
|
|
1161
1018
|
}
|
|
1162
1019
|
//#endregion
|
|
1163
|
-
//#region ../
|
|
1164
|
-
const
|
|
1165
|
-
"
|
|
1166
|
-
"
|
|
1167
|
-
"
|
|
1168
|
-
"
|
|
1169
|
-
"
|
|
1170
|
-
"onSecondary",
|
|
1171
|
-
"onAccent",
|
|
1172
|
-
"onSurface",
|
|
1173
|
-
"neutral-950",
|
|
1174
|
-
"neutral-50"
|
|
1020
|
+
//#region ../site-contracts/src/renderResults/buttonTypes.ts
|
|
1021
|
+
const BUTTON_VISUAL_STATES = [
|
|
1022
|
+
"base",
|
|
1023
|
+
"hover",
|
|
1024
|
+
"focus",
|
|
1025
|
+
"active",
|
|
1026
|
+
"disabled"
|
|
1175
1027
|
];
|
|
1176
|
-
function resolveSurfaceForeground(background, palette, candidates = {}, options = {}) {
|
|
1177
|
-
const authored = foregroundCandidates(background, candidates);
|
|
1178
|
-
if ("measuredBackdrop" in options) return resolveMeasuredForeground(background?.color ?? "background", options.measuredBackdrop, authored, palette);
|
|
1179
|
-
return resolveAuthoredBackground(background, palette, authored, options);
|
|
1180
|
-
}
|
|
1181
|
-
/** Legacy references may be measurable, inherited, or a trusted media treatment. */
|
|
1182
|
-
function resolveAuthoredBackground(background, palette, authored, options) {
|
|
1183
|
-
if (background === null) return resolveDeterministicForeground("background", {
|
|
1184
|
-
...authored,
|
|
1185
|
-
text: authored.text ?? "text"
|
|
1186
|
-
}, palette);
|
|
1187
|
-
if (background.type === "color") {
|
|
1188
|
-
const backgroundReference = normalizedReference(background.color);
|
|
1189
|
-
if (!backgroundReference || backgroundReference === "transparent") return { kind: "inherits" };
|
|
1190
|
-
return resolveDeterministicForeground(backgroundReference, authored, palette, options.compositeBase);
|
|
1191
|
-
}
|
|
1192
|
-
return resolveTrustedTreatmentForeground(authored, palette);
|
|
1193
|
-
}
|
|
1194
|
-
function foregroundCandidates(background, overrides) {
|
|
1195
|
-
return {
|
|
1196
|
-
text: candidateOrBackground(overrides.text, background?.textColor),
|
|
1197
|
-
heading: candidateOrBackground(overrides.heading, background?.headingColor),
|
|
1198
|
-
link: candidateOrBackground(overrides.link, background?.linkColor),
|
|
1199
|
-
linkHover: candidateOrBackground(overrides.linkHover),
|
|
1200
|
-
supporting: candidateOrBackground(overrides.supporting, background?.supportingColor)
|
|
1201
|
-
};
|
|
1202
|
-
}
|
|
1203
|
-
function candidateOrBackground(candidate, backgroundValue) {
|
|
1204
|
-
return candidate ?? backgroundValue ?? null;
|
|
1205
|
-
}
|
|
1206
|
-
function resolveDeterministicForeground(backgroundReference, candidates, palette, compositeBase) {
|
|
1207
|
-
const backgroundHex = resolveOpaqueSurfaceHex(backgroundReference, palette, compositeBase);
|
|
1208
|
-
if (!backgroundHex) return resolveTrustedTreatmentForeground(candidates, palette);
|
|
1209
|
-
return resolveMeasuredForeground(backgroundReference, backgroundHex, candidates, palette);
|
|
1210
|
-
}
|
|
1211
|
-
function resolveMeasuredForeground(backgroundReference, backgroundHex, candidates, palette) {
|
|
1212
|
-
const backgroundToken = paletteToken(backgroundReference);
|
|
1213
|
-
const derivedOnToken = backgroundToken ? onColorTokenName(backgroundToken) : null;
|
|
1214
|
-
const text = firstSafeToken([candidates.text, derivedOnToken], backgroundHex, palette, derivedOnToken ? [derivedOnToken] : []) ?? paletteTextInk(backgroundHex, palette);
|
|
1215
|
-
return certifiedForeground(knownForeground({
|
|
1216
|
-
text,
|
|
1217
|
-
heading: safeTokenOr(candidates.heading, text, backgroundHex, palette),
|
|
1218
|
-
link: safeTokenOr(candidates.link, text, backgroundHex, palette),
|
|
1219
|
-
supporting: safeTokenOr(candidates.supporting, text, backgroundHex, palette)
|
|
1220
|
-
}, {
|
|
1221
|
-
kind: "measured",
|
|
1222
|
-
backdropHex: backgroundHex,
|
|
1223
|
-
inks: solveSurfaceInks(backgroundHex, text, palette)
|
|
1224
|
-
}, candidates.linkHover, palette), palette);
|
|
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
|
-
}
|
|
1230
|
-
/**
|
|
1231
|
-
* Every measured foreground goes through the ink certificate, whoever paints it
|
|
1232
|
-
* (sections, cards, header, footer, accordions). The candidates above are chosen
|
|
1233
|
-
* to pass, so the certificate is normally a no-op and the foreground is returned
|
|
1234
|
-
* as it was; an ink that misses takes black/white, and the solved inks follow
|
|
1235
|
-
* the certified text.
|
|
1236
|
-
*/
|
|
1237
|
-
function certifiedForeground(foreground, palette) {
|
|
1238
|
-
const { backdropHex } = foreground.provenance;
|
|
1239
|
-
const certified = certifySolidSurfaceInks({ foreground: foreground.roles }, backdropHex, { palette });
|
|
1240
|
-
if (certified.fallback.length === 0) return foreground;
|
|
1241
|
-
return {
|
|
1242
|
-
...foreground,
|
|
1243
|
-
roles: certified.foreground,
|
|
1244
|
-
provenance: {
|
|
1245
|
-
...foreground.provenance,
|
|
1246
|
-
inks: solveSurfaceInks(backdropHex, certified.foreground.text, palette),
|
|
1247
|
-
fallback: certified.fallback
|
|
1248
|
-
}
|
|
1249
|
-
};
|
|
1250
|
-
}
|
|
1251
|
-
function resolveTrustedTreatmentForeground(candidates, palette) {
|
|
1252
|
-
const text = canonicalInk(candidates.text, palette);
|
|
1253
|
-
if (!text) return { kind: "unmeasured-paint" };
|
|
1254
|
-
return knownForeground({
|
|
1255
|
-
text,
|
|
1256
|
-
heading: canonicalInk(candidates.heading, palette) ?? text,
|
|
1257
|
-
link: canonicalInk(candidates.link, palette) ?? text,
|
|
1258
|
-
supporting: canonicalInk(candidates.supporting, palette) ?? text
|
|
1259
|
-
}, { kind: "trusted-treatment" }, candidates.linkHover, palette);
|
|
1260
|
-
}
|
|
1261
|
-
function knownForeground(roles, provenance, hoverCandidate, palette) {
|
|
1262
|
-
const hover = planForegroundHover({
|
|
1263
|
-
restingToken: roles.link,
|
|
1264
|
-
candidate: canonicalHoverToken(hoverCandidate, palette),
|
|
1265
|
-
palette,
|
|
1266
|
-
backdrops: provenance.kind === "measured" ? [provenance.backdropHex] : null
|
|
1267
|
-
});
|
|
1268
|
-
return {
|
|
1269
|
-
kind: "known",
|
|
1270
|
-
provenance,
|
|
1271
|
-
roles: {
|
|
1272
|
-
...roles,
|
|
1273
|
-
linkHover: hover.token,
|
|
1274
|
-
muted: provenance.kind === "measured" ? paletteMutedInkOnSolid(provenance.backdropHex, resolveConcreteColorHex(roles.text, palette), paletteInkRoles(palette)) : roles.text
|
|
1275
|
-
},
|
|
1276
|
-
hoverDecoration: hover.decoration
|
|
1277
|
-
};
|
|
1278
|
-
}
|
|
1279
|
-
function canonicalHoverToken(reference, palette) {
|
|
1280
|
-
const token = parseThemeColorToken(reference);
|
|
1281
|
-
if (token) {
|
|
1282
|
-
const parts = parseColorTokenParts(token);
|
|
1283
|
-
if (parts.kind === "token" && resolveConcreteColorHex(parts.token, palette)) return token;
|
|
1284
|
-
}
|
|
1285
|
-
return canonicalToken(reference, palette);
|
|
1286
|
-
}
|
|
1287
|
-
/**
|
|
1288
|
-
* The one rule for what a resolved foreground publishes for the solved inks.
|
|
1289
|
-
* Only a measured paint under a publishing runtime publishes inks; any other
|
|
1290
|
-
* paint it owns resets them, and a paint it only inherits publishes nothing.
|
|
1291
|
-
*/
|
|
1292
|
-
function surfaceInkPublication(foreground, policy) {
|
|
1293
|
-
switch (foreground.kind) {
|
|
1294
|
-
case "inherits": return { kind: "none" };
|
|
1295
|
-
case "unmeasured-paint": return { kind: "reset" };
|
|
1296
|
-
case "known": return foreground.provenance.kind === "measured" && policy === "publish" ? {
|
|
1297
|
-
kind: "solved",
|
|
1298
|
-
inks: foreground.provenance.inks
|
|
1299
|
-
} : { kind: "reset" };
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
/** Keep a candidate only when it meets ordinary-text contrast on the ground. */
|
|
1303
|
-
function safeTokenOr(candidate, fallback, backgroundHex, palette) {
|
|
1304
|
-
return firstSafeToken([candidate], backgroundHex, palette) ?? fallback;
|
|
1305
|
-
}
|
|
1306
|
-
function firstSafeToken(candidates, backgroundHex, palette, preferredEquivalentTokens = []) {
|
|
1307
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1308
|
-
for (const candidate of candidates) {
|
|
1309
|
-
const token = canonicalToken(candidate, palette, preferredEquivalentTokens);
|
|
1310
|
-
if (!token || seen.has(token)) continue;
|
|
1311
|
-
seen.add(token);
|
|
1312
|
-
const foregroundHex = resolveConcreteColorHex(token, palette);
|
|
1313
|
-
if (foregroundHex && contrastRatio(backgroundHex, foregroundHex) >= 4.5) return token;
|
|
1314
|
-
}
|
|
1315
|
-
return null;
|
|
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
|
-
}
|
|
1332
|
-
function canonicalToken(reference, palette, preferredEquivalentTokens = []) {
|
|
1333
|
-
const normalized = normalizedReference(reference);
|
|
1334
|
-
if (!normalized || normalized === "transparent") return null;
|
|
1335
|
-
const direct = parseThemeColorToken(normalized);
|
|
1336
|
-
if (direct && resolveConcreteColorHex(direct, palette)) return direct;
|
|
1337
|
-
const referenceHex = resolveConcreteColorHex(normalized, palette);
|
|
1338
|
-
if (!referenceHex) return null;
|
|
1339
|
-
const equivalent = [
|
|
1340
|
-
...preferredEquivalentTokens,
|
|
1341
|
-
...CANONICAL_EQUIVALENT_TOKEN_ORDER,
|
|
1342
|
-
...Object.keys(palette).sort()
|
|
1343
|
-
].find((token) => {
|
|
1344
|
-
const parsed = parseThemeColorToken(token);
|
|
1345
|
-
return parsed !== null && resolveConcreteColorHex(parsed, palette)?.toLowerCase() === referenceHex.toLowerCase();
|
|
1346
|
-
});
|
|
1347
|
-
return equivalent ? parseThemeColorToken(equivalent) : null;
|
|
1348
|
-
}
|
|
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
1028
|
//#endregion
|
|
1359
1029
|
//#region ../theme-core/src/palette/generateShades.ts
|
|
1360
1030
|
function generateShades(hexColor, name) {
|
|
@@ -1528,6 +1198,62 @@ function scrimTone(samples) {
|
|
|
1528
1198
|
return white === black ? null : white > black ? "dark" : "light";
|
|
1529
1199
|
}
|
|
1530
1200
|
//#endregion
|
|
1201
|
+
//#region ../theme-core/src/palette/utils/textColor.ts
|
|
1202
|
+
/**
|
|
1203
|
+
* Pick the better of black/white text for a given background using actual
|
|
1204
|
+
* contrast ratios, not a simple luminance cutoff. This is
|
|
1205
|
+
* `maxContrastBlackOrWhite` for a solid ground. It is the literal fallback
|
|
1206
|
+
* only: where a palette is in scope, `paletteInkOnSolid` tries the site's own
|
|
1207
|
+
* background and text colours first.
|
|
1208
|
+
*
|
|
1209
|
+
* @param background - Background color in hex or rgb/rgba format (e.g., '#FFFFFF' or 'rgb(255, 255, 255)')
|
|
1210
|
+
* @param _minContrast - Kept for callers. It cannot change the result: when
|
|
1211
|
+
* only one of black or white reaches it, that one is also the better of the two.
|
|
1212
|
+
* @returns '#000000' for light backgrounds, '#FFFFFF' for dark backgrounds
|
|
1213
|
+
*/
|
|
1214
|
+
function pickBlackOrWhiteTextColor(background, _minContrast = 4.5) {
|
|
1215
|
+
const { r, g, b } = parseColorToRgb(background);
|
|
1216
|
+
return literalInkHex(maxContrastBlackOrWhite(luminanceInterval(relativeLuminance(r, g, b))).ink);
|
|
1217
|
+
}
|
|
1218
|
+
function parseColorToRgb(input) {
|
|
1219
|
+
const trimmed = input.trim();
|
|
1220
|
+
if (trimmed.startsWith("#")) return hexToRgb(trimmed);
|
|
1221
|
+
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);
|
|
1222
|
+
if (rgbMatch?.[1] && rgbMatch[2] && rgbMatch[3]) return {
|
|
1223
|
+
r: clamp255(Number(rgbMatch[1])),
|
|
1224
|
+
g: clamp255(Number(rgbMatch[2])),
|
|
1225
|
+
b: clamp255(Number(rgbMatch[3]))
|
|
1226
|
+
};
|
|
1227
|
+
throw new Error("Unsupported color format");
|
|
1228
|
+
}
|
|
1229
|
+
function clamp255(value) {
|
|
1230
|
+
if (Number.isNaN(value)) return 0;
|
|
1231
|
+
return Math.max(0, Math.min(255, value));
|
|
1232
|
+
}
|
|
1233
|
+
//#endregion
|
|
1234
|
+
//#region ../theme-core/src/palette/utils/onColor.ts
|
|
1235
|
+
const BACKGROUND_ROLE_NAMES = /* @__PURE__ */ new Set([
|
|
1236
|
+
"primary",
|
|
1237
|
+
"secondary",
|
|
1238
|
+
"accent",
|
|
1239
|
+
"success",
|
|
1240
|
+
"warning",
|
|
1241
|
+
"destructive",
|
|
1242
|
+
"info",
|
|
1243
|
+
"background",
|
|
1244
|
+
"surface",
|
|
1245
|
+
"surfaceAlt",
|
|
1246
|
+
"muted",
|
|
1247
|
+
"neutral"
|
|
1248
|
+
]);
|
|
1249
|
+
function onColorTokenName(backgroundToken) {
|
|
1250
|
+
return `on${backgroundToken.split("-").filter((part) => part.length > 0).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join("")}`;
|
|
1251
|
+
}
|
|
1252
|
+
function isOnColorBackgroundCandidateToken(token) {
|
|
1253
|
+
const role = token.match(/^(.*?)(?:-\d{2,3})?$/)?.[1] ?? token;
|
|
1254
|
+
return BACKGROUND_ROLE_NAMES.has(role);
|
|
1255
|
+
}
|
|
1256
|
+
//#endregion
|
|
1531
1257
|
//#region ../theme-core/src/palette/expandPalette.ts
|
|
1532
1258
|
function colorsToMap(palette) {
|
|
1533
1259
|
const map = {};
|
|
@@ -1651,109 +1377,423 @@ const MUTED_INK_TOKENS = {
|
|
|
1651
1377
|
* ground its colours were chosen for. Hosted palettes and the SDK bridge both
|
|
1652
1378
|
* derive it here.
|
|
1653
1379
|
*/
|
|
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: []
|
|
1380
|
+
function groundMutedInk(palette, ground) {
|
|
1381
|
+
const groundHex = palette[ground];
|
|
1382
|
+
if (!groundHex) return null;
|
|
1383
|
+
const preferred = palette[onColorTokenName(ground)] ?? null;
|
|
1384
|
+
const roles = paletteInkRoles(palette);
|
|
1385
|
+
const initial = {
|
|
1386
|
+
grounds: [groundHex],
|
|
1387
|
+
hex: paletteMutedInkOnSolid(groundHex, preferred, roles),
|
|
1388
|
+
uncovered: []
|
|
1389
|
+
};
|
|
1390
|
+
const solved = SURFACE_SECONDARY_TEXT_TINTS.reduce((kept, { token, alpha }) => {
|
|
1391
|
+
const tintHex = palette[token];
|
|
1392
|
+
if (!tintHex) return kept;
|
|
1393
|
+
const grounds = [...kept.grounds, compositeHex(tintHex, alpha, groundHex)];
|
|
1394
|
+
const ink = paletteMutedInk(grounds, preferred, roles);
|
|
1395
|
+
return ink.kind === "unpaintable" ? {
|
|
1396
|
+
...kept,
|
|
1397
|
+
uncovered: [...kept.uncovered, {
|
|
1398
|
+
token,
|
|
1399
|
+
alpha,
|
|
1400
|
+
tintHex
|
|
1401
|
+
}]
|
|
1402
|
+
} : {
|
|
1403
|
+
...kept,
|
|
1404
|
+
grounds,
|
|
1405
|
+
hex: ink.hex
|
|
1406
|
+
};
|
|
1407
|
+
}, initial);
|
|
1408
|
+
return {
|
|
1409
|
+
hex: solved.hex,
|
|
1410
|
+
fadedTints: solved.uncovered.map(({ token, alpha, tintHex }) => ({
|
|
1411
|
+
token,
|
|
1412
|
+
hex: tintFadedUntilInkReads(tintHex, alpha, groundHex, solved.hex)
|
|
1413
|
+
}))
|
|
1414
|
+
};
|
|
1415
|
+
}
|
|
1416
|
+
/** The tint colour a ground publishes in place of a tint its muted ink can't read on, e.g. `surfaceTintMuted`. */
|
|
1417
|
+
function groundTintToken(ground, tint) {
|
|
1418
|
+
return `${ground}Tint${tint.charAt(0).toUpperCase()}${tint.slice(1)}`;
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* The tint blended toward the ground in 1% steps, stopping at the first that
|
|
1422
|
+
* the ink reads on when laid at `alpha`. The ground itself always reads, since
|
|
1423
|
+
* the ink was solved on it.
|
|
1424
|
+
*/
|
|
1425
|
+
function tintFadedUntilInkReads(tintHex, alpha, groundHex, inkHex) {
|
|
1426
|
+
const tint = hexToRgb(tintHex);
|
|
1427
|
+
const ground = hexToRgb(groundHex);
|
|
1428
|
+
return Array.from({ length: 101 }, (_, index) => {
|
|
1429
|
+
const amount = index / 100;
|
|
1430
|
+
return rgbToHex(mix$1(tint.r, ground.r, amount), mix$1(tint.g, ground.g, amount), mix$1(tint.b, ground.b, amount));
|
|
1431
|
+
}).find((hex) => contrastRatio(inkHex, compositeHex(hex, alpha, groundHex)) >= 4.5) ?? groundHex;
|
|
1432
|
+
}
|
|
1433
|
+
/**
|
|
1434
|
+
* The muted ink tokens a palette doesn't store itself, and the faded tint
|
|
1435
|
+
* colours of each ground whose ink is solved here, as hex.
|
|
1436
|
+
*/
|
|
1437
|
+
function groundMutedInkTokens(palette) {
|
|
1438
|
+
return Object.fromEntries(Object.entries(MUTED_INK_TOKENS).flatMap(([ground, token]) => {
|
|
1439
|
+
if (palette[token]) return [];
|
|
1440
|
+
const ink = groundMutedInk(palette, ground);
|
|
1441
|
+
if (!ink) return [];
|
|
1442
|
+
const faded = ink.fadedTints.map(({ token: tint, hex }) => [groundTintToken(ground, tint), hex]);
|
|
1443
|
+
return [[token, ink.hex], ...faded.filter(([name]) => !palette[name])];
|
|
1444
|
+
}));
|
|
1445
|
+
}
|
|
1446
|
+
/**
|
|
1447
|
+
* The neutral step stays when it reads on the ground. Otherwise (a dark palette
|
|
1448
|
+
* on a mid-tone ground, or a tinted light one) it's the ground-to-text blend
|
|
1449
|
+
* with a 4.5:1 floor, heading for the palette's own ink on that ground.
|
|
1450
|
+
*/
|
|
1451
|
+
function readableMutedText(step, base, roles) {
|
|
1452
|
+
const ground = base.background || base.surface;
|
|
1453
|
+
if (!ground || contrastRatio(step, ground) >= 4.5) return step;
|
|
1454
|
+
return paletteMutedInkOnSolid(ground, null, roles);
|
|
1455
|
+
}
|
|
1456
|
+
/**
|
|
1457
|
+
* Derived decoration colours never become editable palette swatches. The mark
|
|
1458
|
+
* blends toward literal black or white: it's a graphic endpoint for a 3:1
|
|
1459
|
+
* search, not text, so it stays off the palette ink rule.
|
|
1460
|
+
*/
|
|
1461
|
+
/** `backdrops` lists every colour the decorations sit on, such as each step of a radial glow. */
|
|
1462
|
+
function deriveSurfaceDecorationColors(ground, text, accent, backdrops = [ground]) {
|
|
1463
|
+
const ink = pickBlackOrWhiteTextColor(ground);
|
|
1464
|
+
return {
|
|
1465
|
+
line: deriveSurfaceLineColor(ground, text, backdrops),
|
|
1466
|
+
mark: firstContrastBlend(accent, ink, backdrops, 3)
|
|
1467
|
+
};
|
|
1468
|
+
}
|
|
1469
|
+
/**
|
|
1470
|
+
* Secondary ink blended from its ground toward its text, reading at 4.5:1 over
|
|
1471
|
+
* every backdrop a sampled finish paints under it. When no blend reads on all of
|
|
1472
|
+
* them the text itself is kept (or, with no concrete text, the ink solved on
|
|
1473
|
+
* the ground alone).
|
|
1474
|
+
*/
|
|
1475
|
+
function deriveSurfaceMutedColor(ground, text, backdrops = [ground], roles = null) {
|
|
1476
|
+
const ink = paletteMutedInk([ground, ...backdrops], text, roles);
|
|
1477
|
+
if (ink.kind === "muted") return ink.hex;
|
|
1478
|
+
return text ?? paletteMutedInkOnSolid(ground, null, roles);
|
|
1479
|
+
}
|
|
1480
|
+
/** A section rule is a quiet ground-to-text blend, certified over the complete backing. */
|
|
1481
|
+
function deriveSurfaceLineColor(ground, text, backdrops = [ground]) {
|
|
1482
|
+
return firstContrastBlend(ground, text, backdrops, 1.5);
|
|
1483
|
+
}
|
|
1484
|
+
function firstContrastBlend(from, to, backdrops, threshold) {
|
|
1485
|
+
const start = hexToRgb(from);
|
|
1486
|
+
const end = hexToRgb(to);
|
|
1487
|
+
const luminances = backdrops.map((backdrop) => hexLuminance(backdrop));
|
|
1488
|
+
const paint = luminanceInterval(Math.min(...luminances), Math.max(...luminances));
|
|
1489
|
+
return Array.from({ length: 101 }, (_, index) => {
|
|
1490
|
+
const amount = index / 100;
|
|
1491
|
+
return rgbToHex(mix$1(start.r, end.r, amount), mix$1(start.g, end.g, amount), mix$1(start.b, end.b, amount));
|
|
1492
|
+
}).find((hex) => worstContrast(hexLuminance(hex), paint) >= threshold) ?? to;
|
|
1493
|
+
}
|
|
1494
|
+
/** `markSource` names the colour surface marks are derived from when a style marks in its brand rather than its accent. */
|
|
1495
|
+
function arrangementPaletteTokens(base, options) {
|
|
1496
|
+
if (options.arrangement !== true || !base.text) return {};
|
|
1497
|
+
return {
|
|
1498
|
+
onText: base.onText ?? paletteInkOnSolid(base.text, paletteInkRoles(base)).hex,
|
|
1499
|
+
...options.marksFrom === "primary" && base.primary ? { markSource: base.primary } : {}
|
|
1500
|
+
};
|
|
1501
|
+
}
|
|
1502
|
+
//#endregion
|
|
1503
|
+
//#region ../theme-core/src/surfaces/surfaceInks.ts
|
|
1504
|
+
/** Lines and focus rings are graphics: WCAG non-text contrast. */
|
|
1505
|
+
const GRAPHIC_MIN_CONTRAST_RATIO = 3;
|
|
1506
|
+
/**
|
|
1507
|
+
* The palette token the control edge ink is solved from. Input styles whose
|
|
1508
|
+
* border uses another token keep their own colour, since this ink would carry
|
|
1509
|
+
* the wrong hue for them.
|
|
1510
|
+
*/
|
|
1511
|
+
const CONTROL_EDGE_SEED_TOKEN = "border";
|
|
1512
|
+
const INK_SEEDS = {
|
|
1513
|
+
brand: {
|
|
1514
|
+
token: "primary",
|
|
1515
|
+
ratio: ORDINARY_TEXT_MIN_CONTRAST_RATIO
|
|
1516
|
+
},
|
|
1517
|
+
accent: {
|
|
1518
|
+
token: "accent",
|
|
1519
|
+
ratio: ORDINARY_TEXT_MIN_CONTRAST_RATIO
|
|
1520
|
+
},
|
|
1521
|
+
focus: {
|
|
1522
|
+
token: "primary",
|
|
1523
|
+
ratio: GRAPHIC_MIN_CONTRAST_RATIO
|
|
1524
|
+
},
|
|
1525
|
+
control: {
|
|
1526
|
+
token: CONTROL_EDGE_SEED_TOKEN,
|
|
1527
|
+
ratio: GRAPHIC_MIN_CONTRAST_RATIO,
|
|
1528
|
+
maxDistance: 2
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
/**
|
|
1532
|
+
* Solve the inks for a measured solid paint. `textInk` is the surface's
|
|
1533
|
+
* own (already certified) text ink: it stands in when the owner's colour is
|
|
1534
|
+
* missing, or can only clear the paint by drifting too far from itself.
|
|
1535
|
+
* A block owner can supply an authored shade candidate for a local ink.
|
|
1536
|
+
*/
|
|
1537
|
+
function solveSurfaceInks(backdrop, textInk, palette, candidates = {}) {
|
|
1538
|
+
const [backdropHex] = typeof backdrop === "string" ? [backdrop] : backdrop;
|
|
1539
|
+
const paint = typeof backdrop === "string" ? solidPaint(backdrop) : sampledInkPaint(backdrop);
|
|
1540
|
+
const fallback = literalInk(resolveConcreteColorHex(textInk, palette) ?? pickBlackOrWhiteTextColor(backdropHex));
|
|
1541
|
+
return {
|
|
1542
|
+
brand: solveInk({
|
|
1543
|
+
...INK_SEEDS.brand,
|
|
1544
|
+
token: candidates.brand ?? INK_SEEDS.brand.token
|
|
1545
|
+
}, paint, palette, fallback),
|
|
1546
|
+
accent: solveInk({
|
|
1547
|
+
...INK_SEEDS.accent,
|
|
1548
|
+
token: candidates.accent ?? INK_SEEDS.accent.token
|
|
1549
|
+
}, paint, palette, fallback),
|
|
1550
|
+
focus: solveInk({
|
|
1551
|
+
...INK_SEEDS.focus,
|
|
1552
|
+
token: candidates.focus ?? INK_SEEDS.focus.token
|
|
1553
|
+
}, paint, palette, fallback),
|
|
1554
|
+
control: solveInk({
|
|
1555
|
+
...INK_SEEDS.control,
|
|
1556
|
+
token: candidates.control ?? INK_SEEDS.control.token
|
|
1557
|
+
}, paint, palette, fallback)
|
|
1558
|
+
};
|
|
1559
|
+
}
|
|
1560
|
+
function solveInk(seed, paint, palette, fallback) {
|
|
1561
|
+
const token = parseThemeColorToken(seed.token);
|
|
1562
|
+
const seedHex = hexColorSchema.safeParse(resolveConcreteColorHex(seed.token, palette));
|
|
1563
|
+
if (!token || !seedHex.success) return fallback;
|
|
1564
|
+
const solved = inkFrom(familyOf(seedHex.data), paint, seed.ratio, seed.maxDistance);
|
|
1565
|
+
switch (solved.kind) {
|
|
1566
|
+
case "ink": return solved.source === "exact" ? token : literalInk(solved.hex);
|
|
1567
|
+
case "too-far":
|
|
1568
|
+
case "unpaintable": return fallback;
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
function literalInk(hex) {
|
|
1572
|
+
return hexColorSchema.parse(hex.toLowerCase());
|
|
1573
|
+
}
|
|
1574
|
+
const FAMILY_CACHE_LIMIT = 64;
|
|
1575
|
+
const families = /* @__PURE__ */ new Map();
|
|
1576
|
+
function familyOf(seed) {
|
|
1577
|
+
const cached = families.get(seed);
|
|
1578
|
+
if (cached) return cached;
|
|
1579
|
+
if (families.size >= FAMILY_CACHE_LIMIT) families.clear();
|
|
1580
|
+
const family = colourFamily(seed);
|
|
1581
|
+
families.set(seed, family);
|
|
1582
|
+
return family;
|
|
1583
|
+
}
|
|
1584
|
+
/** The same solver holds local inks against the whole finished ground's luminance range. */
|
|
1585
|
+
function sampledInkPaint(backdrops) {
|
|
1586
|
+
const luminances = backdrops.map((colour) => hexLuminance(colour));
|
|
1587
|
+
return luminanceInterval(Math.min(...luminances), Math.max(...luminances));
|
|
1588
|
+
}
|
|
1589
|
+
//#endregion
|
|
1590
|
+
//#region ../theme-core/src/surfaces/resolveSurfaceForeground.ts
|
|
1591
|
+
const CANONICAL_EQUIVALENT_TOKEN_ORDER = [
|
|
1592
|
+
"text",
|
|
1593
|
+
"primaryForeground",
|
|
1594
|
+
"secondaryForeground",
|
|
1595
|
+
"accentForeground",
|
|
1596
|
+
"onPrimary",
|
|
1597
|
+
"onSecondary",
|
|
1598
|
+
"onAccent",
|
|
1599
|
+
"onSurface",
|
|
1600
|
+
"neutral-950",
|
|
1601
|
+
"neutral-50"
|
|
1602
|
+
];
|
|
1603
|
+
function resolveSurfaceForeground(background, palette, candidates = {}, options = {}) {
|
|
1604
|
+
const authored = foregroundCandidates(background, candidates);
|
|
1605
|
+
if ("measuredBackdrop" in options) return resolveMeasuredForeground(background?.color ?? "background", options.measuredBackdrop, authored, palette);
|
|
1606
|
+
return resolveAuthoredBackground(background, palette, authored, options);
|
|
1607
|
+
}
|
|
1608
|
+
/** Legacy references may be measurable, inherited, or a trusted media treatment. */
|
|
1609
|
+
function resolveAuthoredBackground(background, palette, authored, options) {
|
|
1610
|
+
if (background === null) return resolveDeterministicForeground("background", {
|
|
1611
|
+
...authored,
|
|
1612
|
+
text: authored.text ?? "text"
|
|
1613
|
+
}, palette);
|
|
1614
|
+
if (background.type === "color") {
|
|
1615
|
+
const backgroundReference = normalizedReference(background.color);
|
|
1616
|
+
if (!backgroundReference || backgroundReference === "transparent") return { kind: "inherits" };
|
|
1617
|
+
return resolveDeterministicForeground(backgroundReference, authored, palette, options.compositeBase);
|
|
1618
|
+
}
|
|
1619
|
+
return resolveTrustedTreatmentForeground(authored, palette);
|
|
1620
|
+
}
|
|
1621
|
+
function foregroundCandidates(background, overrides) {
|
|
1622
|
+
return {
|
|
1623
|
+
text: candidateOrBackground(overrides.text, background?.textColor),
|
|
1624
|
+
heading: candidateOrBackground(overrides.heading, background?.headingColor),
|
|
1625
|
+
link: candidateOrBackground(overrides.link, background?.linkColor),
|
|
1626
|
+
linkHover: candidateOrBackground(overrides.linkHover),
|
|
1627
|
+
supporting: candidateOrBackground(overrides.supporting, background?.supportingColor)
|
|
1628
|
+
};
|
|
1629
|
+
}
|
|
1630
|
+
function candidateOrBackground(candidate, backgroundValue) {
|
|
1631
|
+
return candidate ?? backgroundValue ?? null;
|
|
1632
|
+
}
|
|
1633
|
+
function resolveDeterministicForeground(backgroundReference, candidates, palette, compositeBase) {
|
|
1634
|
+
const backgroundHex = resolveOpaqueSurfaceHex(backgroundReference, palette, compositeBase);
|
|
1635
|
+
if (!backgroundHex) return resolveTrustedTreatmentForeground(candidates, palette);
|
|
1636
|
+
return resolveMeasuredForeground(backgroundReference, backgroundHex, candidates, palette);
|
|
1637
|
+
}
|
|
1638
|
+
function resolveMeasuredForeground(backgroundReference, backgroundHex, candidates, palette) {
|
|
1639
|
+
const backgroundToken = paletteToken(backgroundReference);
|
|
1640
|
+
const derivedOnToken = backgroundToken ? onColorTokenName(backgroundToken) : null;
|
|
1641
|
+
const text = firstSafeToken([candidates.text, derivedOnToken], backgroundHex, palette, derivedOnToken ? [derivedOnToken] : []) ?? paletteTextInk(backgroundHex, palette);
|
|
1642
|
+
return certifiedForeground(knownForeground({
|
|
1643
|
+
text,
|
|
1644
|
+
heading: safeTokenOr(candidates.heading, text, backgroundHex, palette),
|
|
1645
|
+
link: safeTokenOr(candidates.link, text, backgroundHex, palette),
|
|
1646
|
+
supporting: safeTokenOr(candidates.supporting, text, backgroundHex, palette)
|
|
1647
|
+
}, {
|
|
1648
|
+
kind: "measured",
|
|
1649
|
+
backdropHex: backgroundHex,
|
|
1650
|
+
inks: solveSurfaceInks(backgroundHex, text, palette)
|
|
1651
|
+
}, candidates.linkHover, palette), palette);
|
|
1652
|
+
}
|
|
1653
|
+
/** The automatic text when neither the authored ink nor the ground's on-colour reads: the palette's own pair, then black or white. */
|
|
1654
|
+
function paletteTextInk(backgroundHex, palette) {
|
|
1655
|
+
return paletteInkToken(paletteInkOnSolid(backgroundHex, paletteInkRoles(palette)));
|
|
1656
|
+
}
|
|
1657
|
+
/**
|
|
1658
|
+
* Every measured foreground goes through the ink certificate, whoever paints it
|
|
1659
|
+
* (sections, cards, header, footer, accordions). The candidates above are chosen
|
|
1660
|
+
* to pass, so the certificate is normally a no-op and the foreground is returned
|
|
1661
|
+
* as it was; an ink that misses takes black/white, and the solved inks follow
|
|
1662
|
+
* the certified text.
|
|
1663
|
+
*/
|
|
1664
|
+
function certifiedForeground(foreground, palette) {
|
|
1665
|
+
const { backdropHex } = foreground.provenance;
|
|
1666
|
+
const certified = certifySolidSurfaceInks({ foreground: foreground.roles }, backdropHex, { palette });
|
|
1667
|
+
if (certified.fallback.length === 0) return foreground;
|
|
1668
|
+
return {
|
|
1669
|
+
...foreground,
|
|
1670
|
+
roles: certified.foreground,
|
|
1671
|
+
provenance: {
|
|
1672
|
+
...foreground.provenance,
|
|
1673
|
+
inks: solveSurfaceInks(backdropHex, certified.foreground.text, palette),
|
|
1674
|
+
fallback: certified.fallback
|
|
1675
|
+
}
|
|
1663
1676
|
};
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
} : {
|
|
1677
|
-
...kept,
|
|
1678
|
-
grounds,
|
|
1679
|
-
hex: ink.hex
|
|
1680
|
-
};
|
|
1681
|
-
}, initial);
|
|
1677
|
+
}
|
|
1678
|
+
function resolveTrustedTreatmentForeground(candidates, palette) {
|
|
1679
|
+
const text = canonicalInk(candidates.text, palette);
|
|
1680
|
+
if (!text) return { kind: "unmeasured-paint" };
|
|
1681
|
+
return knownForeground({
|
|
1682
|
+
text,
|
|
1683
|
+
heading: canonicalInk(candidates.heading, palette) ?? text,
|
|
1684
|
+
link: canonicalInk(candidates.link, palette) ?? text,
|
|
1685
|
+
supporting: canonicalInk(candidates.supporting, palette) ?? text
|
|
1686
|
+
}, { kind: "trusted-treatment" }, candidates.linkHover, palette);
|
|
1687
|
+
}
|
|
1688
|
+
function knownForeground(roles, provenance, hoverCandidate, palette) {
|
|
1682
1689
|
return {
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1690
|
+
kind: "known",
|
|
1691
|
+
provenance,
|
|
1692
|
+
...deriveSurfaceForegroundDetails(roles, {
|
|
1693
|
+
palette,
|
|
1694
|
+
hoverCandidate,
|
|
1695
|
+
ground: provenance.kind === "measured" ? provenance.backdropHex : void 0,
|
|
1696
|
+
backdrops: provenance.kind === "measured" ? provenance.backdropSamples ?? [provenance.backdropHex] : null
|
|
1697
|
+
})
|
|
1688
1698
|
};
|
|
1689
1699
|
}
|
|
1690
|
-
/**
|
|
1691
|
-
function
|
|
1692
|
-
|
|
1700
|
+
/** Normal muted and hover derivation, using all of a sampled paint rather than one stop. */
|
|
1701
|
+
function deriveSurfaceForegroundDetails(roles, input) {
|
|
1702
|
+
const { palette, ground, backdrops } = input;
|
|
1703
|
+
const hover = planForegroundHover({
|
|
1704
|
+
restingToken: roles.link,
|
|
1705
|
+
candidate: canonicalHoverToken(input.hoverCandidate ?? null, palette),
|
|
1706
|
+
palette,
|
|
1707
|
+
backdrops
|
|
1708
|
+
});
|
|
1709
|
+
const text = resolveConcreteColorHex(roles.text, palette);
|
|
1710
|
+
const muted = ground && backdrops ? deriveSurfaceMutedColor(ground, text, backdrops, paletteInkRoles(palette)) : roles.text;
|
|
1711
|
+
return {
|
|
1712
|
+
roles: {
|
|
1713
|
+
...roles,
|
|
1714
|
+
linkHover: hover.token,
|
|
1715
|
+
muted
|
|
1716
|
+
},
|
|
1717
|
+
hoverDecoration: hover.decoration
|
|
1718
|
+
};
|
|
1693
1719
|
}
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
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;
|
|
1720
|
+
function canonicalHoverToken(reference, palette) {
|
|
1721
|
+
const token = parseThemeColorToken(reference);
|
|
1722
|
+
if (token) {
|
|
1723
|
+
const parts = parseColorTokenParts(token);
|
|
1724
|
+
if (parts.kind === "token" && resolveConcreteColorHex(parts.token, palette)) return token;
|
|
1725
|
+
}
|
|
1726
|
+
return canonicalToken(reference, palette);
|
|
1706
1727
|
}
|
|
1707
1728
|
/**
|
|
1708
|
-
* The
|
|
1709
|
-
*
|
|
1729
|
+
* The one rule for what a resolved foreground publishes for the solved inks.
|
|
1730
|
+
* Only a measured paint under a publishing runtime publishes inks; any other
|
|
1731
|
+
* paint it owns resets them, and a paint it only inherits publishes nothing.
|
|
1710
1732
|
*/
|
|
1711
|
-
function
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1733
|
+
function surfaceInkPublication(foreground, policy) {
|
|
1734
|
+
switch (foreground.kind) {
|
|
1735
|
+
case "inherits": return { kind: "none" };
|
|
1736
|
+
case "unmeasured-paint": return { kind: "reset" };
|
|
1737
|
+
case "known": return foreground.provenance.kind === "measured" && policy === "publish" ? {
|
|
1738
|
+
kind: "solved",
|
|
1739
|
+
inks: foreground.provenance.inks
|
|
1740
|
+
} : { kind: "reset" };
|
|
1741
|
+
}
|
|
1719
1742
|
}
|
|
1720
|
-
/**
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
const
|
|
1727
|
-
|
|
1728
|
-
|
|
1743
|
+
/** Keep a candidate only when it meets ordinary-text contrast on the ground. */
|
|
1744
|
+
function safeTokenOr(candidate, fallback, backgroundHex, palette) {
|
|
1745
|
+
return firstSafeToken([candidate], backgroundHex, palette) ?? fallback;
|
|
1746
|
+
}
|
|
1747
|
+
function firstSafeToken(candidates, backgroundHex, palette, preferredEquivalentTokens = []) {
|
|
1748
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1749
|
+
for (const candidate of candidates) {
|
|
1750
|
+
const token = canonicalToken(candidate, palette, preferredEquivalentTokens);
|
|
1751
|
+
if (!token || seen.has(token)) continue;
|
|
1752
|
+
seen.add(token);
|
|
1753
|
+
const foregroundHex = resolveConcreteColorHex(token, palette);
|
|
1754
|
+
if (foregroundHex && contrastRatio(backgroundHex, foregroundHex) >= 4.5) return token;
|
|
1755
|
+
}
|
|
1756
|
+
return null;
|
|
1729
1757
|
}
|
|
1730
1758
|
/**
|
|
1731
|
-
*
|
|
1732
|
-
*
|
|
1733
|
-
*
|
|
1759
|
+
* A media treatment's ink as the resolved contract spells it. Nothing measures
|
|
1760
|
+
* the paint, so black or white (the photo tint's fallback) uses its fixed token
|
|
1761
|
+
* rather than borrowing a palette role with the same value today. Any other reference is a palette token.
|
|
1762
|
+
* Measured solids keep `firstSafeToken`, whose equivalent on-colour carries the
|
|
1763
|
+
* ground's own hover softening.
|
|
1734
1764
|
*/
|
|
1735
|
-
function
|
|
1736
|
-
|
|
1737
|
-
return {
|
|
1738
|
-
line: firstContrastBlend(ground, text, ground, 1.5),
|
|
1739
|
-
mark: firstContrastBlend(accent, ink, ground, 3)
|
|
1740
|
-
};
|
|
1765
|
+
function canonicalInk(reference, palette) {
|
|
1766
|
+
return absoluteInk(reference) ?? canonicalToken(reference, palette);
|
|
1741
1767
|
}
|
|
1742
|
-
function
|
|
1743
|
-
const
|
|
1744
|
-
|
|
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;
|
|
1768
|
+
function absoluteInk(reference) {
|
|
1769
|
+
const normalized = normalizedReference(reference)?.toUpperCase();
|
|
1770
|
+
return parseThemeColorToken(normalized === "#000000" ? "absoluteBlack" : normalized === "#FFFFFF" ? "absoluteWhite" : null);
|
|
1749
1771
|
}
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
if (
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1772
|
+
function canonicalToken(reference, palette, preferredEquivalentTokens = []) {
|
|
1773
|
+
const normalized = normalizedReference(reference);
|
|
1774
|
+
if (!normalized || normalized === "transparent") return null;
|
|
1775
|
+
const direct = parseThemeColorToken(normalized);
|
|
1776
|
+
if (direct && resolveConcreteColorHex(direct, palette)) return direct;
|
|
1777
|
+
const referenceHex = resolveConcreteColorHex(normalized, palette);
|
|
1778
|
+
if (!referenceHex) return null;
|
|
1779
|
+
const equivalent = [
|
|
1780
|
+
...preferredEquivalentTokens,
|
|
1781
|
+
...CANONICAL_EQUIVALENT_TOKEN_ORDER,
|
|
1782
|
+
...Object.keys(palette).sort()
|
|
1783
|
+
].find((token) => {
|
|
1784
|
+
const parsed = parseThemeColorToken(token);
|
|
1785
|
+
return parsed !== null && resolveConcreteColorHex(parsed, palette)?.toLowerCase() === referenceHex.toLowerCase();
|
|
1786
|
+
});
|
|
1787
|
+
return equivalent ? parseThemeColorToken(equivalent) : null;
|
|
1788
|
+
}
|
|
1789
|
+
function paletteToken(reference) {
|
|
1790
|
+
const parts = parseColorTokenParts(reference);
|
|
1791
|
+
return parts.kind === "token" && parts.opacityPercent === null ? parts.token : null;
|
|
1792
|
+
}
|
|
1793
|
+
function normalizedReference(value) {
|
|
1794
|
+
if (typeof value !== "string") return null;
|
|
1795
|
+
const normalized = value.trim();
|
|
1796
|
+
return normalized.length > 0 ? normalized : null;
|
|
1757
1797
|
}
|
|
1758
1798
|
//#endregion
|
|
1759
1799
|
//#region ../theme-core/src/utils/cssValueSafety.ts
|
|
@@ -2520,7 +2560,7 @@ function buttonSurfaceSeparation(fill, surface, edge) {
|
|
|
2520
2560
|
}
|
|
2521
2561
|
/** The worst ground for a fill: the first it fails to stand out from, otherwise the closest. */
|
|
2522
2562
|
function buttonGroundSeparation(fill, grounds, edge) {
|
|
2523
|
-
const ink = edge?.border?.marksBoundary ? edge.border.boundaryInk ? edge.
|
|
2563
|
+
const ink = edge?.border?.marksBoundary ? edge.border.boundaryInk ? resolveConcreteColorHex(edge.border.boundaryInk, edge.palette) ?? void 0 : edge.labelInk : void 0;
|
|
2524
2564
|
return grounds.map((ground) => {
|
|
2525
2565
|
const separation = buttonFillSeparation(fill, ground);
|
|
2526
2566
|
const distinct = separation.distinct || ink !== void 0 && contrastRatio(ink, ground) >= BUTTON_CONTRAST_POLICY.nonTextMinimumRatio;
|
|
@@ -2536,7 +2576,7 @@ function buttonGroundSeparation(fill, grounds, edge) {
|
|
|
2536
2576
|
}
|
|
2537
2577
|
function validateButtonFillSeparation(input) {
|
|
2538
2578
|
const token = input.border?.marksBoundary ? input.border.boundaryInk : void 0;
|
|
2539
|
-
if (token && !input.palette
|
|
2579
|
+
if (token && !resolveConcreteColorHex(token, input.palette)) return {
|
|
2540
2580
|
ok: false,
|
|
2541
2581
|
error: {
|
|
2542
2582
|
tag: "unknown_palette_token",
|
|
@@ -2964,16 +3004,16 @@ function standsApartFromSurface(hex, labelInk, input) {
|
|
|
2964
3004
|
}
|
|
2965
3005
|
/** 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
3006
|
function preferredInkHolds(token, input) {
|
|
2967
|
-
const hex = input.palette
|
|
2968
|
-
const labelInk =
|
|
2969
|
-
if (hex ===
|
|
3007
|
+
const hex = resolveConcreteColorHex(token, input.palette);
|
|
3008
|
+
const labelInk = resolveConcreteColorHex(solidForegroundToken(token), input.palette) ?? void 0;
|
|
3009
|
+
if (hex === null || !labelReadable(hex, labelInk, input.colourIndex)) return false;
|
|
2970
3010
|
return input.surface === void 0 || standsApartFromSurface(hex, labelInk, input) && contrastRatio(hex, input.surface.backgroundHex, input.colourIndex) >= FILL_CLEARS_GROUND;
|
|
2971
3011
|
}
|
|
2972
3012
|
/** The other steps of the seed's scale (`primary-100` … `primary-950`), measured against the seed and the ground. */
|
|
2973
3013
|
function shadeCandidates(input) {
|
|
2974
3014
|
const { instruction, palette, colourIndex } = input;
|
|
2975
|
-
const seedHex =
|
|
2976
|
-
if (seedHex ===
|
|
3015
|
+
const seedHex = resolveConcreteColorHex(instruction.seedToken, palette);
|
|
3016
|
+
if (seedHex === null) return [];
|
|
2977
3017
|
const family = String(instruction.seedToken).match(/^(.*?)(?:-\d{2,3})?$/)?.[1] ?? String(instruction.seedToken);
|
|
2978
3018
|
const step = new RegExp(`^${escapeRegExp(family)}-\\d{2,3}$`);
|
|
2979
3019
|
const ground = input.surface?.backgroundHex ?? palette.background;
|
|
@@ -3000,7 +3040,7 @@ function describeShade(token, hex, seed, input) {
|
|
|
3000
3040
|
token,
|
|
3001
3041
|
hex,
|
|
3002
3042
|
direction,
|
|
3003
|
-
labelInk:
|
|
3043
|
+
labelInk: resolveConcreteColorHex(solidForegroundToken(token), palette) ?? void 0,
|
|
3004
3044
|
distance: hexOklabDistance(seed.hex, hex),
|
|
3005
3045
|
stronger: seed.ground === void 0 ? direction === instruction.fallbackDirection : seed.ground.contrast(hex) >= seed.ground.restContrast,
|
|
3006
3046
|
keepsHue: keepsHue(oklab(hex), seed.chroma),
|
|
@@ -3279,8 +3319,8 @@ function resolveSolidButtonColour(input, backgroundToken, preferredForeground) {
|
|
|
3279
3319
|
/** A solid rest fill with the label ink resolveSolidInk gives it, so a contextual hover compares against the ink visitors see. */
|
|
3280
3320
|
function restingFill(input, treatment) {
|
|
3281
3321
|
if (treatment.type !== "solid") return { kind: "not-solid" };
|
|
3282
|
-
const hex = input.palette
|
|
3283
|
-
if (hex ===
|
|
3322
|
+
const hex = resolveConcreteColorHex(treatment.colorToken, input.palette);
|
|
3323
|
+
if (hex === null) return { kind: "not-solid" };
|
|
3284
3324
|
const ink = resolveSolidInk(input, treatment.colorToken, hex, treatment.foregroundToken);
|
|
3285
3325
|
return {
|
|
3286
3326
|
kind: "solid",
|
|
@@ -3297,7 +3337,7 @@ function resolveSolidInk(input, backgroundToken, backgroundHex, preferredForegro
|
|
|
3297
3337
|
return checkedSolidInk(input, backgroundToken, backgroundHex, unsafeAsOpaqueButtonColourToken(solidForegroundToken(backgroundToken))) ?? paletteSolidInk(input, backgroundToken, backgroundHex);
|
|
3298
3338
|
}
|
|
3299
3339
|
function checkedSolidInk(input, backgroundToken, backgroundHex, foregroundToken) {
|
|
3300
|
-
const candidate = input.palette
|
|
3340
|
+
const candidate = resolveConcreteColorHex(foregroundToken, input.palette);
|
|
3301
3341
|
if ((typeof candidate === "string" ? validateButtonTextContrast({
|
|
3302
3342
|
...input,
|
|
3303
3343
|
background: backgroundToken,
|
|
@@ -3381,7 +3421,7 @@ function resolveGradient(input, treatment) {
|
|
|
3381
3421
|
};
|
|
3382
3422
|
}
|
|
3383
3423
|
function paletteHex(input, token) {
|
|
3384
|
-
const hex = input.palette
|
|
3424
|
+
const hex = resolveConcreteColorHex(token, input.palette);
|
|
3385
3425
|
return typeof hex === "string" ? {
|
|
3386
3426
|
ok: true,
|
|
3387
3427
|
hex
|
|
@@ -3769,8 +3809,7 @@ function resolveKnownColour(value, palette) {
|
|
|
3769
3809
|
const reference = parseThemeColorReference(value, { palette });
|
|
3770
3810
|
if (reference.kind !== "literal-css") {
|
|
3771
3811
|
const token = String(reference.token);
|
|
3772
|
-
const
|
|
3773
|
-
const hex = paletteHex ? normalizeOpaqueHex(paletteHex) : null;
|
|
3812
|
+
const hex = resolveConcreteColorHex(token, palette);
|
|
3774
3813
|
if (hex) return {
|
|
3775
3814
|
hex,
|
|
3776
3815
|
css: resolveThemeColorReferenceValue(value, { palette }),
|
|
@@ -3958,8 +3997,8 @@ const surfaceRecipes = {
|
|
|
3958
3997
|
}
|
|
3959
3998
|
};
|
|
3960
3999
|
const missingBackgroundTokens = {
|
|
3961
|
-
background: "
|
|
3962
|
-
foreground: "
|
|
4000
|
+
background: "absoluteWhite",
|
|
4001
|
+
foreground: "absoluteBlack"
|
|
3963
4002
|
};
|
|
3964
4003
|
function toAccessibleColorSurfaceIntent(surface) {
|
|
3965
4004
|
switch (surface) {
|
|
@@ -4178,8 +4217,7 @@ function expandForegroundCandidate(candidate, backgroundToken) {
|
|
|
4178
4217
|
}
|
|
4179
4218
|
}
|
|
4180
4219
|
function readPaletteHex(palette, token) {
|
|
4181
|
-
|
|
4182
|
-
return typeof value === "string" && value.trim().length > 0 ? value : null;
|
|
4220
|
+
return resolveConcreteColorHex(token, palette);
|
|
4183
4221
|
}
|
|
4184
4222
|
function asAccessibleSurfaceToken(token) {
|
|
4185
4223
|
if (token.length === 0) throw new Error("AccessibleSurfaceToken must be non-empty.");
|
|
@@ -4189,11 +4227,11 @@ function surfaceResolutionFailureReason(rejectedCandidates) {
|
|
|
4189
4227
|
return rejectedCandidates.some((candidate) => candidate.kind === "foreground-candidate") ? "no-safe-foreground-candidate" : "no-background-candidate";
|
|
4190
4228
|
}
|
|
4191
4229
|
function missingBackgroundSurface(input) {
|
|
4192
|
-
const contrast = contrastRatio(missingBackgroundTokens.foreground, missingBackgroundTokens.background);
|
|
4230
|
+
const contrast = contrastRatio(absoluteInkColors[missingBackgroundTokens.foreground], absoluteInkColors[missingBackgroundTokens.background]);
|
|
4193
4231
|
const foreground = {
|
|
4194
4232
|
kind: "safe-token",
|
|
4195
4233
|
token: asAccessibleSurfaceToken(missingBackgroundTokens.foreground),
|
|
4196
|
-
hex: missingBackgroundTokens.foreground,
|
|
4234
|
+
hex: absoluteInkColors[missingBackgroundTokens.foreground],
|
|
4197
4235
|
contrastRatio: contrast
|
|
4198
4236
|
};
|
|
4199
4237
|
return {
|
|
@@ -4201,7 +4239,7 @@ function missingBackgroundSurface(input) {
|
|
|
4201
4239
|
surface: input.surface,
|
|
4202
4240
|
background: {
|
|
4203
4241
|
token: asAccessibleSurfaceToken(missingBackgroundTokens.background),
|
|
4204
|
-
hex: missingBackgroundTokens.background,
|
|
4242
|
+
hex: absoluteInkColors[missingBackgroundTokens.background],
|
|
4205
4243
|
inherited: false
|
|
4206
4244
|
},
|
|
4207
4245
|
heading: {
|
|
@@ -4304,6 +4342,7 @@ function prepareSurfaceIndex(specs, context) {
|
|
|
4304
4342
|
colourIndex: context.colourIndex,
|
|
4305
4343
|
linkHoverToken: context.linkHoverToken,
|
|
4306
4344
|
foreground: context.foreground,
|
|
4345
|
+
backdropSamples: context.backdropSamples,
|
|
4307
4346
|
compositeBase: context.compositeBase,
|
|
4308
4347
|
buttonContext: context.buttonContext,
|
|
4309
4348
|
solvedInks: context.solvedInks
|
|
@@ -4356,6 +4395,7 @@ function surfaceResolutionKey(spec, context) {
|
|
|
4356
4395
|
declaration,
|
|
4357
4396
|
context.linkHoverToken,
|
|
4358
4397
|
context.foreground,
|
|
4398
|
+
context.backdropSamples,
|
|
4359
4399
|
context.compositeBase,
|
|
4360
4400
|
context.buttonContext,
|
|
4361
4401
|
context.solvedInks
|
|
@@ -4512,7 +4552,7 @@ function withCertifiedButtons(decision, context) {
|
|
|
4512
4552
|
}
|
|
4513
4553
|
/** A radial tint's grounds besides its painted end, so its buttons are judged on every sample. */
|
|
4514
4554
|
function tintGroundSamples(decision, context) {
|
|
4515
|
-
if (decision.tintBase === void 0) return void 0;
|
|
4555
|
+
if (decision.tintBase === void 0 && !decision.backdropSamples) return void 0;
|
|
4516
4556
|
const [first, ...rest] = surfaceBackdrops(decision, context).slice(0, -1);
|
|
4517
4557
|
return first === void 0 ? void 0 : [first, ...rest];
|
|
4518
4558
|
}
|
|
@@ -4532,15 +4572,13 @@ function surfaceContrast(roles, backdrop, palette, colourIndex) {
|
|
|
4532
4572
|
}
|
|
4533
4573
|
/** Runtime backgrounds retain authored media, compositing and unknown foregrounds. */
|
|
4534
4574
|
function resolveSectionSurface(background, context) {
|
|
4535
|
-
const foreground =
|
|
4536
|
-
linkHover: context.linkHoverToken,
|
|
4537
|
-
...context.foreground
|
|
4538
|
-
}, { compositeBase: context.compositeBase });
|
|
4575
|
+
const foreground = sectionSurfaceForeground(background, context);
|
|
4539
4576
|
const surface = background === null ? { kind: "inherit" } : background.type === "color" ? {
|
|
4540
4577
|
kind: "solid",
|
|
4541
4578
|
color: background.color,
|
|
4542
4579
|
composited: false,
|
|
4543
|
-
foreground: foreground.kind === "known" ? foreground.roles.link : void 0
|
|
4580
|
+
foreground: foreground.kind === "known" ? foreground.roles.link : void 0,
|
|
4581
|
+
backgroundSamples: nonemptySamples(context.backdropSamples)
|
|
4544
4582
|
} : background.type === "gradient" ? { kind: "gradient" } : { kind: "image" };
|
|
4545
4583
|
const revision = ownSurfaceRevision(context);
|
|
4546
4584
|
const buttonContext = resolveSurfaceButtonContext({
|
|
@@ -4577,7 +4615,14 @@ function surfaceDecorationColors(foreground, palette) {
|
|
|
4577
4615
|
if (foreground.kind !== "known" || foreground.provenance.kind !== "measured") return void 0;
|
|
4578
4616
|
const text = resolveConcreteColorHex(foreground.roles.text, palette);
|
|
4579
4617
|
if (text === null) return void 0;
|
|
4580
|
-
|
|
4618
|
+
const decorations = deriveSurfaceDecorationColors(foreground.provenance.backdropHex, text, palette.markSource ?? palette.accent ?? text);
|
|
4619
|
+
if (!foreground.provenance.backdropSamples) return decorations;
|
|
4620
|
+
const samples = foreground.provenance.backdropSamples;
|
|
4621
|
+
const line = deriveSurfaceLineColor(samples[samples.length - 1] ?? foreground.provenance.backdropHex, text, samples);
|
|
4622
|
+
return {
|
|
4623
|
+
...decorations,
|
|
4624
|
+
line
|
|
4625
|
+
};
|
|
4581
4626
|
}
|
|
4582
4627
|
/** Composite the declared palette tint before checking every foreground role. */
|
|
4583
4628
|
function resolveTintSurface(spec, context) {
|
|
@@ -4585,12 +4630,8 @@ function resolveTintSurface(spec, context) {
|
|
|
4585
4630
|
kind: "token",
|
|
4586
4631
|
token: spec.base
|
|
4587
4632
|
}, context);
|
|
4588
|
-
const
|
|
4589
|
-
|
|
4590
|
-
const hex = source ? resolveConcreteColorHex(source, context.palette) : null;
|
|
4591
|
-
const tinted = token ?? (hex ? resolveOpaqueSurfaceHex(hexToRgba(hex, spec.opacity / 100), context.palette, spec.base) : null);
|
|
4592
|
-
if (!tinted) throw new Error(`Cannot derive tint on ${spec.base}`);
|
|
4593
|
-
const solid = resolveDeclaredSolidSurface({
|
|
4633
|
+
const { hex, tinted } = tintColour(spec, tintSource(spec.source, base, context.palette), context);
|
|
4634
|
+
if (spec.gradient !== "radial" && !context.backdropSamples) return resolveDeclaredSolidSurface({
|
|
4594
4635
|
kind: "solid",
|
|
4595
4636
|
token: tinted
|
|
4596
4637
|
}, {
|
|
@@ -4598,11 +4639,64 @@ function resolveTintSurface(spec, context) {
|
|
|
4598
4639
|
buttonContext: surfaceButtonRequest(spec, context),
|
|
4599
4640
|
foreground: base.foreground
|
|
4600
4641
|
});
|
|
4601
|
-
|
|
4642
|
+
const solid = {
|
|
4643
|
+
kind: "owned",
|
|
4644
|
+
paint: {
|
|
4645
|
+
kind: "solid",
|
|
4646
|
+
token: tinted
|
|
4647
|
+
},
|
|
4648
|
+
foreground: base.foreground,
|
|
4649
|
+
decorations: tintDecorations(spec, base, tinted, context),
|
|
4650
|
+
inks: base.inks,
|
|
4651
|
+
hoverDecoration: base.hoverDecoration,
|
|
4652
|
+
contrast: surfaceContrast(base.foreground, tinted, context.palette, context.colourIndex),
|
|
4653
|
+
primaryButton: surfaceButtonRequest(spec, context)
|
|
4654
|
+
};
|
|
4655
|
+
const samples = context.backdropSamples ? tintSamples(spec, hex, tinted, context.backdropSamples) : void 0;
|
|
4656
|
+
const sampled = samples ? {
|
|
4602
4657
|
...solid,
|
|
4603
|
-
|
|
4604
|
-
tintBase: spec.base
|
|
4658
|
+
backdropSamples: samples
|
|
4605
4659
|
} : solid;
|
|
4660
|
+
return {
|
|
4661
|
+
kind: "tint",
|
|
4662
|
+
painted: spec.gradient === "radial" ? {
|
|
4663
|
+
...sampled,
|
|
4664
|
+
inks: { kind: "reset" },
|
|
4665
|
+
tintBase: spec.base
|
|
4666
|
+
} : sampled,
|
|
4667
|
+
original: base
|
|
4668
|
+
};
|
|
4669
|
+
}
|
|
4670
|
+
/**
|
|
4671
|
+
* Decoration colours (mark, line) are chosen against the paint they sit on. A radial glow fades from
|
|
4672
|
+
* the tint back to its base, so its decorations must clear both ends; a mark that does keeps the glow.
|
|
4673
|
+
*/
|
|
4674
|
+
function tintDecorations(spec, base, tinted, context) {
|
|
4675
|
+
const { palette } = context;
|
|
4676
|
+
const tintHex = resolveOpaqueSurfaceHex(tinted, palette, context.compositeBase);
|
|
4677
|
+
const baseHex = resolveOpaqueSurfaceHex(base.paint.token, palette, context.compositeBase);
|
|
4678
|
+
const text = resolveConcreteColorHex(base.foreground.text, palette);
|
|
4679
|
+
if (tintHex === null || baseHex === null || text === null || !base.decorations) return base.decorations;
|
|
4680
|
+
const backdrops = spec.gradient === "radial" ? [tintHex, baseHex] : [tintHex];
|
|
4681
|
+
return deriveSurfaceDecorationColors(tintHex, text, palette.markSource ?? palette.accent ?? text, backdrops);
|
|
4682
|
+
}
|
|
4683
|
+
/** The tint's opaque paint, and its source as a concrete hex when it has one. */
|
|
4684
|
+
function tintColour(spec, source, context) {
|
|
4685
|
+
const token = source ? resolveOpaqueSurfaceHex(`${source}/${spec.opacity}`, context.palette, spec.base) : null;
|
|
4686
|
+
const hex = source ? resolveConcreteColorHex(source, context.palette) : null;
|
|
4687
|
+
const tinted = token ?? (hex ? resolveOpaqueSurfaceHex(hexToRgba(hex, spec.opacity / 100), context.palette, spec.base) : null);
|
|
4688
|
+
if (!tinted) throw new Error(`Cannot derive tint on ${spec.base}`);
|
|
4689
|
+
return {
|
|
4690
|
+
hex,
|
|
4691
|
+
tinted
|
|
4692
|
+
};
|
|
4693
|
+
}
|
|
4694
|
+
/** Every colour a tint shows over each backdrop: its end, or each step of a radial. */
|
|
4695
|
+
function tintSamples(spec, hex, tinted, backdrops) {
|
|
4696
|
+
return backdrops.flatMap((backdrop) => {
|
|
4697
|
+
const end = hex ? compositeHex(hex, spec.opacity / 100, backdrop) : tinted;
|
|
4698
|
+
return spec.gradient === "radial" ? TINT_SAMPLE_ALPHAS.map((alpha) => compositeHex(end, alpha, backdrop)) : [end];
|
|
4699
|
+
});
|
|
4606
4700
|
}
|
|
4607
4701
|
/**
|
|
4608
4702
|
* The button colour a surface asks for, which it also hands to what is painted on it. An explicit request
|
|
@@ -4625,7 +4719,7 @@ function tintSource(source, base, palette) {
|
|
|
4625
4719
|
case "mark": return base.decorations?.mark;
|
|
4626
4720
|
case "shade": {
|
|
4627
4721
|
const background = resolveOpaqueSurfaceHex("background", palette, "background");
|
|
4628
|
-
return background && featuresFromHex(background).Y < .5 ? "
|
|
4722
|
+
return background && featuresFromHex(background).Y < .5 ? "absoluteWhite" : "absoluteBlack";
|
|
4629
4723
|
}
|
|
4630
4724
|
}
|
|
4631
4725
|
}
|
|
@@ -4693,6 +4787,7 @@ const surfaceTransportSchema = z.object({ $surface: z.object({
|
|
|
4693
4787
|
buttonSystem: buttonSystemSchema.optional(),
|
|
4694
4788
|
foreground: foregroundInputSchema.optional(),
|
|
4695
4789
|
linkHoverToken: z.string().optional(),
|
|
4790
|
+
backdropSamples: z.array(z.string()).optional(),
|
|
4696
4791
|
compositeBase: z.string().optional(),
|
|
4697
4792
|
buttonContext: buttonInputSchema.optional(),
|
|
4698
4793
|
solvedInks: solvedInksSchema.optional()
|
|
@@ -4727,6 +4822,7 @@ function certifySurface(spec, context) {
|
|
|
4727
4822
|
...ownedThemeSnapshot({
|
|
4728
4823
|
foreground: context.foreground,
|
|
4729
4824
|
linkHoverToken: context.linkHoverToken,
|
|
4825
|
+
backdropSamples: context.backdropSamples,
|
|
4730
4826
|
compositeBase: context.compositeBase,
|
|
4731
4827
|
buttonContext: context.buttonContext,
|
|
4732
4828
|
solvedInks: context.solvedInks
|
|
@@ -4763,59 +4859,97 @@ const TINT_SAMPLE_ALPHAS = [
|
|
|
4763
4859
|
];
|
|
4764
4860
|
/**
|
|
4765
4861
|
* The certificate asserts every threshold it measures, on every backdrop the
|
|
4766
|
-
* paint shows
|
|
4767
|
-
*
|
|
4768
|
-
*
|
|
4769
|
-
* certified inks, so they never keep a link ink the certificate replaced, and
|
|
4862
|
+
* paint shows. A sampled tint keeps its original declared inks and mark or
|
|
4863
|
+
* returns to its original ground. Solid paints retain black/white fallback.
|
|
4864
|
+
* Buttons are derived from the certified inks, so they never keep a link ink the certificate replaced, and
|
|
4770
4865
|
* the button resolver judges them on every sample of a radial tint.
|
|
4771
4866
|
*/
|
|
4772
4867
|
function certifyThresholds(decision, context) {
|
|
4868
|
+
if (decision.kind === "tint") return certifyTintPaint(decision, context);
|
|
4773
4869
|
if (!isSolidInkDecision(decision)) return decision;
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
|
|
4779
|
-
|
|
4870
|
+
return withCertifiedButtons(withFallbackInks(decision, context) ?? decision, context);
|
|
4871
|
+
}
|
|
4872
|
+
/** One drop-or-keep decision, before any declared ink or mark can be replaced. */
|
|
4873
|
+
function certifyTintPaint(decision, context) {
|
|
4874
|
+
const certified = withFallbackInks(decision.painted, context);
|
|
4875
|
+
if (certified) return withCertifiedButtons(certified, context);
|
|
4876
|
+
const original = decision.original;
|
|
4877
|
+
return {
|
|
4878
|
+
...original,
|
|
4780
4879
|
contrast: {
|
|
4781
|
-
...
|
|
4782
|
-
fallback: ["radial-tint", ...
|
|
4880
|
+
...original.contrast,
|
|
4881
|
+
fallback: ["radial-tint", ...original.contrast.fallback ?? []]
|
|
4783
4882
|
}
|
|
4784
|
-
}
|
|
4883
|
+
};
|
|
4785
4884
|
}
|
|
4786
4885
|
/** Every backdrop a solid paint shows: its colour, or each sample from a radial tint's base to its paint. */
|
|
4787
4886
|
function surfaceBackdrops(decision, context) {
|
|
4887
|
+
if (decision.backdropSamples) return decision.backdropSamples;
|
|
4788
4888
|
const paint = resolveOpaqueSurfaceHex(decision.paint.token, context.palette, decision.tintBase ?? context.compositeBase);
|
|
4789
4889
|
if (!paint) return [];
|
|
4790
4890
|
const underlay = decision.tintBase ? resolveOpaqueSurfaceHex(decision.tintBase, context.palette, "background") : null;
|
|
4791
4891
|
return underlay ? TINT_SAMPLE_ALPHAS.map((alpha) => compositeHex(paint, alpha, underlay)) : [paint];
|
|
4792
4892
|
}
|
|
4793
|
-
/**
|
|
4893
|
+
/** A sampled finish may re-solve derived inks, but never replace a declared role or mark. */
|
|
4794
4894
|
function withFallbackInks(decision, context) {
|
|
4795
4895
|
const backdrops = surfaceBackdrops(decision, context);
|
|
4796
|
-
|
|
4797
|
-
|
|
4896
|
+
if (backdrops.length === 0) return decision;
|
|
4897
|
+
const derived = sampledPaint(decision) ? sampledPaintDetails(decision, backdrops, context) : decision;
|
|
4798
4898
|
const certified = certifySurfaceInks({
|
|
4799
|
-
foreground:
|
|
4800
|
-
mark:
|
|
4899
|
+
foreground: derived.foreground,
|
|
4900
|
+
mark: derived.decorations?.mark
|
|
4801
4901
|
}, backdrops, context);
|
|
4802
|
-
if (!certified) return null;
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4902
|
+
if (!certified || sampledPaint(decision) && requiresDeclaredInkFallback(certified)) return null;
|
|
4903
|
+
return applyPaintInkCertificate(derived, certified, backdrops, context);
|
|
4904
|
+
}
|
|
4905
|
+
function sampledPaint(decision) {
|
|
4906
|
+
return decision.tintBase !== void 0 || decision.backdropSamples !== void 0;
|
|
4907
|
+
}
|
|
4908
|
+
/** Muted and hover are derived; text, heading, link, supporting and mark decide drop-or-keep. */
|
|
4909
|
+
function requiresDeclaredInkFallback(certificate) {
|
|
4910
|
+
return certificate.fallback.some((role) => role !== "muted" && role !== "linkHover");
|
|
4911
|
+
}
|
|
4912
|
+
/** Keep the certificate and derived local inks on the exact samples the paint draws. */
|
|
4913
|
+
function applyPaintInkCertificate(decision, certified, backdrops, context) {
|
|
4914
|
+
const samples = nonemptySamples(backdrops);
|
|
4915
|
+
if (!samples || !sampledPaint(decision) && certified.fallback.length === 0) return decision;
|
|
4916
|
+
const endpoint = samples[samples.length - 1] ?? samples[0];
|
|
4917
|
+
const decorations = decision.decorations;
|
|
4918
|
+
const inks = decision.inks.kind === "solved" ? {
|
|
4919
|
+
kind: "solved",
|
|
4920
|
+
inks: solveSurfaceInks(samples, certified.foreground.text, context.palette)
|
|
4921
|
+
} : decision.inks;
|
|
4809
4922
|
return {
|
|
4810
4923
|
...decision,
|
|
4924
|
+
inks,
|
|
4811
4925
|
foreground: certified.foreground,
|
|
4812
4926
|
decorations,
|
|
4813
4927
|
contrast: {
|
|
4814
|
-
...
|
|
4928
|
+
...surfaceContrast(certified.foreground, endpoint, context.palette, context.colourIndex),
|
|
4815
4929
|
fallback: certified.fallback
|
|
4816
4930
|
}
|
|
4817
4931
|
};
|
|
4818
4932
|
}
|
|
4933
|
+
function sampledPaintDetails(decision, samples, context) {
|
|
4934
|
+
const ground = resolveOpaqueSurfaceHex(decision.paint.token, context.palette, decision.tintBase ?? context.compositeBase);
|
|
4935
|
+
const derived = deriveSurfaceForegroundDetails(decision.foreground, {
|
|
4936
|
+
palette: context.palette,
|
|
4937
|
+
ground: ground ?? void 0,
|
|
4938
|
+
backdrops: samples,
|
|
4939
|
+
hoverCandidate: context.foreground?.linkHover ?? context.linkHoverToken ?? decision.foreground.linkHover
|
|
4940
|
+
});
|
|
4941
|
+
const text = resolveConcreteColorHex(decision.foreground.text, context.palette);
|
|
4942
|
+
const decorations = decision.decorations && ground && text ? {
|
|
4943
|
+
...decision.decorations,
|
|
4944
|
+
line: deriveSurfaceLineColor(ground, text, samples)
|
|
4945
|
+
} : decision.decorations;
|
|
4946
|
+
return {
|
|
4947
|
+
...decision,
|
|
4948
|
+
foreground: derived.roles,
|
|
4949
|
+
hoverDecoration: derived.hoverDecoration,
|
|
4950
|
+
decorations
|
|
4951
|
+
};
|
|
4952
|
+
}
|
|
4819
4953
|
function surfaceProof(decision, spec) {
|
|
4820
4954
|
if (decision.kind === "inherit") return {
|
|
4821
4955
|
...decision,
|
|
@@ -4903,6 +5037,7 @@ const surfaceReferenceSchema = z.object({ $surface: z.object({
|
|
|
4903
5037
|
context: z.object({
|
|
4904
5038
|
foreground: foregroundInputSchema.optional(),
|
|
4905
5039
|
linkHoverToken: z.string().optional(),
|
|
5040
|
+
backdropSamples: z.array(z.string()).optional(),
|
|
4906
5041
|
compositeBase: z.string().optional(),
|
|
4907
5042
|
buttonContext: buttonInputSchema.optional(),
|
|
4908
5043
|
solvedInks: solvedInksSchema.optional()
|
|
@@ -4962,5 +5097,60 @@ function mapSurfaceTreeChildren(value, map) {
|
|
|
4962
5097
|
if (value instanceof Date) return value;
|
|
4963
5098
|
return isSurfaceTreeRecord(value) ? Object.fromEntries(Object.entries(value).map(([key, item]) => [key, map(item)])) : value;
|
|
4964
5099
|
}
|
|
5100
|
+
/** Section grounds and slot tints share the same all-samples ink certificate. */
|
|
5101
|
+
function certifyFinishedGround(finish, foreground, context) {
|
|
5102
|
+
const certified = certifySampledForeground(foreground, finish.samples, context);
|
|
5103
|
+
return certified ? {
|
|
5104
|
+
kind: "certified",
|
|
5105
|
+
finish,
|
|
5106
|
+
foreground: certified
|
|
5107
|
+
} : {
|
|
5108
|
+
kind: "dropped",
|
|
5109
|
+
reason: "unreadable-finish"
|
|
5110
|
+
};
|
|
5111
|
+
}
|
|
5112
|
+
function nonemptySamples(samples) {
|
|
5113
|
+
const [first, ...rest] = samples ?? [];
|
|
5114
|
+
return first === void 0 ? void 0 : [first, ...rest];
|
|
5115
|
+
}
|
|
5116
|
+
/** Certify section inks against the finish rather than just its base colour. */
|
|
5117
|
+
function sectionSurfaceForeground(background, context) {
|
|
5118
|
+
if (background === null) return { kind: "inherits" };
|
|
5119
|
+
const foreground = resolveSurfaceForeground(background, context.palette, {
|
|
5120
|
+
linkHover: context.linkHoverToken,
|
|
5121
|
+
...context.foreground
|
|
5122
|
+
}, { compositeBase: context.compositeBase });
|
|
5123
|
+
if (foreground.kind !== "known" || !context.backdropSamples) return foreground;
|
|
5124
|
+
return certifySampledForeground(foreground, context.backdropSamples, context) ?? foreground;
|
|
5125
|
+
}
|
|
5126
|
+
/** Foreground roles and published local inks must agree on the full sampled backing. */
|
|
5127
|
+
function certifySampledForeground(foreground, backdrops, context) {
|
|
5128
|
+
if (foreground.kind !== "known" || foreground.provenance.kind !== "measured") return null;
|
|
5129
|
+
const samples = nonemptySamples(backdrops);
|
|
5130
|
+
if (!samples) return null;
|
|
5131
|
+
const decorations = surfaceDecorationColors(foreground, context.palette);
|
|
5132
|
+
const derived = deriveSurfaceForegroundDetails(foreground.roles, {
|
|
5133
|
+
palette: context.palette,
|
|
5134
|
+
ground: samples[samples.length - 1],
|
|
5135
|
+
backdrops: samples,
|
|
5136
|
+
hoverCandidate: foreground.roles.linkHover
|
|
5137
|
+
});
|
|
5138
|
+
const certified = certifySurfaceInks({
|
|
5139
|
+
foreground: derived.roles,
|
|
5140
|
+
mark: decorations?.mark
|
|
5141
|
+
}, samples, context);
|
|
5142
|
+
if (!certified || requiresDeclaredInkFallback(certified)) return null;
|
|
5143
|
+
return {
|
|
5144
|
+
...foreground,
|
|
5145
|
+
hoverDecoration: derived.hoverDecoration,
|
|
5146
|
+
roles: certified.foreground,
|
|
5147
|
+
provenance: {
|
|
5148
|
+
...foreground.provenance,
|
|
5149
|
+
backdropSamples: samples,
|
|
5150
|
+
inks: solveSurfaceInks(samples, certified.foreground.text, context.palette),
|
|
5151
|
+
fallback: certified.fallback
|
|
5152
|
+
}
|
|
5153
|
+
};
|
|
5154
|
+
}
|
|
4965
5155
|
//#endregion
|
|
4966
|
-
export {
|
|
5156
|
+
export { expandPalette as $, PUBLIC_BUTTON_ROLES as A, paletteValueKey as At, cssVarValue as B, featuresFromHex as Bt, materializeRuntimeButtonAppearance as C, resolveOpaqueSurfaceHex as Ct, ELEVATION_OFFSET as D, paletteInkToken as Dt, DEFAULT_BUTTON_SIZES as E, paletteInkRoles as Et, resolveOnColorForThemeToken as F, hexLuminance as Ft, callsCssLoadingFunction as G, oklchToHexGamut as Gt, rgbColorValue as H, linearToSrgb as Ht, resolveThemeColorReferenceValue as I, luminanceInterval as It, safeTokenOr as J, staysInsideDeclaration as K, rgbToHex as Kt, resolveTokenOrCssColorValue as L, preparePaletteColourIndex as Lt, mapButtonRoleAppearances as M, requirePaletteColorsFromEntries as Mt, mapButtonVisualAppearances as N, ORDINARY_TEXT_MIN_CONTRAST_RATIO as Nt, FONT_SIZE_MAP as O, _classPrivateFieldGet2 as Ot, isCssColorLiteral as P, contrastRatio as Pt, SURFACE_SECONDARY_TEXT_TINT_ALPHA as Q, backgroundColorStyle as R, solidPaint as Rt, buttonTypographyDeclarations as S, resolveConcreteColorHex as St, BORDER_WIDTH_MAP as T, paletteInk as Tt, textColorStyle as U, oklabToOklch as Ut, mergeStyles as V, hexToRgb as Vt, textColorValue as W, oklabToSrgb as Wt, CONTROL_EDGE_SEED_TOKEN as X, surfaceInkPublication as Y, solveSurfaceInks as Z, formatButtonColourContractError as _, surfaceInkDeclarations as _t, prepareThemeSurfaceRevision as a, planForegroundHover as at, buttonStateAppearanceDeclarations as b, freezeOwnedThemeValue as bt, serializeSurfaceTree as c, contrastThresholdByPolicy as ct, surfaceTransportContext as d, SURFACE_INK_CSS_VARS as dt, pickBlackOrWhiteTextColor as et, toAccessibleColorSurfaceIntent as f, surfaceForegroundDeclarations as ft, BUTTON_CONTRAST_POLICY as g, surfaceForegroundValueWithOpacity as gt, resolveSolidButtonColour as h, surfaceForegroundValue as ht, prepareSurfaceIndex as i, scrimTone as it, defineButtonStyleRecipe as j, paletteValueKeySchema as jt, generateShadowValue as k, _classPrivateFieldSet2 as kt, surfaceButtonRequest as l, DEFAULT_SURFACE_TEXT_COLOR as lt, compileButtonColourStates as m, surfaceForegroundStyle as mt, parseResolvedSurface as n, gradientScrimSamples as nt, requireResolvedSurface as o, HOVER_TEXT_THRESHOLD as ot, contextualButtonSurfaceResetStyles as p, surfaceForegroundInputFromResolved as pt, resolveSurfaceForeground as q, srgbToOklab as qt, parseSurfaceTree as r, minimumScrimOpacity as rt, resolveSurface as s, certifyPaint as st, certifyFinishedGround as t, compositeHex as tt, surfaceDecorationColors as u, SURFACE_FOREGROUND_CSS_VARS as ut, buttonBorder as v, surfaceInkStyle as vt, paddingDeclarations as w, neutralInk as wt, buttonStateShadow as x, ownedThemeSnapshot as xt, buttonRadius as y, surfaceInkValue as yt, borderColorStyle as z, _classPrivateFieldInitSpec as zt };
|