@riverbankcms/sdk 0.169.1 → 0.171.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/dist/_dts/{BlocksIslandsHydrator-DEhlJEwj.d.ts → BlocksIslandsHydrator-xuFmD41p.d.ts} +1 -1
  3. package/dist/_dts/{Page-BhCfStX1.d.ts → Page-4fzXy8H9.d.ts} +13 -11
  4. package/dist/_dts/{SdkPreviewMode-DSYdsdmJ.d.ts → SdkPreviewMode-BlHgMsc8.d.ts} +4 -3
  5. package/dist/_dts/{client-BZMn4Y99.d.ts → client-BPoU758C.d.ts} +32 -1
  6. package/dist/_dts/{content-types-EMK-E_r9.d.ts → content-types-TnkhoSls.d.ts} +3 -3
  7. package/dist/_dts/{contracts-DjYsGY3B.d.ts → contracts-7wrMA79U.d.ts} +5 -3
  8. package/dist/_dts/{footerPageOutline-BtYUi-m0.d.ts → footerPageOutline-DaOsPQ_Q.d.ts} +6 -6
  9. package/dist/_dts/{generatePageMetadata-D_fNTi5r.d.ts → generatePageMetadata-D9aDEzKK.d.ts} +2 -2
  10. package/dist/_dts/{index-NaRauKDR.d.ts → index-585vn6qb.d.ts} +72 -36
  11. package/dist/_dts/{index-BR0i0c3G.d.ts → index-CZKSUcDs.d.ts} +4 -4
  12. package/dist/_dts/{index-BV-qVnt7.d.ts → index-Cbw0IiY7.d.ts} +2 -2
  13. package/dist/_dts/{index-DgEwZ5WQ.d.ts → index-ChNbrcgD.d.ts} +1 -1
  14. package/dist/_dts/{index-QIbYMeI7.d.ts → index-DDKJfaLY.d.ts} +2 -2
  15. package/dist/_dts/{index-BzguBJzR.d.ts → index-DNCDENic.d.ts} +1 -1
  16. package/dist/_dts/{index-BYYhTQ_b.d.ts → index-W9R3Bnf2.d.ts} +3 -3
  17. package/dist/_dts/{loadContent-BmGH6NKl.d.ts → loadContent-DPyNAJym.d.ts} +7 -7
  18. package/dist/_dts/{request-DssgRQSm.d.ts → request-jXTRN1Y4.d.ts} +45927 -42247
  19. package/dist/_dts/{resolveBlockData-5BqNxwL8.d.ts → resolveBlockData-BbvE-gsZ.d.ts} +5 -5
  20. package/dist/_dts/{resolvePageContent-DIuwuFA7.d.ts → resolvePageContent-BBgih00D.d.ts} +2 -2
  21. package/dist/_dts/{runtime-BY8DQBbT.d.ts → runtime-BEoNgYbd.d.ts} +2 -2
  22. package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
  23. package/dist/_dts/sdk/src/client/types.d.ts +2 -2
  24. package/dist/_dts/sdk/src/client.d.ts +7 -7
  25. package/dist/_dts/sdk/src/config/index.d.ts +6 -6
  26. package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
  27. package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
  28. package/dist/_dts/sdk/src/data/dataLoaderContext.d.ts +2 -2
  29. package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +1 -1
  30. package/dist/_dts/sdk/src/data/types.d.ts +2 -2
  31. package/dist/_dts/sdk/src/index.d.ts +8 -8
  32. package/dist/_dts/sdk/src/manifest/index.d.ts +7 -7
  33. package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
  34. package/dist/_dts/sdk/src/navigation/index.d.ts +2 -2
  35. package/dist/_dts/sdk/src/next/index.d.ts +7 -7
  36. package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
  37. package/dist/_dts/sdk/src/page-converter/index.d.ts +4 -4
  38. package/dist/_dts/sdk/src/portal/client.d.ts +1 -1
  39. package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
  40. package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
  41. package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
  42. package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
  43. package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
  44. package/dist/_dts/sdk/src/rendering/components/pageShared.d.ts +1 -1
  45. package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +1 -1
  46. package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +4 -4
  47. package/dist/_dts/sdk/src/rendering/index.d.ts +6 -6
  48. package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
  49. package/dist/_dts/sdk/src/rendering/server.d.ts +3 -2
  50. package/dist/_dts/sdk/src/rendering/themeAdmission.d.ts +1 -1
  51. package/dist/_dts/sdk/src/routing/index.d.ts +5 -5
  52. package/dist/_dts/sdk/src/server.d.ts +5 -5
  53. package/dist/_dts/sdk/src/spam-protection/index.d.ts +2 -2
  54. package/dist/_dts/sdk/src/theme/index.d.ts +4740 -3
  55. package/dist/_dts/{types-cObpvZGF.d.ts → types-BXuVxDYo.d.ts} +2 -2
  56. package/dist/_dts/{types-DrAWDtqR.d.ts → types-DEAKoDNi.d.ts} +3 -3
  57. package/dist/_dts/{types-Z388-GR1.d.ts → types-kWvBwYK6.d.ts} +7 -7
  58. package/dist/_dts/{validation-hLr8zVrc.d.ts → validation-BAO0_ntM.d.ts} +17 -17
  59. package/dist/client/{BlocksIslandsHydrator-CN2GyuuA.mjs → BlocksIslandsHydrator-DfMsMIej.mjs} +17 -17
  60. package/dist/client/{BookingMailingListNote-Br1VyHkP.mjs → BookingMailingListNote-aaSicywS.mjs} +7 -7
  61. package/dist/client/{StepIndicator-BK0GEDoP.mjs → BookingPanelArrangement-OgftZ9QC.mjs} +16 -4
  62. package/dist/client/{BookingQuestionFields-LLGCWjvU.mjs → BookingQuestionFields-BlaCItmH.mjs} +5 -5
  63. package/dist/client/{CalendarNavigationChevron-DSnSBNeq.mjs → CalendarNavigationChevron-iMWrY6Hz.mjs} +7 -7
  64. package/dist/client/{CheckboxChoice-W_uiRgDK.mjs → CheckboxChoice-B65wFjqx.mjs} +1 -1
  65. package/dist/client/{DemoBookingPortalAccess-Cilv5zdS.mjs → DemoBookingPortalAccess-BCumOTLY.mjs} +7 -7
  66. package/dist/client/{EventCalendar.client-ucgdMS35.mjs → EventCalendar.client-kh7mkYnW.mjs} +9 -9
  67. package/dist/client/{EventCombined.client-BEdfJGpx.mjs → EventCombined.client-DXD5i0Ar.mjs} +8 -8
  68. package/dist/client/{EventEmbeddedCheckoutStep-Cf-HRHtb.mjs → EventEmbeddedCheckoutStep-DKKRCuta.mjs} +1 -1
  69. package/dist/client/{EventItem-OpLehMpT.mjs → EventItem-BnwcoFQN.mjs} +13 -9
  70. package/dist/client/{EventListWeekNavigation-DTsVU6gc.mjs → EventListWeekNavigation-DuG6z02f.mjs} +2 -1
  71. package/dist/client/{EventListing.client-8MFGI9BA.mjs → EventListing.client-18yfHrcr.mjs} +3 -3
  72. package/dist/client/{EventListing.view-BCvRqU86.mjs → EventListing.view-BM7rTVSL.mjs} +42 -397
  73. package/dist/client/{EventRegistrationPayment-CqH3hE-k.mjs → EventRegistrationPayment-D5J3DR0x.mjs} +13 -13
  74. package/dist/client/{LocationMapActions-BFp2uQQQ.mjs → LocationMapActions-QahdLtdE.mjs} +2 -2
  75. package/dist/client/{MapDrawingSvg-DDWfmgpA.mjs → MapDrawingSvg-Dy6UMuIw.mjs} +1 -1
  76. package/dist/client/Page-DH2sm4Cf.mjs +30247 -0
  77. package/dist/client/{ProtectedSubmitButton-C3H26pN9.mjs → ProtectedSubmitButton-AOUzjDK9.mjs} +1 -1
  78. package/dist/client/StepIndicator-CsRlU46Y.mjs +894 -0
  79. package/dist/client/{TabBarFragment-DkVKtK5a.mjs → TabBarFragment-CsAufYwT.mjs} +1 -1
  80. package/dist/client/{ThemedButton-BdnEwA38.mjs → ThemedButton-BMDHwnM6.mjs} +1 -1
  81. package/dist/client/{accessibleSurfaces-_7jkuinl.mjs → accessibleSurfaces-Bbn1-jJ8.mjs} +52 -2
  82. package/dist/client/{accordion-DMItWylU.mjs → accordion-DT4MD3Np.mjs} +1 -1
  83. package/dist/client/{booking-form.client-wd71DG19.mjs → booking-form.client-DdqNQNCa.mjs} +79 -42
  84. package/dist/client/{bookingForm-Cyr2qeS1.mjs → bookingForm-CLN396HU.mjs} +4 -4
  85. package/dist/client/bookings.mjs +6 -6
  86. package/dist/client/boxStyleClassNames-iLF_3KX9.mjs +369 -0
  87. package/dist/client/{carousel-B5-Hzzif.mjs → carousel-DFLomCGm.mjs} +2 -2
  88. package/dist/client/{carousel.client-eSSr1oYA.mjs → carousel.client-YF4mUK5t.mjs} +1 -1
  89. package/dist/client/{cart-B-M5l__W.mjs → cart-BozMM5NK.mjs} +3 -3
  90. package/dist/client/{cart.client-COAP4CEy.mjs → cart.client-CqOOxPbW.mjs} +1 -1
  91. package/dist/client/{checkout-ZHc8GfaG.mjs → checkout-CTWF5nbB.mjs} +3 -3
  92. package/dist/client/{checkout.client-DRralR3e.mjs → checkout.client-CpqxN8e0.mjs} +1 -1
  93. package/dist/client/{checkoutUrls-CY8qywXl.mjs → checkoutUrls-Ccg6yfjq.mjs} +1 -1
  94. package/dist/client/client.mjs +640 -226
  95. package/dist/client/{context-Xhf81Q-c.mjs → context-Dzjv2CpA.mjs} +10 -1
  96. package/dist/client/{creditProducts-CMOmhWm2.mjs → creditProducts-BTRX4edc.mjs} +54 -23
  97. package/dist/client/{cta-CfuyGqXL.mjs → cta-pzQkBLgS.mjs} +2 -2
  98. package/dist/client/{dateFormatting-Bv6kjUW3.mjs → dateFormatting-BfurxGwg.mjs} +1 -1
  99. package/dist/client/{demoPortalMagicLink-DQtwf_s2.mjs → demoPortalMagicLink-D0dcPsRE.mjs} +1 -1
  100. package/dist/client/{display-DDNmyb0z.mjs → display-Cl6mgSJa.mjs} +3186 -81
  101. package/dist/client/{enhanceHeaderSection-D7gRy-pL.mjs → enhanceHeaderSection-CJCl0HJC.mjs} +4 -4
  102. package/dist/client/{event-details.client-DZZaoCUc.mjs → event-details.client-Pn9Kxh3I.mjs} +3 -2
  103. package/dist/client/{event-registration.client-CLBdHUfd.mjs → event-registration.client-BAmBdWXE.mjs} +48 -34
  104. package/dist/client/{eventCalendar-BY3AfYkK.mjs → eventCalendar-C5Bh2L8L.mjs} +4 -4
  105. package/dist/client/{eventCombined-86P2vQCb.mjs → eventCombined-dELKxxIe.mjs} +4 -4
  106. package/dist/client/{eventDetails-DIJYMzVg.mjs → eventDetails-Do9D_fJ_.mjs} +2 -2
  107. package/dist/client/{eventListing-8jS0qGGC.mjs → eventListing-B2HTUWLq.mjs} +4 -4
  108. package/dist/client/{eventRegistration-DyseP_sY.mjs → eventRegistration-ByOJnqGc.mjs} +4 -4
  109. package/dist/client/form-DX70QG-J.mjs +27 -0
  110. package/dist/client/{form.client-D3_RF29v.mjs → form.client-CJoqBrS6.mjs} +5 -5
  111. package/dist/client/{form.parts-DWLf_3PF.mjs → form.parts-DTof9pL3.mjs} +3 -3
  112. package/dist/client/formSnapshot-Cy4abc0T.mjs +73 -0
  113. package/dist/client/{formatDate-BGlhrmhF.mjs → formatDate-Cjouxh4Y.mjs} +1 -1
  114. package/dist/client/gifting/client.mjs +3 -3
  115. package/dist/client/{headerSection-CyNGt23J.mjs → headerSection-CJuPX_1K.mjs} +2 -2
  116. package/dist/client/{newsletter-form.client-IfLup4o0.mjs → newsletter-form.client-CqzNjOft.mjs} +6 -6
  117. package/dist/client/{newsletter-form.parts-DDD-LRyW.mjs → newsletter-form.parts-DjJsFms2.mjs} +2 -2
  118. package/dist/client/{newsletterForm-o5wFBVHv.mjs → newsletterForm-D1MHoPbh.mjs} +5 -26
  119. package/dist/client/{noop-B_f7RqLD.mjs → noop-poI1m2yW.mjs} +69 -2
  120. package/dist/client/portal/client.mjs +294 -48
  121. package/dist/client/{product-detail.client-5hNA8aKU.mjs → product-detail.client-DOQ7El1d.mjs} +1 -1
  122. package/dist/client/{product-list.client-c-777ohj.mjs → product-list.client-CmxOZbzL.mjs} +1 -1
  123. package/dist/client/{productDetail-hXttfQhE.mjs → productDetail-BN3zv5sa.mjs} +3 -3
  124. package/dist/client/{productList-BPsYP_jA.mjs → productList-GN_Id4bF.mjs} +3 -3
  125. package/dist/client/{propsDecoder-Dc8j5i79.mjs → propsDecoder-BdmzM3D5.mjs} +8 -4
  126. package/dist/client/{registry.server-CMrdUGGv.mjs → registry.server-BOyra8CA.mjs} +1032 -925
  127. package/dist/client/rendering/client.mjs +57 -32
  128. package/dist/client/rendering/islandDelivery.flight.mjs +43 -10
  129. package/dist/client/rendering/islands.mjs +1 -1
  130. package/dist/client/rendering.mjs +1956 -191
  131. package/dist/client/{richText-coerce-BTurYEao.mjs → richText-coerce-CtoGLZ_e.mjs} +1 -1
  132. package/dist/client/{routeIslandApiConfig-DFjRKvzM.mjs → routeIslandApiConfig-DnaJ8PQc.mjs} +1 -1
  133. package/dist/client/{runtimeResponse-D2LT--Gj.mjs → runtimeResponse-B1-cyLXt.mjs} +1 -1
  134. package/dist/client/{runtimeResponse-BGU8sMZY.mjs → runtimeResponse-BN8PoIVp.mjs} +1 -1
  135. package/dist/client/{shop-Ds47onRS.mjs → shop-LjBLDBqF.mjs} +3 -3
  136. package/dist/client/{shop-commerce-B3PyRHaN.mjs → shop-commerce-B8aZTdRJ.mjs} +13 -13
  137. package/dist/client/{shop-commerce-store-D9CHihQv.mjs → shop-commerce-store-C1FtHYl7.mjs} +1 -1
  138. package/dist/client/{shop.client-RljK0qPB.mjs → shop.client-D0qZ3KZp.mjs} +13 -13
  139. package/dist/client/{shop.interactive-BH0xDlMF.mjs → shop.interactive-DAKyWK1B.mjs} +89 -19
  140. package/dist/client/{shopShared-BEfD0e4m.mjs → shopShared-CztcSe9i.mjs} +2 -2
  141. package/dist/client/spam-protection.mjs +1 -1
  142. package/dist/client/{timetableModel-BG7Ejxdr.mjs → timetableModel-D1jDTbms.mjs} +11 -11
  143. package/dist/client/{types-5fOsPIpL.mjs → types-B0hJldSt.mjs} +2 -0
  144. package/dist/client/{useAvailableSlots-GP8tnAVW.mjs → useAvailableSlots-ByHedoBi.mjs} +4 -8
  145. package/dist/client/{useDiscountApply-Cq07nTyG.mjs → useDiscountApply-CHGYDxdM.mjs} +2 -2
  146. package/dist/client/{useDiscountCodeUi-CD82QX5i.mjs → useDiscountCodeUi-Dew9UAEy.mjs} +1 -1
  147. package/dist/client/{useEventPagination-spj7sGQP.mjs → useEventPagination-BpC7-ksE.mjs} +7 -7
  148. package/dist/client/{view-oToSpu1N.mjs → view-BxeiAL3c.mjs} +121 -28
  149. package/dist/client/{view-aAP2WbCR.mjs → view-ShYH3WXh.mjs} +3 -3
  150. package/dist/preview-next/before-render.mjs +33 -13
  151. package/dist/preview-next/chrome.css +4 -0
  152. package/dist/preview-next/client/{EventEmbeddedCheckoutStep-8-qtHjpb.mjs → EventEmbeddedCheckoutStep-CKe4cjZ4.mjs} +1 -1
  153. package/dist/preview-next/client/{LocationPickerEnvironment-CwxRbAs2.mjs → LocationPickerEnvironment-lW2aLGWd.mjs} +1 -1
  154. package/dist/preview-next/client/{MapLibreEditMap-CKjYUp_E.mjs → MapLibreEditMap-C9InQJpd.mjs} +2 -2
  155. package/dist/preview-next/client/{ArrangementLookControls-CoWdilcI.mjs → PageSectionToolbar-DsSqwrMS.mjs} +397 -23
  156. package/dist/preview-next/client/{PreviewEditorSidebar-BNCrO6PQ.mjs → PreviewEditorSidebar-BEEWzXnU.mjs} +3266 -3215
  157. package/dist/preview-next/client/{PreviewEditorUI-inVZkLCd.mjs → PreviewEditorUI-C86Out4V.mjs} +6 -39
  158. package/dist/preview-next/client/{PreviewShell-CFQlAHTe.mjs → PreviewShell-CBWYjBvQ.mjs} +50 -41
  159. package/dist/preview-next/client/{SdkPreviewModeRuntime-Dgl7ktO4.mjs → SdkPreviewModeRuntime-o-mVqWLx.mjs} +88 -394
  160. package/dist/preview-next/client/{SiteChromeCustomizeButton-DgDYHwkG.mjs → SiteChromeCustomizeButton-H_ciMNHA.mjs} +1249 -22697
  161. package/dist/preview-next/client/{ThemedButton-BQU45t-E.mjs → ThemedButton-CKYjeU_M.mjs} +2 -0
  162. package/dist/preview-next/client/{lucide-react-DbC1o6_9.mjs → lucide-react-DygTyy7K.mjs} +1 -1
  163. package/dist/preview-next/client/{previewAssistantSlot-DRDu7Ndv.mjs → previewAssistantSlot-CuOcsG_N.mjs} +3481 -2113
  164. package/dist/preview-next/client/{previewChromeSurface-K6Q5uEMC.mjs → previewChromeRoot-DPeV7KaP.mjs} +52 -14
  165. package/dist/preview-next/client/runtime.mjs +3 -3
  166. package/dist/preview-next/client/{sdk-runtime-AGypzhcO.mjs → sdk-runtime-zTTFZ4MM.mjs} +2 -2
  167. package/dist/preview-next/client/{useAutosaveStatus-B2mn_l6c.mjs → useAutosaveStatus-DNA1Q4L1.mjs} +2 -2
  168. package/dist/preview-next/client/{useBlockCustomizeControls-CBXHo6ph.mjs → useOpenBlockForSetup-BdnMlHC6.mjs} +40 -21
  169. package/dist/preview-next/container-responsive.css +3093 -0
  170. package/dist/preview-next/editor-base.css +90 -178
  171. package/dist/preview-next/editor-chrome.css +25 -8
  172. package/dist/preview-next/keepAlive.mjs +1 -1
  173. package/dist/preview-next/middleware.mjs +1 -1
  174. package/dist/preview-next/{route-contract-jc2Bug-h.mjs → route-contract-CtSgU8UZ.mjs} +547 -196
  175. package/dist/server/{Block.shared-BHgQjX16.mjs → Block.shared-ifgaBglp.mjs} +4 -4
  176. package/dist/server/ThemeScopeCore-DGDOH6OU.mjs +1983 -0
  177. package/dist/server/{accessibleSurfaces-D0q5tLSW.mjs → accessibleSurfaces-BuPNCWAK.mjs} +52 -2
  178. package/dist/server/bindings-CiYpie1M.mjs +1802 -0
  179. package/dist/server/{block-kinds-CdI7NvAW.mjs → block-kinds-DkzOr19P.mjs} +2 -0
  180. package/dist/server/{client-C-asG6Cf.mjs → client-ngWuFsmN.mjs} +638 -224
  181. package/dist/server/config-template-validation.mjs +30 -4
  182. package/dist/server/config-validation.mjs +1 -1
  183. package/dist/server/config.mjs +3 -34
  184. package/dist/server/data/resolveBlockData.mjs +1 -1
  185. package/dist/server/index.mjs +3 -3
  186. package/dist/server/loadContent-DeLQeJAZ.mjs +2310 -0
  187. package/dist/server/{loadPage-XgtQR90Z.mjs → loadPage-D4J747FQ.mjs} +2 -2
  188. package/dist/server/manifest.mjs +1 -1
  189. package/dist/server/next.mjs +8 -6
  190. package/dist/server/{opaqueSurface-Yltv_u7r.mjs → opaqueSurface-ukEz1BaM.mjs} +2 -2
  191. package/dist/server/{overrideResolution-Z5pwH-kz.mjs → overrideResolution-DSuVkpqm.mjs} +3 -2
  192. package/dist/server/page-converter.mjs +3 -3
  193. package/dist/server/pageRegions-BaeEF2MU.mjs +30 -0
  194. package/dist/server/{pageRenderPlan-DQAo35og.mjs → pageRenderPlan-DFv3h4Ib.mjs} +309 -289
  195. package/dist/server/{pageRuntimeSupport-g-K-FCHa.mjs → pageRuntimeSupport-yHaRNWMj.mjs} +48 -35
  196. package/dist/server/{pageShared-7mPhqqXX.mjs → pageShared-CAZD0LcY.mjs} +875 -328
  197. package/dist/server/parseThemeForPersistence-Dl7LIBJq.mjs +52 -0
  198. package/dist/server/{prebuild-C0m4KOT9.mjs → prebuild-BKOCND3b.mjs} +1 -1
  199. package/dist/server/prebuild.mjs +1 -1
  200. package/dist/server/{prefetchBlockData-DcLKHfHG.mjs → prefetchBlockData-GIoExi8A.mjs} +4 -3
  201. package/dist/server/{registry-7_0_lUrh.mjs → registry-BogXzcOD.mjs} +4015 -2009
  202. package/dist/server/rendering/components/pageShared.mjs +1 -1
  203. package/dist/server/rendering/helpers/loadPage.mjs +1 -1
  204. package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +1 -1
  205. package/dist/server/rendering/server.mjs +3 -3
  206. package/dist/server/rendering.mjs +7 -7
  207. package/dist/server/{resolveBlockData-q3WnpvyZ.mjs → resolveBlockData-CT4YSBve.mjs} +4 -3
  208. package/dist/server/{resolveButtonColourStates-Cn6j8Ee0.mjs → resolveButtonColourStates-DVISOQD9.mjs} +2 -0
  209. package/dist/server/rich-text-CRcONdyM.mjs +33 -0
  210. package/dist/server/{richTextSchema-DQ2NBP0n.mjs → richTextSchema-QLaQrbII.mjs} +31 -2
  211. package/dist/server/{parseThemeForPersistence-BebSeE17.mjs → schema-C92Q8y0-.mjs} +463 -53
  212. package/dist/server/server.mjs +3 -3
  213. package/dist/server/theme-bridge.mjs +2 -2
  214. package/dist/server/theme.mjs +2 -1
  215. package/dist/server/{three-pass-converter-CQWdnfjV.mjs → three-pass-converter-Bsfdy_ZV.mjs} +11 -8
  216. package/dist/server/{validation-CSMS6XmP.mjs → validation-vSBCWU3w.mjs} +9 -9
  217. package/dist/server/{version-DWeqmTXc.mjs → version-Cw5vFmUY.mjs} +1 -1
  218. package/dist/styles/index.css +521 -59
  219. package/package.json +1 -1
  220. package/dist/client/Page-Bu5TJU3L.mjs +0 -52239
  221. package/dist/client/StepIndicator-CR7_0yu4.mjs +0 -432
  222. package/dist/client/form-RTqunrpz.mjs +0 -85
  223. package/dist/preview-next/client/useOpenBlockForSetup-BpZnBznt.mjs +0 -28
  224. package/dist/server/ThemeScopeCore-Ck0dhZA6.mjs +0 -24236
  225. package/dist/server/bindings-CAbTvrCZ.mjs +0 -257
  226. package/dist/server/headerVariant-8O5MvxIU.mjs +0 -464
  227. package/dist/server/loadContent-DKerbSnI.mjs +0 -578
@@ -1,15 +1,50 @@
1
1
  "use client";
2
+ import { bn as unsafeAsContentEntryId } from "./shop.interactive-DAKyWK1B.mjs";
2
3
  import { a as mediaIdentifierSchema, i as resolveManagedMediaReference, n as renderableMediaAssetSchema, o as parseCanonicalMediaIdentifier, s as parseMediaIdentifier, t as buildRenderableMediaAssetIndex } from "./renderableMediaAssetAdmission-BlfqYLJW.mjs";
3
- import { An as resolveImageSourceSetWithContext$1, Ci as readRuntimeNow, Cn as RichText$2, En as computeMediaTransformStyle, Mn as resolveImageUrlWithContext$1, jn as resolveImageUrl$1, po as sanitizeHref, wi as resolveDateRuntimeContext } from "./display-DDNmyb0z.mjs";
4
- import { $ as persistableMediaSchema, Q as mediaSchema, et as runtimeMediaSchema, tn as toUtcIsoDateTimeString } from "./noop-B_f7RqLD.mjs";
5
- import { A as renderBlock, B as compileManifestContentContract, C as resolveSiteCustomBlocks, D as prefetchBlockDataWithFailures, E as requireSdkTheme, F as resolveRouteHrefForStage, G as isRecord, H as deriveFieldValidationPlan, I as getBlockDefinition, J as readPublishedBlockPlacement, L as siteFooterManifest, M as resolveAuthoredLinkHref, N as isRouteVisibleInStage, P as normalizeRenderStage, R as siteHeaderManifest, S as siteLocationRenderContext, T as MissingSdkThemeError, U as projectRepeaterGridLayout$1, V as admitLayoutGridForPlan, W as projectRepeaterGridLayoutForRendering$1, _ as invalidRenderableBlock, a as solvedInksForThemeRuntime, b as resolveSdkBlockManifest, c as MissingBlockOverrideError, d as buildThemeRuntime, f as parseBlocksTheme, g as collectMediaAssetSidecar, h as buildSiteRenderSupport, i as renderWithSdkThemeRuntime, j as getDefaultComponentRegistry, k as makeDefaultBlockComponent, l as PageRenderer, m as buildRenderablePageOutline, n as planLayoutThemeRuntime, o as ThemeScope, p as applyBindingsToContent, r as renderWithOverrideOnlyRuntime, s as EditorPageRenderer, t as Page, u as toBlocksPageRendererDataContext, v as projectRenderablePageOutline, w as MISSING_SDK_THEME_ERROR_CODE, x as sanitizeSdkRuntimeBlockContent, y as readInvalidBlockAdmission, z as admitTransportedRenderableManifestContent } from "./Page-Bu5TJU3L.mjs";
6
- import { Nt as parseFieldDefinition } from "./registry.server-CMrdUGGv.mjs";
4
+ import { $o as sanitizeHref, An as resolveImageUrl$1, Ca as surfaceResolutionContextFromTheme, Jo as asDesignBlockId, Os as unsafeAsEventCategoryId, Ra as parsePageDesignIntent, Sn as RichText$2, Ti as resolveDateRuntimeContext, Tn as computeMediaTransformStyle, Yo as asLayoutVariantKey, _a as designRuntimeRulesForSiteStyle, fa as buildInitialPolicyPageDesignIntent, ga as componentRuntimeRulesForSiteStyle, jn as resolveImageUrlWithContext$1, kn as resolveImageSourceSetWithContext$1, lo as appearancePresets, qo as asAppearancePresetId, wi as readRuntimeNow, ya as requireCuratedSiteStyle } from "./display-Cl6mgSJa.mjs";
5
+ import { Ct as isRecord$1, J as buildRichTextSchema, Y as createRichTextDoc, et as mediaSchema, in as toUtcIsoDateTimeString, nt as runtimeMediaSchema, tt as persistableMediaSchema, wt as EVENT_PRESET_VALUES } from "./noop-poI1m2yW.mjs";
6
+ import { $ as normalizeRepeaterGridSpan, B as systemBlockDefinitions, C as sanitizeSdkRuntimeBlockContent, D as MissingSdkThemeError, E as MISSING_SDK_THEME_ERROR_CODE, F as isRouteVisibleInStage, G as compileManifestContentContract, H as siteHeaderManifest, I as normalizeRenderStage, J as deriveFieldValidationPlan, K as registeredManifestContentContract, L as resolveRouteHrefForStage, M as renderBlock, N as getDefaultComponentRegistry, O as requireSdkTheme, P as resolveAuthoredLinkHref, Q as flowRepeaterGridItems, R as allOutlineBlocks, S as resolveSdkBlockManifest, T as resolveSiteCustomBlocks, U as blockDesignCapabilityMapFromDefinitions, V as siteFooterManifest, W as admitTransportedRenderableManifestContent, X as projectRepeaterGridLayout$1, Y as fieldPlanToZod, Z as projectRepeaterGridLayoutForRendering$1, _ as buildSiteRenderSupport, a as solvedInksForThemeRuntime, at as applyCompiledRuntimeFieldsToContent, b as projectRenderablePageOutline, c as MissingBlockOverrideError, ct as readPublishedBlockPlacement, d as buildThemeRuntime, et as resolveRepeaterGridAcceptedSpans, f as parseBlocksTheme, g as buildRenderablePageOutline, h as blockDesignInputsForDefinition, i as renderWithSdkThemeRuntime, it as buildPageDesignEditorReadModel, j as makeDefaultBlockComponent, k as prefetchBlockDataWithFailures, l as PageRenderer, m as resolveRuntimeJoinFacts, n as planLayoutThemeRuntime, o as ThemeScope, ot as compileEditorModelRuntime, p as applyBindingsToContent, q as admitLayoutGridForPlan, r as renderWithOverrideOnlyRuntime, rt as parseListLook, s as EditorPageRenderer, t as Page, tt as isRecord$2, u as toBlocksPageRendererDataContext, v as collectMediaAssetSidecar, w as siteLocationRenderContext, x as readInvalidBlockAdmission, y as invalidRenderableBlock$1, z as getBlockDefinition } from "./Page-DH2sm4Cf.mjs";
7
+ import { Cn as resolveRepeaterGridColumnFieldId, Rt as parseFieldDefinition, Tn as resolveRepeaterGridSpanFieldId, wn as resolveRepeaterGridRowFieldId } from "./registry.server-BOyra8CA.mjs";
8
+ import { g as plainTextToInlineText, h as parseInlineTextFromUnknown, m as inlineTextToPlainText } from "./timetableModel-D1jDTbms.mjs";
9
+ import { l as parseBackgroundContent } from "./boxStyleClassNames-iLF_3KX9.mjs";
7
10
  import { o as setContextResolveImageUrlContext, t as buildResolveImageUrlContext } from "./mediaContext-Fusweriw.mjs";
8
11
  import { n as toBlocksImageResolveContextInput, r as toBlocksMediaAssets } from "./mediaAssets-B99AP7ai.mjs";
9
12
  import "react";
10
13
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
14
  import { z } from "zod";
12
15
  import { BlocksIslandsHydrator } from "#sdk-rendering-client";
16
+ //#region ../core/src/rich-text.ts
17
+ function isRecord(value) {
18
+ return typeof value === "object" && value !== null && !Array.isArray(value);
19
+ }
20
+ function hasOnlyKeys(value, allowed) {
21
+ return Object.keys(value).every((key) => allowed.has(key));
22
+ }
23
+ const rootKeys = /* @__PURE__ */ new Set(["type", "content"]);
24
+ const nodeKeys = /* @__PURE__ */ new Set([
25
+ "type",
26
+ "content",
27
+ "text",
28
+ "attrs",
29
+ "marks"
30
+ ]);
31
+ const markKeys = /* @__PURE__ */ new Set(["type", "attrs"]);
32
+ function isDenseArrayOf(value, predicate) {
33
+ for (let index = 0; index < value.length; index += 1) if (!(index in value) || !predicate(value[index])) return false;
34
+ return true;
35
+ }
36
+ function isTipTapMark(value) {
37
+ return isRecord(value) && hasOnlyKeys(value, markKeys) && typeof value.type === "string" && value.type.length > 0 && (value.attrs === void 0 || isRecord(value.attrs));
38
+ }
39
+ function isTipTapNode(value) {
40
+ if (!isRecord(value) || !hasOnlyKeys(value, nodeKeys) || typeof value.type !== "string" || value.type.length === 0 || value.type === "doc" || value.attrs !== void 0 && !isRecord(value.attrs) || value.marks !== void 0 && (!Array.isArray(value.marks) || !isDenseArrayOf(value.marks, isTipTapMark)) || value.content !== void 0 && (!Array.isArray(value.content) || !isDenseArrayOf(value.content, isTipTapNode))) return false;
41
+ if (value.type === "text") return typeof value.text === "string" && value.text.length > 0 && value.content === void 0;
42
+ return value.text === void 0;
43
+ }
44
+ function isCanonicalRichTextDoc(value) {
45
+ return isRecord(value) && hasOnlyKeys(value, rootKeys) && value.type === "doc" && Array.isArray(value.content) && isDenseArrayOf(value.content, isTipTapNode);
46
+ }
47
+ //#endregion
13
48
  //#region ../core/src/navigation-portal-labels.ts
14
49
  /**
15
50
  * What a customer sign-in link in a site's menu says when the site hasn't set
@@ -29,6 +64,77 @@ const footerModeSchema = z.enum([
29
64
  "none"
30
65
  ]);
31
66
  //#endregion
67
+ //#region ../theme-core/src/site-styles/contentTemplateDesignIntent.ts
68
+ function asContentTemplateDesignBlockId(value) {
69
+ return asDesignBlockId(value);
70
+ }
71
+ function parseContentTemplateDesignIntent(value) {
72
+ return parsePageDesignIntent(value, {
73
+ unsupportedSchemaVersionMessage: "Unsupported Theme V2 content template design intent schemaVersion.",
74
+ invalidShapeMessage: "Invalid Theme V2 content template design intent shape."
75
+ });
76
+ }
77
+ function contentTemplateDesignIntentToJsonRecord(intent) {
78
+ return {
79
+ schemaVersion: intent.schemaVersion,
80
+ siteStyleId: intent.siteStyleId,
81
+ pageFlowPresetId: intent.pageFlowPresetId,
82
+ blockLookPins: intent.blockLookPins.map((pin) => ({
83
+ blockId: pin.blockId,
84
+ blockKind: pin.blockKind,
85
+ choice: {
86
+ kind: pin.choice.kind,
87
+ value: pin.choice.value
88
+ }
89
+ })),
90
+ boundaryPins: intent.boundaryPins.map((pin) => ({
91
+ boundaryId: pin.boundaryId,
92
+ previousBlockId: pin.previousBlockId,
93
+ nextBlockId: pin.nextBlockId,
94
+ choice: {
95
+ kind: pin.choice.kind,
96
+ value: pin.choice.value
97
+ }
98
+ }))
99
+ };
100
+ }
101
+ //#endregion
102
+ //#region ../theme-core/src/site-styles/contentTemplateRuntimeCompiler.ts
103
+ function compileContentTemplateRuntimeFields(input) {
104
+ const orderedBlocks = [...input.blocks].sort((a, b) => a.orderIndex - b.orderIndex);
105
+ const editorModel = buildPageDesignEditorReadModel({
106
+ joinResolution: {
107
+ surfaceResolutionContext: input.surfaceResolutionContext,
108
+ resolveFacts: input.resolveJoinFacts,
109
+ contentForBlock: (id) => {
110
+ const block = orderedBlocks.find((block) => block.blockId === id);
111
+ if (!block) throw new Error(`Missing materialized template content for ${id}`);
112
+ return block.content;
113
+ }
114
+ },
115
+ siteStyleId: input.intent.siteStyleId,
116
+ siteStyle: input.siteStyle,
117
+ intent: input.intent,
118
+ blocks: orderedBlocks
119
+ });
120
+ const compiled = compileEditorModelRuntime({
121
+ editorModel,
122
+ surfaceResolutionContext: input.surfaceResolutionContext,
123
+ designRules: designRuntimeRulesForSiteStyle(requireCuratedSiteStyle(input.intent.siteStyleId)),
124
+ componentRules: componentRuntimeRulesForSiteStyle(requireCuratedSiteStyle(input.intent.siteStyleId))
125
+ });
126
+ const blocks = compiled.blocks.map((block) => ({
127
+ blockId: block.blockId,
128
+ fields: block.fields
129
+ }));
130
+ return {
131
+ blocks,
132
+ joins: compiled.joins,
133
+ fieldsByBlockId: new Map(blocks.map((block) => [block.blockId, block.fields])),
134
+ issues: editorModel.issues
135
+ };
136
+ }
137
+ //#endregion
32
138
  //#region ../theme-core/src/footer/mode.ts
33
139
  /** Reads only SDK footer intent; unrelated config and theme fields are not authorities. */
34
140
  function resolveSdkFooterMode(config) {
@@ -1029,7 +1135,7 @@ function defineOwnDataProperty(target, key, value) {
1029
1135
  }
1030
1136
  //#endregion
1031
1137
  //#region src/data/dataLoaderContext.ts
1032
- function assertNever$1(value) {
1138
+ function assertNever$2(value) {
1033
1139
  throw new Error(`Unhandled data loader render target: ${String(value)}`);
1034
1140
  }
1035
1141
  function getDataLoaderOwnerPageId(target) {
@@ -1037,7 +1143,7 @@ function getDataLoaderOwnerPageId(target) {
1037
1143
  case "page": return target.pageId;
1038
1144
  case "entry-template":
1039
1145
  case "page-surface-template": return target.templateId;
1040
- default: return assertNever$1(target);
1146
+ default: return assertNever$2(target);
1041
1147
  }
1042
1148
  }
1043
1149
  function normalizeDataLoaderSearchParams(input) {
@@ -1085,6 +1191,7 @@ const SYSTEM_BLOCK_KINDS = [
1085
1191
  "block.body-text",
1086
1192
  "block.location-map",
1087
1193
  "block.faq",
1194
+ "block.list",
1088
1195
  "block.testimonials",
1089
1196
  "block.team-members",
1090
1197
  "block.embed",
@@ -1096,6 +1203,7 @@ const SYSTEM_BLOCK_KINDS = [
1096
1203
  "block.contact-newsletter",
1097
1204
  "block.appointment-booking",
1098
1205
  "block.appointment-services",
1206
+ "block.service-details",
1099
1207
  "block.weekly-slot-availability",
1100
1208
  "block.event-registration",
1101
1209
  "block.event-details",
@@ -1382,7 +1490,7 @@ function toFailureBase(context, loaderKey) {
1382
1490
  */
1383
1491
  async function executeCodeLoaders(page, context, overrides) {
1384
1492
  const tasks = [];
1385
- for (const block of page.blocks) {
1493
+ for (const block of allOutlineBlocks(page)) {
1386
1494
  const blockId = block.id;
1387
1495
  if (!blockId || !isBlockKind(block.kind)) continue;
1388
1496
  const blockLoaders = overrides[block.kind];
@@ -1460,7 +1568,7 @@ const CONFIG_ONLY_BLOCK_DATA_POLICY = Object.freeze({ kind: "config-only" });
1460
1568
  function warnHostDataLoaderFailure(warning) {
1461
1569
  console.warn("[resolveBlockData] Host data loader failed:", warning);
1462
1570
  }
1463
- function assertNever(value, context) {
1571
+ function assertNever$1(value, context) {
1464
1572
  throw new Error(`Unhandled ${context}: ${String(value)}`);
1465
1573
  }
1466
1574
  function toHostDataLoaderWarning(failure) {
@@ -1483,7 +1591,7 @@ function toHostDataLoaderWarning(failure) {
1483
1591
  failureKind: failure.kind,
1484
1592
  validationIssueKind: failure.validationIssueKind
1485
1593
  };
1486
- default: return assertNever(failure, "host data loader failure");
1594
+ default: return assertNever$1(failure, "host data loader failure");
1487
1595
  }
1488
1596
  }
1489
1597
  const DEFAULT_RESOLVE_BLOCK_DATA_DEPS = {
@@ -1515,7 +1623,7 @@ function configLoaderRoot(renderTarget, bookingTimeZone, now) {
1515
1623
  ...zone,
1516
1624
  subject: renderTarget.subject
1517
1625
  };
1518
- default: return assertNever(renderTarget, "config loader render target");
1626
+ default: return assertNever$1(renderTarget, "config loader render target");
1519
1627
  }
1520
1628
  }
1521
1629
  async function resolveBlockDataWithDeps(deps, input) {
@@ -1673,6 +1781,10 @@ function requirePageRecord(response) {
1673
1781
  if ("pageSurface" in response) throw new Error("This path resolves to a page surface, not a page. Use loadContent() instead, which handles pages, entries, and page surfaces.");
1674
1782
  return response.page;
1675
1783
  }
1784
+ const PAGE_SECTIONS_ANCHOR_BLOCK_KIND = "system.page-sections";
1785
+ function isSystemTemplateBlockKind(value) {
1786
+ return value === "system.entry-slot" || value === "system.page-sections";
1787
+ }
1676
1788
  //#endregion
1677
1789
  //#region ../content-model/src/entry-slots/types.ts
1678
1790
  function ok(value) {
@@ -1705,204 +1817,1867 @@ function selectBlocksForDeclaredEntrySlot(input) {
1705
1817
  return input.entrySlots.find((slot) => slot.slotKey === input.declaredSlotKey)?.blocks ?? [];
1706
1818
  }
1707
1819
  //#endregion
1708
- //#region src/rendering/helpers/templateContent.ts
1709
- function admitMaterializedSdkTemplateBlockContent(input) {
1710
- const baseContent = sanitizeSdkRuntimeBlockContent(input.block.blockKind, input.block.content ?? {});
1711
- const bindings = input.block.bindings ?? {};
1712
- const materialized = input.block.scope === "entry" && Object.keys(bindings).length > 0 ? applyBindingsToContent(baseContent, bindings, input.bindingContext) : baseContent;
1713
- return admitTransportedRenderableManifestContent(compileManifestContentContract(input.manifestOrFields), materialized);
1820
+ //#region ../content-model/src/page-sections/types.ts
1821
+ /**
1822
+ * Page sections (#1703): owner-defined, structured sections on a subject's
1823
+ * pages. A definition says what a section is (its heading, what goes in it)
1824
+ * and where it applies. The values live in each page's own content.
1825
+ */
1826
+ const BODY_SECTION_KINDS = [
1827
+ "list",
1828
+ "headedLists",
1829
+ "questions",
1830
+ "cards",
1831
+ "text",
1832
+ "textWithPhoto"
1833
+ ];
1834
+ function unsafeAsPageSectionId(value) {
1835
+ return value;
1714
1836
  }
1715
- function createTemplateRenderTarget(source, templateId) {
1716
- switch (source.kind) {
1717
- case "entry-template": return {
1718
- kind: source.kind,
1719
- templateId,
1720
- entryId: source.entryId,
1721
- entryType: source.entryType
1722
- };
1723
- case "page-surface-template": return {
1724
- kind: source.kind,
1725
- templateId,
1726
- pageSurfaceId: source.pageSurfaceId,
1727
- routeId: source.routeId,
1728
- subject: source.subject
1729
- };
1730
- }
1837
+ const uuidSchema = z.string().trim().toLowerCase().uuid();
1838
+ const pageSectionIdSchema = uuidSchema.transform(unsafeAsPageSectionId);
1839
+ const FACT_OPTION_MAX = 30;
1840
+ const factTextSchema = z.string().trim().max(120).refine((value) => !/[\r\n\u2028\u2029]/u.test(value), { message: "Use a single line" });
1841
+ const sectionLabelSchema = z.string().trim().min(1).max(120);
1842
+ const sectionHintSchema = z.string().trim().max(500).nullable().transform((hint) => hint === null || hint === "" ? null : hint);
1843
+ const bodySectionKindSchema = z.enum(BODY_SECTION_KINDS);
1844
+ const factSectionShapeSchema = z.discriminatedUnion("kind", [z.object({
1845
+ placement: z.literal("facts"),
1846
+ kind: z.literal("choice"),
1847
+ options: z.array(factTextSchema.pipe(z.string().min(1))).min(1).max(FACT_OPTION_MAX).refine((options) => new Set(options).size === options.length, { message: "Name each option once" })
1848
+ }).strict(), z.object({
1849
+ placement: z.literal("facts"),
1850
+ kind: z.literal("shortText")
1851
+ }).strict()]);
1852
+ const sectionShapeSchema = z.union([z.object({
1853
+ placement: z.literal("body"),
1854
+ kind: bodySectionKindSchema
1855
+ }).strict(), factSectionShapeSchema]);
1856
+ /** The distinct values, in first-seen order, or null when there are none. */
1857
+ function toNonEmptyUnique(values) {
1858
+ const [first, ...rest] = [...new Set(values)];
1859
+ return first === void 0 ? null : [first, ...rest];
1731
1860
  }
1732
- function processEntryTemplate(input) {
1733
- return processTemplatePage({
1734
- ...input,
1735
- slotContent: input.entrySlots,
1736
- bindingContext: {
1737
- dateContext: resolveDateRuntimeContext(input.bookingTimeZone),
1738
- fields: input.entry.content && typeof input.entry.content === "object" ? input.entry.content : {},
1739
- meta: {
1740
- id: input.entry.id,
1741
- title: input.entry.title,
1742
- slug: input.entry.slug,
1743
- path: input.entry.path,
1744
- publishAt: input.entry.publishAt,
1745
- status: input.entry.status,
1746
- createdAt: input.entry.createdAt,
1747
- updatedAt: input.entry.updatedAt
1748
- }
1749
- },
1750
- pageName: "Entry Template",
1751
- pagePath: input.entry.path || "/",
1752
- pagePurpose: "entry-template",
1753
- renderTargetSource: {
1754
- kind: "entry-template",
1755
- entryId: input.entry.id,
1756
- entryType: input.entry.type
1861
+ function nonEmptyUnique(item) {
1862
+ return z.array(item).transform((values, ctx) => {
1863
+ const unique = toNonEmptyUnique(values);
1864
+ if (unique) return unique;
1865
+ ctx.addIssue({
1866
+ code: "custom",
1867
+ message: "Name at least one, or use \"all\""
1868
+ });
1869
+ return z.NEVER;
1870
+ });
1871
+ }
1872
+ const eventCategoryIdSchema = uuidSchema.transform(unsafeAsEventCategoryId);
1873
+ const applicabilitySchema = z.discriminatedUnion("subject", [z.object({ subject: z.literal("service") }).strict(), z.object({
1874
+ subject: z.literal("event"),
1875
+ presets: z.union([z.literal("all"), nonEmptyUnique(z.enum(EVENT_PRESET_VALUES))]),
1876
+ categories: z.union([z.literal("all"), nonEmptyUnique(eventCategoryIdSchema)])
1877
+ }).strict()]);
1878
+ function isActiveSection(definition) {
1879
+ return definition.state.kind === "active";
1880
+ }
1881
+ z.object({
1882
+ id: pageSectionIdSchema,
1883
+ label: sectionLabelSchema,
1884
+ hint: sectionHintSchema,
1885
+ shape: sectionShapeSchema,
1886
+ applicability: applicabilitySchema,
1887
+ position: z.number().int().nonnegative(),
1888
+ state: z.discriminatedUnion("kind", [z.object({ kind: z.literal("active") }).strict(), z.object({
1889
+ kind: z.literal("archived"),
1890
+ archivedAt: z.string()
1891
+ }).strict()])
1892
+ }).strict();
1893
+ //#endregion
1894
+ //#region ../content-model/src/page-sections/values.ts
1895
+ /**
1896
+ * The most a section of each list-like kind can hold: how many items, and how
1897
+ * long each piece of text can be. They're the one source for these limits.
1898
+ * The stored-value schema enforces them when a value is saved, and the Content
1899
+ * tab's fields take them as `maxLength` and `maxItems`.
1900
+ *
1901
+ * A headed list's `maxPoints` counts the points in all its groups together,
1902
+ * the same limit as a List's, so turning Headed lists into a List always
1903
+ * gives a List that can be saved, with every point kept.
1904
+ */
1905
+ const SECTION_VALUE_LIMITS = {
1906
+ list: {
1907
+ maxPoints: 100,
1908
+ maxPointLength: 500
1909
+ },
1910
+ headedLists: {
1911
+ maxGroups: 100,
1912
+ maxPoints: 100,
1913
+ maxHeadingLength: 500,
1914
+ maxPointLength: 500
1915
+ },
1916
+ questions: {
1917
+ maxQuestions: 30,
1918
+ maxQuestionLength: 160,
1919
+ maxAnswerLength: 5e3
1920
+ },
1921
+ cards: {
1922
+ maxCards: 8,
1923
+ maxTitleLength: 120,
1924
+ maxTextLength: 5e3
1925
+ }
1926
+ };
1927
+ const tooMany = (items, count, limit) => count > limit ? {
1928
+ kind: "tooMany",
1929
+ items,
1930
+ count,
1931
+ limit
1932
+ } : null;
1933
+ const tooLong = (text, values, limit) => values.some((value) => value.length > limit) ? {
1934
+ kind: "tooLong",
1935
+ text,
1936
+ limit
1937
+ } : null;
1938
+ /** The first breach in the order given, or null. */
1939
+ const firstBreach = (...breaches) => breaches.find((breach) => breach !== null) ?? null;
1940
+ /**
1941
+ * The first limit a value goes over, or null when it's within all of them.
1942
+ * Counts come before lengths, so the message names the bigger problem first.
1943
+ */
1944
+ function findSectionLimitBreach(value) {
1945
+ switch (value.kind) {
1946
+ case "list": {
1947
+ const limits = SECTION_VALUE_LIMITS.list;
1948
+ return firstBreach(tooMany("points", value.items.length, limits.maxPoints), tooLong("point", value.items, limits.maxPointLength));
1949
+ }
1950
+ case "headedLists": {
1951
+ const limits = SECTION_VALUE_LIMITS.headedLists;
1952
+ const points = value.groups.flatMap((group) => group.items);
1953
+ return firstBreach(tooMany("groups", value.groups.length, limits.maxGroups), tooMany("points", points.length, limits.maxPoints), tooLong("heading", value.groups.map((group) => group.heading), limits.maxHeadingLength), tooLong("point", points, limits.maxPointLength));
1954
+ }
1955
+ case "questions": {
1956
+ const limits = SECTION_VALUE_LIMITS.questions;
1957
+ return firstBreach(tooMany("questions", value.items.length, limits.maxQuestions), tooLong("question", value.items.map((item) => item.question), limits.maxQuestionLength), tooLong("answer", value.items.map((item) => item.answer), limits.maxAnswerLength));
1757
1958
  }
1959
+ case "cards": {
1960
+ const limits = SECTION_VALUE_LIMITS.cards;
1961
+ return firstBreach(tooMany("cards", value.cards.length, limits.maxCards), tooLong("cardTitle", value.cards.map((card) => card.title), limits.maxTitleLength), tooLong("cardText", value.cards.map((card) => card.text), limits.maxTextLength));
1962
+ }
1963
+ case "choice":
1964
+ case "shortText":
1965
+ case "text":
1966
+ case "textWithPhoto": return null;
1967
+ }
1968
+ }
1969
+ const richTextDocSchema = z.custom(isCanonicalRichTextDoc, { message: "Expected a rich text document" });
1970
+ const mediaValueSchema = z.object({ identifier: z.string().trim().min(1) }).passthrough();
1971
+ /** A value that can be stored: the right shape, and within `SECTION_VALUE_LIMITS`. */
1972
+ const sectionValueSchema = z.discriminatedUnion("kind", [
1973
+ z.object({
1974
+ kind: z.literal("choice"),
1975
+ value: factTextSchema
1976
+ }).strict(),
1977
+ z.object({
1978
+ kind: z.literal("shortText"),
1979
+ value: factTextSchema
1980
+ }).strict(),
1981
+ z.object({
1982
+ kind: z.literal("list"),
1983
+ items: z.array(z.string())
1984
+ }).strict(),
1985
+ z.object({
1986
+ kind: z.literal("headedLists"),
1987
+ groups: z.array(z.object({
1988
+ heading: z.string(),
1989
+ items: z.array(z.string())
1990
+ }).strict())
1991
+ }).strict(),
1992
+ z.object({
1993
+ kind: z.literal("questions"),
1994
+ items: z.array(z.object({
1995
+ question: z.string(),
1996
+ answer: z.string()
1997
+ }).strict())
1998
+ }).strict(),
1999
+ z.object({
2000
+ kind: z.literal("cards"),
2001
+ cards: z.array(z.object({
2002
+ title: z.string(),
2003
+ text: z.string()
2004
+ }).strict())
2005
+ }).strict(),
2006
+ z.object({
2007
+ kind: z.literal("text"),
2008
+ body: richTextDocSchema
2009
+ }).strict(),
2010
+ z.object({
2011
+ kind: z.literal("textWithPhoto"),
2012
+ body: richTextDocSchema,
2013
+ photo: z.nullable(mediaValueSchema)
2014
+ }).strict()
2015
+ ]).superRefine((value, ctx) => {
2016
+ const breach = findSectionLimitBreach(value);
2017
+ if (!breach) return;
2018
+ const what = breach.kind === "tooMany" ? breach.items : breach.text;
2019
+ ctx.addIssue({
2020
+ code: "custom",
2021
+ message: `Over the ${what} limit of ${breach.limit}`,
2022
+ params: { breach }
1758
2023
  });
2024
+ });
2025
+ function parseSectionValue(value) {
2026
+ const parsed = z.safeParse(sectionValueSchema, value);
2027
+ return parsed.success ? parsed.data : null;
1759
2028
  }
1760
- async function processTemplatePage(input) {
1761
- const template = input.templates?.[0];
1762
- if (!template?.blocks?.length) return {
1763
- templatePage: null,
1764
- resolvedData: {}
2029
+ function nodeHasVisibleText(node) {
2030
+ if (typeof node.text === "string" && node.text.trim().length > 0) return true;
2031
+ return (node.content ?? []).some(nodeHasVisibleText);
2032
+ }
2033
+ function richTextHasVisibleText(doc) {
2034
+ return doc.content.some(nodeHasVisibleText);
2035
+ }
2036
+ const trimmedItems = (items) => items.map((item) => item.trim()).filter((item) => item.length > 0);
2037
+ /** One normaliser per kind: incomplete items go, and whitespace is trimmed. */
2038
+ const normalisers = {
2039
+ choice: (value) => ({
2040
+ kind: "choice",
2041
+ value: value.value.trim()
2042
+ }),
2043
+ shortText: (value) => ({
2044
+ kind: "shortText",
2045
+ value: value.value.trim()
2046
+ }),
2047
+ list: (value) => ({
2048
+ kind: "list",
2049
+ items: trimmedItems(value.items)
2050
+ }),
2051
+ headedLists: (value) => ({
2052
+ kind: "headedLists",
2053
+ groups: value.groups.map((group) => ({
2054
+ heading: group.heading.trim(),
2055
+ items: trimmedItems(group.items)
2056
+ })).filter((group) => group.items.length > 0)
2057
+ }),
2058
+ questions: (value) => ({
2059
+ kind: "questions",
2060
+ items: value.items.map((item) => ({
2061
+ question: item.question.trim(),
2062
+ answer: item.answer.trim()
2063
+ })).filter((item) => item.question.length > 0 && item.answer.length > 0)
2064
+ }),
2065
+ cards: (value) => ({
2066
+ kind: "cards",
2067
+ cards: value.cards.map((card) => ({
2068
+ title: card.title.trim(),
2069
+ text: card.text.trim()
2070
+ })).filter((card) => card.title.length > 0)
2071
+ }),
2072
+ text: (value) => value,
2073
+ textWithPhoto: (value) => value
2074
+ };
2075
+ function normaliseOf(value) {
2076
+ const normalise = normalisers[value.kind];
2077
+ return normalise(value);
2078
+ }
2079
+ function normaliseSectionValue(value) {
2080
+ return normaliseOf(value);
2081
+ }
2082
+ /** Emptiness is decided only from a normalised value. */
2083
+ function isSectionValueEmpty(value) {
2084
+ switch (value.kind) {
2085
+ case "choice":
2086
+ case "shortText": return value.value.length === 0;
2087
+ case "list": return value.items.length === 0;
2088
+ case "headedLists": return value.groups.length === 0;
2089
+ case "questions": return value.items.length === 0;
2090
+ case "cards": return value.cards.length === 0;
2091
+ case "text":
2092
+ case "textWithPhoto": return !richTextHasVisibleText(value.body);
2093
+ }
2094
+ }
2095
+ /**
2096
+ * Read a stored value as another kind. List/Headed lists and choice/short text
2097
+ * convert within their placements. Choice membership is checked by readFactValue.
2098
+ * Other pairs are incompatible, and the value is treated as
2099
+ * empty but kept.
2100
+ */
2101
+ function convertSectionValue(value, toKind) {
2102
+ if (value.kind === toKind) return {
2103
+ kind: "converted",
2104
+ value
1765
2105
  };
1766
- const blocks = template.blocks.flatMap((block) => resolveTemplateBlockSequence({
1767
- block,
1768
- bindingContext: input.bindingContext,
1769
- slotContent: input.slotContent,
1770
- customBlocks: input.customBlocks,
1771
- previewStage: input.previewStage
1772
- }));
1773
- if (blocks.length === 0) return {
1774
- templatePage: null,
1775
- resolvedData: {}
2106
+ if ((value.kind === "choice" || value.kind === "shortText") && (toKind === "choice" || toKind === "shortText")) return {
2107
+ kind: "converted",
2108
+ value: {
2109
+ kind: toKind,
2110
+ value: value.value
2111
+ }
1776
2112
  };
1777
- const templatePage = {
1778
- name: template.name || input.pageName,
1779
- path: input.pagePath,
1780
- purpose: input.pagePurpose,
1781
- blocks
2113
+ if (value.kind === "list" && toKind === "headedLists") return {
2114
+ kind: "converted",
2115
+ value: {
2116
+ kind: "headedLists",
2117
+ groups: [{
2118
+ heading: "",
2119
+ items: value.items
2120
+ }]
2121
+ }
1782
2122
  };
1783
- const prefetched = await resolveBlockDataWithDeps(input.deps, {
1784
- bookingTimeZone: input.bookingTimeZone,
1785
- now: input.now,
1786
- page: projectRenderablePageOutline(templatePage),
1787
- siteId: input.siteId,
1788
- renderTarget: createTemplateRenderTarget(input.renderTargetSource, template.id),
1789
- previewStage: input.previewStage,
1790
- policy: input.blockDataPolicy,
1791
- client: input.client,
1792
- customBlocks: input.customBlocks
1793
- });
2123
+ if (value.kind === "headedLists" && toKind === "list") return {
2124
+ kind: "converted",
2125
+ value: {
2126
+ kind: "list",
2127
+ items: value.groups.flatMap((group) => group.items)
2128
+ }
2129
+ };
2130
+ return { kind: "incompatible" };
2131
+ }
2132
+ function readSectionValue(stored, kind) {
2133
+ if (stored === void 0 || stored === null) return {
2134
+ kind: "empty",
2135
+ reason: "missing"
2136
+ };
2137
+ const parsed = parseSectionValue(stored);
2138
+ if (!parsed) return {
2139
+ kind: "empty",
2140
+ reason: "unreadable"
2141
+ };
2142
+ const converted = convertSectionValue(parsed, kind);
2143
+ if (converted.kind === "incompatible") return {
2144
+ kind: "empty",
2145
+ reason: "incompatible"
2146
+ };
2147
+ const normalised = normaliseSectionValue(converted.value);
2148
+ return isSectionValueEmpty(normalised) ? {
2149
+ kind: "empty",
2150
+ reason: "blank"
2151
+ } : {
2152
+ kind: "filled",
2153
+ value: normalised
2154
+ };
2155
+ }
2156
+ //#endregion
2157
+ //#region ../content-model/src/page-sections/applicability.ts
2158
+ /** Whether one applicability covers a subject with these facts. */
2159
+ function appliesTo(applicability, facts) {
2160
+ if (applicability.subject === "service" || facts.subject === "service") return applicability.subject === facts.subject;
2161
+ const presetMatches = applicability.presets === "all" || applicability.presets.includes(facts.preset);
2162
+ const categoryMatches = applicability.categories === "all" || facts.categoryId !== null && applicability.categories.includes(facts.categoryId);
2163
+ return presetMatches && categoryMatches;
2164
+ }
2165
+ const applicableBrand = Symbol("applicable-sections");
2166
+ function compareSectionOrder(left, right) {
2167
+ return left.position - right.position || left.id.localeCompare(right.id);
2168
+ }
2169
+ /** The one rule for which sections a subject's page has. */
2170
+ function resolveApplicableSections(definitions, facts) {
2171
+ const applicable = definitions.filter((definition) => isActiveSection(definition) && appliesTo(definition.applicability, facts));
1794
2172
  return {
1795
- templatePage,
1796
- prefetchedBlockData: prefetched,
1797
- ...prefetched
2173
+ [applicableBrand]: true,
2174
+ sections: [...applicable].sort(compareSectionOrder)
1798
2175
  };
1799
2176
  }
1800
- function resolveTemplateBlockSequence(input) {
1801
- const { block } = input;
1802
- const slotKey = readEntrySlotKey(block);
1803
- if (slotKey) return selectBlocksForDeclaredEntrySlot({
1804
- declaredSlotKey: slotKey,
1805
- entrySlots: input.slotContent ?? []
1806
- }).map((slotBlock) => admitEntrySlotBlock(slotBlock, input.customBlocks, input.previewStage));
1807
- if (block.blockKind === "system.entry-slot") return [];
1808
- return [resolveTemplateBlock(block, input.bindingContext, input.customBlocks)];
1809
- }
1810
- function resolveTemplateBlock(block, bindingContext, customBlocks) {
1811
- const base = {
1812
- id: block.id,
1813
- kind: block.blockKind,
1814
- purpose: block.scope === "template" ? "template-layout" : "entry-content",
1815
- publishedPlacement: null,
1816
- ...isRecord(block.bindings) ? { bindings: block.bindings } : {}
2177
+ Object.freeze({
2178
+ [applicableBrand]: true,
2179
+ sections: []
2180
+ });
2181
+ //#endregion
2182
+ //#region ../content-model/src/page-sections/contentValues.ts
2183
+ /**
2184
+ * Section values live in a page's own content, under one key, as
2185
+ * `{ sections: { [definitionId]: SectionValue } }`.
2186
+ */
2187
+ const SECTION_VALUES_CONTENT_KEY = "sections";
2188
+ function readStoredSectionValues(content) {
2189
+ if (!isRecord$1(content)) return {};
2190
+ const sections = content[SECTION_VALUES_CONTENT_KEY];
2191
+ return isRecord$1(sections) ? sections : {};
2192
+ }
2193
+ //#endregion
2194
+ //#region ../content-model/src/page-sections/facts.ts
2195
+ /** A removed option is hidden, never rewritten. Restoring that option restores its value. */
2196
+ function readShapeValue(stored, shape) {
2197
+ const read = readSectionValue(stored, shape.kind);
2198
+ if (read.kind === "empty" || shape.kind !== "choice" || read.value.kind !== "choice") return read;
2199
+ return shape.options.includes(read.value.value) ? read : {
2200
+ kind: "empty",
2201
+ reason: "removedOption"
1817
2202
  };
1818
- const manifest = resolveSdkBlockManifest(block.blockKind, customBlocks);
1819
- if (manifest === null) return invalidRenderableBlock(base, { kind: "manifest_unavailable" });
1820
- const admission = admitMaterializedSdkTemplateBlockContent({
1821
- block,
1822
- bindingContext,
1823
- manifestOrFields: manifest
1824
- });
1825
- return admission.ok ? {
1826
- ...base,
1827
- admission: {
1828
- kind: "renderable",
1829
- content: admission.value
1830
- }
1831
- } : invalidRenderableBlock(base, {
1832
- kind: "invalid_manifest_content",
1833
- error: admission.error
2203
+ }
2204
+ function readFactValue(stored, shape) {
2205
+ const read = readShapeValue(stored, shape);
2206
+ return read.kind === "filled" && (read.value.kind === "choice" || read.value.kind === "shortText") ? read.value.value : null;
2207
+ }
2208
+ /** Uses the selected content version; listing callers must supply published values. */
2209
+ function projectPageFacts(input) {
2210
+ return resolveApplicableSections(input.definitions, input.facts).sections.flatMap((definition) => {
2211
+ if (definition.shape.placement !== "facts") return [];
2212
+ const value = readFactValue(input.values[definition.id], definition.shape);
2213
+ return value === null ? [] : [{
2214
+ label: definition.label,
2215
+ value
2216
+ }];
1834
2217
  });
1835
2218
  }
1836
- function readEntrySlotKey(block) {
1837
- if (block.blockKind !== "system.entry-slot" || block.scope !== "template") return null;
1838
- const parsed = parseSlotKey(block.content?.slotKey);
1839
- return parsed.ok ? parsed.value : null;
2219
+ //#endregion
2220
+ //#region ../block-form/src/widgets/utils/readNumericUiConfig.ts
2221
+ function readNumericInputUiConfig(ui) {
2222
+ if (!ui || typeof ui !== "object") return {};
2223
+ const rec = ui;
2224
+ return {
2225
+ min: typeof rec.min === "number" ? rec.min : void 0,
2226
+ max: typeof rec.max === "number" ? rec.max : void 0,
2227
+ step: typeof rec.step === "number" ? rec.step : void 0
2228
+ };
1840
2229
  }
1841
- function admitEntrySlotBlock(block, customBlocks, previewStage) {
1842
- const base = {
1843
- id: block.id ?? block.blockId ?? null,
1844
- contentVersionId: block.contentVersionId,
1845
- ...entrySlotBlockIdentity(block, previewStage),
1846
- kind: block.kind,
1847
- purpose: block.purpose,
1848
- ...isRecord(block.bindings) ? { bindings: block.bindings } : {}
2230
+ function readNumberFieldUiConfig(ui) {
2231
+ return readNumericInputUiConfig(ui);
2232
+ }
2233
+ //#endregion
2234
+ //#region ../block-form/src/manifest/utils.ts
2235
+ function assertNever(value) {
2236
+ throw new Error(`Unhandled manifest variant: ${JSON.stringify(value)}`);
2237
+ }
2238
+ function getGroupChildFields(field) {
2239
+ return field.schema?.fields ?? field.fields;
2240
+ }
2241
+ function getRepeaterChildFields(field) {
2242
+ return field.schema?.fields ?? field.fields ?? [];
2243
+ }
2244
+ /** Data fields of a repeater item: flattened groups contribute children at the item level. */
2245
+ function getRepeaterItemDataFields(fields) {
2246
+ return fields.flatMap((field) => field.type === "group" && field.ui?.flattenInRepeater ? getGroupChildFields(field) : [field]);
2247
+ }
2248
+ //#endregion
2249
+ //#region ../block-form/src/manifest/canonicalValidation.ts
2250
+ function buildCanonicalFieldSchema(field) {
2251
+ return fieldPlanToZod(deriveFieldValidationPlan(normalizeFieldForCanonicalValidation(field)), { allowNull: !field.required });
2252
+ }
2253
+ function normalizeFieldForCanonicalValidation(field) {
2254
+ return parseFieldDefinition(toManifestFieldInput(field));
2255
+ }
2256
+ function toManifestFieldInput(field) {
2257
+ switch (field.type) {
2258
+ case "number": return numberFieldToManifestInput(field);
2259
+ case "group": return groupFieldToManifestInput(field);
2260
+ case "modal": return modalFieldToManifestInput(field);
2261
+ case "repeater": return repeaterFieldToManifestInput(field);
2262
+ case "tabGroup": return {
2263
+ ...field,
2264
+ tabs: field.tabs.map((tab) => ({
2265
+ ...tab,
2266
+ fields: tab.fields.map(toManifestFieldInput)
2267
+ }))
2268
+ };
2269
+ case "button": throw new Error("Button fields do not have canonical content validation");
2270
+ case "text":
2271
+ case "inlineText":
2272
+ case "richText":
2273
+ case "media":
2274
+ case "file":
2275
+ case "boolean":
2276
+ case "date":
2277
+ case "time":
2278
+ case "datetime":
2279
+ case "slug":
2280
+ case "url":
2281
+ case "link":
2282
+ case "select":
2283
+ case "reference":
2284
+ case "presetOrCustom":
2285
+ case "contentTypeSelect":
2286
+ case "entryPicker": return field;
2287
+ }
2288
+ return assertNever(field);
2289
+ }
2290
+ function numberFieldToManifestInput(field) {
2291
+ const ui = readNumberFieldUiConfig(field.ui);
2292
+ return {
2293
+ ...field,
2294
+ min: field.min ?? ui.min,
2295
+ max: field.max ?? ui.max,
2296
+ step: field.step ?? ui.step
1849
2297
  };
1850
- const transportedAdmission = readInvalidBlockAdmission(block.admission);
1851
- if (transportedAdmission) return invalidRenderableBlock(base, transportedAdmission.error);
1852
- const manifest = resolveSdkBlockManifest(block.kind, customBlocks);
1853
- if (manifest === null) return invalidRenderableBlock(base, { kind: "manifest_unavailable" });
1854
- const renderable = admitTransportedRenderableManifestContent(compileManifestContentContract(manifest), block.content ?? {});
1855
- return renderable.ok ? {
1856
- ...base,
1857
- admission: {
1858
- kind: "renderable",
1859
- content: renderable.value
2298
+ }
2299
+ function groupFieldToManifestInput(field) {
2300
+ return {
2301
+ ...field,
2302
+ schema: {
2303
+ ...field.schema,
2304
+ fields: getGroupChildFields(field).map(toManifestFieldInput)
1860
2305
  }
1861
- } : invalidRenderableBlock(base, {
1862
- kind: "invalid_manifest_content",
1863
- error: renderable.error
1864
- });
2306
+ };
1865
2307
  }
1866
- function entrySlotBlockIdentity(block, previewStage) {
2308
+ function modalFieldToManifestInput(field) {
1867
2309
  return {
1868
- draftContentId: block.draftContentId ?? null,
1869
- publishedPlacement: previewStage === "preview" ? readPublishedBlockPlacement(block.publishedContentId, isRecord(block.publishedContent) && isRecord(block.publishedContent.data) ? block.publishedContent.data : null) : null
2310
+ ...field,
2311
+ schema: {
2312
+ ...field.schema,
2313
+ fields: field.schema.fields.map(toManifestFieldInput)
2314
+ }
2315
+ };
2316
+ }
2317
+ function repeaterFieldToManifestInput(field) {
2318
+ if (field.polymorphic) return {
2319
+ ...field,
2320
+ itemTypes: Object.fromEntries(Object.entries(field.itemTypes).map(([typeId, itemType]) => [typeId, {
2321
+ ...itemType,
2322
+ fields: itemType.fields.map(toManifestFieldInput)
2323
+ }]))
2324
+ };
2325
+ return {
2326
+ ...field,
2327
+ schema: {
2328
+ ...field.schema,
2329
+ fields: getRepeaterChildFields(field).map(toManifestFieldInput)
2330
+ }
1870
2331
  };
1871
2332
  }
1872
2333
  //#endregion
1873
- //#region src/rendering/helpers/loadContent.ts
2334
+ //#region ../block-form/src/widgets/TextField/textFieldSchema.ts
2335
+ function buildTextFieldSchema(field) {
2336
+ return buildCanonicalFieldSchema(field);
2337
+ }
2338
+ //#endregion
2339
+ //#region ../block-form/src/widgets/stringDefaultValue.ts
2340
+ function readStringDefaultValue(value) {
2341
+ if (typeof value === "string") return value;
2342
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") return String(value);
2343
+ return null;
2344
+ }
2345
+ //#endregion
2346
+ //#region ../block-form/src/widgets/TextField/textFieldDefaults.ts
2347
+ function getTextFieldDefault(field) {
2348
+ const defaultValue = readStringDefaultValue(field.defaultValue);
2349
+ if (defaultValue !== null) return defaultValue;
2350
+ if (field.required) return field.label;
2351
+ return "";
2352
+ }
2353
+ //#endregion
2354
+ //#region ../block-form/src/widgets/NumberField/numberFieldSchema.ts
2355
+ function buildNumberFieldSchema(field) {
2356
+ return buildCanonicalFieldSchema(field);
2357
+ }
2358
+ //#endregion
2359
+ //#region ../block-form/src/widgets/NumberField/numberFieldDefaults.ts
2360
+ function getNumberFieldDefault(field) {
2361
+ if (field.defaultValue !== void 0) return typeof field.defaultValue === "number" ? field.defaultValue : null;
2362
+ return null;
2363
+ }
2364
+ //#endregion
2365
+ //#region ../block-form/src/widgets/SelectField/selectFieldSchema.ts
2366
+ function buildSelectFieldSchema(field) {
2367
+ return buildCanonicalFieldSchema(field);
2368
+ }
2369
+ //#endregion
2370
+ //#region ../block-form/src/widgets/SelectField/selectFieldDefaults.ts
2371
+ function getSelectFieldDefault(field) {
2372
+ if (field.multiple) {
2373
+ if (Array.isArray(field.defaultValue)) return field.defaultValue.filter((v) => typeof v === "string");
2374
+ if (typeof field.defaultValue === "string" && field.defaultValue.trim().length > 0) return [field.defaultValue];
2375
+ if (field.required) {
2376
+ const first = field.options?.[0]?.value;
2377
+ if (typeof first === "string") return [first];
2378
+ }
2379
+ return [];
2380
+ }
2381
+ const defaultValue = readStringDefaultValue(field.defaultValue);
2382
+ if (defaultValue !== null) return defaultValue;
2383
+ return field.options?.[0]?.value ?? "";
2384
+ }
2385
+ //#endregion
2386
+ //#region ../block-form/src/widgets/BooleanField/booleanFieldSchema.ts
1874
2387
  /**
1875
- * Type guard to check if result is a page
2388
+ * BooleanField validation schema builder
2389
+ * Server-safe - no React, no browser APIs
1876
2390
  */
1877
- function isPageContent(result) {
1878
- return result.type === "page";
2391
+ function buildBooleanFieldSchema(field) {
2392
+ const base = z.boolean();
2393
+ return field.required ? base : base.optional().nullable();
2394
+ }
2395
+ //#endregion
2396
+ //#region ../block-form/src/widgets/BooleanField/booleanFieldDefaults.ts
2397
+ function getBooleanFieldDefault(field) {
2398
+ if (field.defaultValue !== void 0) return Boolean(field.defaultValue);
2399
+ return false;
1879
2400
  }
2401
+ //#endregion
2402
+ //#region ../block-form/src/widgets/GroupField/groupFieldSchema.ts
1880
2403
  /**
1881
- * Type guard to check if result is an entry
2404
+ * GroupField validation schema builder
2405
+ * Server-safe - no React, no browser APIs
1882
2406
  */
1883
- function isEntryContent(result) {
1884
- return result.type === "entry";
2407
+ function buildGroupFieldSchema(field, ctx) {
2408
+ const shape = {};
2409
+ const fields = field.fields ?? field.schema?.fields ?? [];
2410
+ for (const child of fields) shape[child.id] = ctx.getFieldSchema(child);
2411
+ return z.object(shape).catchall(z.unknown()).passthrough();
1885
2412
  }
1886
- function isPageSurfaceContent(result) {
1887
- return result.type === "pageSurface";
2413
+ //#endregion
2414
+ //#region ../block-form/src/widgets/GroupField/groupFieldDefaults.ts
2415
+ function getGroupFieldDefault(field, ctx) {
2416
+ if (field.ui?.valueContract === "location") return null;
2417
+ const fields = field.fields ?? field.schema?.fields ?? [];
2418
+ return Object.fromEntries(fields.map((child) => [child.id, ctx.resolve(child)]));
1888
2419
  }
1889
- function isContentLoadNotFoundError(error) {
1890
- if (typeof error !== "object" || error === null || !("status" in error)) return false;
1891
- return Reflect.get(error, "status") === 404;
2420
+ //#endregion
2421
+ //#region ../block-form/src/widgets/ModalGroupField/modalFieldSchema.ts
2422
+ /**
2423
+ * ModalGroupField validation schema builder
2424
+ * Server-safe - no React, no browser APIs
2425
+ *
2426
+ * Modal fields are structurally identical to group fields - they just render differently in the UI.
2427
+ */
2428
+ function buildModalFieldSchema(field, ctx) {
2429
+ const shape = {};
2430
+ const fields = field.schema.fields;
2431
+ for (const child of fields) shape[child.id] = ctx.getFieldSchema(child);
2432
+ return z.object(shape).catchall(z.unknown()).passthrough();
1892
2433
  }
1893
- function getRejectedReason(result) {
1894
- return result.reason;
2434
+ //#endregion
2435
+ //#region ../block-form/src/widgets/ModalGroupField/modalFieldDefaults.ts
2436
+ function getModalFieldDefault(field, ctx) {
2437
+ const obj = {};
2438
+ const fields = field.schema?.fields ?? field.fields ?? [];
2439
+ for (const child of fields) obj[child.id] = ctx.resolve(child);
2440
+ return obj;
1895
2441
  }
1896
- function toTemplateContentRenderSupport(support, siteId) {
1897
- return {
1898
- bookingOfferingPresets: support.bookingOfferingPresets,
1899
- openingHours: support.openingHours,
1900
- siteTerms: support.siteTerms,
1901
- mailingList: support.mailingList,
1902
- interactionContext: support.interactionContext,
1903
- bookingTimeZone: support.bookingTimeZone,
1904
- now: support.now,
1905
- ...support.customBlocks ? { customBlocks: support.customBlocks } : {},
2442
+ //#endregion
2443
+ //#region ../block-form/src/widgets/RepeaterField/repeaterFieldSchema.ts
2444
+ /**
2445
+ * RepeaterField validation schema builder
2446
+ * Server-safe - no React, no browser APIs
2447
+ */
2448
+ function hasAtLeastTwo(items) {
2449
+ return items.length >= 2;
2450
+ }
2451
+ function buildRepeaterFieldSchema(field, ctx) {
2452
+ const itemSchema = buildRepeaterItemSchema(field, ctx);
2453
+ const customValidation = field.validation;
2454
+ if (customValidation) {
2455
+ if (field.required) return customValidation;
2456
+ return z.optional(customValidation);
2457
+ }
2458
+ const arraySchema = z.array(itemSchema);
2459
+ const minItems = field.minItems ?? 0;
2460
+ const minSchema = minItems > 0 ? arraySchema.min(minItems, `Must have at least ${minItems} item(s)`) : arraySchema;
2461
+ const schema = field.maxItems !== void 0 ? minSchema.max(field.maxItems, `Must have at most ${field.maxItems} item(s)`) : minSchema;
2462
+ return field.required ? schema : z.optional(schema);
2463
+ }
2464
+ function buildItemSchema(fields, ctx, typeKey) {
2465
+ return z.object({
2466
+ ...typeKey !== void 0 ? { _type: z.literal(typeKey) } : {},
2467
+ ...Object.fromEntries(getRepeaterItemDataFields(fields).map((child) => [child.id, ctx.getFieldSchema(child)]))
2468
+ }).catchall(z.unknown()).passthrough();
2469
+ }
2470
+ function buildRepeaterItemSchema(field, ctx) {
2471
+ if (!field.polymorphic) return buildItemSchema(getRepeaterChildFields(field), ctx);
2472
+ const schemas = Object.entries(field.itemTypes).map(([typeKey, itemType]) => buildItemSchema(itemType.fields, ctx, typeKey));
2473
+ return hasAtLeastTwo(schemas) ? z.discriminatedUnion("_type", schemas) : schemas[0] ?? z.object({ _type: z.string() }).passthrough();
2474
+ }
2475
+ //#endregion
2476
+ //#region ../block-form/src/widgets/RepeaterField/repeaterFieldDefaults.ts
2477
+ /**
2478
+ * RepeaterField default value builder
2479
+ * Server-safe - no React, no browser APIs
2480
+ */
2481
+ function isRecordArray(value) {
2482
+ return Array.isArray(value) && value.every((item) => {
2483
+ return typeof item === "object" && item !== null && !Array.isArray(item);
2484
+ });
2485
+ }
2486
+ function getRepeaterFieldDefault(field, ctx) {
2487
+ if (field.defaultValue !== void 0) return isRecordArray(field.defaultValue) ? field.defaultValue : [];
2488
+ return seedFixedLayoutGridPositions(field, Array.from({ length: field.minItems ?? 0 }, () => getRepeaterItemDefault(field, ctx)));
2489
+ }
2490
+ /** Shared owner for newly added rows and manifest-seeded minimum rows. */
2491
+ function getRepeaterItemDefault(field, ctx, itemType) {
2492
+ const typeKey = field.polymorphic ? itemType ?? Object.keys(field.itemTypes)[0] ?? "" : void 0;
2493
+ const fields = field.polymorphic ? field.itemTypes[typeKey ?? ""]?.fields ?? [] : getRepeaterChildFields(field);
2494
+ return applyLayoutGridDefaultWidth(field, fields, {
2495
+ ...typeKey !== void 0 ? { _type: typeKey } : {},
2496
+ ...Object.fromEntries(getRepeaterItemDataFields(fields).map((child) => [child.id, ctx.resolve(child)]))
2497
+ });
2498
+ }
2499
+ /** New rows get an accepted default; existing saved values are never normalized here. */
2500
+ function applyLayoutGridDefaultWidth(field, fields, value) {
2501
+ if (field.ui?.repeaterPreset !== "layoutGrid") return value;
2502
+ const spanField = resolveRepeaterGridSpanFieldId({ id: typeof field.ui.layoutGridSpanField === "string" ? field.ui.layoutGridSpanField : void 0 });
2503
+ const acceptedSpans = resolveRepeaterGridAcceptedSpans(fields, spanField);
2504
+ if (!acceptedSpans) return value;
2505
+ const columns = typeof field.ui.layoutGridColumns === "number" ? field.ui.layoutGridColumns : 6;
2506
+ return {
2507
+ ...value,
2508
+ [spanField]: String(normalizeRepeaterGridSpan(value[spanField], columns, acceptedSpans))
2509
+ };
2510
+ }
2511
+ /** Minimum rows are new content too: place them through the same planner as Add. */
2512
+ function seedFixedLayoutGridPositions(field, defaults) {
2513
+ const columns = field.ui?.layoutGridColumns;
2514
+ if (field.ui?.repeaterPreset !== "layoutGrid" || typeof columns !== "number") return defaults;
2515
+ const spanId = resolveRepeaterGridSpanFieldId({ id: typeof field.ui.layoutGridSpanField === "string" ? field.ui.layoutGridSpanField : void 0 });
2516
+ const rowId = resolveRepeaterGridRowFieldId({ id: typeof field.ui.layoutGridRowField === "string" ? field.ui.layoutGridRowField : void 0 });
2517
+ const columnId = resolveRepeaterGridColumnFieldId({ id: typeof field.ui.layoutGridColumnField === "string" ? field.ui.layoutGridColumnField : void 0 });
2518
+ const placed = flowRepeaterGridItems(defaults.map((item, index) => ({
2519
+ id: String(index),
2520
+ span: Number(item[spanId]),
2521
+ row: 1,
2522
+ colStart: 1,
2523
+ startNewRow: typeof field.ui?.layoutGridStartNewRowField === "string" && item[field.ui.layoutGridStartNewRowField] === true
2524
+ })), columns);
2525
+ return defaults.map((item, index) => ({
2526
+ ...item,
2527
+ [rowId]: placed[index]?.row,
2528
+ [columnId]: placed[index]?.colStart
2529
+ }));
2530
+ }
2531
+ //#endregion
2532
+ //#region ../block-form/src/widgets/UrlField/urlFieldSchema.ts
2533
+ /**
2534
+ * Build Zod validation schema for URL field
2535
+ */
2536
+ function buildUrlFieldSchema(field) {
2537
+ return buildCanonicalFieldSchema(field);
2538
+ }
2539
+ //#endregion
2540
+ //#region ../block-form/src/widgets/UrlField/urlFieldDefaults.ts
2541
+ /**
2542
+ * Get default value for URL field
2543
+ */
2544
+ function getUrlFieldDefault(field) {
2545
+ return field.defaultValue ?? "";
2546
+ }
2547
+ //#endregion
2548
+ //#region ../block-form/src/widgets/TimeField/timeFieldSchema.ts
2549
+ /**
2550
+ * Build Zod validation schema for Time field
2551
+ */
2552
+ function buildTimeFieldSchema(field) {
2553
+ return buildCanonicalFieldSchema(field);
2554
+ }
2555
+ //#endregion
2556
+ //#region ../block-form/src/widgets/TimeField/timeFieldDefaults.ts
2557
+ /**
2558
+ * Get default value for Time field
2559
+ */
2560
+ function getTimeFieldDefault(field) {
2561
+ return field.defaultValue ?? null;
2562
+ }
2563
+ //#endregion
2564
+ //#region ../block-form/src/widgets/DateField/dateFieldSchema.ts
2565
+ /**
2566
+ * Build Zod validation schema for Date field
2567
+ */
2568
+ function buildDateFieldSchema(field) {
2569
+ return buildCanonicalFieldSchema(field);
2570
+ }
2571
+ //#endregion
2572
+ //#region ../block-form/src/widgets/DateField/dateFieldDefaults.ts
2573
+ /**
2574
+ * Get default value for Date field
2575
+ */
2576
+ function getDateFieldDefault(field) {
2577
+ return field.defaultValue ?? null;
2578
+ }
2579
+ //#endregion
2580
+ //#region ../block-form/src/widgets/DateTimeField/dateTimeFieldSchema.ts
2581
+ /**
2582
+ * Build Zod validation schema for DateTime field
2583
+ *
2584
+ * Validates ISO 8601 date-time strings
2585
+ */
2586
+ function buildDateTimeFieldSchema(field) {
2587
+ return buildCanonicalFieldSchema(field);
2588
+ }
2589
+ //#endregion
2590
+ //#region ../block-form/src/widgets/DateTimeField/dateTimeFieldDefaults.ts
2591
+ /**
2592
+ * Get default value for DateTime field
2593
+ */
2594
+ function getDateTimeFieldDefault(field) {
2595
+ return field.defaultValue ?? null;
2596
+ }
2597
+ //#endregion
2598
+ //#region ../block-form/src/widgets/SlugField/slugFieldSchema.ts
2599
+ /**
2600
+ * Build Zod validation schema for Slug field
2601
+ *
2602
+ * Validates:
2603
+ * - Lowercase letters, numbers, and dashes only
2604
+ * - Optional slashes for paths (e.g., 'parent/child')
2605
+ * - Optional maxLength constraint
2606
+ */
2607
+ function buildSlugFieldSchema(field) {
2608
+ return buildCanonicalFieldSchema(field);
2609
+ }
2610
+ //#endregion
2611
+ //#region ../block-form/src/widgets/SlugField/slugFieldDefaults.ts
2612
+ /**
2613
+ * Get default value for Slug field
2614
+ */
2615
+ function getSlugFieldDefault(field) {
2616
+ return field.defaultValue ?? "";
2617
+ }
2618
+ //#endregion
2619
+ //#region ../block-form/src/widgets/LinkField/linkFieldSchema.ts
2620
+ function buildLinkFieldSchema(field) {
2621
+ return buildCanonicalFieldSchema(field);
2622
+ }
2623
+ //#endregion
2624
+ //#region ../block-form/src/widgets/LinkField/linkFieldDefaults.ts
2625
+ /**
2626
+ * Get default value for LinkField
2627
+ */
2628
+ function getLinkFieldDefault(field) {
2629
+ if (field.defaultValue !== void 0) return field.defaultValue;
2630
+ if (field.required) return {
2631
+ kind: "url",
2632
+ href: "#"
2633
+ };
2634
+ }
2635
+ //#endregion
2636
+ //#region ../block-form/src/widgets/RichTextField/richTextFieldSchema.ts
2637
+ /**
2638
+ * Build Zod validation schema for rich text field
2639
+ *
2640
+ * Uses the shared rich text schema from @riverbankcms/blocks to ensure consistency
2641
+ * between the form editor and block rendering validation.
2642
+ *
2643
+ * @param config - Rich text field configuration
2644
+ * @returns Zod schema for rich text validation
2645
+ */
2646
+ function buildRichTextFieldSchema(config) {
2647
+ const schema = buildRichTextSchema({
2648
+ required: config.required,
2649
+ label: config.label
2650
+ });
2651
+ return config.required ? schema : z.union([schema, z.null()]).optional();
2652
+ }
2653
+ //#endregion
2654
+ //#region ../block-form/src/widgets/RichTextField/richTextFieldDefaults.ts
2655
+ /**
2656
+ * Empty TipTap document structure
2657
+ */
2658
+ const EMPTY_RICH_TEXT_DOC = createRichTextDoc([""]);
2659
+ /**
2660
+ * Get default value for rich text field
2661
+ * Returns empty TipTap document structure
2662
+ */
2663
+ function getRichTextFieldDefaultValue(_config) {
2664
+ return EMPTY_RICH_TEXT_DOC;
2665
+ }
2666
+ //#endregion
2667
+ //#region ../block-form/src/widgets/InlineTextField/inlineTextFieldSchema.ts
2668
+ function buildInlineTextFieldSchema(field) {
2669
+ return buildCanonicalFieldSchema(field);
2670
+ }
2671
+ //#endregion
2672
+ //#region ../block-form/src/widgets/InlineTextField/inlineTextFieldDefaults.ts
2673
+ function getInlineTextFieldDefaultValue(field) {
2674
+ if (field.defaultValue !== void 0) return field.defaultValue;
2675
+ return field.required ? plainTextToInlineText(field.label) : [];
2676
+ }
2677
+ //#endregion
2678
+ //#region ../block-form/src/widgets/MediaField/mediaFieldSchema.ts
2679
+ /**
2680
+ * Build Zod validation schema for media field
2681
+ * Validates media object structure or null
2682
+ */
2683
+ function buildMediaFieldSchema(config) {
2684
+ return buildCanonicalFieldSchema(config);
2685
+ }
2686
+ //#endregion
2687
+ //#region ../block-form/src/widgets/MediaField/mediaFieldDefaults.ts
2688
+ /**
2689
+ * Get default value for media field
2690
+ * Media fields default to null (no media selected)
2691
+ */
2692
+ function getMediaFieldDefaultValue(_config) {
2693
+ return null;
2694
+ }
2695
+ //#endregion
2696
+ //#region ../block-form/src/widgets/TabGroupField/tabGroupFieldSchema.ts
2697
+ /**
2698
+ * TabGroupField validation schema builder
2699
+ * Server-safe - no React, no browser APIs
2700
+ */
2701
+ /**
2702
+ * Build validation schema for TabGroupField
2703
+ *
2704
+ * TabGroup is a UI container that organizes fields into tabs.
2705
+ * It validates all child fields across all tabs, and optionally
2706
+ * validates the activeTabField if one is specified.
2707
+ */
2708
+ function buildTabGroupFieldSchema(field, ctx) {
2709
+ const shape = {};
2710
+ for (const tab of field.tabs) for (const child of tab.fields) shape[child.id] = ctx.getFieldSchema(child);
2711
+ if (field.activeTabField) {
2712
+ const tabIds = field.tabs.map((t) => t.id);
2713
+ if (tabIds.length > 0) shape[field.activeTabField] = z.enum(tabIds);
2714
+ }
2715
+ return z.object(shape).catchall(z.unknown()).passthrough();
2716
+ }
2717
+ /**
2718
+ * Get default value for TabGroupField
2719
+ *
2720
+ * Returns an object containing default values for all child fields
2721
+ * across all tabs, plus the activeTabField if specified.
2722
+ *
2723
+ * Follows the same pattern as GroupField - includes all fields
2724
+ * even if their default value is undefined.
2725
+ */
2726
+ function getTabGroupFieldDefault(field, ctx) {
2727
+ const defaults = {};
2728
+ for (const tab of field.tabs) for (const child of tab.fields) defaults[child.id] = ctx.resolve(child);
2729
+ if (field.activeTabField && field.tabs.length > 0 && field.tabs[0]) defaults[field.activeTabField] = field.tabs[0].id;
2730
+ return defaults;
2731
+ }
2732
+ //#endregion
2733
+ //#region ../block-form/src/widgets/PresetOrCustomField/presetOrCustomFieldSchema.ts
2734
+ function buildPresetOrCustomFieldSchema(field, _ctx) {
2735
+ field.presets.map((p) => p.value);
2736
+ return z.string();
2737
+ }
2738
+ //#endregion
2739
+ //#region ../block-form/src/widgets/PresetOrCustomField/presetOrCustomFieldDefaults.ts
2740
+ function getPresetOrCustomFieldDefault(field, _ctx) {
2741
+ const defaultValue = readStringDefaultValue(field.defaultValue);
2742
+ if (defaultValue !== null) return defaultValue;
2743
+ return field.presets[0]?.value ?? "";
2744
+ }
2745
+ //#endregion
2746
+ //#region ../block-form/src/widgets/ReferenceField/referenceFieldSchema.ts
2747
+ function buildReferenceFieldSchema(field, _ctx) {
2748
+ return buildCanonicalFieldSchema(field);
2749
+ }
2750
+ //#endregion
2751
+ //#region ../block-form/src/widgets/ReferenceField/referenceFieldDefaults.ts
2752
+ function getReferenceFieldDefault(field, _ctx) {
2753
+ const defaultValue = readStringDefaultValue(field.defaultValue);
2754
+ if (defaultValue !== null) return defaultValue;
2755
+ if (field.required) return `placeholder-${field.id}`;
2756
+ return "";
2757
+ }
2758
+ //#endregion
2759
+ //#region ../block-form/src/widgets/ContentTypeSelectField/contentTypeSelectFieldSchema.ts
2760
+ function buildContentTypeSelectFieldSchema(field, _ctx) {
2761
+ const schema = z.string();
2762
+ if (field.required) return schema.min(1, "This field is required");
2763
+ return z.optional(schema).nullable().or(z.literal(""));
2764
+ }
2765
+ //#endregion
2766
+ //#region ../block-form/src/widgets/ContentTypeSelectField/contentTypeSelectFieldDefaults.ts
2767
+ function getContentTypeSelectFieldDefault(field, _ctx) {
2768
+ const defaultValue = readStringDefaultValue(field.defaultValue);
2769
+ if (defaultValue !== null) return defaultValue;
2770
+ return "";
2771
+ }
2772
+ //#endregion
2773
+ //#region ../block-form/src/widgets/EntryPickerField/entryPickerFieldSchema.ts
2774
+ function buildEntryPickerFieldSchema(field, _ctx) {
2775
+ const schema = z.string();
2776
+ if (field.required) return schema.min(1, "This field is required");
2777
+ return z.optional(schema).nullable().or(z.literal(""));
2778
+ }
2779
+ //#endregion
2780
+ //#region ../block-form/src/widgets/EntryPickerField/entryPickerFieldDefaults.ts
2781
+ function getEntryPickerFieldDefault(field, _ctx) {
2782
+ const defaultValue = readStringDefaultValue(field.defaultValue);
2783
+ if (defaultValue !== null) return defaultValue;
2784
+ if (field.required) return `placeholder-${field.id}`;
2785
+ return "";
2786
+ }
2787
+ //#endregion
2788
+ //#region ../block-form/src/registry/schemas.ts
2789
+ /**
2790
+ * Schema and Default Value Registry
2791
+ * Maps field types to validation schemas and default value builders
2792
+ *
2793
+ * Server-safe - no React, no browser APIs
2794
+ * Can be used in API routes, server components, and validation
2795
+ */
2796
+ const SCHEMA_BUILDERS = {
2797
+ text: buildTextFieldSchema,
2798
+ number: buildNumberFieldSchema,
2799
+ select: buildSelectFieldSchema,
2800
+ boolean: buildBooleanFieldSchema,
2801
+ group: buildGroupFieldSchema,
2802
+ modal: buildModalFieldSchema,
2803
+ repeater: buildRepeaterFieldSchema,
2804
+ url: buildUrlFieldSchema,
2805
+ time: buildTimeFieldSchema,
2806
+ date: buildDateFieldSchema,
2807
+ datetime: buildDateTimeFieldSchema,
2808
+ slug: buildSlugFieldSchema,
2809
+ link: buildLinkFieldSchema,
2810
+ richText: buildRichTextFieldSchema,
2811
+ inlineText: buildInlineTextFieldSchema,
2812
+ media: buildMediaFieldSchema,
2813
+ file: buildMediaFieldSchema,
2814
+ tabGroup: buildTabGroupFieldSchema,
2815
+ presetOrCustom: buildPresetOrCustomFieldSchema,
2816
+ reference: buildReferenceFieldSchema,
2817
+ contentTypeSelect: buildContentTypeSelectFieldSchema,
2818
+ entryPicker: buildEntryPickerFieldSchema
2819
+ };
2820
+ const DEFAULT_VALUE_BUILDERS = {
2821
+ text: getTextFieldDefault,
2822
+ number: getNumberFieldDefault,
2823
+ select: getSelectFieldDefault,
2824
+ boolean: getBooleanFieldDefault,
2825
+ group: getGroupFieldDefault,
2826
+ modal: getModalFieldDefault,
2827
+ repeater: getRepeaterFieldDefault,
2828
+ url: getUrlFieldDefault,
2829
+ time: getTimeFieldDefault,
2830
+ date: getDateFieldDefault,
2831
+ datetime: getDateTimeFieldDefault,
2832
+ slug: getSlugFieldDefault,
2833
+ link: getLinkFieldDefault,
2834
+ richText: getRichTextFieldDefaultValue,
2835
+ inlineText: getInlineTextFieldDefaultValue,
2836
+ media: getMediaFieldDefaultValue,
2837
+ file: getMediaFieldDefaultValue,
2838
+ tabGroup: getTabGroupFieldDefault,
2839
+ presetOrCustom: getPresetOrCustomFieldDefault,
2840
+ reference: getReferenceFieldDefault,
2841
+ contentTypeSelect: getContentTypeSelectFieldDefault,
2842
+ entryPicker: getEntryPickerFieldDefault
2843
+ };
2844
+ /**
2845
+ * Helper to build a validation schema for a single field
2846
+ * Recursively handles nested fields (group, repeater)
2847
+ */
2848
+ function buildFieldSchema(field, ctx) {
2849
+ const builder = SCHEMA_BUILDERS[field.type];
2850
+ if (!builder) {
2851
+ console.warn(`No schema builder registered for field type: ${field.type}`);
2852
+ return z.any();
2853
+ }
2854
+ return builder(field, ctx);
2855
+ }
2856
+ /**
2857
+ * Helper to get default value for a single field
2858
+ * Recursively handles nested fields (group, repeater)
2859
+ */
2860
+ function getFieldDefault(field, ctx) {
2861
+ const getDefault = DEFAULT_VALUE_BUILDERS[field.type];
2862
+ if (!getDefault) {
2863
+ console.warn(`No default value builder registered for field type: ${field.type}`);
2864
+ return field.defaultValue;
2865
+ }
2866
+ return getDefault(field, ctx);
2867
+ }
2868
+ //#endregion
2869
+ //#region ../block-form/src/manifest/manifestFormAdapter.ts
2870
+ const DEFAULT_ROLE = "author";
2871
+ const rolePriority = {
2872
+ author: 0,
2873
+ designer: 1,
2874
+ admin: 2
2875
+ };
2876
+ /**
2877
+ * Transform a BlockManifest into form fields and validation schema
2878
+ */
2879
+ function createManifestFormAdapter(manifest, options) {
2880
+ const role = options?.role ?? DEFAULT_ROLE;
2881
+ const fields = (manifest.fields ?? []).map((field) => transformField(field, role)).filter(Boolean);
2882
+ return {
2883
+ fields,
2884
+ schema: buildValidationSchema(fields)
2885
+ };
2886
+ }
2887
+ /**
2888
+ * Transform a single field, filtering by role and flattening nested structure
2889
+ */
2890
+ function transformField(field, role) {
2891
+ if (!isFieldVisible(field, role)) return;
2892
+ if (field.type !== "group" && field.type !== "repeater" && field.type !== "modal" && field.type !== "tabGroup") return field;
2893
+ if (field.type === "group") {
2894
+ const children = (field.schema?.fields ?? []).map((child) => transformField(child, role)).filter(Boolean);
2895
+ if (!children.length) return;
2896
+ const { schema: _schema, ...rest } = field;
2897
+ return {
2898
+ ...rest,
2899
+ fields: children
2900
+ };
2901
+ }
2902
+ if (field.type === "modal") {
2903
+ const children = (field.schema?.fields ?? []).map((child) => transformField(child, role)).filter(Boolean);
2904
+ if (!children.length) return;
2905
+ const { schema: _schema, ...rest } = field;
2906
+ return {
2907
+ ...rest,
2908
+ schema: { fields: children }
2909
+ };
2910
+ }
2911
+ if (field.type === "tabGroup") {
2912
+ const tabs = (field.tabs ?? []).flatMap((tab) => {
2913
+ const children = (tab.fields ?? []).map((child) => transformField(child, role)).filter(Boolean);
2914
+ return children.length ? [{
2915
+ ...tab,
2916
+ fields: children
2917
+ }] : [];
2918
+ });
2919
+ if (!tabs.length) return;
2920
+ return {
2921
+ ...field,
2922
+ tabs
2923
+ };
2924
+ }
2925
+ if (field.type === "repeater") {
2926
+ if (field.polymorphic && field.itemTypes) {
2927
+ const itemTypes = {};
2928
+ for (const [typeKey, itemType] of Object.entries(field.itemTypes)) {
2929
+ const children = (itemType.fields ?? []).map((child) => transformField(child, role)).filter(Boolean);
2930
+ if (children.length > 0) itemTypes[typeKey] = {
2931
+ label: itemType.label,
2932
+ icon: itemType.icon,
2933
+ fields: children
2934
+ };
2935
+ }
2936
+ if (Object.keys(itemTypes).length === 0) return;
2937
+ const { schema: _schema2, ...rest } = field;
2938
+ return {
2939
+ ...rest,
2940
+ polymorphic: true,
2941
+ itemTypes
2942
+ };
2943
+ }
2944
+ const children = (field.schema?.fields ?? []).map((child) => transformField(child, role)).filter(Boolean);
2945
+ if (!children.length) return;
2946
+ const { schema: _schema3, polymorphic: _polymorphic, itemTypes: _itemTypes, ...rest } = field;
2947
+ return {
2948
+ ...rest,
2949
+ fields: children
2950
+ };
2951
+ }
2952
+ }
2953
+ /**
2954
+ * Check if a field is visible to the current role
2955
+ */
2956
+ function isFieldVisible(field, role) {
2957
+ if (role === "admin") return true;
2958
+ const allowed = field.visibleRoles;
2959
+ if (!allowed || allowed.length === 0) return true;
2960
+ return allowed.some((visibility) => rolePriority[role] >= rolePriority[visibility]);
2961
+ }
2962
+ /**
2963
+ * Build a Zod validation schema from field configs using the schema registry
2964
+ */
2965
+ function buildValidationSchema(fields) {
2966
+ const shape = {};
2967
+ const ctx = { getFieldSchema: (field) => buildManifestFieldSchema(field, ctx) };
2968
+ for (const field of fields) shape[field.id] = buildManifestFieldSchema(field, ctx);
2969
+ return z.object(shape).catchall(z.unknown()).passthrough();
2970
+ }
2971
+ function buildManifestFieldSchema(field, ctx) {
2972
+ if (shouldUseCanonicalSchema(field)) return buildCanonicalFieldSchema(field);
2973
+ return buildFieldSchema(field, ctx);
2974
+ }
2975
+ function shouldUseCanonicalSchema(field) {
2976
+ switch (field.type) {
2977
+ case "text":
2978
+ case "number":
2979
+ case "select":
2980
+ case "boolean":
2981
+ case "url":
2982
+ case "slug":
2983
+ case "link":
2984
+ case "media":
2985
+ case "file":
2986
+ case "reference":
2987
+ case "inlineText": return true;
2988
+ case "group": return getGroupChildFields(field).every(shouldUseCanonicalSchema);
2989
+ case "modal": return field.schema.fields.every(shouldUseCanonicalSchema);
2990
+ case "repeater":
2991
+ if (field.polymorphic) return Object.values(field.itemTypes).every((itemType) => itemType.fields.every(shouldUseCanonicalSchema));
2992
+ return getRepeaterChildFields(field).every(shouldUseCanonicalSchema);
2993
+ case "tabGroup":
2994
+ if (field.activeTabField) return false;
2995
+ return field.tabs.every((tab) => tab.fields.every(shouldUseCanonicalSchema));
2996
+ case "richText":
2997
+ case "date":
2998
+ case "time":
2999
+ case "datetime":
3000
+ case "presetOrCustom":
3001
+ case "contentTypeSelect":
3002
+ case "entryPicker":
3003
+ case "button": return false;
3004
+ }
3005
+ return assertNever(field);
3006
+ }
3007
+ //#endregion
3008
+ //#region ../block-form/src/manifest/manifestDefaultValues.ts
3009
+ /** Construct initial field values through the same field-type default owner on server and client. */
3010
+ function createManifestDefaultValues(manifest, data = {}, options = {}) {
3011
+ const { fields } = createManifestFormAdapter(manifest, {
3012
+ role: options.role,
3013
+ ...options.adapterOptions
3014
+ });
3015
+ const ctx = { resolve: (field) => getFieldDefault(field, ctx) };
3016
+ return fields.reduce((values, field) => ({
3017
+ ...values,
3018
+ ...defaultFieldEntry(field, data, ctx)
3019
+ }), {});
3020
+ }
3021
+ /** Inline text owns both its document value and its declared plain-text mirror. */
3022
+ function defaultFieldEntry(field, data, ctx) {
3023
+ const raw = data[field.id];
3024
+ const plain = field.type === "inlineText" && field.plainTextField ? data[field.plainTextField] : void 0;
3025
+ const value = raw === void 0 && typeof plain === "string" ? plainTextToInlineText(plain) : ensureFieldValue(field, raw, ctx);
3026
+ if (field.type !== "inlineText" || !field.plainTextField) return { [field.id]: value };
3027
+ const parsed = parseInlineTextFromUnknown(value);
3028
+ return parsed.ok ? {
3029
+ [field.id]: value,
3030
+ [field.plainTextField]: inlineTextToPlainText(parsed.value)
3031
+ } : { [field.id]: value };
3032
+ }
3033
+ function ensureFieldValue(field, raw, ctx) {
3034
+ const value = raw === void 0 ? getFieldDefault(field, ctx) : raw;
3035
+ if (field.type !== "repeater") return value;
3036
+ return (Array.isArray(value) ? value : []).map((item) => ensureRepeaterItem(field, item, ctx));
3037
+ }
3038
+ function ensureRepeaterItem(field, value, ctx) {
3039
+ const itemData = isRecord$1(value) ? value : {};
3040
+ const itemType = typeof itemData._type === "string" ? itemData._type : Object.keys(field.itemTypes ?? {})[0] ?? "";
3041
+ const fields = field.polymorphic ? field.itemTypes[itemType]?.fields ?? [] : getRepeaterChildFields(field);
3042
+ return {
3043
+ ...itemData,
3044
+ ...Object.fromEntries(getRepeaterItemDataFields(fields).map((child) => [child.id, ensureFieldValue(child, itemData[child.id], ctx)]))
3045
+ };
3046
+ }
3047
+ //#endregion
3048
+ //#region ../site-renderer/dist/index.mjs
3049
+ /** Each adapter maps meaning to manifest fields; layout stays with the block and site style. */
3050
+ function sectionBlockContent(label, value) {
3051
+ switch (value.kind) {
3052
+ case "list": return {
3053
+ title: label,
3054
+ list: {
3055
+ kind: "list",
3056
+ items: value.items.map((text) => ({ text }))
3057
+ }
3058
+ };
3059
+ case "headedLists": return {
3060
+ title: label,
3061
+ list: {
3062
+ kind: "headedLists",
3063
+ groups: value.groups.map((group) => ({
3064
+ heading: group.heading,
3065
+ items: group.items.map((text) => ({ text }))
3066
+ }))
3067
+ }
3068
+ };
3069
+ case "questions": return {
3070
+ title: label,
3071
+ items: value.items.map((item) => ({
3072
+ question: item.question,
3073
+ answer: createRichTextDoc([item.answer])
3074
+ }))
3075
+ };
3076
+ case "cards": return {
3077
+ title: label,
3078
+ cards: value.cards.map((card) => ({
3079
+ title: card.title,
3080
+ ...card.text === "" ? {} : { body: createRichTextDoc([card.text]) }
3081
+ }))
3082
+ };
3083
+ case "text": return {
3084
+ heading: label,
3085
+ body: value.body
3086
+ };
3087
+ case "textWithPhoto": return {
3088
+ title: label,
3089
+ text: value.body,
3090
+ images: value.photo !== null ? [{ image: {
3091
+ ...value.photo,
3092
+ type: "image"
3093
+ } }] : []
3094
+ };
3095
+ }
3096
+ }
3097
+ /** The same kind-aware Look admission is used when writing and rendering. */
3098
+ function resolvePageSectionLook(kind, raw) {
3099
+ if (kind === "list" || kind === "headedLists") return parseListLook(kind, raw);
3100
+ const blockKind = pageSectionBlockKind(kind);
3101
+ return appearancePresets.find((preset) => preset.id === raw && preset.blockKinds.some((candidate) => candidate === blockKind))?.id ?? null;
3102
+ }
3103
+ /** The block each body section kind renders through. */
3104
+ function pageSectionBlockKind(kind) {
3105
+ switch (kind) {
3106
+ case "list":
3107
+ case "headedLists": return "block.list";
3108
+ case "questions": return "block.faq";
3109
+ case "cards": return "block.feature-cards";
3110
+ case "text": return "block.body-text";
3111
+ case "textWithPhoto": return "block.media-text";
3112
+ }
3113
+ }
3114
+ /** Section Looks stored on the template anchor. Full pages only: booking pages always use the style's default (README decision 8). */
3115
+ function pageSectionLookOverrides(blocks) {
3116
+ const looks = blocks.find((block) => block.blockKind === PAGE_SECTIONS_ANCHOR_BLOCK_KIND)?.content?.looks;
3117
+ return isRecord$2(looks) ? looks : {};
3118
+ }
3119
+ /** Pure, shared by public pages and preview. Empty values disappear before layout. */
3120
+ function compilePageSections(input, lookOverrides) {
3121
+ const sections = resolveApplicableSections(input.definitions, input.facts).sections.flatMap((definition) => {
3122
+ if (definition.shape.placement !== "body") return [];
3123
+ const read = readSectionValue(input.values[definition.id], definition.shape.kind);
3124
+ if (read.kind === "empty") return [];
3125
+ const block = {
3126
+ blockKind: pageSectionBlockKind(definition.shape.kind),
3127
+ content: sectionBlockContent(definition.label, read.value)
3128
+ };
3129
+ return [{
3130
+ look: resolvePageSectionLook(definition.shape.kind, lookOverrides[definition.id]),
3131
+ block: {
3132
+ id: `page-section-${definition.id}`,
3133
+ orderIndex: definition.position,
3134
+ scope: "template",
3135
+ blockKind: block.blockKind,
3136
+ content: block.content,
3137
+ bindings: null
3138
+ }
3139
+ }];
3140
+ });
3141
+ return {
3142
+ blocks: sections.map((section) => section.block),
3143
+ lookPins: sections.flatMap(({ block, look }) => look === null ? [] : [{
3144
+ blockId: asContentTemplateDesignBlockId(block.id),
3145
+ blockKind: block.blockKind,
3146
+ choice: {
3147
+ kind: "user-pinned",
3148
+ value: asAppearancePresetId(look)
3149
+ }
3150
+ }])
3151
+ };
3152
+ }
3153
+ function buildContentTemplateRuntime(template, theme, contentForBlock) {
3154
+ const parsed = parseContentTemplateDesignIntent(template.designState);
3155
+ if (parsed.kind !== "parsed" || theme === null) return {
3156
+ fieldsByBlockId: /* @__PURE__ */ new Map(),
3157
+ joins: []
3158
+ };
3159
+ const compiled = compileContentTemplateRuntimeFields({
3160
+ intent: parsed.intent,
3161
+ resolveJoinFacts: resolveRuntimeJoinFacts,
3162
+ surfaceResolutionContext: surfaceResolutionContextFromTheme(theme),
3163
+ blocks: template.blocks.map((block) => {
3164
+ const content = contentForBlock(block);
3165
+ const storedVariant = resolveTemplateBlockLayoutVariantKey({
3166
+ ...block,
3167
+ content
3168
+ });
3169
+ const definition = systemBlockDefinitions.find((definition) => definition.manifest.name === block.blockKind);
3170
+ const designInputs = blockDesignInputsForDefinition(block.blockKind, definition, content);
3171
+ return {
3172
+ blockId: asContentTemplateDesignBlockId(block.id),
3173
+ blockKind: block.blockKind,
3174
+ content,
3175
+ scope: block.scope,
3176
+ orderIndex: block.orderIndex,
3177
+ ...designInputs,
3178
+ storedVariant
3179
+ };
3180
+ })
3181
+ });
3182
+ return {
3183
+ fieldsByBlockId: new Map(compiled.blocks.map((block) => [block.blockId, block.fields])),
3184
+ joins: compiled.joins
3185
+ };
3186
+ }
3187
+ function resolveTemplateBlockLayoutVariantKey(block) {
3188
+ const key = toLayoutVariantKey(readLiteralBindingString(block.bindings?.variant)) ?? toLayoutVariantKey(readStringProperty(block.content, "variant"));
3189
+ return key !== null ? {
3190
+ kind: "explicit",
3191
+ key
3192
+ } : { kind: "absent" };
3193
+ }
3194
+ function readStringProperty(value, key) {
3195
+ const property = value?.[key];
3196
+ if (typeof property !== "string") return null;
3197
+ const trimmed = property.trim();
3198
+ return trimmed.length > 0 ? trimmed : null;
3199
+ }
3200
+ function readLiteralBindingString(value) {
3201
+ if (!isRecord$2(value)) return null;
3202
+ if (value.source !== "literal") return null;
3203
+ const literal = value.value;
3204
+ if (typeof literal !== "string") return null;
3205
+ const trimmed = literal.trim();
3206
+ return trimmed.length > 0 ? trimmed : null;
3207
+ }
3208
+ function toLayoutVariantKey(value) {
3209
+ if (value === null || value.length === 0) return null;
3210
+ try {
3211
+ return asLayoutVariantKey(value);
3212
+ } catch {
3213
+ return null;
3214
+ }
3215
+ }
3216
+ /** A block that renders as a diagnostic (authoring) or is omitted (public). */
3217
+ function invalidRenderableBlock(block, error) {
3218
+ return {
3219
+ ...block,
3220
+ admission: {
3221
+ kind: "invalid",
3222
+ error
3223
+ }
3224
+ };
3225
+ }
3226
+ /** The content contract of a registered system block, or null when unknown. */
3227
+ function resolveRegisteredBlockContentContract(blockKind) {
3228
+ const manifest = getBlockDefinition(blockKind)?.manifest;
3229
+ return manifest !== void 0 ? registeredManifestContentContract(manifest) : null;
3230
+ }
3231
+ const CONTENT_ENTRY_SUBJECT_BINDING_SCHEMA = {
3232
+ kind: "contentEntry",
3233
+ fieldSource: "entry.content",
3234
+ metaSource: "entry.meta.v1",
3235
+ metaKeys: [
3236
+ "id",
3237
+ "title",
3238
+ "slug",
3239
+ "path",
3240
+ "publishAt",
3241
+ "status",
3242
+ "createdAt",
3243
+ "updatedAt",
3244
+ "subject"
3245
+ ]
3246
+ };
3247
+ function buildContentEntryRenderableSurface({ entry, dateContext, subject, page }) {
3248
+ const contentEntryId = unsafeAsContentEntryId(entry.id);
3249
+ const route = buildContentEntryRouteRenderMetadata(entry, page);
3250
+ const bindingContext = buildContentEntrySubjectBindingContext(entry, contentEntryId, route, dateContext, subject);
3251
+ return {
3252
+ kind: "contentEntry",
3253
+ route,
3254
+ subject: {
3255
+ kind: "contentEntry",
3256
+ id: contentEntryId,
3257
+ entry
3258
+ },
3259
+ bindingSchema: CONTENT_ENTRY_SUBJECT_BINDING_SCHEMA,
3260
+ bindingContext,
3261
+ slotContainer: {
3262
+ kind: "entrySlots",
3263
+ owner: {
3264
+ kind: "contentEntry",
3265
+ contentEntryId
3266
+ }
3267
+ }
3268
+ };
3269
+ }
3270
+ function resolveRenderableSurfaceOutlineMetadata(surface, template) {
3271
+ return {
3272
+ name: surface.route.outlineName ?? surface.route.title,
3273
+ path: surface.route.outlinePath ?? surface.route.path ?? (surface.route.slug !== null && surface.route.slug.length > 0 ? `/${surface.route.slug}` : "/"),
3274
+ purpose: surface.route.outlinePurpose ?? template.templateKey
3275
+ };
3276
+ }
3277
+ function buildContentEntrySubjectBindingContext(entry, id, route, dateContext, subject) {
3278
+ return {
3279
+ dateContext,
3280
+ fields: isRecord$2(entry.content) ? entry.content : {},
3281
+ meta: {
3282
+ ...subject === void 0 ? {} : { subject },
3283
+ id,
3284
+ title: route.title,
3285
+ slug: route.slug,
3286
+ path: route.path,
3287
+ publishAt: route.publishAt,
3288
+ status: route.status,
3289
+ ...entry.createdAt === void 0 ? {} : { createdAt: entry.createdAt },
3290
+ ...entry.updatedAt === void 0 ? {} : { updatedAt: entry.updatedAt }
3291
+ }
3292
+ };
3293
+ }
3294
+ function buildContentEntryRouteRenderMetadata(entry, page) {
3295
+ return {
3296
+ title: entry.title,
3297
+ slug: entry.slug,
3298
+ path: entry.path,
3299
+ publishAt: entry.publishAt,
3300
+ status: entry.status,
3301
+ outlineName: page?.name,
3302
+ outlinePath: page?.path,
3303
+ outlinePurpose: page?.purpose
3304
+ };
3305
+ }
3306
+ function materializeTemplateBlockContent(input) {
3307
+ const rawContent = isRecord$2(input.block.content) ? { ...input.block.content } : {};
3308
+ return applyTemplateRuntimeFields(input.block.scope === "entry" && isRecord$2(input.block.bindings) ? applyBindingsToContent(rawContent, input.block.bindings, input.context) : rawContent, input.runtimeFields);
3309
+ }
3310
+ /**
3311
+ * Admits materialized template content for rendering only.
3312
+ *
3313
+ * Entry-scoped blocks bind values from an entry that the loaders have already
3314
+ * hydrated, so a bound media field legitimately carries `assetId`,
3315
+ * `storagePath` and friends. Stored admission rejects exactly those keys as
3316
+ * non-portable, which is right for persistence and wrong here: this content is
3317
+ * on its way to a renderer and can never reach a writer, because the
3318
+ * transported admitter returns `RenderableManifestContent` rather than granting
3319
+ * a stored proof. Portability stays enforced where it belongs — write admission
3320
+ * and the backup export gate, both of which see the raw stored content.
3321
+ */
3322
+ function admitMaterializedTemplateContent(materialized, contract) {
3323
+ return admitTransportedRenderableManifestContent(contract, materialized);
3324
+ }
3325
+ /**
3326
+ * Builds a renderable page outline from a content entry and its template.
3327
+ *
3328
+ * This is the single binding/runtime merge path used by both public rendering and
3329
+ * dashboard preview. Template-scoped blocks render their stored content exactly;
3330
+ * entry-scoped blocks render stored defaults with bound entry data layered on top.
3331
+ * Theme V2 runtime fields are applied after that content decision so preview and
3332
+ * public render cannot drift.
3333
+ */
3334
+ function buildTemplatePageOutline(input) {
3335
+ const { entry, resolveEntrySlotBlocks, resolveBlockContentContract = resolveRegisteredBlockContentContract } = input;
3336
+ const { template, pageSections, surface, context, runtime } = prepareTemplatePage(input);
3337
+ if (!template.blocks.length) return null;
3338
+ const outlineBlocks = withTitleFacts(template, pageSections, runtime.fieldsByBlockId).blocks.flatMap((block) => buildBlocksFromTemplateBlock({
3339
+ block,
3340
+ context,
3341
+ entry,
3342
+ template,
3343
+ runtimeFields: runtime.fieldsByBlockId.get(block.id),
3344
+ resolveEntrySlotBlocks,
3345
+ resolveBlockContentContract
3346
+ }));
3347
+ if (!outlineBlocks.length) return null;
3348
+ return {
3349
+ ...resolveRenderableSurfaceOutlineMetadata(surface, template),
3350
+ runtimeJoins: runtime.joins,
3351
+ blocks: outlineBlocks
3352
+ };
3353
+ }
3354
+ /** Public and editor outlines materialize the same subject bindings and design runtime. */
3355
+ function prepareTemplatePage({ entry, dateContext, subject, template: sourceTemplate, pageSections: sectionContext, page, theme }) {
3356
+ const pageSections = sectionContext === void 0 ? void 0 : {
3357
+ ...sectionContext,
3358
+ values: readStoredSectionValues(entry.content)
3359
+ };
3360
+ const template = expandPageSections(sourceTemplate, pageSections, theme ?? null);
3361
+ const surface = buildContentEntryRenderableSurface({
3362
+ entry,
3363
+ page,
3364
+ dateContext,
3365
+ subject
3366
+ });
3367
+ const context = surface.bindingContext;
3368
+ return {
3369
+ template,
3370
+ pageSections,
3371
+ surface,
3372
+ context,
3373
+ runtime: buildContentTemplateRuntime(template, theme ?? null, (block) => materializeTemplateBlockContent({
3374
+ block,
3375
+ context,
3376
+ runtimeFields: null
3377
+ }))
3378
+ };
3379
+ }
3380
+ function buildBlocksFromTemplateBlock({ block, context, entry, template, runtimeFields, resolveEntrySlotBlocks, resolveBlockContentContract }) {
3381
+ const slotKey = readEntrySlotKey(block);
3382
+ if (slotKey !== null) return resolveEntrySlotBlocks?.({
3383
+ entry,
3384
+ template,
3385
+ templateBlock: block,
3386
+ slotKey
3387
+ }) ?? [];
3388
+ if (isSystemTemplateBlockKind(block.blockKind)) return [];
3389
+ return [buildBlockFromTemplate(block, context, runtimeFields, resolveBlockContentContract(block.blockKind))];
3390
+ }
3391
+ function readEntrySlotKey(block) {
3392
+ if (block.blockKind !== "system.entry-slot" || block.scope !== "template") return null;
3393
+ const parsed = parseSlotKey(block.content?.slotKey);
3394
+ return parsed.ok ? parsed.value : null;
3395
+ }
3396
+ function buildBlockFromTemplate(block, context, runtimeFields, contract) {
3397
+ const base = {
3398
+ id: block.id,
3399
+ kind: block.blockKind,
3400
+ purpose: "content",
3401
+ publishedPlacement: null,
3402
+ ...isRecord$2(block.bindings) ? { bindings: block.bindings } : {}
3403
+ };
3404
+ if (contract === null) return invalidRenderableBlock(base, { kind: "manifest_unavailable" });
3405
+ const admission = admitMaterializedTemplateContent(materializeTemplateBlockContent({
3406
+ block,
3407
+ context,
3408
+ runtimeFields
3409
+ }), contract);
3410
+ return admission.ok ? {
3411
+ ...base,
3412
+ admission: {
3413
+ kind: "renderable",
3414
+ content: admission.value
3415
+ }
3416
+ } : invalidRenderableBlock(base, {
3417
+ kind: "invalid_manifest_content",
3418
+ error: admission.error
3419
+ });
3420
+ }
3421
+ function applyTemplateRuntimeFields(content, runtimeFields) {
3422
+ return applyMissingImageBackgroundFallback(canonicalizeSectionBackground(runtimeFields !== null && runtimeFields !== void 0 ? applyCompiledRuntimeFieldsToContent(content, runtimeFields) : content));
3423
+ }
3424
+ function canonicalizeSectionBackground(content) {
3425
+ const sectionStyles = isRecord$2(content._sectionStyles) ? content._sectionStyles : null;
3426
+ if (sectionStyles === null || sectionStyles.background === void 0) return content;
3427
+ const background = parseBackgroundContent(sectionStyles.background);
3428
+ return background !== null ? {
3429
+ ...content,
3430
+ _sectionStyles: {
3431
+ ...sectionStyles,
3432
+ background
3433
+ }
3434
+ } : content;
3435
+ }
3436
+ function applyMissingImageBackgroundFallback(content) {
3437
+ const sectionStyles = isRecord$2(content._sectionStyles) ? content._sectionStyles : null;
3438
+ const background = parseBackgroundContent(sectionStyles?.background);
3439
+ if (sectionStyles === null || background?.type !== "image" || background.image !== null && background.image !== void 0) return content;
3440
+ const fallbackColor = resolveMissingImageFallbackColor(background);
3441
+ return {
3442
+ ...content,
3443
+ _sectionStyles: {
3444
+ ...sectionStyles,
3445
+ background: {
3446
+ type: "color",
3447
+ color: fallbackColor,
3448
+ textColor: background.textColor,
3449
+ headingColor: background.headingColor,
3450
+ linkColor: background.linkColor,
3451
+ supportingColor: background.supportingColor
3452
+ }
3453
+ }
3454
+ };
3455
+ }
3456
+ function resolveMissingImageFallbackColor(background) {
3457
+ const overlayColor = background.overlay?.type === "color" ? background.overlay.color?.trim() ?? null : null;
3458
+ if (overlayColor !== null && overlayColor !== "") return overlayColor;
3459
+ return background.textColor === "primaryForeground" ? "primary" : "surface";
3460
+ }
3461
+ /** Replace the anchor before runtime joins and manifest admission see the outline. */
3462
+ function expandPageSections(template, input, theme) {
3463
+ if (!template.blocks.some((block) => block.blockKind === "system.page-sections")) return template;
3464
+ const sections = input !== void 0 ? compilePageSections(input, pageSectionLookOverrides(template.blocks)) : {
3465
+ blocks: [],
3466
+ lookPins: []
3467
+ };
3468
+ const design = parseContentTemplateDesignIntent(template.designState);
3469
+ const intent = design.kind === "parsed" ? design.intent : sections.lookPins.length > 0 && theme?.siteStyleId !== void 0 ? buildInitialPolicyPageDesignIntent(theme.siteStyleId) : null;
3470
+ const sectionIds = new Set(sections.blocks.map((block) => block.id));
3471
+ return {
3472
+ ...template,
3473
+ designState: sections.lookPins.length > 0 && intent !== null ? contentTemplateDesignIntentToJsonRecord({
3474
+ ...intent,
3475
+ blockLookPins: [...intent.blockLookPins.filter((pin) => !sectionIds.has(pin.blockId)), ...sections.lookPins]
3476
+ }) : template.designState,
3477
+ blocks: template.blocks.flatMap((block) => block.blockKind === "system.page-sections" ? sections.blocks : [block]).map((block, orderIndex) => ({
3478
+ ...block,
3479
+ orderIndex
3480
+ }))
3481
+ };
3482
+ }
3483
+ /** The title owner is selected once, after the template's Look arrangements are known. */
3484
+ function withTitleFacts(template, input, runtime) {
3485
+ const facts = input !== void 0 ? projectPageFacts(input) : [];
3486
+ const title = template.blocks.find((block) => isPageTitleBlock(block, runtime.get(block.id)));
3487
+ if (facts.length === 0 || title === void 0) return template;
3488
+ return {
3489
+ ...template,
3490
+ blocks: template.blocks.map((block) => block.id === title.id ? {
3491
+ ...block,
3492
+ content: {
3493
+ ...block.content,
3494
+ _pageFacts: facts
3495
+ }
3496
+ } : block)
3497
+ };
3498
+ }
3499
+ function isPageTitleBlock(block, runtime) {
3500
+ if (block.blockKind === "block.event-details") return runtime?._arrangementLooks?.byMode.default?.look.structure.byMode.default === "event-header";
3501
+ return block.blockKind === "block.hero" && block.scope === "entry" && (isEntryTitleBinding(block.bindings?.headlineInline) || isEntryTitleBinding(block.bindings?.headline));
3502
+ }
3503
+ function isEntryTitleBinding(binding) {
3504
+ if (!isRecord$2(binding)) return false;
3505
+ return binding.source === "meta" && binding.path === "title" || binding.source === "transform" && isEntryTitleBinding(binding.input);
3506
+ }
3507
+ blockDesignCapabilityMapFromDefinitions(systemBlockDefinitions);
3508
+ createManifestDefaultValues(siteHeaderManifest);
3509
+ createManifestDefaultValues(siteFooterManifest);
3510
+ //#endregion
3511
+ //#region src/rendering/helpers/templateContent.ts
3512
+ function createTemplateRenderTarget(source, templateId) {
3513
+ switch (source.kind) {
3514
+ case "entry-template": return {
3515
+ kind: source.kind,
3516
+ templateId,
3517
+ entryId: source.entryId,
3518
+ entryType: source.entryType
3519
+ };
3520
+ case "page-surface-template": return {
3521
+ kind: source.kind,
3522
+ templateId,
3523
+ pageSurfaceId: source.pageSurfaceId,
3524
+ routeId: source.routeId,
3525
+ subject: source.subject
3526
+ };
3527
+ }
3528
+ }
3529
+ function processEntryTemplate(input) {
3530
+ return processTemplatePage({
3531
+ ...input,
3532
+ slotContent: input.entrySlots,
3533
+ pageName: "Entry Template",
3534
+ pagePath: input.entry.path || "/",
3535
+ pagePurpose: "entry-template",
3536
+ renderTargetSource: {
3537
+ kind: "entry-template",
3538
+ entryId: input.entry.id,
3539
+ entryType: input.entry.type
3540
+ }
3541
+ });
3542
+ }
3543
+ async function processTemplatePage(input) {
3544
+ const template = input.templates?.[0];
3545
+ if (!template?.blocks?.length) return {
3546
+ templatePage: null,
3547
+ resolvedData: {}
3548
+ };
3549
+ const templatePage = materializeSdkTemplate(input, template);
3550
+ if (templatePage === null) return {
3551
+ templatePage: null,
3552
+ resolvedData: {}
3553
+ };
3554
+ const prefetched = await resolveBlockDataWithDeps(input.deps, {
3555
+ bookingTimeZone: input.bookingTimeZone,
3556
+ now: input.now,
3557
+ page: projectRenderablePageOutline(templatePage),
3558
+ siteId: input.siteId,
3559
+ renderTarget: createTemplateRenderTarget(input.renderTargetSource, template.id),
3560
+ previewStage: input.previewStage,
3561
+ policy: input.blockDataPolicy,
3562
+ client: input.client,
3563
+ customBlocks: input.customBlocks
3564
+ });
3565
+ return {
3566
+ templatePage,
3567
+ prefetchedBlockData: prefetched,
3568
+ ...prefetched
3569
+ };
3570
+ }
3571
+ /** Pure adapter: the shared renderer owns bindings, applicability, Looks and admission. */
3572
+ function materializeSdkTemplate(input, template) {
3573
+ return buildTemplatePageOutline({
3574
+ entry: input.entry,
3575
+ subject: templateCompilerSubject(input.renderTargetSource),
3576
+ dateContext: resolveDateRuntimeContext(input.bookingTimeZone),
3577
+ template: toContentTemplate(template),
3578
+ page: {
3579
+ name: template.name || input.pageName,
3580
+ path: input.pagePath,
3581
+ purpose: input.pagePurpose
3582
+ },
3583
+ theme: input.theme,
3584
+ pageSections: input.pageSections,
3585
+ resolveEntrySlotBlocks: ({ slotKey }) => selectBlocksForDeclaredEntrySlot({
3586
+ declaredSlotKey: slotKey,
3587
+ entrySlots: input.slotContent ?? []
3588
+ }).map((block) => admitEntrySlotBlock(block, input.customBlocks, input.previewStage)),
3589
+ resolveBlockContentContract: (kind) => {
3590
+ const manifest = resolveSdkBlockManifest(kind, input.customBlocks);
3591
+ return manifest === null ? null : compileManifestContentContract(manifest);
3592
+ }
3593
+ });
3594
+ }
3595
+ function templateCompilerSubject(source) {
3596
+ switch (source.kind) {
3597
+ case "entry-template": return;
3598
+ case "page-surface-template": return source.subject;
3599
+ }
3600
+ }
3601
+ /** Adapt the SDK transport to the shared template renderer; decisions stay there. */
3602
+ function toContentTemplate(template) {
3603
+ return {
3604
+ id: template.id,
3605
+ name: template.name,
3606
+ templateKey: template.templateKey,
3607
+ designState: template.designState,
3608
+ blocks: template.blocks.map((block, orderIndex) => ({
3609
+ ...block,
3610
+ orderIndex,
3611
+ content: sanitizeSdkRuntimeBlockContent(block.blockKind, block.content ?? {}),
3612
+ bindings: block.bindings ?? null
3613
+ }))
3614
+ };
3615
+ }
3616
+ function admitEntrySlotBlock(block, customBlocks, previewStage) {
3617
+ const base = {
3618
+ id: block.id ?? block.blockId ?? null,
3619
+ contentVersionId: block.contentVersionId,
3620
+ ...entrySlotBlockIdentity(block, previewStage),
3621
+ kind: block.kind,
3622
+ purpose: block.purpose,
3623
+ ...isRecord$2(block.bindings) ? { bindings: block.bindings } : {}
3624
+ };
3625
+ const transportedAdmission = readInvalidBlockAdmission(block.admission);
3626
+ if (transportedAdmission) return invalidRenderableBlock$1(base, transportedAdmission.error);
3627
+ const manifest = resolveSdkBlockManifest(block.kind, customBlocks);
3628
+ if (manifest === null) return invalidRenderableBlock$1(base, { kind: "manifest_unavailable" });
3629
+ const renderable = admitTransportedRenderableManifestContent(compileManifestContentContract(manifest), block.content ?? {});
3630
+ return renderable.ok ? {
3631
+ ...base,
3632
+ admission: {
3633
+ kind: "renderable",
3634
+ content: renderable.value
3635
+ }
3636
+ } : invalidRenderableBlock$1(base, {
3637
+ kind: "invalid_manifest_content",
3638
+ error: renderable.error
3639
+ });
3640
+ }
3641
+ function entrySlotBlockIdentity(block, previewStage) {
3642
+ return {
3643
+ draftContentId: block.draftContentId ?? null,
3644
+ publishedPlacement: previewStage === "preview" ? readPublishedBlockPlacement(block.publishedContentId, isRecord$2(block.publishedContent) && isRecord$2(block.publishedContent.data) ? block.publishedContent.data : null) : null
3645
+ };
3646
+ }
3647
+ //#endregion
3648
+ //#region src/rendering/helpers/loadContent.ts
3649
+ /**
3650
+ * Type guard to check if result is a page
3651
+ */
3652
+ function isPageContent(result) {
3653
+ return result.type === "page";
3654
+ }
3655
+ /**
3656
+ * Type guard to check if result is an entry
3657
+ */
3658
+ function isEntryContent(result) {
3659
+ return result.type === "entry";
3660
+ }
3661
+ function isPageSurfaceContent(result) {
3662
+ return result.type === "pageSurface";
3663
+ }
3664
+ function isContentLoadNotFoundError(error) {
3665
+ if (typeof error !== "object" || error === null || !("status" in error)) return false;
3666
+ return Reflect.get(error, "status") === 404;
3667
+ }
3668
+ function getRejectedReason(result) {
3669
+ return result.reason;
3670
+ }
3671
+ function toTemplateContentRenderSupport(support, siteId) {
3672
+ return {
3673
+ bookingOfferingPresets: support.bookingOfferingPresets,
3674
+ openingHours: support.openingHours,
3675
+ siteTerms: support.siteTerms,
3676
+ mailingList: support.mailingList,
3677
+ interactionContext: support.interactionContext,
3678
+ bookingTimeZone: support.bookingTimeZone,
3679
+ now: support.now,
3680
+ ...support.customBlocks ? { customBlocks: support.customBlocks } : {},
1906
3681
  entriesByIdentifier: support.entriesByIdentifier,
1907
3682
  ...support.mediaAssets ? { mediaAssets: support.mediaAssets } : {},
1908
3683
  pagesByIdentifier: support.pagesByIdentifier,
@@ -2031,6 +3806,7 @@ async function loadContentFromContentResponseWithDeps(deps, params) {
2031
3806
  updatedAt: entryData.updatedAt
2032
3807
  };
2033
3808
  const { templatePage, resolvedData, prefetchedBlockData, loaderSnapshot, loaderFailures } = await processEntryTemplate({
3809
+ theme: support.theme,
2034
3810
  bookingTimeZone: support.bookingTimeZone,
2035
3811
  now: support.now,
2036
3812
  templates: contentResponse.templates,
@@ -2088,24 +3864,13 @@ async function loadContentFromContentResponseWithDeps(deps, params) {
2088
3864
  contentSource: pageSurfaceData.contentSource
2089
3865
  };
2090
3866
  const { templatePage, resolvedData, prefetchedBlockData, loaderSnapshot, loaderFailures } = await processTemplatePage({
3867
+ entry: pageSurface,
3868
+ theme: support.theme,
3869
+ pageSections: contentResponse.pageSections,
2091
3870
  bookingTimeZone: support.bookingTimeZone,
2092
3871
  now: support.now,
2093
3872
  templates: contentResponse.templates,
2094
3873
  slotContent: contentResponse.surfaceSlots,
2095
- bindingContext: {
2096
- dateContext: resolveDateRuntimeContext(support.bookingTimeZone),
2097
- fields: pageSurface.content && typeof pageSurface.content === "object" ? pageSurface.content : {},
2098
- meta: {
2099
- id: pageSurface.id,
2100
- title: pageSurface.title,
2101
- slug: pageSurface.slug,
2102
- path: pageSurface.path,
2103
- publishAt: pageSurface.publishAt,
2104
- status: pageSurface.status,
2105
- createdAt: pageSurface.createdAt,
2106
- updatedAt: pageSurface.updatedAt
2107
- }
2108
- },
2109
3874
  pageName: pageSurface.title || "Page Surface Template",
2110
3875
  pagePath: pageSurface.path || "/",
2111
3876
  pagePurpose: "page-surface-template",