@riverbankcms/sdk 0.159.0 → 0.161.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 (218) hide show
  1. package/README.md +4 -4
  2. package/dist/_dts/{BlocksIslandsHydrator-Cj1i1Yhh.d.ts → BlocksIslandsHydrator-Bx4kLiTA.d.ts} +1 -1
  3. package/dist/_dts/{Page-Cgzbv22M.d.ts → Page-Dm7_P13o.d.ts} +217 -8
  4. package/dist/_dts/{SdkPreviewMode-BC_FGc6b.d.ts → SdkPreviewMode-D7HdWWwF.d.ts} +55 -127
  5. package/dist/_dts/{auth-contract-FPg0-2MC.d.ts → auth-contract-CgJ5nMaH.d.ts} +2 -0
  6. package/dist/_dts/{client-BOK-YHVJ.d.ts → client-Ep0jI9eE.d.ts} +1 -1
  7. package/dist/_dts/{content-types-CsrYWxq_.d.ts → content-types-BgAzCrBc.d.ts} +18 -18
  8. package/dist/_dts/{contracts-ClgMD-9g.d.ts → contracts-DUiOnj9e.d.ts} +10 -6
  9. package/dist/_dts/{footerPageOutline-C_IDuELl.d.ts → footerPageOutline-B-uXamTG.d.ts} +6 -6
  10. package/dist/_dts/{generatePageMetadata-B7bhYSWx.d.ts → generatePageMetadata-BDkZYEcS.d.ts} +2 -2
  11. package/dist/_dts/index-BQDBQvdu.d.ts +13 -0
  12. package/dist/_dts/index-BVkP8f70.d.ts +66 -0
  13. package/dist/_dts/{index-Dt3XSGzY.d.ts → index-CF6Cjs7b.d.ts} +2 -2
  14. package/dist/_dts/{index-Ci1PEk82.d.ts → index-CSsfq6KG.d.ts} +3 -17
  15. package/dist/_dts/{index-BZ4fb2zz.d.ts → index-D_8uz4OP.d.ts} +3 -3
  16. package/dist/_dts/{index-CcaG6O13.d.ts → index-DvKQA6AZ.d.ts} +4 -4
  17. package/dist/_dts/{index-DMOfW1A7.d.ts → index-KPrWM0KF.d.ts} +2 -2
  18. package/dist/_dts/{index-DzUdUaJ-.d.ts → index-ylivB7Jj.d.ts} +2 -2
  19. package/dist/_dts/{loadContent-C1JI2pG0.d.ts → loadContent-DTjKOO-T.d.ts} +19 -10
  20. package/dist/_dts/{resolvePageContent-BtRUtrJa.d.ts → resolvePageContent-C1vA5c5w.d.ts} +2 -2
  21. package/dist/_dts/{constants-DkcKHMX-.d.ts → runtime-BY8DQBbT.d.ts} +10 -16
  22. package/dist/_dts/{hosted-booking-appearance-ChGCQYdQ.d.ts → schema-BHu0PYWl.d.ts} +25911 -23567
  23. package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
  24. package/dist/_dts/sdk/src/client/types.d.ts +2 -2
  25. package/dist/_dts/sdk/src/client.d.ts +13 -7
  26. package/dist/_dts/sdk/src/config/index.d.ts +6 -6
  27. package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
  28. package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
  29. package/dist/_dts/sdk/src/index.d.ts +8 -8
  30. package/dist/_dts/sdk/src/manifest/index.d.ts +6 -6
  31. package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
  32. package/dist/_dts/sdk/src/navigation/index.d.ts +2 -2
  33. package/dist/_dts/sdk/src/next/index.d.ts +7 -7
  34. package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
  35. package/dist/_dts/sdk/src/page-converter/index.d.ts +10 -28
  36. package/dist/_dts/sdk/src/portal/client.d.ts +1 -1
  37. package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
  38. package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
  39. package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
  40. package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
  41. package/dist/_dts/sdk/src/preview-next/keep-alive.d.ts +1 -1
  42. package/dist/_dts/sdk/src/preview-next/session.d.ts +2 -2
  43. package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
  44. package/dist/_dts/sdk/src/rendering/index.d.ts +6 -6
  45. package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
  46. package/dist/_dts/sdk/src/rendering/server.d.ts +2 -2
  47. package/dist/_dts/sdk/src/routing/index.d.ts +5 -5
  48. package/dist/_dts/sdk/src/server.d.ts +5 -5
  49. package/dist/_dts/sdk/src/theme/index.d.ts +1 -1
  50. package/dist/_dts/{session-Ba2CsnK5.d.ts → session-C_gtSFyZ.d.ts} +2 -1
  51. package/dist/_dts/{navigation-BnV_hOZy.d.ts → types-BR1Yboa9.d.ts} +15530 -16017
  52. package/dist/_dts/{types-CMFIZGUI.d.ts → types-CJXTCF_F.d.ts} +10 -13
  53. package/dist/_dts/{types-CI9dYWJ8.d.ts → types-D02ngcUH.d.ts} +4 -2
  54. package/dist/_dts/{types--oWXIfyz.d.ts → types-ZGUiHpDE.d.ts} +7 -7
  55. package/dist/_dts/{validation-Ct-GL0eA.d.ts → validation-BaV565gb.d.ts} +4 -4
  56. package/dist/client/{BlocksIslandsHydrator-DKS8Ba30.mjs → BlocksIslandsHydrator-DTExCJsb.mjs} +22 -21
  57. package/dist/client/{BookingMailingListNote-Cg9v6d7Y.mjs → BookingMailingListNote-BDpxmn1p.mjs} +2 -2
  58. package/dist/client/{CalendarNavigationChevron-BoVCTUXy.mjs → CalendarNavigationChevron-PeCiL82X.mjs} +6 -6
  59. package/dist/client/{CheckboxChoice-BF9eCNno.mjs → CheckboxChoice-DWexRLf6.mjs} +1 -1
  60. package/dist/client/{DemoBookingPortalAccess-BxRVCJG3.mjs → DemoBookingPortalAccess-3zmIqakW.mjs} +6 -6
  61. package/dist/client/{DemoPortalSignInLink-DHxYgkT6.mjs → DemoPortalSignInLink-GHi-8BW5.mjs} +1 -1
  62. package/dist/client/{EventCalendar.client-BI-kvwXf.mjs → EventCalendar.client-BxQLY5cX.mjs} +10 -9
  63. package/dist/client/{EventCombined.client-DIvnoN5l.mjs → EventCombined.client-B5bmQ03b.mjs} +8 -8
  64. package/dist/client/{EventEmbeddedCheckoutStep-B3XUyNY9.mjs → EventEmbeddedCheckoutStep-CgMZ9TeU.mjs} +1 -1
  65. package/dist/client/{EventItem-BRMtEaa6.mjs → EventItem-BEx-qiDE.mjs} +11 -6
  66. package/dist/client/{EventListWeekNavigation-B8DzAUDa.mjs → EventListWeekNavigation-CyH5tA6Y.mjs} +1 -1
  67. package/dist/client/{EventListing.client-Bo4qzQi0.mjs → EventListing.client-D3uySdGP.mjs} +3 -3
  68. package/dist/client/{EventListing.view-D2vemnCx.mjs → EventListing.view-9RFrBejr.mjs} +31 -15
  69. package/dist/client/{EventRegistrationPayment-e5XWtygG.mjs → EventRegistrationPayment-CG2tQx8K.mjs} +92 -99
  70. package/dist/client/LocationMapActions-Wsr83Q7q.mjs +268 -0
  71. package/dist/client/{Page-Dqpv9Ggi.mjs → Page-Bf2nPACI.mjs} +2673 -2290
  72. package/dist/client/{StepIndicator-BrvKa_8H.mjs → StepIndicator-CZweb1vs.mjs} +3 -3
  73. package/dist/client/{TabBarFragment-DvzIV75f.mjs → TabBarFragment-Bkgz67gt.mjs} +1 -1
  74. package/dist/client/ThemedButton-CnyL3s1A.mjs +2243 -0
  75. package/dist/client/{accordion-ByLpb4Dz.mjs → accordion-TcimLLRQ.mjs} +1 -1
  76. package/dist/client/{booking-form.client-BLndwxpx.mjs → booking-form.client-q-RpJ4aF.mjs} +13 -13
  77. package/dist/client/{bookingForm-CTxTEgHX.mjs → bookingForm-DjGfk3Wj.mjs} +4 -4
  78. package/dist/client/bookings.mjs +6 -6
  79. package/dist/client/{carousel-C8ef0vnT.mjs → carousel-CGAk6j0m.mjs} +2 -2
  80. package/dist/client/{carousel.client-BJGoJVtg.mjs → carousel.client-ArlGmYWV.mjs} +1 -1
  81. package/dist/client/{cart-BpH6jkUO.mjs → cart-D_h3rAZ2.mjs} +3 -3
  82. package/dist/client/{cart.client-DV78Td13.mjs → cart.client-DHOxZbJ7.mjs} +1 -1
  83. package/dist/client/{checkout-BJVb2RpL.mjs → checkout-tC-3CzuM.mjs} +3 -3
  84. package/dist/client/{checkout.client-CqGPXPSm.mjs → checkout.client-DsBb2Pkm.mjs} +1 -1
  85. package/dist/client/client.mjs +28 -15
  86. package/dist/client/{context-BRgBWthI.mjs → context-9ZfMb6GA.mjs} +1 -1
  87. package/dist/client/{cta-D8ucLsvX.mjs → cta-D-ZqL7-e.mjs} +2 -1
  88. package/dist/client/{dateFormatting-LeKNQ-iX.mjs → dateFormatting-BCwLqYpW.mjs} +1 -1
  89. package/dist/client/{demoPortalMagicLink-CjstiFPh.mjs → demoPortalMagicLink-BxkSS9fx.mjs} +1 -1
  90. package/dist/client/{enhanceHeaderSection-BaQJyI9x.mjs → enhanceHeaderSection-xg6to91E.mjs} +3 -3
  91. package/dist/client/{event-details.client-CYNQYOsP.mjs → event-details.client-C670TgRd.mjs} +2 -17
  92. package/dist/client/{event-registration.client-DDqSpN36.mjs → event-registration.client-C6GApWTB.mjs} +17 -17
  93. package/dist/client/{eventCalendar-3vQtuC9X.mjs → eventCalendar-CWc0dg9i.mjs} +4 -4
  94. package/dist/client/{eventCombined-CEJFMjqV.mjs → eventCombined-D4DbOrvQ.mjs} +4 -4
  95. package/dist/client/{eventDetails-nGh47jef.mjs → eventDetails-C2DfmbC0.mjs} +2 -2
  96. package/dist/client/{eventListing-BL3Ptb83.mjs → eventListing-C_yXmHyz.mjs} +4 -4
  97. package/dist/client/{eventRegistration-DDSO6KB2.mjs → eventRegistration-DJuaCB-O.mjs} +4 -4
  98. package/dist/client/{form-DjNLfy2Z.mjs → form-QZhtdFHA.mjs} +3 -3
  99. package/dist/client/{form.client-Cj0By6ot.mjs → form.client-CgvPACwG.mjs} +5 -5
  100. package/dist/client/{form.parts-DyA9C5Hy.mjs → form.parts-2uI0-5N-.mjs} +3 -3
  101. package/dist/client/{formatDate-CZo0MPTA.mjs → formatDate-Danr0Nk4.mjs} +1 -1
  102. package/dist/client/gifting/client.mjs +3 -3
  103. package/dist/client/{headerSection-JjSq6Mzp.mjs → headerSection-DJdlLdvZ.mjs} +2 -2
  104. package/dist/client/{mediaAssets-BOj-Co0B.mjs → mediaAssets-BvjcAZpS.mjs} +1 -1
  105. package/dist/client/mediaContext-jPeJ2PmJ.mjs +10801 -0
  106. package/dist/client/{newsletter-form.client-C2EgEBP1.mjs → newsletter-form.client-Cbepz2KU.mjs} +8 -8
  107. package/dist/client/{newsletter-form.parts-CaldoFmi.mjs → newsletter-form.parts-DN8oMCQ0.mjs} +2 -2
  108. package/dist/client/{newsletterForm-hm7L17LM.mjs → newsletterForm-wjLtW-wq.mjs} +3 -3
  109. package/dist/client/{noop-M8FTSgm2.mjs → noop-B7H6gCbj.mjs} +306 -5
  110. package/dist/client/portal/client.mjs +4560 -115
  111. package/dist/client/{product-detail.client-y86uwzEI.mjs → product-detail.client-CYTR165c.mjs} +1 -1
  112. package/dist/client/{product-list.client-_JBndYZT.mjs → product-list.client-B4vTvag8.mjs} +1 -1
  113. package/dist/client/{productDetail-D-9fb2cW.mjs → productDetail-k8LEMSWn.mjs} +3 -3
  114. package/dist/client/{productList-BSRlnwBW.mjs → productList-DEo8Bqoe.mjs} +3 -3
  115. package/dist/client/{propsDecoder-DhbGL302.mjs → propsDecoder-G0j0HXBO.mjs} +3 -28
  116. package/dist/client/{registry.server-BaX0hxf5.mjs → registry.server-BTmSXE3D.mjs} +1154 -997
  117. package/dist/client/rendering/client.mjs +28 -28
  118. package/dist/client/rendering/islands.mjs +1 -1
  119. package/dist/client/rendering.mjs +57 -32
  120. package/dist/client/{richText-coerce-Cny2Ukb6.mjs → richText-coerce-B19taoH6.mjs} +1 -1
  121. package/dist/client/{routeIslandApiConfig-96er7pIx.mjs → routeIslandApiConfig-Chu5BHra.mjs} +1 -1
  122. package/dist/client/{ThemedButton-DVBC_pS9.mjs → schema-C-m8XHuW.mjs} +1123 -2362
  123. package/dist/client/{shop-CnIJfdZA.mjs → shop-RGWa43H7.mjs} +3 -3
  124. package/dist/client/{shop-commerce-CsLwzq5O.mjs → shop-commerce-TJYCBO_H.mjs} +12 -12
  125. package/dist/client/{shop-commerce-store--O8GRBwr.mjs → shop-commerce-store-CjCcUB_o.mjs} +1 -1
  126. package/dist/client/{shop.client-BcaJ-acA.mjs → shop.client-tsKfZw1W.mjs} +15 -15
  127. package/dist/client/{shop.interactive-BxL_bshW.mjs → shop.interactive-CVqLAU53.mjs} +370 -189
  128. package/dist/client/{shopShared-VZjPOfCX.mjs → shopShared-C3lHMz_R.mjs} +2 -2
  129. package/dist/client/{src-7cXhT0G_.mjs → src-VIsPY-kw.mjs} +6 -1
  130. package/dist/client/timetableModel-V2ifvGGy.mjs +1100 -0
  131. package/dist/client/{useAvailableSlots-pTXuY3jV.mjs → useAvailableSlots-D1X69-pN.mjs} +4 -4
  132. package/dist/client/{useBookingNowIso-D14J-EhJ.mjs → useBookingNowIso-Ch30jino.mjs} +1 -1
  133. package/dist/client/{useDiscountApply-o5sIVZ2u.mjs → useDiscountApply-Bwzr1RjV.mjs} +3 -3
  134. package/dist/client/{useDiscountCodeUi-DJhFP_rg.mjs → useDiscountCodeUi-BimJbFC7.mjs} +1 -1
  135. package/dist/client/{useEventPagination-DMmNf2FP.mjs → useEventPagination-CLAS0upd.mjs} +12 -24
  136. package/dist/client/uuid-BETKW8rS.mjs +12 -0
  137. package/dist/client/{view-BgPql2yH2.mjs → view-BUh4LnLS.mjs} +4 -4
  138. package/dist/client/{view-D1R3Lk05.mjs → view-Dj_FZHmg.mjs} +19 -15
  139. package/dist/client/wizardSteps-BkZc-hKH.mjs +6598 -0
  140. package/dist/preview-next/before-render.mjs +5 -4
  141. package/dist/preview-next/chrome.css +2 -0
  142. package/dist/preview-next/client/{EventEmbeddedCheckoutStep-BFlBqSu4.mjs → EventEmbeddedCheckoutStep-CwerMfzn.mjs} +2 -1
  143. package/dist/preview-next/client/LocationPickerEnvironment-QtSG2Bl-.mjs +138 -0
  144. package/dist/preview-next/client/MapLibreEditMap-B-rohNcG.mjs +488 -0
  145. package/dist/preview-next/client/{PreviewEditorSidebar-DADCj_ET.mjs → PreviewEditorSidebar-Dvq-RW9-.mjs} +1328 -171
  146. package/dist/preview-next/client/{PreviewEditorUI-La40Dmmh.mjs → PreviewEditorUI-BdFjS39R.mjs} +53 -79
  147. package/dist/preview-next/client/{SdkPreviewModeRuntime-406Hw9zY.mjs → SdkPreviewModeRuntime-BEfHln1E.mjs} +1249 -2551
  148. package/dist/preview-next/client/{SdkPreviewModeRuntime-CWN44I_B.mjs → SdkPreviewModeRuntime-CjkGh1IG.mjs} +1 -1
  149. package/dist/preview-next/client/{SiteChromeCustomizeContext-BdwEZoo9.mjs → SiteChromeCustomizeContext-CDbxk_qZ.mjs} +117481 -162497
  150. package/dist/preview-next/client/{ThemedButton-BEOPss9H.mjs → ThemedButton-b14Bv03E.mjs} +1253 -403
  151. package/dist/preview-next/client/lucide-react-CA9cpo0P.mjs +51984 -0
  152. package/dist/preview-next/client/maplibre-gl-DykfOYYn.mjs +34208 -0
  153. package/dist/preview-next/client/{previewChromeSurface-BVUKIYG0.mjs → previewChromeSurface-Dd1_mNIg.mjs} +3 -8
  154. package/dist/preview-next/client/result-BjJUoxUF.mjs +16 -0
  155. package/dist/preview-next/client/rolldown-runtime-CE6sIgz8.mjs +34 -0
  156. package/dist/preview-next/client/runtime.mjs +3 -3
  157. package/dist/preview-next/client/{sdk-runtime-Cy9AKPy5.mjs → sdk-runtime-B-CXyGVb.mjs} +1 -1
  158. package/dist/preview-next/client/siteStyleAccess-Kqk0j0dE.mjs +5812 -0
  159. package/dist/preview-next/client/{spinner-Bhpzz2vO.mjs → spinner-CGxS8Ns-.mjs} +2 -1
  160. package/dist/preview-next/{constants-D8Ya7bO4.mjs → constants-Bf-vqdKH.mjs} +2 -1
  161. package/dist/preview-next/editor-base.css +64 -2
  162. package/dist/preview-next/editor-chrome.css +85 -0
  163. package/dist/preview-next/keepAlive.mjs +2 -2
  164. package/dist/preview-next/middleware.mjs +7 -3
  165. package/dist/preview-next/{route-contract-DM22uOXM.mjs → route-contract-hLg-yjQN.mjs} +190 -116
  166. package/dist/preview-next/{session-BgkrPqu0.mjs → session-P1R_ajT7.mjs} +12 -2
  167. package/dist/preview-next/session.mjs +1 -1
  168. package/dist/server/{Block.shared-DB6fb1pR.mjs → Block.shared-CeTd2saO.mjs} +6 -6
  169. package/dist/server/{bindings-z2daXp-2.mjs → bindings-C5YpKuKt.mjs} +3 -2
  170. package/dist/server/{client-Cv-osXoU.mjs → client-Cv26lZQ4.mjs} +14 -10
  171. package/dist/server/config-template-validation.mjs +50 -10
  172. package/dist/server/config-validation.mjs +1 -1
  173. package/dist/server/config.mjs +2 -2
  174. package/dist/server/{siteChromeOverlayClearance-BangtD8A.mjs → effectiveNavLinkStyle-CGvGr3yD.mjs} +572 -1078
  175. package/dist/server/index.mjs +3 -3
  176. package/dist/server/{loadContent-BNMDYCm8.mjs → loadContent-C8a0b-cC.mjs} +40 -21
  177. package/dist/server/loadPage--DXBwI8V.mjs +2 -0
  178. package/dist/server/{loadPage-CjA_F_AF.mjs → loadPage-BW7dklu3.mjs} +9 -5
  179. package/dist/server/manifest.mjs +1 -1
  180. package/dist/server/next.mjs +9 -9
  181. package/dist/server/{overrideResolution-CGodrtqi.mjs → overrideResolution-tIuqmJB3.mjs} +1 -1
  182. package/dist/server/{overrides-DxRC724a.mjs → overrides-D1fiPOKF.mjs} +1158 -754
  183. package/dist/server/page-converter.mjs +8 -10
  184. package/dist/server/{prebuild-C6bhjRKT.mjs → prebuild--fO0E2tr.mjs} +1 -1
  185. package/dist/server/prebuild.mjs +1 -1
  186. package/dist/server/{prefetchBlockData-DZ5Fq_-r.mjs → prefetchBlockData-CqJnokWJ.mjs} +968 -968
  187. package/dist/server/{publicProducts-C3meXS2o.mjs → publicProducts-CvvZ4JIe.mjs} +207 -132
  188. package/dist/server/{blocks-BaG8Qpaa.mjs → registry-BVfCqaCq.mjs} +2853 -2799
  189. package/dist/server/rendering/server.mjs +4 -4
  190. package/dist/server/rendering.mjs +8 -8
  191. package/dist/server/{resolveBlockData-CbGDakvp.mjs → resolveBlockData-DPNvhXEz.mjs} +6 -3
  192. package/dist/server/routing.mjs +1 -1
  193. package/dist/server/{schema-Bs735S27.mjs → schema-CD4peO7m.mjs} +2441 -1401
  194. package/dist/server/server.mjs +3 -3
  195. package/dist/server/site-styles-H-EvTJiW.mjs +787 -0
  196. package/dist/server/siteChromeOverlayClearance-DNC2k1U0.mjs +750 -0
  197. package/dist/server/{src-B935_bzN.mjs → src-ILxc6pid.mjs} +427 -190
  198. package/dist/server/theme-bridge.mjs +1 -1
  199. package/dist/server/theme.mjs +1 -1
  200. package/dist/server/{themeAdmission-DK2YBNqy.mjs → themeAdmission-BNHIXiUj.mjs} +117 -26
  201. package/dist/server/{three-pass-converter-CmmchOFC.mjs → three-pass-converter-Chnb1XD-.mjs} +2 -58
  202. package/dist/server/{validation-BtHE2S_D.mjs → validation-B1ieVemg.mjs} +22 -63
  203. package/dist/server/{version-CNCdL6id.mjs → version-BQK44wFg.mjs} +1 -1
  204. package/dist/styles/index.css +235 -0
  205. package/package.json +8 -3
  206. package/dist/_dts/index-CXsnaCGe.d.ts +0 -10
  207. package/dist/_dts/index-cnymEAZY.d.ts +0 -1
  208. package/dist/client/LeafletStaticMap-dlapZ6mi.mjs +0 -135
  209. package/dist/client/location-map.client-DRN1JePj.mjs +0 -28
  210. package/dist/client/location-map.view-CuCvQdvp.mjs +0 -282
  211. package/dist/client/locationMap-B9srHHzZ.mjs +0 -15
  212. package/dist/client/mediaContext-DThoeEBU.mjs +0 -136
  213. package/dist/client/renderableMediaAssetAdmission-DGjBr_e-.mjs +0 -152
  214. package/dist/client/timetableModel-D09jPdue.mjs +0 -480
  215. package/dist/client/wizardSteps-C0TsNqJc.mjs +0 -17049
  216. package/dist/preview-next/client/siteStyleAccess-CFMmoMZb.mjs +0 -1326
  217. package/dist/server/loadPage-jade28Xh.mjs +0 -2
  218. package/dist/server/media-CcHwZkdJ.mjs +0 -243
@@ -1,15 +1,212 @@
1
1
  "use client";
2
- import { Cr as asSiteStyleId, Fr as makeBoundaryId, K as corners, On as defaultThemeTokens, U as parseThemeForPersistence, Xn as paletteColorsSchema, Zn as paletteModeSchema, Zt as resolveSurface, ar as buildRenderableMediaAssetIndex, bn as expandPalette, cr as resolveManagedMediaReference, gr as asDesignBlockId, lr as mediaIdentifierSchema$2, on as textColorStyle, or as renderableMediaAssetSchema$1, sr as indexRenderableMediaAssets, vt as stripStaleTransitionStyleGroup, wr as assertNever$1, xr as asLayoutVariantKey } from "./ThemedButton-BEOPss9H.mjs";
3
2
  import { i as useOptionalPreviewLayout, t as PreviewQueryProvider } from "./PreviewQueryProvider-BC0V7iAR.mjs";
4
- import { $ as createGuardedPreviewApiClient, $a as getResponsiveScopeSpec, $i as compileManifestContentContract, $o as isObjectRecord, Aa as coerceLinkedContentEntriesPayload, Ai as imagePoolForOverride, Ar as Tabs, B as arrangementBlockControlsFor, Ba as faqAccordionFragment, Bi as createCustomBlockRegistry, Bo as sectionFactsForContent, Ca as bookingConsentCarrierSchema, Cn as resolveRenderedValues, Co as surfaceResolutionContextFromTheme, Ct as VIEWING_PARTICIPATION, Da as planSiteChromePlacement, Di as canCycleBackgroundOverrideValue, Dn as isEdited, Do as deriveSiteStyleBlockPolicy, Ds as toUtcIsoDateTimeString, Dt as EditorWriteSurface, Ea as resolveRouteTarget, Ei as backgroundColorTokens, En as baselineRevisionOf, Eo as getGradientPreset, Et as EditLeaseModal, Fa as getCurrentResolveImageUrlContext, Fi as resolveBackgroundCapability, Fn as FormRenderer, Fr as DialogContent, G as usePreviewPageDesignEditorState, Ga as formCopyFragment, Gi as offeringsPreviewBlockDefinition, Gn as MediaEditorContextProvider, Go as deriveSectionGround, Ha as blogFeaturedPostFragment, Hi as resolveBlockVariantKey, Hn as decodePublicProductCategorySelectorQuery, Ho as sectionTransitionFamilies, Ia as setContextResolveImageUrlContext, Ii as isSupportedLoaderEndpoint, Ir as DialogDescription, Ja as ctaCopyFragment, Ji as SITE_CHROME_VISIBLE_HEADER_SELECTOR, Jn as ApiRequestError, Jo as resolveCompiledSectionForegroundFromContent, K as PreviewDesignHistoryOrderProvider, Ka as testimonialsCarouselFragment, Ki as publicRouteCandidatesSchema, Kn as useMediaEditorOptional, Ko as heroPhotoPaintsGround, La as richTextFragment, Li as ThemeScope, Ln as civilPickerDisplay, Lo as formatSiteChromeBackgroundTokenLabel, Lr as DialogFooter, Ma as resolveImageUrlWithContext, Mi as planBackgroundOverride, Mo as arrangementSlotNames, Mr as TabsList, Na as SECTION_BACKGROUND_MIN_SOURCE_WIDTH, Ni as planBackgroundTransition, No as resolveItemSurface, Nr as TabsTrigger, Nt as OfferingsPreviewWidgetProvider, Oa as formatDate, Oi as defaultBackgroundOverrideForMode, Os as assertNever$2, Pa as buildResolveImageUrlContext, Pi as rankBackgroundImagePoolItems, Po as resolveLookSlotSurfaces, Pr as Dialog, Q as resolvePreviewSidebarTab, Qa as DEFAULT_THEME_RESPONSIVE_MODE, Qi as parseStoredVariant, Qo as isRichTextDoc, Qr as Upload, Ra as headingFragment, Ri as containerResponsiveThemeCss, Rn as MediaEditor, Ro as boundaryLayout, Rr as DialogHeader, Sa as publicEventsArraySchema, Si as Button, Sn as renderedFieldChanges, Ss as unsafeAsEditorBlockId, St as useRetentionTicks, Ta as resolvePageRouteTarget, Tn as unsafeAsLinkedContentEntryId, Tt as EditLeaseDiscardedNotice, U as nextArrangementLookPin, Ua as singleButtonFragment, Ui as getBlockDefinition, Un as DEFAULT_LAUNCH_READINESS_INPUT, Uo as sectionTransitionFamilyForBoundaryOptionId, Va as faqHeadingFragment, Vi as makeDefaultBlockComponent, Vn as blocksKeys, Vo as defaultSectionTransitionVariantForFamily, W as PreviewPageDesignEditorStateProvider, Wa as formEmbedFragment, Wi as normalizeBlockContent, Wn as deriveLaunchReadiness, Wo as sectionTransitionVariantForBoundaryOptionId, Xa as ctaRowFragment, Xi as planSiteOverlayHeaderClearance, Xo as readRuntimeNow, Xt as EditorProvider, Ya as heroCtaRowFragment, Yi as SITE_OVERLAY_HEADER_CLEARANCE_CSS_VAR, Yn as unwrapResponse, Yo as resolveSectionBackground, Za as heroCopyFragment, Zi as visibleHeaderClearancePx, Zo as resolveDateRuntimeContext, Zr as X, Zt as useEditor, _a as logger, _o as componentRuntimeRulesForTheme, _s as selectedContentVersionId, _t as useEntryEditorController, aa as systemCustomizeFacetLabelForValue, ai as RotateCcw, an as createRoutingHelpers, ao as blockLookFromContent, as as inlineTextToPlainText, ba as defaultTransforms, bn as remoteDraftValues, bo as headerStyleRecipeForTheme, bt as createEditorApiClientFactory, c as PreviewThemeOverlayProvider, ca as escapeStyleContent, co as applyCompiledRuntimeFieldsToContent, cs as bindingSchema, ct as PreviewRichTextEditor, da as buildLoadedOfferingsPreviewListing, ds as buildMailingListSignupBlockSourceRef, dt as PREVIEW_EDITABLE_OUTLINE, ea as validateManifestDraft, eo as ctaButton, es as isRecord$8, et as initPreviewAuth, fa as buildAppointmentServicesView, fo as arrangementManifestFromVariants, fs as parseFooterModuleId, ga as renderInlineText, gn as useOptionalEditorUiStoreInstance, go as resolvePublishedLook, gs as readEditorBlockVersionsFromPlacement, hi as GripVertical, hn as useEditorUiStoreInstance, ho as resolveModeArrangement, hs as NO_BLOCK_VERSIONS, ht as EntryControllerProvider, ia as systemCustomizeFacetDefinitionsForBlock, ii as SlidersHorizontal, io as arrangementHooksFromContent, ir as BlockApiProvider, is as coerceInlineTextWithFallback, it as usePreviewToken, ja as getLinkedContentEntryMeta, ji as parseBackgroundOverrideFromContent, jr as TabsContent, ka as LINKED_CONTENT_ENTRY_META_KEY, ki as enabledBackgroundModes, kn as canEditorWrite, l as usePreviewThemeOverlay, la as mergeContentWithBlockStyleOverrides, lo as compileEditorModelRuntime, ls as getAtPath, lt as PreviewInlineTextEditor, ma as offeringsListingFor, mi as Image, mn as useEditorUiStore, mo as resolveEffectiveArrangement, ms as sameMailingListPlacementTargeting, mt as EditableBlockProvider, n as useSiteChromeCustomizeOptional, na as systemCustomizeFacetAppliesToLayoutVariant, no as runTransforms, nr as clientComponentRegistry, ns as parseGeneratedIconAssetId, nt as renewPreviewSession, o as PreviewDesignCoordinatorProvider, oa as systemCustomizeFacetNextValue, on as createSnapshotFromPageRecord, oo as readBlockComposition, os as isInlineTextEmpty, ot as renderSiteChromeBlock, pa as OFFERINGS_PREVIEW_EVENT_PRESET_DEFINITIONS, pi as Info, po as readStoredMode, ps as parseMailingListPlacementTargeting, qa as testimonialsHeadingFragment, qi as projectRecurringSchedule, qn as useApiMediaUploader, qo as parseCanonicalRuntimeBackground, ra as systemCustomizeFacetCurrentValue, ro as defineFragment, rr as ImageResolveContextProvider, rs as parseGeneratedIconSetId, rt as usePreviewAuth, sa as buildThemeRuntime, so as applyPageOpeningForegroundToTheme, ss as plainTextToInlineText, t as SiteChromeCustomizeProvider, ta as resolveArrangementKnobs, to as bodyCopyFragment, tr as API_ENDPOINTS, ts as parseBlockIconValue, tt as registerPreviewRenewalFetcher, ua as getDefaultComponentRegistry, us as siblingPath, ut as PreviewTextEditor, va as Text$1, vi as ChevronRight, vn as activeLinkedSaveHandover, vo as designRuntimeRulesForTheme, vs as parseEditLeaseScope, wa as resolveEntryRouteTarget, wi as cn, wo as gradientToCss, xa as calendarWindowQuerySchema, xn as renderSourceFor, xt as createPageSurfaceEditorServices, ya as RichText$1, yi as ChevronLeft, yn as planLinkedSaveHandoverRetention, yo as getCuratedSiteStyle, z as arrangementBackgroundControlFor, za as cardFragment, zi as resolveSdkFooterMode, zo as composeBoundary, zr as DialogTitle } from "./SiteChromeCustomizeContext-BdwEZoo9.mjs";
5
- import { a as sanitizeDashboardPath, d as useBlockCustomizeControls, f as PreviewBlockCustomizeSelectionProvider, h as previewWidgetOverrides, i as resolvePreviewDashboardSetupHandoff, l as PreviewSiteFontStorageProvider, n as resolveSiteStyleAccess, p as usePreviewBlockCustomizeSelectionOptional, r as buildPreviewDashboardSetupUrl, s as resolvePreviewSetupBannerModel, t as canInspectSiteStyle } from "./siteStyleAccess-CFMmoMZb.mjs";
6
- import { a as resolvePreviewChromeSurface, i as getPreviewChromeSurfaceDataProps, l as PREVIEW_CHROME_Z_INDEX, n as PREVIEW_CHROME_THEME_CLASS_NAME, o as PREVIEW_KEEP_ALIVE_INTERVAL_MS, s as PREVIEW_KEEP_ALIVE_JITTER_RATIO, u as FixedBottomSurface } from "./previewChromeSurface-BVUKIYG0.mjs";
3
+ import { Br as makeBoundaryId, Ln as defaultThemeTokens, Or as asSiteStyleId, U as parseThemeForPersistence, cn as parseResolvedSurface, dn as resolveSurface, dr as renderableMediaAssetSchema$1, fr as indexRenderableMediaAssets, kn as expandPalette, kr as assertNever$1, ln as parseSurfaceTree, nn as textColorStyle, ur as buildRenderableMediaAssetIndex, vt as stripStaleTransitionStyleGroup, xr as asDesignBlockId } from "./ThemedButton-b14Bv03E.mjs";
4
+ import { $ as lookTilePosition, $a as heroPhotoPaintsGround, $i as testimonialsHeadingFragment, Ai as resolveEntryRouteTarget, An as useEditorUiStoreInstance, At as useRetentionTicks, Bi as buildResolveImageUrlContext, Bn as unsafeAsLinkedContentEntryId, Br as isSupportedLoaderEndpoint, Ca as readStoredMode, Ci as logger, Ct as useEntryEditorController, Da as deriveSiteStyleBlockPolicy, Di as calendarWindowQuerySchema, Ea as resolvePublishedLook, Ei as defaultTransforms, Fi as LINKED_CONTENT_ENTRY_META_KEY, Fn as remoteDraftValues, Fs as NO_BLOCK_VERSIONS, Ft as EditorWriteSurface, Ga as boundaryLayout, Gi as cardFragment, Go as TabsList, Gr as createCustomBlockRegistry, Hi as setContextResolveImageUrlContext, Hn as isEdited, Ii as coerceLinkedContentEntriesPayload, In as renderSourceFor, Is as readEditorBlockVersionsFromPlacement, It as editorAdmissionNotice, Ja as defaultSectionTransitionVariantForFamily, Ji as blogFeaturedPostFragment, Jo as DialogContent, Jr as getBlockDefinition, Js as toUtcIsoDateTimeString, Ka as composeBoundary, Ki as faqAccordionFragment, Ko as TabsTrigger, Kr as makeDefaultBlockComponent, Li as getLinkedContentEntryMeta, Ln as renderedFieldChanges, Ls as readPublishedBlockPlacement, Mi as resolveRouteTarget, Ms as parseFooterModuleId, Nn as activeLinkedSaveHandover, No as Callout, Ns as parseMailingListPlacementTargeting, Nt as EditLeaseDiscardedNotice, Oa as componentRuntimeRulesForTheme, Oi as publicEventsArraySchema, Os as cn, Ot as createEditorApiClientFactory, Pa as surfaceResolutionContextFromTheme, Pi as formatDate, Pn as planLinkedSaveHandoverRetention, Po as CalloutDescription, Ps as sameMailingListPlacementTargeting, Pt as EditLeaseModal, Q as lookPositionLabel, Qa as deriveSectionGround, Qi as testimonialsCarouselFragment, Qo as DialogTitle, Qr as SITE_CHROME_VISIBLE_HEADER_SELECTOR, Rn as resolveRenderedValues, Rs as selectedContentVersionId, Sa as arrangementManifestFromVariants, Si as renderInlineText, Ta as resolveModeArrangement, Ti as RichText$1, Ts as Button, Ui as richTextFragment, Uo as Tabs, Us as unsafeAsEditorBlockId, Vi as getCurrentResolveImageUrlContext, Vn as baselineRevisionOf, Vr as ThemeScope, Wa as formatSiteChromeBackgroundTokenLabel, Wi as headingFragment, Wn as canEditorWrite, Wo as TabsContent, Wr as resolveSdkFooterMode, Xa as sectionTransitionFamilyForBoundaryOptionId, Xi as formEmbedFragment, Xo as DialogFooter, Xr as offeringsPreviewBlockDefinition, Ya as sectionTransitionFamilies, Yi as singleButtonFragment, Yo as DialogDescription, Yr as normalizeBlockContent, Ys as assertNever$2, Za as sectionTransitionVariantForBoundaryOptionId, Zi as formCopyFragment, Zo as DialogHeader, Zr as publicRouteCandidatesSchema, _ as PreviewDesignHistoryOrderProvider, _i as buildAppointmentServicesView, _o as isInlineTextEmpty, _r as unwrapResponse, _t as PREVIEW_EDITABLE_OUTLINE, ai as resolveArrangementKnobs, ao as admitReadinessFacts, ar as DEFAULT_LAUNCH_READINESS_INPUT, at as registerPreviewRenewalFetcher, ba as resolveItemSurface, bn as createRoutingHelpers, bo as getAtPath, br as BlockApiProvider, bt as EditableBlockProvider, ca as runTransforms, ci as mergeContentWithBlockStyleOverrides, cn as EditorProvider, co as unavailableReadinessFact, ct as usePreviewToken, da as blockLookFromContent, di as chosenString, do as isRecord$7, ea as ctaCopyFragment, eo as parseCanonicalRuntimeBackground, fa as readBlockComposition, fo as parseBlockIconValue, ft as renderSiteChromeBlock, g as usePreviewPageDesignEditorState, gi as resolveLocationMapLocation, go as inlineTextToPlainText, gr as API_ENDPOINTS, gt as PreviewTextEditor, h as PreviewPageDesignEditorStateProvider, ha as compileEditorModelRuntime, hi as normalizeLocationMapSource, ho as coerceInlineTextWithFallback, ht as PreviewInlineTextEditor, i as PreviewDesignCoordinatorProvider, ii as systemCustomizeFacetDefinitionsForBlock, io as resolveDateRuntimeContext, ir as decodePublicProductCategorySelectorQuery, it as initPreviewAuth, ja as headerStyleRecipeForTheme, ji as resolvePageRouteTarget, jn as useOptionalEditorUiStoreInstance, js as buildMailingListSignupBlockSourceRef, jt as VIEWING_PARTICIPATION, ka as designRuntimeRulesForTheme, ki as bookingConsentCarrierSchema, kn as useEditorUiStore, kt as createPageSurfaceEditorServices, la as defineFragment, li as getDefaultComponentRegistry, ln as useEditor, lo as isRichTextDoc, lr as useApiMediaUploader, lt as SiteAdmissionObserver, ma as applyCompiledRuntimeFieldsToContent, mi as buildLoadedOfferingsPreviewListing, mo as parseGeneratedIconSetId, mt as PreviewRichTextEditor, n as useSiteChromeCustomizeOptional, na as ctaRowFragment, ni as compileManifestContentContract, no as resolveSectionBackground, o as PreviewThemeOverlayProvider, oa as ctaButton, oi as buildThemeRuntime, oo as loadedReadinessFact, or as deriveLaunchReadiness, ot as renewPreviewSession, pa as applyPageOpeningForegroundToTheme, po as parseGeneratedIconAssetId, qa as sectionFactsForContent, qi as faqHeadingFragment, qo as Dialog, qr as resolveBlockVariantKey, ra as heroCopyFragment, ri as validateManifestDraft, ro as readRuntimeNow, rr as blocksKeys, rt as createGuardedPreviewApiClient, s as usePreviewThemeOverlay, sa as bodyCopyFragment, so as pageTemplateFromEntry, sr as MediaEditorContextProvider, st as usePreviewAuth, t as SiteChromeCustomizeProvider, ta as heroCtaRowFragment, ti as parseStoredVariant, to as resolveCompiledSectionForegroundFromContent, ua as arrangementHooksFromContent, ui as projectRecurringSchedule, uo as isObjectRecord, ur as ApiRequestError, ut as SessionJournalHost, vi as OFFERINGS_PREVIEW_EVENT_PRESET_DEFINITIONS, vo as plainTextToInlineText, vr as clientComponentRegistry, wa as resolveEffectiveArrangement, wi as Text$1, wt as useOptionalSessionJournal, xa as resolveLookSlotSurfaces, xn as createSnapshotFromPageRecord, xo as siblingPath, xt as EntryControllerProvider, ya as arrangementSlotNames, yi as offeringsListingFor, yo as bindingSchema, yr as ImageResolveContextProvider, zs as parseEditLeaseScope } from "./SiteChromeCustomizeContext-CDbxk_qZ.mjs";
5
+ import { Ft as parseLocationValue, H as GripVertical, It as projectPublicLocation, Lt as publicLocationSchema, _ as RotateCcw, kt as decideLocationSourcePermission, lt as ChevronRight, n as X, ut as ChevronLeft } from "./lucide-react-CA9cpo0P.mjs";
6
+ import { A as PreviewBlockCustomizeSelectionProvider, F as planSiteDocument, I as ResponsiveScope, L as Toaster, N as SITE_CHROME_CLASS_NAMES, P as SiteDocumentLayout, a as sanitizeDashboardPath, b as cyclePageDesignBlockLook, d as useBlockCustomizeControls, g as LookCyclePill, i as resolvePreviewDashboardSetupHandoff, j as usePreviewBlockCustomizeSelectionOptional, k as CustomizeBackgroundColorPicker, l as PreviewSiteFontStorageProvider, m as ArrangementModeSwitchPill, n as resolveSiteStyleAccess, p as ArrangementLookPill, r as buildPreviewDashboardSetupUrl, s as resolvePreviewSetupBannerModel, t as canInspectSiteStyle, v as useArrangementToolbar, x as pageDesignLookPosition, y as CustomizeBackgroundControlRows } from "./siteStyleAccess-Kqk0j0dE.mjs";
7
+ import { n as LocationPickerEnvironmentProvider } from "./LocationPickerEnvironment-QtSG2Bl-.mjs";
8
+ import { a as resolvePreviewChromeSurface, i as getPreviewChromeSurfaceDataProps, n as PREVIEW_CHROME_THEME_CLASS_NAME, o as PREVIEW_KEEP_ALIVE_INTERVAL_MS, s as PREVIEW_KEEP_ALIVE_JITTER_RATIO, u as FixedBottomSurface } from "./previewChromeSurface-Dd1_mNIg.mjs";
7
9
  import * as React$1 from "react";
8
10
  import React, { Children, Fragment, cloneElement, createContext, isValidElement, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
9
11
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
12
  import { useQueryClient } from "@tanstack/react-query";
11
13
  import { z } from "zod";
12
14
  import { createPortal } from "react-dom";
15
+ import { useRouter } from "next/navigation.js";
16
+ //#region ../ui/src/resizable-split-pane.tsx
17
+ /**
18
+ * Resizable split pane component
19
+ *
20
+ * Two-panel layout with draggable resize handle.
21
+ * On mobile (<1024px), switches to tabs.
22
+ */
23
+ function ResizableSplitPane({ left, right, defaultSplit = 40, minLeftWidth = 300, minRightWidth = 400, leftLabel = "Editor", rightLabel = "Preview", defaultTab = "left", className, leftPaneClassName, rightPaneClassName, onSplitChange, splitPercent: controlledSplitPercent }) {
24
+ const [internalSplitPercent, setInternalSplitPercent] = useState(defaultSplit);
25
+ const [isDragging, setIsDragging] = useState(false);
26
+ const [isMobile, setIsMobile] = useState(false);
27
+ const containerRef = useRef(null);
28
+ const splitPercent = controlledSplitPercent ?? internalSplitPercent;
29
+ const setSplitPercent = useCallback((value) => {
30
+ setInternalSplitPercent(value);
31
+ onSplitChange?.(value);
32
+ }, [onSplitChange]);
33
+ useEffect(() => {
34
+ const checkMobile = () => {
35
+ setIsMobile(window.innerWidth < 1024);
36
+ };
37
+ checkMobile();
38
+ window.addEventListener("resize", checkMobile);
39
+ return () => window.removeEventListener("resize", checkMobile);
40
+ }, []);
41
+ const handleMouseDown = useCallback((e) => {
42
+ e.preventDefault();
43
+ setIsDragging(true);
44
+ }, []);
45
+ const handleMouseMove = useCallback((e) => {
46
+ if (!isDragging || !containerRef.current) return;
47
+ const containerRect = containerRef.current.getBoundingClientRect();
48
+ const containerWidth = containerRect.width;
49
+ let newSplitPercent = (e.clientX - containerRect.left) / containerWidth * 100;
50
+ const minLeftPercent = minLeftWidth / containerWidth * 100;
51
+ const minRightPercent = minRightWidth / containerWidth * 100;
52
+ newSplitPercent = Math.max(minLeftPercent, newSplitPercent);
53
+ newSplitPercent = Math.min(100 - minRightPercent, newSplitPercent);
54
+ setSplitPercent(newSplitPercent);
55
+ }, [
56
+ isDragging,
57
+ minLeftWidth,
58
+ minRightWidth,
59
+ setSplitPercent
60
+ ]);
61
+ const handleMouseUp = useCallback(() => {
62
+ setIsDragging(false);
63
+ }, []);
64
+ useEffect(() => {
65
+ if (isDragging) {
66
+ document.addEventListener("mousemove", handleMouseMove);
67
+ document.addEventListener("mouseup", handleMouseUp);
68
+ return () => {
69
+ document.removeEventListener("mousemove", handleMouseMove);
70
+ document.removeEventListener("mouseup", handleMouseUp);
71
+ };
72
+ }
73
+ }, [
74
+ isDragging,
75
+ handleMouseMove,
76
+ handleMouseUp
77
+ ]);
78
+ if (isMobile) return /* @__PURE__ */ jsx("div", {
79
+ className: cn("h-full min-h-0 overflow-hidden", className),
80
+ children: /* @__PURE__ */ jsxs(Tabs, {
81
+ defaultValue: defaultTab,
82
+ className: "flex h-full flex-col",
83
+ children: [
84
+ /* @__PURE__ */ jsxs(TabsList, {
85
+ className: "w-full justify-start rounded-none border-b",
86
+ children: [/* @__PURE__ */ jsx(TabsTrigger, {
87
+ value: "left",
88
+ className: "flex-1",
89
+ children: leftLabel
90
+ }), /* @__PURE__ */ jsx(TabsTrigger, {
91
+ value: "right",
92
+ className: "flex-1",
93
+ children: rightLabel
94
+ })]
95
+ }),
96
+ /* @__PURE__ */ jsx(TabsContent, {
97
+ value: "left",
98
+ className: "flex-1 overflow-auto min-h-0",
99
+ children: left
100
+ }),
101
+ /* @__PURE__ */ jsx(TabsContent, {
102
+ value: "right",
103
+ className: "flex-1 overflow-auto min-h-0",
104
+ children: right
105
+ })
106
+ ]
107
+ })
108
+ });
109
+ return /* @__PURE__ */ jsxs("div", {
110
+ ref: containerRef,
111
+ "data-testid": "resizable-split-pane",
112
+ className: cn("relative flex h-full min-h-0 overflow-hidden", className),
113
+ style: { cursor: isDragging ? "col-resize" : void 0 },
114
+ children: [
115
+ /* @__PURE__ */ jsx("div", {
116
+ className: cn("h-full min-h-0 overflow-auto", leftPaneClassName),
117
+ style: { width: `${splitPercent}%` },
118
+ children: left
119
+ }),
120
+ /* @__PURE__ */ jsx("div", {
121
+ "data-testid": "resizable-split-pane-handle",
122
+ role: "separator",
123
+ "aria-orientation": "vertical",
124
+ className: cn("group relative flex w-1.5 flex-shrink-0 cursor-col-resize items-center justify-center border-x bg-border/30 transition-colors hover:bg-border", isDragging && "bg-primary"),
125
+ onMouseDown: handleMouseDown,
126
+ children: /* @__PURE__ */ jsx("div", {
127
+ className: "absolute inset-y-0 flex items-center",
128
+ children: /* @__PURE__ */ jsx(GripVertical, { className: cn("h-3 w-3 text-muted-foreground transition-colors group-hover:text-foreground", isDragging && "text-primary-foreground") })
129
+ })
130
+ }),
131
+ /* @__PURE__ */ jsx("div", {
132
+ className: cn("relative z-10 h-full min-h-0 overflow-auto", rightPaneClassName),
133
+ style: { width: `${100 - splitPercent}%` },
134
+ children: right
135
+ }),
136
+ isDragging && /* @__PURE__ */ jsx("div", { className: "pointer-events-none fixed inset-0 z-50 cursor-col-resize" })
137
+ ]
138
+ });
139
+ }
140
+ //#endregion
141
+ //#region ../ui/src/toast.tsx
142
+ function ToastProvider() {
143
+ return /* @__PURE__ */ jsx(Toaster, {
144
+ position: "bottom-right",
145
+ offset: {
146
+ right: "calc(var(--assistant-dock-inset, 0px) + 24px)",
147
+ bottom: "24px"
148
+ },
149
+ richColors: false,
150
+ className: "rb-sonner-toaster",
151
+ toastOptions: { classNames: {
152
+ toast: "rb-sonner-toast",
153
+ success: "rb-sonner-toast-success",
154
+ info: "rb-sonner-toast-info",
155
+ error: "rb-sonner-toast-error"
156
+ } }
157
+ });
158
+ }
159
+ //#endregion
160
+ //#region ../blocks/src/pageRenderAudience.tsx
161
+ /**
162
+ * The single policy for what a non-renderable block looks like.
163
+ *
164
+ * Public visitors never see renderer diagnostics, so every reason omits.
165
+ * Authoring surfaces keep the wording they have always had — the strings below
166
+ * are moved verbatim from the five former `fallback()` call sites.
167
+ */
168
+ function presentNotRenderableBlock(reason, audience) {
169
+ if (audience === "public") return null;
170
+ if (reason.kind === "hidden-business-location" && reason.businessDetailsHref) return diagnostic(/* @__PURE__ */ jsxs(Fragment$1, { children: [
171
+ authoringMessage(reason),
172
+ " ",
173
+ /* @__PURE__ */ jsx("a", {
174
+ href: reason.businessDetailsHref,
175
+ children: "Open Business details"
176
+ })
177
+ ] }));
178
+ return diagnostic(authoringMessage(reason));
179
+ }
180
+ function authoringMessage(reason) {
181
+ switch (reason.kind) {
182
+ case "invalid-admission": return `Invalid content for block kind "${reason.blockKind}".`;
183
+ case "missing-definition": return reason.isCustom ? `No renderer available for block kind "${reason.blockKind}". The custom block definition was not found (missing manifest).` : `No renderer available for block kind "${reason.blockKind}".`;
184
+ case "missing-layout": return reason.isCustom ? `No renderer available for block kind "${reason.blockKind}". This custom block has no layout/variants, so it must be rendered via blockOverrides["${reason.blockKind}"].` : `No renderer available for block kind "${reason.blockKind}".`;
185
+ case "hidden-business-location": return "This map is hidden because your business address is hidden.";
186
+ case "unresolved-location":
187
+ if (reason.source === "business_address") return "Business address details are not configured yet.";
188
+ return reason.source === "venue" ? "This map is hidden on your site until the venue has a location." : "This map is hidden on your site until you choose a place.";
189
+ case "editor-unpreviewable":
190
+ case "render-threw": return `Unable to render block kind "${reason.blockKind}".`;
191
+ }
192
+ }
193
+ /**
194
+ * The empty-page notice. Authoring-only for the same reason as the block
195
+ * diagnostics: "No blocks found." is a message for whoever is building the
196
+ * page, not for whoever is reading it.
197
+ */
198
+ function presentEmptyPage(audience) {
199
+ if (audience === "public") return null;
200
+ return diagnostic("No blocks found.");
201
+ }
202
+ function diagnostic(message) {
203
+ return /* @__PURE__ */ jsx("div", {
204
+ className: "rb-p-6 rb-caption",
205
+ style: textColorStyle("mutedText"),
206
+ children: message
207
+ });
208
+ }
209
+ //#endregion
13
210
  //#region ../blocks/src/system/fragments/library/headerCta.ts
14
211
  const headerCtaFragment = defineFragment({
15
212
  variantMeaning: { kind: "arrangement" },
@@ -119,7 +316,7 @@ function getFragmentRegistry() {
119
316
  }
120
317
  //#endregion
121
318
  //#region ../blocks/src/system/icons/generatedAssets.ts
122
- function isRecord$7(value) {
319
+ function isRecord$6(value) {
123
320
  return typeof value === "object" && value !== null && !Array.isArray(value);
124
321
  }
125
322
  function generatedIconAssetRefKey(ref) {
@@ -129,11 +326,11 @@ function collectGeneratedIconAssetRefs(page) {
129
326
  const blocks = [];
130
327
  for (const block of page.blocks) {
131
328
  if (block.kind !== "block.feature-cards" || typeof block.id !== "string") continue;
132
- const content = isRecord$7(block.draftContent) ? block.draftContent : isRecord$7(block.content) ? block.content : null;
329
+ const content = isRecord$6(block.draftContent) ? block.draftContent : isRecord$6(block.content) ? block.content : null;
133
330
  const cards = Array.isArray(content?.cards) ? content.cards : [];
134
331
  const refs = /* @__PURE__ */ new Map();
135
332
  for (const card of cards) {
136
- if (!isRecord$7(card)) continue;
333
+ if (!isRecord$6(card)) continue;
137
334
  const icon = parseBlockIconValue(card.icon);
138
335
  if (icon.kind !== "generated") continue;
139
336
  const ref = {
@@ -398,76 +595,54 @@ function pageBlockPosition(index, blockCount) {
398
595
  //#endregion
399
596
  //#region ../blocks/src/pageRendererContracts.ts
400
597
  function buildPageRendererRootRuntime(dataContext) {
401
- const { siteId = null, siteName, pageId = null, pathname = null, bookingTimeZone, previewStage = "published", apiBaseUrl = null, portalToken = null, readAuthority, bookingOfferingPresets = [], appointmentServicePathPrefix = null, openingHours, siteTerms, mailingList = { tag: "not_configured" }, loaderFailures = {} } = dataContext ?? {};
598
+ const { siteId = null, siteName, pageId = null, pathname = null, previewStage = "published", apiBaseUrl = null, portalToken = null, readAuthority, openingHours, siteTerms, mailingList = { tag: "not_configured" }, loaderFailures = {} } = dataContext ?? {};
402
599
  return {
403
600
  siteId,
404
601
  demoEmailSuppressed: resolveDemoEmailSuppression(dataContext),
405
602
  siteName,
603
+ site: publicLocationRuntime(dataContext),
406
604
  pageId,
407
605
  pathname,
408
- bookingTimeZone,
409
- ...pageDateRuntime(dataContext),
606
+ ...pageBookingRuntime(dataContext),
607
+ ...pageRuntimeContext(dataContext),
410
608
  previewStage,
411
609
  apiBaseUrl,
412
610
  portalToken,
413
611
  readAuthority,
414
- bookingOfferingPresets,
415
- appointmentServicePathPrefix,
416
612
  openingHours,
417
613
  siteTerms,
418
614
  mailingList,
419
615
  loaderFailures
420
616
  };
421
617
  }
618
+ function publicLocationRuntime(context) {
619
+ return {
620
+ businessAddress: context?.businessLocation ?? null,
621
+ venuesById: context?.venuesById ?? {},
622
+ siteCountry: context?.siteCountry ?? null
623
+ };
624
+ }
422
625
  function resolveDemoEmailSuppression(dataContext) {
423
626
  return dataContext?.demoEmailSuppressed === true;
424
627
  }
425
- function pageDateRuntime(dataContext) {
628
+ function pageRuntimeContext(dataContext) {
426
629
  return {
427
630
  dateContext: pageDateRuntimeContext(dataContext),
428
- now: dataContext?.now
631
+ now: dataContext?.now,
632
+ template: dataContext?.template ?? { kind: "page" }
429
633
  };
430
634
  }
431
635
  function pageDateRuntimeContext(dataContext) {
432
636
  return dataContext?.dateContext ?? resolveDateRuntimeContext(dataContext?.bookingTimeZone);
433
637
  }
434
- //#endregion
435
- //#region ../blocks/src/pageRenderAudience.tsx
436
- /**
437
- * The single policy for what a non-renderable block looks like.
438
- *
439
- * Public visitors never see renderer diagnostics, so every reason omits.
440
- * Authoring surfaces keep the wording they have always had — the strings below
441
- * are moved verbatim from the five former `fallback()` call sites.
442
- */
443
- function presentNotRenderableBlock(reason, audience) {
444
- if (audience === "public") return null;
445
- return diagnostic(authoringMessage(reason));
446
- }
447
- function authoringMessage(reason) {
448
- switch (reason.kind) {
449
- case "invalid-admission": return `Invalid content for block kind "${reason.blockKind}".`;
450
- case "missing-definition": return reason.isCustom ? `No renderer available for block kind "${reason.blockKind}". The custom block definition was not found (missing manifest).` : `No renderer available for block kind "${reason.blockKind}".`;
451
- case "missing-layout": return reason.isCustom ? `No renderer available for block kind "${reason.blockKind}". This custom block has no layout/variants, so it must be rendered via blockOverrides["${reason.blockKind}"].` : `No renderer available for block kind "${reason.blockKind}".`;
452
- case "editor-unpreviewable":
453
- case "render-threw": return `Unable to render block kind "${reason.blockKind}".`;
454
- }
455
- }
456
- /**
457
- * The empty-page notice. Authoring-only for the same reason as the block
458
- * diagnostics: "No blocks found." is a message for whoever is building the
459
- * page, not for whoever is reading it.
460
- */
461
- function presentEmptyPage(audience) {
462
- if (audience === "public") return null;
463
- return diagnostic("No blocks found.");
464
- }
465
- function diagnostic(message) {
466
- return /* @__PURE__ */ jsx("div", {
467
- className: "rb-p-6 rb-caption",
468
- style: textColorStyle("mutedText"),
469
- children: message
470
- });
638
+ /** Booking context keeps its defaults together across SSR and authoring. */
639
+ function pageBookingRuntime(context) {
640
+ const { bookingTimeZone, bookingOfferingPresets = [], appointmentServicePathPrefix = null } = context ?? {};
641
+ return {
642
+ bookingTimeZone,
643
+ bookingOfferingPresets,
644
+ appointmentServicePathPrefix
645
+ };
471
646
  }
472
647
  //#endregion
473
648
  //#region ../blocks/src/pageRenderDiagnostics.ts
@@ -576,6 +751,13 @@ function toEditorPresentationPage(page) {
576
751
  };
577
752
  }
578
753
  //#endregion
754
+ //#region ../blocks/src/system/data/selectBlockContent.ts
755
+ /** Canonical admitted content: legacy publishedContent never selects a version. */
756
+ function selectBlockContent(block, stage = "published") {
757
+ const source = stage === "preview" && block.draftContent ? block.draftContent : block.content;
758
+ return isObjectRecord(source) ? stripStaleTransitionStyleGroup(source) : {};
759
+ }
760
+ //#endregion
579
761
  //#region ../blocks/src/pageRenderPlan.ts
580
762
  /**
581
763
  * Decides, once per page render, which blocks can render and what happens to
@@ -731,16 +913,34 @@ function getBlockOverride(blockKind, overrides) {
731
913
  * `site-style-transition-*` styleGroup is dropped; authored values survive.
732
914
  */
733
915
  function getRenderableContent(block, previewStage = "published") {
734
- const source = previewStage === "preview" && block.draftContent ? block.draftContent : block.content ?? {};
735
- return isObjectRecord(source) ? stripStaleTransitionStyleGroup(source) : {};
916
+ return selectBlockContent(block, previewStage);
736
917
  }
737
918
  function arrangementRuntime(content) {
738
- const value = content._arrangementLooks;
739
- return isObjectRecord(value) && isObjectRecord(value.byMode) && Array.isArray(value.available) && Array.isArray(value.rhythm) ? value : null;
919
+ const value = parseSurfaceTree(content._arrangementLooks);
920
+ return isObjectRecord(value) && isObjectRecord(value.byMode) && Array.isArray(value.available) && Array.isArray(value.rhythm) ? restoreArrangementRuntime(value) : null;
921
+ }
922
+ /** JSON transports carry resolver inputs; rebuild every surface at this boundary. */
923
+ function restoreCompiledLook(look) {
924
+ return {
925
+ ...look,
926
+ itemSurfaces: Object.fromEntries(Object.entries(look.itemSurfaces).map(([slot, surface]) => [slot, parseResolvedSurface(surface)])),
927
+ ...look.roleSurfaces ? { roleSurfaces: {
928
+ card: parseResolvedSurface(look.roleSurfaces.card),
929
+ statement: parseResolvedSurface(look.roleSurfaces.statement),
930
+ highlight: parseResolvedSurface(look.roleSurfaces.highlight)
931
+ } } : {}
932
+ };
933
+ }
934
+ function restoreArrangementRuntime(runtime) {
935
+ return {
936
+ ...runtime,
937
+ available: runtime.available.map(restoreCompiledLook),
938
+ byMode: Object.fromEntries(Object.entries(runtime.byMode).map(([mode, look]) => [mode, restoreCompiledLook(look)]))
939
+ };
740
940
  }
741
941
  function effectiveLookFromContent(content) {
742
942
  const value = content._effectiveLook;
743
- return isObjectRecord(value) && isObjectRecord(value.look) ? value : null;
943
+ return isObjectRecord(value) && isObjectRecord(value.look) ? restoreCompiledLook(value) : null;
744
944
  }
745
945
  function planArrangementContent(blockKind, manifest, content, audience) {
746
946
  const runtime = arrangementRuntime(content);
@@ -783,6 +983,7 @@ function planArrangementContent(blockKind, manifest, content, audience) {
783
983
  }),
784
984
  ...arrangementPanelContent(activeContent, effective, mode),
785
985
  ...arrangementQuoteContent(blockKind, effective, values),
986
+ _arrangementLooks: runtime,
786
987
  _effectiveLook: effective,
787
988
  _lookHooks: arrangementContentHooks(effective, mode, length, {
788
989
  ...facts,
@@ -842,7 +1043,8 @@ function arrangementContentFacts(content) {
842
1043
  facts: Array.isArray(content.facts) && content.facts.length > 0,
843
1044
  featured,
844
1045
  outcome: typeof content.outcome === "string" && content.outcome.length > 0,
845
- figure: typeof content.figure === "string" && content.figure.trim().length > 0
1046
+ figure: typeof content.figure === "string" && content.figure.trim().length > 0,
1047
+ entrance: isObjectRecord(content.entrancePhoto)
846
1048
  }
847
1049
  };
848
1050
  }
@@ -851,7 +1053,7 @@ function arrangementPhotoCount(content) {
851
1053
  if (Array.isArray(content.cards)) return content.cards.filter((card) => isObjectRecord(card) && isObjectRecord(card.media)).length;
852
1054
  if (Array.isArray(content.members)) return content.members.filter((member) => isObjectRecord(member) && isObjectRecord(member.photo)).length;
853
1055
  if (Array.isArray(content.images)) return content.images.filter((item) => isObjectRecord(item) && isObjectRecord(item.image)).length;
854
- if (isObjectRecord(content.media)) return 1;
1056
+ if (isObjectRecord(content.media) || isObjectRecord(content.entrancePhoto)) return 1;
855
1057
  const section = isObjectRecord(content._sectionStyles) ? content._sectionStyles : {};
856
1058
  return isObjectRecord((isObjectRecord(section.background) ? section.background : {}).image) ? 1 : 0;
857
1059
  }
@@ -1002,6 +1204,66 @@ function heroPhotoGround(entry) {
1002
1204
  return entry.kind === "renderable" && entry.block.kind === "block.hero" ? { paintsGround: heroPhotoPaintsGround(entry.effectiveArrangementKey ?? void 0) } : void 0;
1003
1205
  }
1004
1206
  //#endregion
1207
+ //#region ../blocks/src/system/data/readinessFacts.ts
1208
+ const countSchema = z.array(z.unknown()).transform((entries) => entries.length);
1209
+ const formSchema = z.union([z.null(), z.object({
1210
+ id: z.string(),
1211
+ slug: z.string().optional()
1212
+ })]).transform((form) => form !== null);
1213
+ const productsSchema = z.object({ products: z.array(z.object({ slug: z.string() })) });
1214
+ /** Both producers pass raw facts through the same stage admission. */
1215
+ function readinessFactsFromLoaders(stage, input) {
1216
+ const facts = {
1217
+ mailingList: loaderFactProducers.mailingList(input),
1218
+ testimonials: loaderFactProducers.testimonials(input),
1219
+ team: loaderFactProducers.team(input),
1220
+ forms: loaderFactProducers.forms(input),
1221
+ products: loaderFactProducers.products(input),
1222
+ template: loaderFactProducers.template(input)
1223
+ };
1224
+ return admitReadinessFacts(stage, {
1225
+ stage: input.prefetched?.loaderSnapshot?.stage ?? (input.previewStage === "preview" ? "draft" : "published"),
1226
+ facts
1227
+ });
1228
+ }
1229
+ const loaderFactProducers = {
1230
+ mailingList: (input) => input.mailingList === void 0 ? unavailableReadinessFact : loadedReadinessFact(input.mailingList),
1231
+ testimonials: (input) => mapFact(firstLoaderFact(input, "testimonials", "entries", countSchema), (count) => ({
1232
+ count,
1233
+ total: "unknown"
1234
+ })),
1235
+ team: (input) => firstLoaderFact(input, "team", "members", countSchema),
1236
+ forms: (input) => new Map(projections(input, "forms").flatMap(({ id, block }) => {
1237
+ const selection = chosenString(block.requests.form?.params.formSlug ?? block.requests.form?.params.formId);
1238
+ return selection ? [[selection, loaderFact(input, id, "form", formSchema)]] : [];
1239
+ })),
1240
+ products: (input) => new Map(projections(input, "products").flatMap(({ id, block }) => {
1241
+ const selection = chosenString(block.content.productSlug);
1242
+ return selection ? [[selection, mapFact(loaderFact(input, id, "products", productsSchema), ({ products }) => products.some((product) => product.slug === selection))]] : [];
1243
+ })),
1244
+ template: (input) => loadedReadinessFact(input.template)
1245
+ };
1246
+ function projections(input, need) {
1247
+ return Object.entries(input.prefetched?.loaderSnapshot?.blocks ?? {}).flatMap(([id, block]) => getBlockDefinition(block.kind)?.readiness?.needs.includes(need) ? [{
1248
+ id,
1249
+ block
1250
+ }] : []);
1251
+ }
1252
+ function firstLoaderFact(input, need, key, schema) {
1253
+ const source = projections(input, need)[0];
1254
+ return source ? loaderFact(input, source.id, key, schema) : unavailableReadinessFact;
1255
+ }
1256
+ function loaderFact(input, id, key, schema) {
1257
+ const prefetched = input.prefetched;
1258
+ if (!prefetched) return unavailableReadinessFact;
1259
+ if (!prefetched.loaderSnapshot.blocks[id]?.requests[key] || prefetched.loaderFailures[id]?.[key]) return unavailableReadinessFact;
1260
+ const parsed = schema.safeParse(prefetched.resolvedData[id]?.[key]);
1261
+ return parsed.success ? loadedReadinessFact(parsed.data) : unavailableReadinessFact;
1262
+ }
1263
+ function mapFact(fact, project) {
1264
+ return fact.kind === "Loaded" ? loadedReadinessFact(project(fact.value)) : fact;
1265
+ }
1266
+ //#endregion
1005
1267
  //#region ../blocks/src/system/blocks/offerings-preview/photoCount.ts
1006
1268
  /** Count the selected cards, without loading or selecting again. */
1007
1269
  function offeringsPreviewPhotoCount(listing) {
@@ -1062,7 +1324,7 @@ function hydrateResolvedBookingConsentValue(value, context) {
1062
1324
  const hydratedItems = value.map((item) => hydrateResolvedBookingConsentValue(item, context));
1063
1325
  return hydratedItems.every((item, index) => item === value[index]) ? value : hydratedItems;
1064
1326
  }
1065
- if (!isRecord$8(value)) return value;
1327
+ if (!isRecord$7(value)) return value;
1066
1328
  if (isBookingConsentCarrier(value)) {
1067
1329
  const agreement = hydrateValue(value.agreement, context);
1068
1330
  return agreement === value.agreement ? value : {
@@ -1082,7 +1344,7 @@ function hydrateValue(value, context) {
1082
1344
  const resolvedItems = value.map((item) => hydrateValue(item, context));
1083
1345
  return resolvedItems.every((item, index) => item === value[index]) ? value : resolvedItems;
1084
1346
  }
1085
- if (isRecord$8(value)) {
1347
+ if (isRecord$7(value)) {
1086
1348
  if (isInternalLink(value)) return hydrateInternalLink(value, context.routes);
1087
1349
  if (isPageLink(value)) return hydratePageLink(value, context);
1088
1350
  if (isEntryLink(value)) return hydrateEntryLink(value, context);
@@ -1147,7 +1409,7 @@ function hydrateEntryLink(link, context) {
1147
1409
  //#region ../blocks/src/system/manifest/resolveBlockData.ts
1148
1410
  function resolveBlockData(blockId, dataLoaders, dataContext, routes) {
1149
1411
  const raw = blockId ? dataContext?.resolvedData?.[blockId] : void 0;
1150
- if (isRecord$8(raw)) return routes ? hydrateResolvedBookingConsentLinks(raw, routes, dataContext?.pagesByIdentifier, dataContext?.entriesByIdentifier) : raw;
1412
+ if (isRecord$7(raw)) return routes ? hydrateResolvedBookingConsentLinks(raw, routes, dataContext?.pagesByIdentifier, dataContext?.entriesByIdentifier) : raw;
1151
1413
  return dataLoaders && typeof dataLoaders === "object" && Object.keys(dataLoaders).length > 0 ? {} : void 0;
1152
1414
  }
1153
1415
  //#endregion
@@ -1208,26 +1470,59 @@ function planNewsletterPreviewSubmission(placement) {
1208
1470
  * stays at the edge (decision D3), matching `buildPageRenderPlan`.
1209
1471
  */
1210
1472
  function preparePageRender(input) {
1211
- const entries = [];
1212
- const constructionFailures = [];
1213
- for (const entry of input.plan.entries) {
1214
- const prepared = prepareEntry(entry, input);
1215
- if (prepared.kind === "render-threw") constructionFailures.push(entry);
1216
- entries.push(preparedPlanEntry(entry, prepared));
1217
- }
1218
- const survivors = input.audience === "authoring" ? entries : entries.filter((candidate) => candidate.prepared.kind !== "render-threw");
1473
+ const facts = readinessFactsFromLoaders("published", {
1474
+ prefetched: input.dataContext?.prefetchedBlockData,
1475
+ previewStage: input.dataContext?.previewStage,
1476
+ mailingList: input.dataContext?.mailingList,
1477
+ template: input.dataContext?.template ?? pageTemplateFromEntry(input.dataContext?.contentEntry)
1478
+ });
1479
+ const permission = input.dataContext?.businessLocationPermission ?? decideLocationSourcePermission("business_address", input.dataContext?.businessAddressVisibility);
1480
+ const entries = input.plan.entries.filter((entry) => input.audience === "authoring" || !entryNeedsSetup(entry, facts)).filter((entry) => isPublicSourcePermitted(entry, permission) || input.audience === "authoring" && permission.kind === "hidden").map((entry) => preparedPlanEntry(entry, prepareSourceEntry(entry, input, permission)));
1481
+ const constructionFailures = entries.filter((candidate) => candidate.prepared.kind === "render-threw").map((candidate) => candidate.entry);
1482
+ const survivors = input.audience === "authoring" ? entries : entries.filter((candidate) => candidate.prepared.kind !== "render-threw" && candidate.prepared.kind !== "unresolved-location");
1219
1483
  return {
1220
1484
  entries: survivors,
1221
1485
  constructionFailures,
1222
1486
  joins: composeSurvivorJoins(input.plan, survivors, input.themeResources)
1223
1487
  };
1224
1488
  }
1489
+ /** Source availability is decided before constructing the block or its hydration props. */
1490
+ function prepareSourceEntry(entry, input, permission) {
1491
+ if (!isPublicSourcePermitted(entry, permission)) return {
1492
+ kind: "hidden-business-location",
1493
+ businessDetailsHref: input.dataContext?.authoringBusinessDetailsHref ?? null
1494
+ };
1495
+ if (entry.block.kind === "block.location-map") {
1496
+ const content = entry.renderableContent;
1497
+ const resolved = resolveLocationMapLocation({
1498
+ location: content.location,
1499
+ locationSource: typeof content.locationSource === "string" ? content.locationSource : null,
1500
+ venueId: typeof content.venueId === "string" ? content.venueId : null,
1501
+ businessAddress: input.dataContext?.businessLocation,
1502
+ venuesById: input.dataContext?.venuesById
1503
+ });
1504
+ if (resolved.kind === "unresolved") return {
1505
+ kind: "unresolved-location",
1506
+ source: resolved.source
1507
+ };
1508
+ }
1509
+ return prepareEntry(entry, input);
1510
+ }
1511
+ /** No source data, override component or wrapper is touched for a hidden map. */
1512
+ function isPublicSourcePermitted(entry, permission) {
1513
+ if (entry.block.kind !== "block.location-map") return true;
1514
+ const rawSource = entry.renderableContent.locationSource;
1515
+ return normalizeLocationMapSource(typeof rawSource === "string" ? rawSource : null) !== "business_address" || permission.kind === "permitted";
1516
+ }
1225
1517
  /**
1226
1518
  * The only place joins are composed. Plan-time omissions were already
1227
1519
  * re-pointed by the plan; construction failures are re-pointed here by the
1228
1520
  * same primitive, so `[A, B, C]` losing B still gets an A→C join. Each
1229
1521
  * survivor is then classified from its final content.
1230
1522
  */
1523
+ function entryNeedsSetup(entry, facts) {
1524
+ return entry.kind === "renderable" && entry.definition.readiness?.assess(entry.renderableContent, facts).kind === "NeedsSetup";
1525
+ }
1231
1526
  function composeSurvivorJoins(plan, survivors, themeResources) {
1232
1527
  return composePageJoins({
1233
1528
  joins: retargetJoinsAcrossOmissions({
@@ -1799,34 +2094,77 @@ function renderSystemBlockElement(input) {
1799
2094
  previewAuthoring: input.previewAuthoring
1800
2095
  });
1801
2096
  }
1802
- /**
1803
- * Memoized block section component.
1804
- *
1805
- * Custom memoization prevents render loops during editing by explicitly checking
1806
- * referential equality of all props that affect rendering. Standard React.memo
1807
- * wouldn't catch all the render triggers from the editor store.
1808
- */
1809
- const MemoBlockSection = React$1.memo(function MemoBlockSection({ themeResources, entry: preparedEntry, routeMap, audience, dataContext, registry, wrapBlock, imageResolveContext, previewAuthoring }) {
1810
- const { entry, prepared } = preparedEntry;
1811
- const block = entry.block;
1812
- const perfStart = globalThis.process?.env?.DEBUG_PERF === "1" && typeof window === "undefined" ? Date.now() : 0;
1813
- const resolvedImageResolveContext = imageResolveContext ?? getCurrentResolveImageUrlContext();
1814
- function finish(node, meta) {
1815
- if (!perfStart) return node;
1816
- const durationMs = Date.now() - perfStart;
1817
- if (durationMs < getPerfSlowBlockRenderThresholdMs()) return node;
1818
- try {
1819
- console.debug("perf.blocks.blockRender", {
1820
- blockId: block.id ?? null,
1821
- blockKind: block.kind,
1822
- durationMs,
1823
- outcome: meta?.outcome ?? "ok",
1824
- override: meta?.override ?? false,
1825
- hasResolvedData: meta?.hasResolvedData ?? false
1826
- });
1827
- } catch {}
1828
- return node;
2097
+ /** Pure diagnostic choice; the audience owner controls its presentation. */
2098
+ function preparationDiagnostic(prepared, blockKind) {
2099
+ switch (prepared.kind) {
2100
+ case "hidden-business-location": return {
2101
+ reason: {
2102
+ kind: prepared.kind,
2103
+ blockKind,
2104
+ businessDetailsHref: prepared.businessDetailsHref
2105
+ },
2106
+ outcome: "invalidPlaceholder"
2107
+ };
2108
+ case "unresolved-location": return {
2109
+ reason: {
2110
+ kind: prepared.kind,
2111
+ blockKind,
2112
+ source: prepared.source
2113
+ },
2114
+ outcome: "invalidPlaceholder"
2115
+ };
2116
+ case "editor-unpreviewable": return {
2117
+ reason: {
2118
+ kind: prepared.kind,
2119
+ blockKind
2120
+ },
2121
+ outcome: "invalidPlaceholder"
2122
+ };
2123
+ case "render-threw": return {
2124
+ reason: {
2125
+ kind: prepared.kind,
2126
+ blockKind
2127
+ },
2128
+ outcome: "exception"
2129
+ };
2130
+ case "content":
2131
+ case "plan-decided": return null;
1829
2132
  }
2133
+ }
2134
+ function blockRenderPerformanceMeta(meta) {
2135
+ return {
2136
+ outcome: meta?.outcome ?? "ok",
2137
+ override: meta?.override ?? false,
2138
+ hasResolvedData: meta?.hasResolvedData ?? false
2139
+ };
2140
+ }
2141
+ function finishBlockRender(node, block, perfStart, meta) {
2142
+ if (!perfStart) return node;
2143
+ const durationMs = Date.now() - perfStart;
2144
+ if (durationMs < getPerfSlowBlockRenderThresholdMs()) return node;
2145
+ try {
2146
+ console.debug("perf.blocks.blockRender", {
2147
+ blockId: block.id ?? null,
2148
+ blockKind: block.kind,
2149
+ durationMs,
2150
+ ...blockRenderPerformanceMeta(meta)
2151
+ });
2152
+ } catch {}
2153
+ return node;
2154
+ }
2155
+ /**
2156
+ * Memoized block section component.
2157
+ *
2158
+ * Custom memoization prevents render loops during editing by explicitly checking
2159
+ * referential equality of all props that affect rendering. Standard React.memo
2160
+ * wouldn't catch all the render triggers from the editor store.
2161
+ */
2162
+ const MemoBlockSection = React$1.memo(function MemoBlockSection({ themeResources, entry: preparedEntry, routeMap, audience, dataContext, registry, wrapBlock, imageResolveContext, previewAuthoring }) {
2163
+ const { entry, prepared } = preparedEntry;
2164
+ const block = entry.block;
2165
+ const perfStart = globalThis.process?.env?.DEBUG_PERF === "1" && typeof window === "undefined" ? Date.now() : 0;
2166
+ const resolvedImageResolveContext = imageResolveContext ?? getCurrentResolveImageUrlContext();
2167
+ const finish = (node, meta) => finishBlockRender(node, block, perfStart, meta);
1830
2168
  function wrapped(node) {
1831
2169
  return wrapBlock && block.id ? /* @__PURE__ */ jsx(Fragment$1, { children: wrapBlock(block.id, node) }) : /* @__PURE__ */ jsx(Fragment$1, { children: node });
1832
2170
  }
@@ -1842,6 +2180,11 @@ const MemoBlockSection = React$1.memo(function MemoBlockSection({ themeResources
1842
2180
  override: false
1843
2181
  });
1844
2182
  }
2183
+ const diagnostic = preparationDiagnostic(prepared, block.kind);
2184
+ if (diagnostic) return finish(wrapped(presentNotRenderableBlock(diagnostic.reason, audience)), {
2185
+ outcome: diagnostic.outcome,
2186
+ override: false
2187
+ });
1845
2188
  if (entry.kind === "override-only") {
1846
2189
  const OverrideOnlyComponent = entry.override;
1847
2190
  return finish(wrapped(/* @__PURE__ */ jsx(OverrideOnlyComponent, { ...buildBlockOverrideProps({
@@ -1858,20 +2201,7 @@ const MemoBlockSection = React$1.memo(function MemoBlockSection({ themeResources
1858
2201
  hasResolvedData: false
1859
2202
  });
1860
2203
  }
1861
- if (prepared.kind === "editor-unpreviewable") return finish(wrapped(presentNotRenderableBlock({
1862
- kind: "editor-unpreviewable",
1863
- blockKind: block.kind
1864
- }, audience)), {
1865
- outcome: "invalidPlaceholder",
1866
- override: false
1867
- });
1868
- if (prepared.kind !== "content") return finish(wrapped(presentNotRenderableBlock({
1869
- kind: "render-threw",
1870
- blockKind: block.kind
1871
- }, audience)), {
1872
- outcome: "exception",
1873
- override: false
1874
- });
2204
+ if (prepared.kind !== "content") return null;
1875
2205
  let rendered;
1876
2206
  if (OverrideComponent) rendered = /* @__PURE__ */ jsx(OverrideComponent, { ...prepared.baseProps });
1877
2207
  else {
@@ -1928,7 +2258,8 @@ function usePageDateRuntime(props) {
1928
2258
  const dateContext = React$1.useMemo(() => supplied ?? resolveDateRuntimeContext(zone), [supplied, zone]);
1929
2259
  const dataContext = React$1.useMemo(() => props.dataContext ? {
1930
2260
  ...props.dataContext,
1931
- dateContext
2261
+ dateContext,
2262
+ template: props.dataContext.template ?? pageTemplateFromEntry(props.dataContext.contentEntry)
1932
2263
  } : void 0, [props.dataContext, dateContext]);
1933
2264
  return {
1934
2265
  ...props,
@@ -1936,214 +2267,6 @@ function usePageDateRuntime(props) {
1936
2267
  };
1937
2268
  }
1938
2269
  //#endregion
1939
- //#region ../theme-core/src/ResponsiveScope.tsx
1940
- /**
1941
- * Structural responsive root for SDK/runtime chrome that opts out of CMS theme
1942
- * styling but still depends on scoped rb-* responsive utility classes.
1943
- */
1944
- function ResponsiveScope({ children, responsiveMode = DEFAULT_THEME_RESPONSIVE_MODE, className }) {
1945
- const responsiveScope = getResponsiveScopeSpec(responsiveMode);
1946
- const isContainerResponsive = responsiveScope.kind === "container";
1947
- const wrapperStyle = isContainerResponsive ? {
1948
- containerType: "inline-size",
1949
- containerName: responsiveScope.containerName
1950
- } : {};
1951
- return /* @__PURE__ */ jsxs("div", {
1952
- className: className ? `theme-scope ${className}` : "theme-scope",
1953
- style: wrapperStyle,
1954
- "data-rb-responsive-mode": responsiveScope.kind,
1955
- children: [isContainerResponsive && /* @__PURE__ */ jsx("style", {
1956
- "data-container-responsive-overrides": true,
1957
- dangerouslySetInnerHTML: { __html: escapeStyleContent(containerResponsiveThemeCss) }
1958
- }), children]
1959
- });
1960
- }
1961
- z.object({
1962
- tokens: z.record(z.string(), z.string()),
1963
- typography: z.object({
1964
- headingFamily: z.string().optional(),
1965
- bodyFamily: z.string().optional(),
1966
- headingWeight: z.number().optional(),
1967
- bodyWeight: z.number().optional()
1968
- }).optional(),
1969
- spacing: z.enum([
1970
- "comfortable",
1971
- "standard",
1972
- "dense"
1973
- ]).optional(),
1974
- corners: z.enum([
1975
- "square",
1976
- "soft",
1977
- "rounded",
1978
- "pill"
1979
- ]).optional(),
1980
- shadows: z.enum([
1981
- "none",
1982
- "low",
1983
- "medium",
1984
- "high"
1985
- ]).optional(),
1986
- components: z.object({
1987
- buttons: z.union([z.boolean(), z.object({ variants: z.array(z.enum([
1988
- "primary",
1989
- "secondary",
1990
- "outline",
1991
- "ghost"
1992
- ])).optional() })]).optional(),
1993
- cards: z.union([z.boolean(), z.object({ variants: z.array(z.enum([
1994
- "default",
1995
- "alternative",
1996
- "open",
1997
- "elevated",
1998
- "outlined"
1999
- ])).optional() })]).optional(),
2000
- inputs: z.boolean().optional()
2001
- }).optional(),
2002
- overrides: z.record(z.string(), z.string()).optional()
2003
- }).passthrough();
2004
- //#endregion
2005
- //#region ../theme-core/src/siteChromePlanning.ts
2006
- function planSiteDocument(input) {
2007
- const placement = planSiteChromePlacement(input.hasVisibleHeader ?? true ? input.headerPositioning : "static");
2008
- const topShell = planSiteTopShell(input);
2009
- const layoutMode = topShell.contentStartsUnderHeader ? "header-overlay" : "normal-flow";
2010
- return {
2011
- placement,
2012
- topShell,
2013
- layoutMode,
2014
- overlayHeaderClearance: planSiteOverlayHeaderClearance({
2015
- topShell,
2016
- layoutMode
2017
- })
2018
- };
2019
- }
2020
- function planSiteTopShell(input) {
2021
- if (input.hasVisibleHeader === false) return {
2022
- behavior: "normal-flow",
2023
- contentStartsUnderHeader: false,
2024
- requiresHeaderOffset: false
2025
- };
2026
- const isOverlayHeader = input.headerVariant === "floating" && (input.headerPositioning === "sticky" || input.headerPositioning === "fixed");
2027
- if (input.hasVisibleBanner && isOverlayHeader) return {
2028
- behavior: "banner-above-overlay-header",
2029
- contentStartsUnderHeader: true,
2030
- requiresHeaderOffset: true
2031
- };
2032
- if (input.hasVisibleBanner && (input.headerPositioning === "sticky" || input.headerPositioning === "fixed")) return {
2033
- behavior: "shared-sticky-shell",
2034
- contentStartsUnderHeader: false,
2035
- requiresHeaderOffset: false
2036
- };
2037
- return {
2038
- behavior: "normal-flow",
2039
- contentStartsUnderHeader: isOverlayHeader,
2040
- requiresHeaderOffset: false
2041
- };
2042
- }
2043
- //#endregion
2044
- //#region ../theme-core/src/siteChrome.tsx
2045
- const SITE_CHROME_CLASS_NAMES = {
2046
- standaloneStickyHeaderShell: "sticky top-0 z-40 w-full",
2047
- standaloneFixedHeaderShell: "fixed left-0 right-0 top-0 z-40 w-full",
2048
- sharedStickyTopShell: "rb-sticky rb-top-0 rb-z-40 rb-w-full",
2049
- defaultMinHeight: "rb-min-h-screen",
2050
- fullMinHeight: "rb-min-h-full",
2051
- overlayRoot: "rb-grid rb-grid-rows-main-footer rb-grid-cols-1",
2052
- normalFlowRoot: "rb-flex rb-flex-col",
2053
- overlayTopShell: "rb-row-start-1 rb-col-start-1 rb-z-40",
2054
- overlayTopShellPlacementMarker: "rb-site-document-overlay-top-shell",
2055
- overlayContent: "rb-row-start-1 rb-col-start-1",
2056
- overlayFooter: "rb-row-start-2 rb-col-start-1",
2057
- normalFlowContent: "rb-flex-1"
2058
- };
2059
- function renderSiteTopChrome({ headerNode, bannerNode = null, bannerShellBehavior = "normal-flow" }) {
2060
- switch (bannerShellBehavior) {
2061
- case "normal-flow": return /* @__PURE__ */ jsxs(Fragment$1, { children: [headerNode, bannerNode] });
2062
- case "shared-sticky-shell": return /* @__PURE__ */ jsxs("div", {
2063
- className: SITE_CHROME_CLASS_NAMES.sharedStickyTopShell,
2064
- children: [headerNode, bannerNode]
2065
- });
2066
- case "banner-above-overlay-header": return /* @__PURE__ */ jsxs(Fragment$1, { children: [bannerNode, headerNode] });
2067
- default: return assertNever$1(bannerShellBehavior);
2068
- }
2069
- }
2070
- function SiteDocumentLayout({ plan, headerNode, bannerNode = null, footerNode, children, as: Root = "div", role, className = null, minHeightClassName = SITE_CHROME_CLASS_NAMES.defaultMinHeight, contentClassName = null, style }) {
2071
- const isHeaderOverlay = plan.layoutMode === "header-overlay";
2072
- const topShell = renderSiteTopChrome({
2073
- headerNode,
2074
- bannerNode,
2075
- bannerShellBehavior: plan.topShell.behavior
2076
- });
2077
- const rootStyle = isHeaderOverlay ? {
2078
- ...style,
2079
- gridTemplateColumns: "minmax(0, 1fr)",
2080
- gridTemplateRows: "1fr auto"
2081
- } : style;
2082
- const rootClassName = joinSiteChromeClassNames(minHeightClassName, isHeaderOverlay ? SITE_CHROME_CLASS_NAMES.overlayRoot : SITE_CHROME_CLASS_NAMES.normalFlowRoot, className);
2083
- if (isHeaderOverlay) {
2084
- const contentStyle = plan.overlayHeaderClearance.kind === "opening-content" ? {
2085
- gridColumn: "1",
2086
- gridRow: "1",
2087
- [SITE_OVERLAY_HEADER_CLEARANCE_CSS_VAR]: plan.overlayHeaderClearance.cssValue
2088
- } : {
2089
- gridColumn: "1",
2090
- gridRow: "1"
2091
- };
2092
- return /* @__PURE__ */ jsxs(Root, {
2093
- role,
2094
- className: rootClassName,
2095
- style: rootStyle,
2096
- "data-site-document-layout": "",
2097
- "data-site-document-layout-mode": plan.layoutMode,
2098
- children: [
2099
- /* @__PURE__ */ jsx("div", {
2100
- className: joinSiteChromeClassNames(SITE_CHROME_CLASS_NAMES.overlayTopShell, SITE_CHROME_CLASS_NAMES.overlayTopShellPlacementMarker, plan.placement.headerRootClassName),
2101
- "data-site-document-overlay-top-shell": "",
2102
- style: {
2103
- gridColumn: "1",
2104
- gridRow: "1",
2105
- alignSelf: "start"
2106
- },
2107
- children: topShell
2108
- }),
2109
- /* @__PURE__ */ jsx("div", {
2110
- "data-site-document-overlay-content": plan.overlayHeaderClearance.kind === "opening-content" ? "true" : void 0,
2111
- className: joinSiteChromeClassNames(SITE_CHROME_CLASS_NAMES.overlayContent, contentClassName),
2112
- style: contentStyle,
2113
- children
2114
- }),
2115
- /* @__PURE__ */ jsx("div", {
2116
- className: SITE_CHROME_CLASS_NAMES.overlayFooter,
2117
- style: {
2118
- gridColumn: "1",
2119
- gridRow: "2"
2120
- },
2121
- children: footerNode
2122
- })
2123
- ]
2124
- });
2125
- }
2126
- return /* @__PURE__ */ jsxs(Root, {
2127
- role,
2128
- className: rootClassName,
2129
- style,
2130
- "data-site-document-layout": "",
2131
- "data-site-document-layout-mode": plan.layoutMode,
2132
- children: [
2133
- topShell,
2134
- /* @__PURE__ */ jsx("div", {
2135
- className: joinSiteChromeClassNames(SITE_CHROME_CLASS_NAMES.normalFlowContent, contentClassName),
2136
- children
2137
- }),
2138
- footerNode
2139
- ]
2140
- });
2141
- }
2142
- function joinSiteChromeClassNames(...values) {
2143
- const className = values.filter(Boolean).join(" ");
2144
- return className.length > 0 ? className : void 0;
2145
- }
2146
- //#endregion
2147
2270
  //#region ../blocks/src/system/data/utils.ts
2148
2271
  /**
2149
2272
  * Normalize data loaders from block definition
@@ -2156,20 +2279,6 @@ function normalizeDataLoaders(def) {
2156
2279
  }));
2157
2280
  }
2158
2281
  /**
2159
- * Normalize block content for data loading.
2160
- * Priority: draftContent > content > publishedContent
2161
- */
2162
- function normalizeContent(block) {
2163
- const source = block.draftContent ?? block.content ?? block.publishedContent ?? {};
2164
- if (!isObjectRecord(source)) return {};
2165
- if ("data" in source) {
2166
- const data = source.data;
2167
- if (isObjectRecord(data)) return data;
2168
- if (data === null || data === void 0) return {};
2169
- }
2170
- return source;
2171
- }
2172
- /**
2173
2282
  * Normalize params for API calls.
2174
2283
  * Converts supplied values to strings, preserving absent versus explicitly empty params.
2175
2284
  */
@@ -2251,7 +2360,7 @@ async function fetchLoaderData(apiClient, endpoint, params) {
2251
2360
  }));
2252
2361
  }
2253
2362
  function planLoaderPage(data, offset, seenPages) {
2254
- if (!isUnknownArray$1(data)) return {
2363
+ if (!isUnknownArray(data)) return {
2255
2364
  kind: "invalid",
2256
2365
  message: "Expected paged loader entries"
2257
2366
  };
@@ -2288,7 +2397,7 @@ async function fetchAllPages(apiClient, endpoint, params, offset, seenPages) {
2288
2397
  default: return assertNever$2(page);
2289
2398
  }
2290
2399
  }
2291
- function isUnknownArray$1(value) {
2400
+ function isUnknownArray(value) {
2292
2401
  return Array.isArray(value);
2293
2402
  }
2294
2403
  //#endregion
@@ -2435,101 +2544,109 @@ function shouldSkipResolvedLoader(input) {
2435
2544
  if (input.loader.requiredParams?.some((param) => !input.params[param]?.trim())) return true;
2436
2545
  return Boolean(input.isValidEndpoint && !input.isValidEndpoint(input.endpoint));
2437
2546
  }
2438
- /**
2439
- * Core data prefetching logic (framework-agnostic).
2440
- *
2441
- * This function is shared between frontend and SDK implementations.
2442
- * It handles:
2443
- * - Extracting data loaders from block definitions
2444
- * - Resolving loader params with block content
2445
- * - Executing server-mode loaders in parallel
2446
- * - Organizing results by block ID and loader key
2447
- *
2448
- * @example
2449
- * ```typescript
2450
- * const resolved = await prefetchBlockData(page, context, {
2451
- * apiClient: async ({ endpoint, params }) => {
2452
- * return await myApiClient({ endpoint, params });
2453
- * },
2454
- * isValidEndpoint: (endpoint) => endpoint in API_ENDPOINTS,
2455
- * });
2456
- * ```
2457
- */
2458
- async function prefetchBlockData(page, context, options) {
2459
- return (await prefetchBlockDataWithFailures(page, context, options)).resolvedData;
2460
- }
2461
2547
  async function prefetchBlockDataWithFailures(page, context, options) {
2462
- const { apiClient, isValidEndpoint, onError, getCustomBlockLoaders, getBlockDefinition: getBlockDefinition$1 = getBlockDefinition, resolveParamsBindings: resolveParamsBindings$1 = resolveParamsBindings, shouldLoad } = options;
2463
- const { now, dateContext } = admitLoaderDateRuntime(context);
2464
- const results = {};
2465
- const loaderFailures = {};
2466
- const tasks = [];
2467
- for (const block of page.blocks) {
2468
- const blockId = block.id;
2469
- if (!blockId) continue;
2470
- let loaders;
2471
- const def = getBlockDefinition$1(block.kind);
2472
- if (def) loaders = normalizeDataLoaders(def);
2473
- else if (getCustomBlockLoaders) {
2474
- const customLoaders = getCustomBlockLoaders(block.kind);
2475
- loaders = customLoaders ? Object.entries(customLoaders).map(([key, loader]) => ({
2476
- key,
2477
- loader
2478
- })) : [];
2479
- } else loaders = [];
2480
- loaders = projectDataLoaders(loaders, shouldLoad, blockId, block.kind);
2481
- if (loaders.length === 0) continue;
2482
- const root = {
2483
- ...context.root ?? {},
2548
+ const runtime = admitLoaderDateRuntime(context);
2549
+ const blocks = page.blocks.flatMap((block) => block.id ? [planBlockRequests(block, block.id, context, options, runtime)] : []);
2550
+ return {
2551
+ ...projectLoaderOutcomes(blocks, await Promise.all(blocks.flatMap((block) => block.requests.map((request) => executeLoaderRequest(request, options))))),
2552
+ loaderSnapshot: {
2553
+ stage: context.previewStage === "preview" ? "draft" : "published",
2554
+ blocks: Object.fromEntries(blocks.map((block) => [block.id, {
2555
+ kind: block.kind,
2556
+ content: block.content,
2557
+ requests: Object.fromEntries(block.requests.map(({ key, endpoint, params }) => [key, {
2558
+ endpoint,
2559
+ params
2560
+ }]))
2561
+ }]))
2562
+ }
2563
+ };
2564
+ }
2565
+ function planBlockRequests(block, id, context, options, runtime) {
2566
+ const definition = (options.getBlockDefinition ?? getBlockDefinition)(block.kind);
2567
+ const loaders = definition ? normalizeDataLoaders(definition) : customLoaders(block.kind, options);
2568
+ const vm = {
2569
+ content: plannedLoaderContent(block, definition, context),
2570
+ $root: {
2571
+ ...context.root,
2484
2572
  siteId: context.siteId,
2485
2573
  pageId: context.pageId,
2486
2574
  previewStage: context.previewStage
2575
+ }
2576
+ };
2577
+ const requests = projectDataLoaders(loaders, options.shouldLoad, id, block.kind).flatMap((entry) => {
2578
+ const request = planLoaderRequest(entry, block, id, vm, options, runtime);
2579
+ return request ? [request] : [];
2580
+ });
2581
+ return {
2582
+ id,
2583
+ kind: block.kind,
2584
+ content: selectBlockContent(block, context.previewStage),
2585
+ requests
2586
+ };
2587
+ }
2588
+ function customLoaders(kind, options) {
2589
+ return Object.entries(options.getCustomBlockLoaders?.(kind) ?? {}).map(([key, loader]) => ({
2590
+ key,
2591
+ loader
2592
+ }));
2593
+ }
2594
+ function planLoaderRequest({ key, loader }, block, blockId, vm, options, runtime) {
2595
+ if (loader.mode === "client") return null;
2596
+ const resolve = options.resolveParamsBindings ?? resolveParamsBindings;
2597
+ const coordinates = { blockKind: block.kind };
2598
+ if (loader.when !== void 0 && resolve(loader.when, vm, coordinates, runtime.dateContext, runtime.now) !== true) return null;
2599
+ const params = normalizeParams(resolve(loader.params, vm, coordinates, runtime.dateContext, runtime.now));
2600
+ if (shouldSkipResolvedLoader({
2601
+ loader,
2602
+ endpoint: loader.endpoint,
2603
+ params,
2604
+ isValidEndpoint: options.isValidEndpoint
2605
+ })) return null;
2606
+ return {
2607
+ blockId,
2608
+ blockKind: block.kind,
2609
+ key,
2610
+ endpoint: loader.endpoint,
2611
+ params
2612
+ };
2613
+ }
2614
+ async function executeLoaderRequest(request, options) {
2615
+ try {
2616
+ return {
2617
+ kind: "loaded",
2618
+ request,
2619
+ data: await fetchLoaderData(options.apiClient, request.endpoint, request.params)
2487
2620
  };
2488
- const vm = {
2489
- content: plannedLoaderContent(block, def, context),
2490
- $root: root
2621
+ } catch (error) {
2622
+ options.onError?.(error, {
2623
+ block: request.blockKind,
2624
+ loader: request.key
2625
+ });
2626
+ return {
2627
+ kind: "failed",
2628
+ request
2491
2629
  };
2492
- for (const { key, loader } of loaders) {
2493
- if (loader.mode === "client") continue;
2494
- if (typeof loader.when !== "undefined") {
2495
- if (resolveParamsBindings$1(loader.when, vm, { blockKind: block.kind }, dateContext, now) !== true) continue;
2496
- }
2497
- const params = normalizeParams(resolveParamsBindings$1(loader.params, vm, { blockKind: block.kind }, dateContext, now));
2498
- const endpoint = loader.endpoint;
2499
- if (shouldSkipResolvedLoader({
2500
- loader,
2501
- endpoint,
2502
- params,
2503
- isValidEndpoint
2504
- })) continue;
2505
- tasks.push((async () => {
2506
- try {
2507
- const data = await fetchLoaderData(apiClient, endpoint, params);
2508
- const blockResults = results[blockId] ?? (results[blockId] = {});
2509
- blockResults[key] = data;
2510
- } catch (error) {
2511
- const blockFailures = loaderFailures[blockId] ?? (loaderFailures[blockId] = {});
2512
- blockFailures[key] = {
2513
- endpoint,
2514
- params
2515
- };
2516
- if (onError) onError(error, {
2517
- block: block.kind,
2518
- loader: key
2519
- });
2520
- }
2521
- })());
2522
- }
2523
2630
  }
2524
- if (tasks.length > 0) await Promise.all(tasks);
2631
+ }
2632
+ function projectLoaderOutcomes(blocks, outcomes) {
2525
2633
  return {
2526
- resolvedData: results,
2527
- loaderFailures
2634
+ resolvedData: Object.fromEntries(blocks.flatMap((block) => {
2635
+ const values = outcomes.flatMap((outcome) => outcome.request.blockId === block.id && outcome.kind === "loaded" ? [[outcome.request.key, outcome.data]] : []);
2636
+ return values.length ? [[block.id, Object.fromEntries(values)]] : [];
2637
+ })),
2638
+ loaderFailures: Object.fromEntries(blocks.flatMap((block) => {
2639
+ const values = outcomes.flatMap((outcome) => outcome.request.blockId === block.id && outcome.kind === "failed" ? [[outcome.request.key, {
2640
+ endpoint: outcome.request.endpoint,
2641
+ params: outcome.request.params
2642
+ }]] : []);
2643
+ return values.length ? [[block.id, Object.fromEntries(values)]] : [];
2644
+ }))
2528
2645
  };
2529
2646
  }
2530
2647
  /** Prefetch executes the render-plan content stage before resolving loader bindings. */
2531
2648
  function plannedLoaderContent(block, definition, context) {
2532
- const content = normalizeContent(block);
2649
+ const content = selectBlockContent(block, context.previewStage);
2533
2650
  if (!definition || content._arrangementLooks === void 0) return content;
2534
2651
  return planArrangementContent(block.kind, definition.manifest, content, context.previewStage === "preview" ? "authoring" : "public");
2535
2652
  }
@@ -2639,7 +2756,7 @@ function ensureSiteId(params, context) {
2639
2756
  * Map the embed block's author-facing order values onto the public
2640
2757
  * `listPublishedEntries` `order` contract enum.
2641
2758
  *
2642
- * `'order'` ("Custom order field") is the MANUAL-ORDERING axis: it means "render
2759
+ * `'order'` ("Your own order") is the MANUAL-ORDERING axis: it means "render
2643
2760
  * entries in the content type's author-defined order". It intentionally maps to
2644
2761
  * `undefined` (endpoint default) here rather than a fixed `manual.asc`, because
2645
2762
  * this transform is schema-blind — it can't tell whether the embedded content
@@ -2749,138 +2866,13 @@ function planOpeningForegroundContent(block, audience) {
2749
2866
  };
2750
2867
  }
2751
2868
  //#endregion
2752
- //#region ../ui/src/resizable-split-pane.tsx
2869
+ //#region ../db/src/schemas/forms.ts
2753
2870
  /**
2754
- * Resizable split pane component
2871
+ * Form Settings Schemas
2755
2872
  *
2756
- * Two-panel layout with draggable resize handle.
2757
- * On mobile (<1024px), switches to tabs.
2758
- */
2759
- function ResizableSplitPane({ left, right, defaultSplit = 40, minLeftWidth = 300, minRightWidth = 400, leftLabel = "Editor", rightLabel = "Preview", defaultTab = "left", className, leftPaneClassName, rightPaneClassName, onSplitChange, splitPercent: controlledSplitPercent }) {
2760
- const [internalSplitPercent, setInternalSplitPercent] = useState(defaultSplit);
2761
- const [isDragging, setIsDragging] = useState(false);
2762
- const [isMobile, setIsMobile] = useState(false);
2763
- const containerRef = useRef(null);
2764
- const splitPercent = controlledSplitPercent ?? internalSplitPercent;
2765
- const setSplitPercent = useCallback((value) => {
2766
- setInternalSplitPercent(value);
2767
- onSplitChange?.(value);
2768
- }, [onSplitChange]);
2769
- useEffect(() => {
2770
- const checkMobile = () => {
2771
- setIsMobile(window.innerWidth < 1024);
2772
- };
2773
- checkMobile();
2774
- window.addEventListener("resize", checkMobile);
2775
- return () => window.removeEventListener("resize", checkMobile);
2776
- }, []);
2777
- const handleMouseDown = useCallback((e) => {
2778
- e.preventDefault();
2779
- setIsDragging(true);
2780
- }, []);
2781
- const handleMouseMove = useCallback((e) => {
2782
- if (!isDragging || !containerRef.current) return;
2783
- const containerRect = containerRef.current.getBoundingClientRect();
2784
- const containerWidth = containerRect.width;
2785
- let newSplitPercent = (e.clientX - containerRect.left) / containerWidth * 100;
2786
- const minLeftPercent = minLeftWidth / containerWidth * 100;
2787
- const minRightPercent = minRightWidth / containerWidth * 100;
2788
- newSplitPercent = Math.max(minLeftPercent, newSplitPercent);
2789
- newSplitPercent = Math.min(100 - minRightPercent, newSplitPercent);
2790
- setSplitPercent(newSplitPercent);
2791
- }, [
2792
- isDragging,
2793
- minLeftWidth,
2794
- minRightWidth,
2795
- setSplitPercent
2796
- ]);
2797
- const handleMouseUp = useCallback(() => {
2798
- setIsDragging(false);
2799
- }, []);
2800
- useEffect(() => {
2801
- if (isDragging) {
2802
- document.addEventListener("mousemove", handleMouseMove);
2803
- document.addEventListener("mouseup", handleMouseUp);
2804
- return () => {
2805
- document.removeEventListener("mousemove", handleMouseMove);
2806
- document.removeEventListener("mouseup", handleMouseUp);
2807
- };
2808
- }
2809
- }, [
2810
- isDragging,
2811
- handleMouseMove,
2812
- handleMouseUp
2813
- ]);
2814
- if (isMobile) return /* @__PURE__ */ jsx("div", {
2815
- className: cn("h-full min-h-0 overflow-hidden", className),
2816
- children: /* @__PURE__ */ jsxs(Tabs, {
2817
- defaultValue: defaultTab,
2818
- className: "flex h-full flex-col",
2819
- children: [
2820
- /* @__PURE__ */ jsxs(TabsList, {
2821
- className: "w-full justify-start rounded-none border-b",
2822
- children: [/* @__PURE__ */ jsx(TabsTrigger, {
2823
- value: "left",
2824
- className: "flex-1",
2825
- children: leftLabel
2826
- }), /* @__PURE__ */ jsx(TabsTrigger, {
2827
- value: "right",
2828
- className: "flex-1",
2829
- children: rightLabel
2830
- })]
2831
- }),
2832
- /* @__PURE__ */ jsx(TabsContent, {
2833
- value: "left",
2834
- className: "flex-1 overflow-auto min-h-0",
2835
- children: left
2836
- }),
2837
- /* @__PURE__ */ jsx(TabsContent, {
2838
- value: "right",
2839
- className: "flex-1 overflow-auto min-h-0",
2840
- children: right
2841
- })
2842
- ]
2843
- })
2844
- });
2845
- return /* @__PURE__ */ jsxs("div", {
2846
- ref: containerRef,
2847
- "data-testid": "resizable-split-pane",
2848
- className: cn("relative flex h-full min-h-0 overflow-hidden", className),
2849
- style: { cursor: isDragging ? "col-resize" : void 0 },
2850
- children: [
2851
- /* @__PURE__ */ jsx("div", {
2852
- className: cn("h-full min-h-0 overflow-auto", leftPaneClassName),
2853
- style: { width: `${splitPercent}%` },
2854
- children: left
2855
- }),
2856
- /* @__PURE__ */ jsx("div", {
2857
- "data-testid": "resizable-split-pane-handle",
2858
- role: "separator",
2859
- "aria-orientation": "vertical",
2860
- className: cn("group relative flex w-1.5 flex-shrink-0 cursor-col-resize items-center justify-center border-x bg-border/30 transition-colors hover:bg-border", isDragging && "bg-primary"),
2861
- onMouseDown: handleMouseDown,
2862
- children: /* @__PURE__ */ jsx("div", {
2863
- className: "absolute inset-y-0 flex items-center",
2864
- children: /* @__PURE__ */ jsx(GripVertical, { className: cn("h-3 w-3 text-muted-foreground transition-colors group-hover:text-foreground", isDragging && "text-primary-foreground") })
2865
- })
2866
- }),
2867
- /* @__PURE__ */ jsx("div", {
2868
- className: cn("relative z-10 h-full min-h-0 overflow-auto", rightPaneClassName),
2869
- style: { width: `${100 - splitPercent}%` },
2870
- children: right
2871
- }),
2872
- isDragging && /* @__PURE__ */ jsx("div", { className: "pointer-events-none fixed inset-0 z-50 cursor-col-resize" })
2873
- ]
2874
- });
2875
- }
2876
- //#endregion
2877
- //#region ../db/src/schemas/forms.ts
2878
- /**
2879
- * Form Settings Schemas
2880
- *
2881
- * Zod schemas for validating form settings JSON stored in the database.
2882
- * These schemas are the single source of truth for form settings validation
2883
- * across API routes, type guards, and client-side form submission.
2873
+ * Zod schemas for validating form settings JSON stored in the database.
2874
+ * These schemas are the single source of truth for form settings validation
2875
+ * across API routes, type guards, and client-side form submission.
2884
2876
  */
2885
2877
  const sensitiveCollectionModeSchema = z.enum(["standard", "sensitive"]).default("standard");
2886
2878
  const sensitiveCollectionConfirmationVersionSchema = z.union([z.literal(1), z.null()]);
@@ -3403,7 +3395,7 @@ function parseRelativeStoragePath(value) {
3403
3395
  if (!validated.ok) return validated;
3404
3396
  return ok$1(brandRelativeStoragePath(validated.value));
3405
3397
  }
3406
- function isRecord$6(value) {
3398
+ function isRecord$5(value) {
3407
3399
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
3408
3400
  }
3409
3401
  function parseFileKindJson(value) {
@@ -3624,7 +3616,7 @@ function parseEntitledCustomerAccessScopeJson(value) {
3624
3616
  }
3625
3617
  }
3626
3618
  function requireRecord(value) {
3627
- if (!isRecord$6(value)) return err("expected-object");
3619
+ if (!isRecord$5(value)) return err("expected-object");
3628
3620
  return ok(value);
3629
3621
  }
3630
3622
  function requireString(value) {
@@ -4014,7 +4006,7 @@ const DEFAULT_MESSAGES = {
4014
4006
  update: "Failed to update media asset",
4015
4007
  delete: "Failed to delete media asset"
4016
4008
  };
4017
- function isRecord$5(value) {
4009
+ function isRecord$4(value) {
4018
4010
  return typeof value === "object" && value !== null;
4019
4011
  }
4020
4012
  const normalizeLabels = (labels) => labels !== void 0 && labels.length > 0 ? labels.map((label) => label.trim()).filter((label) => label.length > 0).join(",") : void 0;
@@ -4048,7 +4040,7 @@ const filterUpdatePayload = (input) => {
4048
4040
  return payload;
4049
4041
  };
4050
4042
  const extractErrorMessage = (body) => {
4051
- if (!isRecord$5(body)) return typeof body === "string" && body.trim().length > 0 ? body : null;
4043
+ if (!isRecord$4(body)) return typeof body === "string" && body.trim().length > 0 ? body : null;
4052
4044
  for (const key of [
4053
4045
  "error",
4054
4046
  "message",
@@ -4061,11 +4053,11 @@ const extractErrorMessage = (body) => {
4061
4053
  const details = body.details;
4062
4054
  if (Array.isArray(details)) for (const entry of details) {
4063
4055
  if (typeof entry === "string" && entry.trim().length > 0) return entry;
4064
- if (isRecord$5(entry) && typeof entry.message === "string" && entry.message.trim().length > 0) return entry.message;
4056
+ if (isRecord$4(entry) && typeof entry.message === "string" && entry.message.trim().length > 0) return entry.message;
4065
4057
  }
4066
4058
  const errors = body.errors;
4067
4059
  if (Array.isArray(errors)) {
4068
- for (const entry of errors) if (isRecord$5(entry) && typeof entry.message === "string" && entry.message.trim().length > 0) return entry.message;
4060
+ for (const entry of errors) if (isRecord$4(entry) && typeof entry.message === "string" && entry.message.trim().length > 0) return entry.message;
4069
4061
  }
4070
4062
  return null;
4071
4063
  };
@@ -4529,7 +4521,7 @@ function overlayValue(value, overlays) {
4529
4521
  });
4530
4522
  return changed ? next : value;
4531
4523
  }
4532
- if (!isRecord$4(value)) return value;
4524
+ if (!isRecord$3(value)) return value;
4533
4525
  const match = matchingOverlay(value, overlays);
4534
4526
  if (match) return overlaidEntry(value, match.meta, match.overlay);
4535
4527
  let changed = false;
@@ -4588,7 +4580,7 @@ function renderedLinkedRevisions(dataContext) {
4588
4580
  }
4589
4581
  function linkedEntryOccurrences(value) {
4590
4582
  if (Array.isArray(value)) return value.flatMap(linkedEntryOccurrences);
4591
- if (!isRecord$4(value)) return [];
4583
+ if (!isRecord$3(value)) return [];
4592
4584
  const meta = parseLinkedEntryMeta(value[LINKED_CONTENT_ENTRY_META_KEY]);
4593
4585
  const nested = Object.entries(value).filter(([key]) => key !== LINKED_CONTENT_ENTRY_META_KEY).flatMap(([, child]) => linkedEntryOccurrences(child));
4594
4586
  return meta ? [meta, ...nested] : nested;
@@ -4624,7 +4616,7 @@ function resolveOverlayTitle(content, meta) {
4624
4616
  function parseLinkedEntryMeta(value) {
4625
4617
  return getLinkedContentEntryMeta({ [LINKED_CONTENT_ENTRY_META_KEY]: value });
4626
4618
  }
4627
- function isRecord$4(value) {
4619
+ function isRecord$3(value) {
4628
4620
  return typeof value === "object" && value !== null && !Array.isArray(value);
4629
4621
  }
4630
4622
  function overlayRevision(overlay, meta) {
@@ -4800,8 +4792,15 @@ function previewValues(entryData, pageMetadata) {
4800
4792
  metadataRevision: revision.metadata
4801
4793
  };
4802
4794
  }
4803
- function PreviewEntryControllerProvider({ children, businessTimeZone, siteId, pageId, pageNodeType = "page", routeId: providedRouteId, entryData, contentTypeSchema, initialStatus = "draft", initialBlocks, blockFieldExtensions, pageMetadata, apiClient, subscribeToLeaseChanges, onLeaseGranted, liveDrafts }) {
4804
- const { isEditingMode, requestedEditingMode } = useEditor();
4795
+ /** Loading may render the document, but grants neither lease participation nor shortcuts. */
4796
+ function previewAuthoringMode(mode, admitted = true) {
4797
+ return {
4798
+ requestedEditingMode: admitted && mode.requestedEditingMode,
4799
+ historyShortcutsEnabled: admitted && mode.isEditingMode
4800
+ };
4801
+ }
4802
+ function PreviewEntryControllerProvider({ children, businessTimeZone, siteId, pageId, pageNodeType = "page", routeId: providedRouteId, entryData, contentTypeSchema, initialStatus = "draft", initialBlocks, blockFieldExtensions, pageMetadata, initialPageJournalState, authoringAdmitted, apiClient, subscribeToLeaseChanges, onLeaseGranted, liveDrafts }) {
4803
+ const authoring = previewAuthoringMode(useEditor(), authoringAdmitted);
4805
4804
  const previewToken = usePreviewToken();
4806
4805
  const schema = contentTypeSchema ?? PAGE_CONTENT_TYPE_SCHEMA;
4807
4806
  const initialEntry = useMemo(() => initialPreviewEntry(entryData, pageMetadata, pageId, schema), [
@@ -4812,17 +4811,14 @@ function PreviewEntryControllerProvider({ children, businessTimeZone, siteId, pa
4812
4811
  ]);
4813
4812
  const normalizedInitialBlocks = useMemo(() => (initialBlocks ?? []).map(toEditorInitialBlock), [initialBlocks]);
4814
4813
  const entity = previewEntity(pageId, pageNodeType, entryData, providedRouteId);
4815
- const leaseScope = requiredPreviewLeaseScope({
4816
- nodeType: previewLeaseNodeType(pageNodeType, entryData),
4817
- nodeId: entity.id
4818
- });
4814
+ const leaseScope = previewLeaseScope(entity.id, pageNodeType, entryData);
4819
4815
  const values = previewValues(entryData, pageMetadata);
4820
4816
  const rendered = /* @__PURE__ */ jsx(RefreshBaselinesForRender, {
4821
4817
  liveDrafts,
4822
4818
  children
4823
4819
  });
4824
4820
  const editLease = usePreviewLeaseParticipation({
4825
- requestedEditingMode,
4821
+ requestedEditingMode: authoring.requestedEditingMode,
4826
4822
  siteId,
4827
4823
  pageId,
4828
4824
  pageNodeType,
@@ -4849,10 +4845,11 @@ function PreviewEntryControllerProvider({ children, businessTimeZone, siteId, pa
4849
4845
  entityLabel: entity.label,
4850
4846
  initialEntry,
4851
4847
  initialMetadataRevision: values.metadataRevision,
4848
+ initialPageJournalState,
4852
4849
  initialBlocks: pageNodeType === "page_surface" ? void 0 : normalizedInitialBlocks,
4853
4850
  blockFieldExtensions,
4854
- historyShortcutsEnabled: isEditingMode,
4855
- liveDrafts: previewLiveDraftsConfig(liveDrafts, previewToken, siteId, leaseScope)
4851
+ historyShortcutsEnabled: authoring.historyShortcutsEnabled,
4852
+ liveDrafts: previewLiveDraftsForScope(liveDrafts, previewToken, siteId, leaseScope)
4856
4853
  };
4857
4854
  if (pageNodeType === "page_surface" && pageId && pageMetadata) {
4858
4855
  if (values.kind !== "content") throw new Error("Preview draft is missing its editor revision");
@@ -4878,10 +4875,23 @@ function PreviewEntryControllerProvider({ children, businessTimeZone, siteId, pa
4878
4875
  children: rendered
4879
4876
  });
4880
4877
  }
4878
+ function previewLeaseScope(id, pageNodeType, entryData) {
4879
+ return id ? requiredPreviewLeaseScope({
4880
+ nodeType: previewLeaseNodeType(pageNodeType, entryData),
4881
+ nodeId: id
4882
+ }) : null;
4883
+ }
4884
+ function previewLiveDraftsForScope(liveDrafts, token, siteId, scope) {
4885
+ return scope ? previewLiveDraftsConfig(liveDrafts, token, siteId, scope) : null;
4886
+ }
4881
4887
  /** Lease participation and its server-read invalidation share the same preview identity. */
4882
4888
  function usePreviewLeaseParticipation({ requestedEditingMode, siteId, pageId, pageNodeType, leaseScope, subscribeToLeaseChanges, onLeaseGranted }) {
4883
4889
  const queryClient = useQueryClient();
4884
- return requestedEditingMode ? {
4890
+ if (requestedEditingMode && !leaseScope) return {
4891
+ kind: "exempt",
4892
+ reason: "sdk"
4893
+ };
4894
+ return requestedEditingMode && leaseScope ? {
4885
4895
  siteId,
4886
4896
  scope: leaseScope,
4887
4897
  subscribeToLeaseChanges,
@@ -5060,7 +5070,7 @@ function PreviewEditingModePersistence({ siteId }) {
5060
5070
  const key = `riverbank:preview-mode:${siteId}`;
5061
5071
  useEffect(() => {
5062
5072
  const restore = () => setEditingMode(readMode(key));
5063
- restore();
5073
+ setEditingMode(Boolean(new URLSearchParams(window.location.search).get("preview_block")) || readMode(key));
5064
5074
  setRestored(true);
5065
5075
  window.addEventListener("pageshow", restore);
5066
5076
  return () => window.removeEventListener("pageshow", restore);
@@ -5369,25 +5379,25 @@ const INITIAL_ONBOARDING_CONFIRMATION_STATE = {
5369
5379
  resendFeedback: null,
5370
5380
  statusLoadFailed: false
5371
5381
  };
5372
- function isRecord$3(value) {
5382
+ function isRecord$2(value) {
5373
5383
  return value !== null && typeof value === "object";
5374
5384
  }
5375
5385
  function getErrorMessageFromEnvelope(payload, fallback) {
5376
- const error = isRecord$3(payload) ? payload.error : null;
5377
- const message = isRecord$3(error) ? error.message : null;
5386
+ const error = isRecord$2(payload) ? payload.error : null;
5387
+ const message = isRecord$2(error) ? error.message : null;
5378
5388
  return typeof message === "string" && message.trim().length > 0 ? message : fallback;
5379
5389
  }
5380
5390
  function isLaunchReadiness(value) {
5381
- return isRecord$3(value) && Array.isArray(value.requirements) && typeof value.pendingRequiredCount === "number" && typeof value.pendingRecommendedCount === "number" && typeof value.pendingOptionalCount === "number" && isRecord$3(value.goLiveDecision) && (value.goLiveDecision.kind === "allowed" || value.goLiveDecision.kind === "blocked");
5391
+ return isRecord$2(value) && Array.isArray(value.requirements) && typeof value.pendingRequiredCount === "number" && typeof value.pendingRecommendedCount === "number" && typeof value.pendingOptionalCount === "number" && isRecord$2(value.goLiveDecision) && (value.goLiveDecision.kind === "allowed" || value.goLiveDecision.kind === "blocked");
5382
5392
  }
5383
5393
  function isOnboardingPreviewStatusResponse(value) {
5384
- return isRecord$3(value) && typeof value.dashboardUnlocked === "boolean" && typeof value.requiresEmailConfirmation === "boolean" && isLaunchReadiness(value.launchReadiness);
5394
+ return isRecord$2(value) && typeof value.dashboardUnlocked === "boolean" && typeof value.requiresEmailConfirmation === "boolean" && isLaunchReadiness(value.launchReadiness);
5385
5395
  }
5386
5396
  function isResendOnboardingPreviewConfirmationResponse(value) {
5387
- return isRecord$3(value) && (value.result === "resent" || value.result === "already_confirmed") && typeof value.dashboardUnlocked === "boolean" && typeof value.requiresEmailConfirmation === "boolean" && isLaunchReadiness(value.launchReadiness);
5397
+ return isRecord$2(value) && (value.result === "resent" || value.result === "already_confirmed") && typeof value.dashboardUnlocked === "boolean" && typeof value.requiresEmailConfirmation === "boolean" && isLaunchReadiness(value.launchReadiness);
5388
5398
  }
5389
5399
  function getSuccessData(payload, isData) {
5390
- if (!isRecord$3(payload) || payload.success !== true || !isData(payload.data)) return null;
5400
+ if (!isRecord$2(payload) || payload.success !== true || !isData(payload.data)) return null;
5391
5401
  return payload.data;
5392
5402
  }
5393
5403
  function useOnboardingConfirmationCheck(input) {
@@ -5784,12 +5794,24 @@ function PreviewAccessBanners({ dashboardBaseUrl, surfaceId, isEntry, pageNodeTy
5784
5794
  const { requestedEditingMode, setEditingMode } = useEditor();
5785
5795
  const showDiscardedNotice = useEditorUiStore((editor) => canEditorWrite(editor.editability) && editor.leaseDiscardedChanges);
5786
5796
  const thing = previewLeaseThing(isEntry, pageNodeType);
5797
+ const admissionNotice = useEditorUiStore((editor) => editorAdmissionNotice(editor.editAdmission));
5787
5798
  const active = state === "ok";
5788
5799
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
5789
5800
  /* @__PURE__ */ jsx(PreviewAuthBanner, {
5790
5801
  dashboardBaseUrl,
5791
5802
  surfaceId
5792
5803
  }),
5804
+ active && admissionNotice ? /* @__PURE__ */ jsx(FixedBottomSurface, {
5805
+ variant: "light",
5806
+ width: "centered",
5807
+ offsetCssVar: "--builder-editor-chrome-offset",
5808
+ reserveOffsetCssVar: "--builder-preview-banner-offset",
5809
+ children: /* @__PURE__ */ jsx(Callout, {
5810
+ tone: "info",
5811
+ role: "status",
5812
+ children: /* @__PURE__ */ jsx(CalloutDescription, { children: admissionNotice })
5813
+ })
5814
+ }) : null,
5793
5815
  active && requestedEditingMode ? /* @__PURE__ */ jsx(EditLeaseModal, {
5794
5816
  thing,
5795
5817
  onKeepViewing: () => setEditingMode(false)
@@ -5804,23 +5826,6 @@ function PreviewAccessBanners({ dashboardBaseUrl, surfaceId, isEntry, pageNodeTy
5804
5826
  ] });
5805
5827
  }
5806
5828
  //#endregion
5807
- //#region ../preview-next/src/client/preview/sidebarTabPreference.ts
5808
- const STORAGE_KEY = "preview-sidebar-tab";
5809
- function getPreviewSidebarTab() {
5810
- if (typeof window === "undefined") return "editor";
5811
- try {
5812
- return resolvePreviewSidebarTab(window.localStorage.getItem(STORAGE_KEY) === "assistant" ? "assistant" : "editor");
5813
- } catch {
5814
- return "editor";
5815
- }
5816
- }
5817
- function setPreviewSidebarTab(tab) {
5818
- if (typeof window === "undefined") return;
5819
- try {
5820
- window.localStorage.setItem(STORAGE_KEY, resolvePreviewSidebarTab(tab));
5821
- } catch {}
5822
- }
5823
- //#endregion
5824
5829
  //#region ../preview-next/src/client/preview/previewThemeRoles.ts
5825
5830
  /**
5826
5831
  * Splits the preview theme inputs into their two distinct roles so the
@@ -5832,41 +5837,64 @@ function resolvePreviewThemeRoles(input) {
5832
5837
  documentTheme: input.renderTheme ?? input.theme
5833
5838
  };
5834
5839
  }
5835
- z.object({
5836
- palette: paletteColorsSchema,
5837
- paletteMode: paletteModeSchema,
5838
- typography: z.object({
5839
- headingFamily: z.string().trim().min(1),
5840
- bodyFamily: z.string().trim().min(1)
5841
- }).strict(),
5842
- corners
5843
- }).strict();
5844
5840
  const DEFAULT_PREVIEW_CHROME_FLOATING_PLACEMENT = Object.freeze({
5845
5841
  kind: "anchor-top-right",
5846
5842
  topPx: 8,
5847
- rightPx: 8
5843
+ rightPx: 16
5848
5844
  });
5845
+ /** Set by the preview shell on the wrapper around the site's banner. */
5846
+ const PREVIEW_SITE_BANNER_ATTRIBUTE = "data-preview-site-banner";
5847
+ /** Room a rich-text format bar needs above its field: its own height plus the gap. */
5848
+ const FLOATING_BAR_ROOM_PX = 56;
5849
+ /**
5850
+ * A format bar sits above its field while it fits below the site's top chrome,
5851
+ * and drops under the field once it would cover the header or a banner.
5852
+ */
5853
+ function planFloatingBarSide(input) {
5854
+ const chromeBottomPx = input.headerClearance.kind === "overlay" ? input.headerClearance.px : 0;
5855
+ return input.anchorTopPx - chromeBottomPx >= FLOATING_BAR_ROOM_PX ? "above" : "below";
5856
+ }
5849
5857
  function headerClearanceFromPx(px) {
5850
5858
  return Number.isFinite(px) && px > 0 ? {
5851
5859
  kind: "overlay",
5852
5860
  px: Math.ceil(px)
5853
5861
  } : { kind: "none" };
5854
5862
  }
5863
+ /** Sub-pixel rounding between a header and the banner stacked under it. */
5864
+ const SITE_CHROME_STACK_TOLERANCE_PX = 2;
5865
+ /**
5866
+ * How far down the viewport the site's top chrome reaches: the header plus any
5867
+ * announcement banner stacked against it, above or below. A banner elsewhere on
5868
+ * the page doesn't count, and nor does chrome scrolled out of view. Measured
5869
+ * live, so a normal-flow header counts only while it's on screen, when no block
5870
+ * sits under it anyway.
5871
+ */
5872
+ function siteTopChromeClearance(input) {
5873
+ if (!input.header || !isVisibleChromeBox(input.header)) return { kind: "none" };
5874
+ return headerClearanceFromPx(input.banners.filter(isVisibleChromeBox).slice().sort((left, right) => left.top - right.top).reduce((edges, banner) => banner.top <= edges.bottom + SITE_CHROME_STACK_TOLERANCE_PX && banner.bottom >= edges.top - SITE_CHROME_STACK_TOLERANCE_PX ? {
5875
+ top: Math.min(edges.top, banner.top),
5876
+ bottom: Math.max(edges.bottom, banner.bottom)
5877
+ } : edges, input.header).bottom);
5878
+ }
5879
+ function isVisibleChromeBox(box) {
5880
+ return Number.isFinite(box.top) && Number.isFinite(box.bottom) && box.bottom > box.top && box.bottom > 0;
5881
+ }
5855
5882
  /**
5856
- * Every block's controls stay below a sticky or fixed site header, so they
5857
- * never sit over the header's own buttons.
5883
+ * Every block's controls stay below the site's top chrome (its header and any
5884
+ * banner stacked with it), so they never sit over the chrome's own buttons and
5885
+ * slide down inside the block while its top is covered.
5858
5886
  */
5859
5887
  function planBlockToolbarPlacement(input) {
5860
5888
  if (input.headerClearance.kind === "overlay") return {
5861
5889
  kind: "anchor-top-right-clamped",
5862
5890
  topPx: 8,
5863
- rightPx: 8,
5891
+ rightPx: 16,
5864
5892
  minTopPx: input.headerClearance.px + 8
5865
5893
  };
5866
5894
  return {
5867
5895
  kind: "anchor-top-right",
5868
5896
  topPx: 8,
5869
- rightPx: 8
5897
+ rightPx: 16
5870
5898
  };
5871
5899
  }
5872
5900
  function planSiteChromeCustomizePlacement(input) {
@@ -5916,6 +5944,97 @@ function isUsableAnchorBox(box) {
5916
5944
  return Boolean(box && Number.isFinite(box.top) && Number.isFinite(box.right) && Number.isFinite(box.bottom) && Number.isFinite(box.height) && box.height > 0);
5917
5945
  }
5918
5946
  //#endregion
5947
+ //#region ../preview-next/src/client/preview/useSiteTopChromeClearance.ts
5948
+ const SITE_HEADER_SELECTOR = ".block-site-header";
5949
+ /** The banner's own elements, inside the box-less wrapper the preview shell puts round it. */
5950
+ const SITE_BANNER_SELECTOR = `[${PREVIEW_SITE_BANNER_ATTRIBUTE}] > *`;
5951
+ function findSiteTopChrome() {
5952
+ return {
5953
+ header: document.querySelector(SITE_HEADER_SELECTOR),
5954
+ banners: Array.from(document.querySelectorAll(SITE_BANNER_SELECTOR))
5955
+ };
5956
+ }
5957
+ function clearanceOf({ header, banners }) {
5958
+ return siteTopChromeClearance({
5959
+ header: header ? chromeBox(visibleHeaderPart(header)) : null,
5960
+ banners: banners.map(chromeBox)
5961
+ });
5962
+ }
5963
+ /** One live reading, for chrome that already re-measures itself on layout changes. */
5964
+ function measureSiteTopChromeClearance() {
5965
+ return clearanceOf(findSiteTopChrome());
5966
+ }
5967
+ /**
5968
+ * How far the site's header and any banner stacked with it reach down the
5969
+ * canvas right now. Re-measured on scroll as well as on layout changes, since
5970
+ * sticky chrome and a header scrolling away both change it.
5971
+ */
5972
+ function useSiteTopChromeClearance() {
5973
+ const [clearance, setClearance] = useState({ kind: "none" });
5974
+ useEffect(() => {
5975
+ const frame = { id: null };
5976
+ const observed = { elements: [] };
5977
+ const resizeObserver = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(() => schedule());
5978
+ const measure = () => {
5979
+ frame.id = null;
5980
+ const chrome = findSiteTopChrome();
5981
+ observe(chrome.header ? [chrome.header, ...chrome.banners] : chrome.banners);
5982
+ const next = clearanceOf(chrome);
5983
+ setClearance((current) => headerClearanceEquals(current, next) ? current : next);
5984
+ };
5985
+ const schedule = () => {
5986
+ if (frame.id === null) frame.id = window.requestAnimationFrame(measure);
5987
+ };
5988
+ const observe = (elements) => {
5989
+ if (!resizeObserver || sameElements(observed.elements, elements)) return;
5990
+ resizeObserver.disconnect();
5991
+ elements.forEach((element) => resizeObserver.observe(element));
5992
+ observed.elements = elements;
5993
+ };
5994
+ measure();
5995
+ const mutationObserver = new MutationObserver(schedule);
5996
+ mutationObserver.observe(document.body, {
5997
+ attributes: true,
5998
+ attributeFilter: ["class"],
5999
+ childList: true,
6000
+ subtree: true
6001
+ });
6002
+ window.addEventListener("resize", schedule);
6003
+ window.addEventListener("scroll", schedule, true);
6004
+ return () => {
6005
+ if (frame.id !== null) window.cancelAnimationFrame(frame.id);
6006
+ resizeObserver?.disconnect();
6007
+ mutationObserver.disconnect();
6008
+ window.removeEventListener("resize", schedule);
6009
+ window.removeEventListener("scroll", schedule, true);
6010
+ };
6011
+ }, []);
6012
+ return clearance;
6013
+ }
6014
+ /** The header's visible bar, when it marks one, rather than its whole box. */
6015
+ function visibleHeaderPart(header) {
6016
+ return Array.from(header.querySelectorAll(SITE_CHROME_VISIBLE_HEADER_SELECTOR)).find((candidate) => {
6017
+ const rect = candidate.getBoundingClientRect();
6018
+ return window.getComputedStyle(candidate).display !== "none" && rect.height > 0 && rect.bottom > 0;
6019
+ }) ?? header;
6020
+ }
6021
+ function chromeBox(element) {
6022
+ const rect = element.getBoundingClientRect();
6023
+ return {
6024
+ top: rect.top,
6025
+ bottom: rect.bottom
6026
+ };
6027
+ }
6028
+ function sameElements(left, right) {
6029
+ return left.length === right.length && left.every((element, index) => element === right[index]);
6030
+ }
6031
+ function headerClearanceEquals(left, right) {
6032
+ switch (left.kind) {
6033
+ case "none": return right.kind === "none";
6034
+ case "overlay": return right.kind === "overlay" && left.px === right.px;
6035
+ }
6036
+ }
6037
+ //#endregion
5919
6038
  //#region ../preview-next/src/client/preview/PreviewChromeLayer.tsx
5920
6039
  const PreviewChromeLayerContext = createContext(null);
5921
6040
  function PreviewChromeLayerProvider({ children }) {
@@ -5941,7 +6060,7 @@ function PreviewChromeLayerProvider({ children }) {
5941
6060
  children: [children, layerHost ? createPortal(/* @__PURE__ */ jsx("div", {
5942
6061
  ref: setPortalTarget,
5943
6062
  className: "pointer-events-none fixed inset-0",
5944
- style: { zIndex: PREVIEW_CHROME_Z_INDEX },
6063
+ style: { zIndex: 30 },
5945
6064
  "data-preview-chrome-layer": ""
5946
6065
  }), layerHost) : null]
5947
6066
  });
@@ -6134,6 +6253,21 @@ function PreviewChromeFloatingControl({ anchorSelector, anchorTargetSelector, pl
6134
6253
  children
6135
6254
  }), layer.portalTarget)] });
6136
6255
  }
6256
+ /** Where a format bar goes for its field right now, in the chrome layer's coordinates. */
6257
+ function measureFloatingBarPosition(anchor, portalTarget, gapPx) {
6258
+ const anchorRect = anchor.getBoundingClientRect();
6259
+ const layerRect = portalTarget.getBoundingClientRect();
6260
+ const placement = planFloatingBarSide({
6261
+ anchorTopPx: anchorRect.top,
6262
+ headerClearance: measureSiteTopChromeClearance()
6263
+ });
6264
+ return {
6265
+ left: anchorRect.left - layerRect.left,
6266
+ top: placement === "above" ? anchorRect.top - layerRect.top - gapPx : anchorRect.bottom - layerRect.top + gapPx,
6267
+ width: anchorRect.width,
6268
+ placement
6269
+ };
6270
+ }
6137
6271
  function PreviewChromeFloatingBar({ anchorSelector, gapPx = 8, children }) {
6138
6272
  const layer = usePreviewChromeLayerOptional();
6139
6273
  const probeRef = useRef(null);
@@ -6158,16 +6292,8 @@ function PreviewChromeFloatingBar({ anchorSelector, gapPx = 8, children }) {
6158
6292
  setPosition(null);
6159
6293
  return;
6160
6294
  }
6161
- const anchorRect = anchor.getBoundingClientRect();
6162
- const layerRect = portalTarget.getBoundingClientRect();
6163
- const placement = anchorRect.top >= 56 ? "above" : "below";
6164
6295
  setThemeCustomProperties(readThemeCustomProperties(anchor));
6165
- setPosition({
6166
- left: anchorRect.left - layerRect.left,
6167
- top: placement === "above" ? anchorRect.top - layerRect.top - gapPx : anchorRect.bottom - layerRect.top + gapPx,
6168
- width: anchorRect.width,
6169
- placement
6170
- });
6296
+ setPosition(measureFloatingBarPosition(anchor, portalTarget, gapPx));
6171
6297
  };
6172
6298
  update();
6173
6299
  const unsubscribe = layer.subscribeLayout(update);
@@ -6480,13 +6606,6 @@ function CustomizeCycleRow({ label, valueLabel, previousLabel, nextLabel, availa
6480
6606
  })]
6481
6607
  });
6482
6608
  }
6483
- function cycleAvailability(input) {
6484
- if (input.kind === "available") return input;
6485
- return {
6486
- kind: "unavailable",
6487
- reason: input.kind
6488
- };
6489
- }
6490
6609
  function cycleUnavailableReasonLabel(reason) {
6491
6610
  if (reason === "preview-only") return "Preview-only users cannot change this control.";
6492
6611
  if (reason === "single-option") return "There are no other options to cycle to.";
@@ -6504,157 +6623,6 @@ function cycleAvailabilityFromFlags(input) {
6504
6623
  return { kind: "available" };
6505
6624
  }
6506
6625
  //#endregion
6507
- //#region ../preview-next/src/client/preview/CustomizeColorTokenPicker.tsx
6508
- function CustomizeColorTokenPicker({ title, selectedToken, recommendedTokens, advancedTokens = [], disabled = false, columnsClassName = "grid-cols-2", showTitle = true, labelForToken, swatchColorForToken, onChooseToken }) {
6509
- if (recommendedTokens.length === 0 && advancedTokens.length === 0) return null;
6510
- const renderGrid = (tokens) => /* @__PURE__ */ jsx("div", {
6511
- className: `grid gap-1 ${columnsClassName}`,
6512
- children: tokens.map((token) => /* @__PURE__ */ jsx(ColorTokenButton, {
6513
- token,
6514
- label: labelForToken(token),
6515
- swatchColor: swatchColorForToken(token),
6516
- selected: selectedToken === token,
6517
- disabled,
6518
- onClick: (event) => onChooseToken(token, event)
6519
- }, token))
6520
- });
6521
- return /* @__PURE__ */ jsxs("div", { children: [
6522
- showTitle ? /* @__PURE__ */ jsx("div", {
6523
- className: "mb-1 text-xs font-medium text-muted-foreground",
6524
- children: title
6525
- }) : null,
6526
- renderGrid(recommendedTokens),
6527
- advancedTokens.length > 0 ? /* @__PURE__ */ jsxs("details", {
6528
- className: "mt-1",
6529
- children: [/* @__PURE__ */ jsx("summary", {
6530
- className: "cursor-pointer text-xs text-muted-foreground",
6531
- children: "More colors"
6532
- }), /* @__PURE__ */ jsx("div", {
6533
- className: "mt-1",
6534
- children: renderGrid(advancedTokens)
6535
- })]
6536
- }) : null
6537
- ] });
6538
- }
6539
- function CustomizeBackgroundColorPicker({ title = "Colors", selectedToken, recommendedTokens, advancedTokens = [], disabled = false, columnsClassName = "grid-cols-2", defaultSelected = false, defaultLabel = "Default", labelForToken, swatchColorForToken, onChooseDefault, onChooseToken }) {
6540
- const hasTokens = recommendedTokens.length > 0 || advancedTokens.length > 0;
6541
- if (!onChooseDefault && !hasTokens) return null;
6542
- return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
6543
- className: "mb-2 flex items-center justify-between gap-2",
6544
- children: [/* @__PURE__ */ jsx("div", {
6545
- className: "text-xs font-medium text-muted-foreground",
6546
- children: title
6547
- }), onChooseDefault ? /* @__PURE__ */ jsx("button", {
6548
- type: "button",
6549
- className: `rounded-md border px-2 py-1 text-xs hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 ${defaultSelected ? "border-foreground" : "bg-background"}`,
6550
- disabled,
6551
- onClick: onChooseDefault,
6552
- children: defaultLabel
6553
- }) : null]
6554
- }), hasTokens ? /* @__PURE__ */ jsx(CustomizeColorTokenPicker, {
6555
- title,
6556
- selectedToken,
6557
- recommendedTokens,
6558
- advancedTokens,
6559
- disabled,
6560
- columnsClassName,
6561
- labelForToken,
6562
- swatchColorForToken,
6563
- onChooseToken,
6564
- showTitle: false
6565
- }) : null] });
6566
- }
6567
- function ColorTokenButton({ token, label, swatchColor, selected, disabled, onClick }) {
6568
- return /* @__PURE__ */ jsxs("button", {
6569
- type: "button",
6570
- className: `flex min-w-0 items-center gap-2 rounded-md border px-2 py-1 text-left text-xs hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 ${selected ? "border-foreground" : "bg-background"}`,
6571
- disabled,
6572
- "aria-label": `Choose ${label}`,
6573
- onClick,
6574
- "data-token": token,
6575
- children: [/* @__PURE__ */ jsx("span", {
6576
- className: "h-3 w-3 shrink-0 rounded-full border",
6577
- style: { backgroundColor: swatchColor }
6578
- }), /* @__PURE__ */ jsx("span", {
6579
- className: "truncate",
6580
- children: label
6581
- })]
6582
- });
6583
- }
6584
- //#endregion
6585
- //#region ../preview-next/src/client/preview/CustomizeBackgroundControlRows.tsx
6586
- function CustomizeBackgroundControlRows({ modeLabel, valueLabel, valueAriaLabel, swatch, chooserOpen, chooser, canCycleMode, canCycleValue, onCycleMode, onCycleValue, onToggleChooser }) {
6587
- return /* @__PURE__ */ jsxs("div", {
6588
- className: "space-y-2",
6589
- children: [
6590
- /* @__PURE__ */ jsxs("div", {
6591
- className: "flex items-stretch overflow-hidden rounded-full border bg-background",
6592
- children: [
6593
- /* @__PURE__ */ jsx("button", {
6594
- type: "button",
6595
- onClick: (event) => onCycleMode("prev", event),
6596
- className: "grid h-8 w-8 place-items-center hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",
6597
- "aria-label": "Previous background mode",
6598
- disabled: !canCycleMode,
6599
- children: /* @__PURE__ */ jsx(ChevronLeft, { size: 14 })
6600
- }),
6601
- /* @__PURE__ */ jsxs("div", {
6602
- className: "min-w-0 flex-1 border-x px-2 py-1 text-center",
6603
- children: [/* @__PURE__ */ jsx("div", {
6604
- className: "text-xs font-medium leading-3 text-muted-foreground",
6605
- children: "Background:"
6606
- }), /* @__PURE__ */ jsx("div", {
6607
- className: "truncate text-xs font-semibold leading-4",
6608
- children: modeLabel
6609
- })]
6610
- }),
6611
- /* @__PURE__ */ jsx("button", {
6612
- type: "button",
6613
- onClick: (event) => onCycleMode("next", event),
6614
- className: "grid h-8 w-8 place-items-center hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",
6615
- "aria-label": "Next background mode",
6616
- disabled: !canCycleMode,
6617
- children: /* @__PURE__ */ jsx(ChevronRight, { size: 14 })
6618
- })
6619
- ]
6620
- }),
6621
- /* @__PURE__ */ jsxs("div", {
6622
- className: "flex items-stretch overflow-hidden rounded-full border bg-background",
6623
- children: [
6624
- /* @__PURE__ */ jsx("button", {
6625
- type: "button",
6626
- onClick: (event) => onCycleValue("prev", event),
6627
- className: "grid h-8 w-8 place-items-center hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",
6628
- "aria-label": "Previous background value",
6629
- disabled: !canCycleValue,
6630
- children: /* @__PURE__ */ jsx(ChevronLeft, { size: 14 })
6631
- }),
6632
- /* @__PURE__ */ jsxs("button", {
6633
- type: "button",
6634
- className: "flex min-w-0 flex-1 items-center justify-center gap-2 border-x px-2 py-1 text-center hover:bg-muted",
6635
- "aria-expanded": chooserOpen,
6636
- "aria-label": valueAriaLabel,
6637
- onClick: onToggleChooser,
6638
- children: [swatch, /* @__PURE__ */ jsx("span", {
6639
- className: "truncate text-xs font-medium",
6640
- children: valueLabel
6641
- })]
6642
- }),
6643
- /* @__PURE__ */ jsx("button", {
6644
- type: "button",
6645
- onClick: (event) => onCycleValue("next", event),
6646
- className: "grid h-8 w-8 place-items-center hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50",
6647
- "aria-label": "Next background value",
6648
- disabled: !canCycleValue,
6649
- children: /* @__PURE__ */ jsx(ChevronRight, { size: 14 })
6650
- })
6651
- ]
6652
- }),
6653
- chooserOpen ? chooser : null
6654
- ]
6655
- });
6656
- }
6657
- //#endregion
6658
6626
  //#region ../preview-next/src/client/preview/SiteChromeCustomizeButton.tsx
6659
6627
  function SiteChromeCustomizeButton({ surface, containerClassName = "pointer-events-auto absolute right-2 top-2 z-50 flex gap-1 opacity-0 transition group-focus-within/site-chrome:opacity-100 group-hover/site-chrome:opacity-100" }) {
6660
6628
  const customize = useSiteChromeCustomizeOptional();
@@ -6950,7 +6918,7 @@ function SiteChromeBackgroundControl({ background, applyAllowed, chooserOpen, on
6950
6918
  advancedTokens: background.advancedTokens,
6951
6919
  disabled: !applyAllowed,
6952
6920
  labelForToken: formatSiteChromeBackgroundTokenLabel,
6953
- swatchColorForToken: tokenSwatchCss$1,
6921
+ swatchColorForToken: tokenSwatchCss,
6954
6922
  onChooseToken: (token, event) => {
6955
6923
  choose({
6956
6924
  kind: "color",
@@ -6984,10 +6952,10 @@ function SiteChromeBackgroundSwatch({ override }) {
6984
6952
  });
6985
6953
  return /* @__PURE__ */ jsx("span", {
6986
6954
  className: baseClassName,
6987
- style: { backgroundColor: tokenSwatchCss$1(override.token) }
6955
+ style: { backgroundColor: tokenSwatchCss(override.token) }
6988
6956
  });
6989
6957
  }
6990
- function tokenSwatchCss$1(token) {
6958
+ function tokenSwatchCss(token) {
6991
6959
  return `rgb(var(--tb-${token}))`;
6992
6960
  }
6993
6961
  //#endregion
@@ -7121,11 +7089,11 @@ function joinClassNames(...values) {
7121
7089
  //#region ../preview-next/src/client/utils/path.ts
7122
7090
  const PATH_SEPARATOR_REGEX = /\./g;
7123
7091
  const BRACKET_ACCESS_REGEX = /\[([^\]]+)\]/g;
7124
- function isRecord$2(value) {
7092
+ function isRecord$1(value) {
7125
7093
  return typeof value === "object" && value !== null && !Array.isArray(value);
7126
7094
  }
7127
7095
  function isPathContainer(value) {
7128
- return Array.isArray(value) || isRecord$2(value);
7096
+ return Array.isArray(value) || isRecord$1(value);
7129
7097
  }
7130
7098
  function createPathContainer(nextIsIndex) {
7131
7099
  return nextIsIndex ? [] : {};
@@ -7297,12 +7265,12 @@ function runtimeFieldsByBlockId(blocks) {
7297
7265
  function applyRuntimeContentDecorationProjection(block, content, projection) {
7298
7266
  const blockId = designBlockIdFromBlockItem(block);
7299
7267
  const fields = blockId ? projection.fieldsByBlockId.get(blockId) : void 0;
7300
- return applyCompiledRuntimeFieldsToContent(isRecord$1(content) ? content : {}, fields);
7268
+ return applyCompiledRuntimeFieldsToContent(isRecord(content) ? content : {}, fields);
7301
7269
  }
7302
7270
  function designBlockIdFromBlockItem(block) {
7303
7271
  return typeof block.id === "string" && block.id.length > 0 ? asDesignBlockId(block.id) : null;
7304
7272
  }
7305
- function isRecord$1(value) {
7273
+ function isRecord(value) {
7306
7274
  return typeof value === "object" && value !== null && !Array.isArray(value);
7307
7275
  }
7308
7276
  //#endregion
@@ -7362,7 +7330,7 @@ function applyBindings(bindings, context) {
7362
7330
  if (value !== void 0 && value !== null) setBindingValue(result, key, value);
7363
7331
  continue;
7364
7332
  }
7365
- if (isRecord$8(bindingSpec)) {
7333
+ if (isRecord$7(bindingSpec)) {
7366
7334
  const nested = applyBindings(bindingSpec, context);
7367
7335
  if (Object.keys(nested).length > 0) setBindingValue(result, key, nested);
7368
7336
  }
@@ -7403,7 +7371,7 @@ function mergeResolvedBindings(base, resolved) {
7403
7371
  const merged = { ...base };
7404
7372
  for (const [key, resolvedValue] of Object.entries(resolved)) {
7405
7373
  const baseValue = merged[key];
7406
- merged[key] = isRecord$8(baseValue) && isRecord$8(resolvedValue) ? mergeResolvedBindings(baseValue, resolvedValue) : resolvedValue;
7374
+ merged[key] = isRecord$7(baseValue) && isRecord$7(resolvedValue) ? mergeResolvedBindings(baseValue, resolvedValue) : resolvedValue;
7407
7375
  }
7408
7376
  return merged;
7409
7377
  }
@@ -7428,7 +7396,7 @@ function setBindingValue(target, path, value) {
7428
7396
  current[Number(segment)] = value;
7429
7397
  return;
7430
7398
  }
7431
- if (isRecord$8(current)) current[segment] = value;
7399
+ if (isRecord$7(current)) current[segment] = value;
7432
7400
  return;
7433
7401
  }
7434
7402
  const nextWantsArray = typeof nextSegment === "string" && isIndex(nextSegment);
@@ -7437,15 +7405,15 @@ function setBindingValue(target, path, value) {
7437
7405
  const existing = current[index];
7438
7406
  if (nextWantsArray) {
7439
7407
  if (!Array.isArray(existing)) current[index] = [];
7440
- } else if (!isRecord$8(existing)) current[index] = {};
7408
+ } else if (!isRecord$7(existing)) current[index] = {};
7441
7409
  current = current[index];
7442
7410
  continue;
7443
7411
  }
7444
- if (isRecord$8(current)) {
7412
+ if (isRecord$7(current)) {
7445
7413
  const existing = current[segment];
7446
7414
  if (nextWantsArray) {
7447
7415
  if (!Array.isArray(existing)) current[segment] = [];
7448
- } else if (!isRecord$8(existing)) current[segment] = {};
7416
+ } else if (!isRecord$7(existing)) current[segment] = {};
7449
7417
  current = current[segment];
7450
7418
  continue;
7451
7419
  }
@@ -7483,7 +7451,7 @@ function getPath(source, path) {
7483
7451
  const segments = path.split(".").map((segment) => segment.trim()).filter(Boolean);
7484
7452
  let current = source;
7485
7453
  for (const segment of segments) {
7486
- if (!isRecord$8(current)) return void 0;
7454
+ if (!isRecord$7(current)) return void 0;
7487
7455
  current = current[segment];
7488
7456
  }
7489
7457
  return current;
@@ -7516,7 +7484,7 @@ function textToInlineText(value) {
7516
7484
  function extractFirstParagraph(value) {
7517
7485
  if (!isRichTextDoc(value)) return null;
7518
7486
  for (const node of value.content) {
7519
- if (!isRecord$8(node)) continue;
7487
+ if (!isRecord$7(node)) continue;
7520
7488
  if (node.type !== "paragraph" || !Array.isArray(node.content)) continue;
7521
7489
  const text = node.content.filter((item) => item.type === "text").map((item) => typeof item.text === "string" ? item.text : "").join("").trim();
7522
7490
  if (text.length > 0) return text;
@@ -7527,7 +7495,7 @@ function extractFirstParagraph(value) {
7527
7495
  * Type guard to check if a value is a valid binding descriptor.
7528
7496
  */
7529
7497
  function isBindingDescriptor(value) {
7530
- if (!isRecord$8(value) || typeof value.source !== "string") return false;
7498
+ if (!isRecord$7(value) || typeof value.source !== "string") return false;
7531
7499
  if (!BINDING_SOURCES.includes(value.source)) return false;
7532
7500
  switch (value.source) {
7533
7501
  case "field":
@@ -7542,7 +7510,7 @@ function isBindingDescriptor(value) {
7542
7510
  * Type guard to check if a value is binding-descriptor-like (can be normalized).
7543
7511
  */
7544
7512
  function isBindingDescriptorLike(value) {
7545
- return isBindingDescriptor(value) || typeof value === "string" || isRecord$8(value) && typeof value.source === "string" && typeof value.path === "string";
7513
+ return isBindingDescriptor(value) || typeof value === "string" || isRecord$7(value) && typeof value.source === "string" && typeof value.path === "string";
7546
7514
  }
7547
7515
  /**
7548
7516
  * Normalizes a binding input to a binding descriptor.
@@ -7578,7 +7546,7 @@ function entryFieldRebindingProjection(changedFields, dateContext) {
7578
7546
  * whose source did not change resolves to nothing and leaves the content as it is.
7579
7547
  */
7580
7548
  function applyEntryFieldRebindingProjection(block, content, projection) {
7581
- if (!isRecord$8(block.bindings)) return content;
7549
+ if (!isRecord$7(block.bindings)) return content;
7582
7550
  return applyBindingsToContent(content ?? {}, block.bindings, {
7583
7551
  fields: { ...projection.changedFields },
7584
7552
  meta: {},
@@ -7772,6 +7740,8 @@ function PreviewThemedSiteDocument({ children, themeRuntime = defaultPreviewThem
7772
7740
  const { effectiveTheme: overlayTheme } = usePreviewThemeOverlay();
7773
7741
  const effectiveTheme = usePreviewOpeningTheme(overlayTheme);
7774
7742
  const headerNode = renderPreviewHeader(siteChromeRenderModel, effectiveTheme, staticHeaderNode);
7743
+ const siteDocumentPlan = planPreviewSiteDocument(effectiveTheme, bannerNode, headerNode);
7744
+ const footerNode = renderPreviewFooter(siteChromeRenderModel, effectiveTheme, staticFooterNode);
7775
7745
  const documentNode = renderPreviewDocument({
7776
7746
  viewportMode,
7777
7747
  viewportWidth,
@@ -7779,14 +7749,26 @@ function PreviewThemedSiteDocument({ children, themeRuntime = defaultPreviewThem
7779
7749
  contentHeight,
7780
7750
  scaleContainerRef,
7781
7751
  contentRef,
7782
- siteDocumentPlan: planPreviewSiteDocument(effectiveTheme, bannerNode, headerNode),
7752
+ siteDocumentPlan,
7783
7753
  headerNode,
7784
- bannerNode,
7785
- footerNode: renderPreviewFooter(siteChromeRenderModel, effectiveTheme, staticFooterNode),
7754
+ bannerNode: markPreviewSiteBanner(bannerNode),
7755
+ footerNode,
7786
7756
  children
7787
7757
  });
7788
7758
  return renderThemedDocument(themeRuntime, effectiveTheme, resolveDocumentResponsiveMode(themeRuntime, useContainerResponsiveMode), documentNode);
7789
7759
  }
7760
+ /**
7761
+ * The shell marks whatever banner it's given, so preview chrome can stay clear
7762
+ * of it without the site's own markup having to cooperate (SDK sites render
7763
+ * their own). The wrapper has no box; the banner's elements are its children.
7764
+ */
7765
+ function markPreviewSiteBanner(bannerNode) {
7766
+ return bannerNode ? /* @__PURE__ */ jsx("div", {
7767
+ [PREVIEW_SITE_BANNER_ATTRIBUTE]: "",
7768
+ style: { display: "contents" },
7769
+ children: bannerNode
7770
+ }) : null;
7771
+ }
7790
7772
  function renderPreviewFooter(model, theme, fallback) {
7791
7773
  if (!model || model.footer.canRenderReactively === false) return fallback;
7792
7774
  return /* @__PURE__ */ jsx(SiteChromeEditableSurface, {
@@ -7973,10 +7955,10 @@ function resolveShellThemeRoles(props) {
7973
7955
  }
7974
7956
  const previewContainerResponsiveEnabled = process.env.NEXT_PUBLIC_ENABLE_PREVIEW_CONTAINER_RESPONSIVE !== "false";
7975
7957
  const PreviewEditorSidebar = React.lazy(async () => {
7976
- return { default: (await import("./PreviewEditorSidebar-DADCj_ET.mjs")).PreviewEditorSidebar };
7958
+ return { default: (await import("./PreviewEditorSidebar-Dvq-RW9-.mjs")).PreviewEditorSidebar };
7977
7959
  });
7978
7960
  const PreviewEditorUI = React.lazy(async () => {
7979
- return { default: (await import("./PreviewEditorUI-La40Dmmh.mjs")).PreviewEditorUI };
7961
+ return { default: (await import("./PreviewEditorUI-BdFjS39R.mjs")).PreviewEditorUI };
7980
7962
  });
7981
7963
  const previewPaneContainmentStyle = {
7982
7964
  contain: "layout paint",
@@ -8053,7 +8035,7 @@ function PreviewDocumentContent(input) {
8053
8035
  }
8054
8036
  function PreviewShellLayout(props) {
8055
8037
  const themeRoles = resolveShellThemeRoles(props);
8056
- const { children, rendering, surfaceId, siteId, dashboardBaseUrl = null, pageId, entryData, contentTypeSchema, referenceContentTypeKeys = [], draftContent, currentTemplate, apiClient, bearerToken, themeId = null, themeSelectionId = null, themeSelectionVersion = null, themeSelectionUpdatedAt = null, themeSelectionButtonStyleSelection = null, themeSelectionButtonStyleRepairs, themeSelectionHeaderSelection = null, themeSelectionFooterLookId = null, themeSelectionHeaderLogo, isSiteLaunched, maintenanceModeEnabled, entrySubrouteContext, assistantPanel, sdkConfig, bookingOfferingPresets, themeRuntime = defaultPreviewThemeRuntime, siteStyleAccess = { kind: "hidden" }, onFooterSaved } = props;
8038
+ const { children, rendering, surfaceId, siteId, dashboardBaseUrl = null, pageId, entryData, contentTypeSchema, referenceContentTypeKeys = [], draftContent, currentTemplate, apiClient, themeId = null, themeSelectionId = null, themeSelectionVersion = null, themeSelectionUpdatedAt = null, themeSelectionButtonStyleSelection = null, themeSelectionButtonStyleRepairs, themeSelectionHeaderSelection = null, themeSelectionFooterLookId = null, themeSelectionHeaderLogo, isSiteLaunched, maintenanceModeEnabled, entrySubrouteContext, sdkConfig, bookingOfferingPresets, themeRuntime = defaultPreviewThemeRuntime, siteStyleAccess = { kind: "hidden" }, onFooterSaved } = props;
8057
8039
  const layout = useOptionalPreviewLayout();
8058
8040
  const headerNode = layout?.headerNode ?? null;
8059
8041
  const bannerNode = layout?.bannerNode ?? null;
@@ -8063,8 +8045,6 @@ function PreviewShellLayout(props) {
8063
8045
  const isOpen = usePreviewDrawerOpen();
8064
8046
  usePreviewModeRootAttribute(useEditor().isEditingMode);
8065
8047
  const setDrawerOpen = useEditorUiStore((s) => s.setDrawerOpen);
8066
- const sidebarTab = useEditorUiStore((s) => s.previewSidebarTab);
8067
- const setPreviewSidebarActiveTab = useEditorUiStore((s) => s.setPreviewSidebarTab);
8068
8048
  const viewportMode = useEditorUiStore((s) => s.viewport.mode);
8069
8049
  const viewportWidth = useEditorUiStore((s) => s.viewport.width);
8070
8050
  const sidebarWidth = useEditorUiStore((s) => s.viewport.sidebarWidth);
@@ -8134,9 +8114,6 @@ function PreviewShellLayout(props) {
8134
8114
  const handleSidebarWidthChange = useCallback((width) => {
8135
8115
  setSidebarWidth(width);
8136
8116
  }, [setSidebarWidth]);
8137
- useEffect(() => {
8138
- setPreviewSidebarActiveTab(getPreviewSidebarTab());
8139
- }, [setPreviewSidebarActiveTab]);
8140
8117
  const [containerWidth, setContainerWidth] = useState(0);
8141
8118
  const [contentHeight, setContentHeight] = useState(0);
8142
8119
  const containerObserverRef = useRef(null);
@@ -8221,7 +8198,6 @@ function PreviewShellLayout(props) {
8221
8198
  currentTemplate,
8222
8199
  theme: themeRoles?.persistenceTheme,
8223
8200
  apiClient,
8224
- bearerToken,
8225
8201
  themeId,
8226
8202
  themeSelectionId,
8227
8203
  themeSelectionVersion,
@@ -8232,15 +8208,9 @@ function PreviewShellLayout(props) {
8232
8208
  themeSelectionFooterLookId,
8233
8209
  themeSelectionHeaderLogo,
8234
8210
  sdkConfig: sdkConfig ?? null,
8235
- activeTab: sidebarTab,
8236
- onTabChange: (tab) => {
8237
- setPreviewSidebarTab(tab);
8238
- setPreviewSidebarActiveTab(tab);
8239
- },
8240
8211
  onFooterSaved,
8241
8212
  onClose: () => setDrawerOpen(false),
8242
8213
  entrySubrouteContext: entrySubrouteContext ?? null,
8243
- assistantPanel,
8244
8214
  bookingOfferingPresets,
8245
8215
  siteStyleAccess,
8246
8216
  viewportMode,
@@ -8302,6 +8272,16 @@ function usePreviewDrawerOpen() {
8302
8272
  return requestedEditingMode && drawerOpen;
8303
8273
  }
8304
8274
  //#endregion
8275
+ //#region ../preview-next/src/client/preview/PreviewSessionJournalHost.tsx
8276
+ /** Preview supplies its existing server refresh to the shared document-session host. */
8277
+ function PreviewSessionJournalHost(props) {
8278
+ const router = useRouter();
8279
+ return /* @__PURE__ */ jsx(SessionJournalHost, {
8280
+ ...props,
8281
+ onReplay: router.refresh
8282
+ });
8283
+ }
8284
+ //#endregion
8305
8285
  //#region ../preview-next/src/auth-contract.ts
8306
8286
  function isPreviewRuntimeSessionEditable(session) {
8307
8287
  return session?.kind === "userSession" && session.canEdit;
@@ -8325,7 +8305,6 @@ function resolveShellLayoutProps(input) {
8325
8305
  draftContent: props.draftContent,
8326
8306
  currentTemplate: props.currentTemplate,
8327
8307
  apiClient: input.apiClient,
8328
- bearerToken: input.bearerToken,
8329
8308
  themeId: props.themeId ?? null,
8330
8309
  themeSelectionId: props.themeSelectionId ?? null,
8331
8310
  themeSelectionVersion: props.themeSelectionVersion ?? null,
@@ -8340,7 +8319,6 @@ function resolveShellLayoutProps(input) {
8340
8319
  isSiteLaunched: props.isSiteLaunched,
8341
8320
  maintenanceModeEnabled: props.maintenanceModeEnabled,
8342
8321
  entrySubrouteContext: props.entrySubrouteContext,
8343
- assistantPanel: props.assistantPanel,
8344
8322
  sdkConfig: props.sdkConfig ?? null,
8345
8323
  bookingOfferingPresets: props.bookingOfferingPresets,
8346
8324
  siteStyleAccess: input.siteStyleAccess,
@@ -8371,7 +8349,8 @@ function wrapPreviewSiteFontStorage(children, siteFontStorageUrl) {
8371
8349
  function PreviewEditorBody({ props, designEditorEnabled, siteStyleAccess }) {
8372
8350
  const { apiClient } = useEntryEditorController();
8373
8351
  const bearerToken = usePreviewToken();
8374
- return /* @__PURE__ */ jsx(PreviewDesignHistoryOrderProvider, { children: /* @__PURE__ */ jsx(PreviewPageDesignEditorStateProvider, {
8352
+ const journal = useOptionalSessionJournal();
8353
+ const content = /* @__PURE__ */ jsx(PreviewPageDesignEditorStateProvider, {
8375
8354
  apiClient,
8376
8355
  siteId: props.siteId,
8377
8356
  pageId: props.pageId,
@@ -8385,11 +8364,11 @@ function PreviewEditorBody({ props, designEditorEnabled, siteStyleAccess }) {
8385
8364
  children: [/* @__PURE__ */ jsx(PreviewKeepAliveClient, { baseFetch: props.baseFetch }), wrapPreviewSiteFontStorage(renderShellLayout({
8386
8365
  props,
8387
8366
  apiClient,
8388
- siteStyleAccess,
8389
- bearerToken
8367
+ siteStyleAccess
8390
8368
  }), props.siteFontStorageUrl)]
8391
8369
  })
8392
- }) });
8370
+ });
8371
+ return journal ? content : /* @__PURE__ */ jsx(PreviewDesignHistoryOrderProvider, { children: content });
8393
8372
  }
8394
8373
  function PreviewBlockApiProvider({ config, children }) {
8395
8374
  const token = usePreviewToken();
@@ -8412,50 +8391,99 @@ function PreviewBlockApiProvider({ config, children }) {
8412
8391
  });
8413
8392
  }
8414
8393
  function PreviewShell(props) {
8415
- const { apiBaseUrl, blockApiConfig, siteId, siteSlug, editableId, previewSession, previewToken, pageId, routeId, entryData, contentTypeSchema, initialStatus, initialBlocks, pageMetadata, designEditorEligibility, hideSiteStyleConfigurator = false } = props;
8416
- const apiClient = useMemo(() => createGuardedPreviewApiClient(apiBaseUrl), [apiBaseUrl]);
8417
- const { designEditorEnabled, siteStyleAccess } = resolveShellAccess({
8418
- previewSession,
8419
- designEditorEligibility,
8420
- pageId,
8421
- entryData,
8422
- hideSiteStyleConfigurator
8394
+ const apiClient = useMemo(() => createGuardedPreviewApiClient(props.apiBaseUrl), [props.apiBaseUrl]);
8395
+ const access = resolveShellAccess({
8396
+ ...props,
8397
+ hideSiteStyleConfigurator: props.hideSiteStyleConfigurator ?? false
8423
8398
  });
8424
- return /* @__PURE__ */ jsx(PreviewQueryProvider, { children: /* @__PURE__ */ jsx(PreviewAuthInit, {
8425
- session: previewSession,
8426
- token: previewToken,
8427
- siteId,
8428
- siteSlug,
8429
- pageId: editableId,
8430
- children: /* @__PURE__ */ jsx(PreviewBlockApiProvider, {
8431
- config: blockApiConfig,
8432
- children: /* @__PURE__ */ jsx(PreviewEditingModeProvider, {
8433
- siteId,
8434
- children: /* @__PURE__ */ jsxs(PreviewEntryControllerProvider, {
8435
- blockFieldExtensions: props.sdkConfig?.blockFieldExtensions ?? null,
8436
- businessTimeZone: props.businessTimeZone,
8437
- siteId,
8438
- pageId,
8439
- pageNodeType: props.pageNodeType,
8440
- routeId,
8441
- entryData,
8442
- contentTypeSchema,
8443
- initialStatus,
8444
- initialBlocks,
8445
- pageMetadata,
8446
- apiClient,
8447
- subscribeToLeaseChanges: props.subscribeToLeaseChanges,
8448
- onLeaseGranted: props.onLeaseGranted,
8449
- liveDrafts: props.liveDrafts ?? void 0,
8450
- children: [/* @__PURE__ */ jsx(PreviewLeaseEditingMode, {}), /* @__PURE__ */ jsx(PreviewEditorBody, {
8399
+ return /* @__PURE__ */ jsxs(LocationPickerEnvironmentProvider, {
8400
+ siteId: props.siteId,
8401
+ apiClient,
8402
+ tilesKey: props.previewSession?.tilesKey,
8403
+ dashboardBaseUrl: props.dashboardBaseUrl ?? props.apiBaseUrl,
8404
+ children: [/* @__PURE__ */ jsx(ToastProvider, {}), /* @__PURE__ */ jsx(PreviewQueryProvider, { children: /* @__PURE__ */ jsx(PreviewAuthInit, {
8405
+ session: props.previewSession,
8406
+ token: props.previewToken,
8407
+ siteId: props.siteId,
8408
+ siteSlug: props.siteSlug,
8409
+ pageId: props.editableId,
8410
+ children: /* @__PURE__ */ jsx(PreviewBlockApiProvider, {
8411
+ config: props.blockApiConfig,
8412
+ children: /* @__PURE__ */ jsx(PreviewEditingModeProvider, {
8413
+ siteId: props.siteId,
8414
+ children: /* @__PURE__ */ jsx(PreviewEditorMount, {
8451
8415
  props,
8452
- designEditorEnabled,
8453
- siteStyleAccess
8454
- })]
8416
+ apiClient,
8417
+ access
8418
+ })
8455
8419
  })
8456
8420
  })
8457
- })
8458
- }) });
8421
+ }) })]
8422
+ });
8423
+ }
8424
+ function previewJournalScope(props) {
8425
+ const nodeId = props.pageId ?? props.entryData?.id;
8426
+ return isPreviewRuntimeSessionEditable(props.previewSession) && nodeId ? {
8427
+ siteId: props.siteId,
8428
+ nodeId,
8429
+ nodeType: props.pageNodeType === "page_surface" ? "page_surface" : props.entryData ? "content_entry" : "page"
8430
+ } : null;
8431
+ }
8432
+ /** Render the preview during admission loading through the existing viewing participation. */
8433
+ function PreviewEditorMount({ props, apiClient, access }) {
8434
+ const scope = useMemo(() => previewJournalScope(props), [
8435
+ props.pageId,
8436
+ props.entryData,
8437
+ props.previewSession,
8438
+ props.pageNodeType,
8439
+ props.siteId
8440
+ ]);
8441
+ const editable = isPreviewRuntimeSessionEditable(props.previewSession);
8442
+ const ordinaryPageId = props.pageId && !props.entryData && props.pageNodeType !== "page_surface" ? props.pageId : null;
8443
+ const renderContent = (initialPageJournalState, checkpoint, authoringAdmitted) => /* @__PURE__ */ jsxs(PreviewEntryControllerProvider, {
8444
+ blockFieldExtensions: props.sdkConfig?.blockFieldExtensions ?? null,
8445
+ businessTimeZone: props.businessTimeZone,
8446
+ siteId: props.siteId,
8447
+ pageId: props.pageId,
8448
+ pageNodeType: props.pageNodeType,
8449
+ routeId: props.routeId,
8450
+ entryData: props.entryData,
8451
+ contentTypeSchema: props.contentTypeSchema,
8452
+ initialStatus: props.initialStatus,
8453
+ initialBlocks: props.initialBlocks,
8454
+ pageMetadata: props.pageMetadata,
8455
+ initialPageJournalState,
8456
+ authoringAdmitted,
8457
+ apiClient,
8458
+ subscribeToLeaseChanges: props.subscribeToLeaseChanges,
8459
+ onLeaseGranted: props.onLeaseGranted,
8460
+ liveDrafts: props.liveDrafts ?? void 0,
8461
+ children: [
8462
+ authoringAdmitted && /* @__PURE__ */ jsx(SiteAdmissionObserver, {
8463
+ siteId: props.siteId,
8464
+ apiClient,
8465
+ checkpoint,
8466
+ siteOnly: !scope && editable,
8467
+ subscribeToAdmissionChanges: props.subscribeToAdmissionChanges
8468
+ }),
8469
+ authoringAdmitted && /* @__PURE__ */ jsx(PreviewLeaseEditingMode, {}),
8470
+ /* @__PURE__ */ jsx(PreviewEditorBody, {
8471
+ props,
8472
+ ...access,
8473
+ designEditorEnabled: authoringAdmitted && access.designEditorEnabled,
8474
+ siteStyleAccess: authoringAdmitted ? access.siteStyleAccess : { kind: "hidden" }
8475
+ })
8476
+ ]
8477
+ });
8478
+ return /* @__PURE__ */ jsx(PreviewSessionJournalHost, {
8479
+ apiClient,
8480
+ siteId: props.siteId,
8481
+ editable,
8482
+ scope,
8483
+ ordinaryPageId,
8484
+ fallback: renderContent(void 0, void 0, false),
8485
+ children: (initialPageJournalState, checkpoint) => renderContent(initialPageJournalState, checkpoint, true)
8486
+ });
8459
8487
  }
8460
8488
  function defaultDesignEditorEligibility(input) {
8461
8489
  if (input.entryData) return { kind: "content-entry" };
@@ -8473,6 +8501,46 @@ function resolveShellAccess(input) {
8473
8501
  };
8474
8502
  }
8475
8503
  //#endregion
8504
+ //#region ../preview-next/src/client/blocks/authoringLocationMaps.ts
8505
+ /** A render-only projection. Canonical drafts in the editor store remain untouched. */
8506
+ function projectAuthoringLocationMaps(page, admitted, siteCountry) {
8507
+ const ready = new Map((admitted?.blocks ?? []).flatMap((block) => {
8508
+ const parsed = publicLocationSchema.safeParse(block.content?.location);
8509
+ return block.id && parsed.success ? [[block.id, parsed.data]] : [];
8510
+ }));
8511
+ return {
8512
+ ...page,
8513
+ blocks: page.blocks.map((block) => {
8514
+ if (block.kind !== "block.location-map") return block;
8515
+ const project = (content) => projectAuthoringMapContent(content, block.id ? ready.get(block.id) : void 0, siteCountry);
8516
+ return {
8517
+ ...block,
8518
+ content: project(block.content),
8519
+ draftContent: block.draftContent ? project(block.draftContent) : block.draftContent
8520
+ };
8521
+ })
8522
+ };
8523
+ }
8524
+ function projectAuthoringMapContent(content, ready, siteCountry) {
8525
+ if (!content || content.locationSource === "business_address" || content.locationSource === "venue") return content ?? void 0;
8526
+ const canonical = parseLocationValue(content.location ?? null);
8527
+ if (!canonical.ok || canonical.value === null) return content;
8528
+ const location = projectPublicLocation(canonical.value, siteCountry);
8529
+ const drawing = drawingAtCurrentPin(location, ready);
8530
+ return {
8531
+ ...content,
8532
+ location: {
8533
+ ...location,
8534
+ ...drawing ? { drawing } : {}
8535
+ }
8536
+ };
8537
+ }
8538
+ /** Geometry identity is the pin, never the block ID or an older address label. */
8539
+ function drawingAtCurrentPin(location, ready) {
8540
+ if (!ready?.pin || !location.pin) return void 0;
8541
+ return ready.pin.lat === location.pin.lat && ready.pin.lng === location.pin.lng ? ready.drawing : void 0;
8542
+ }
8543
+ //#endregion
8476
8544
  //#region ../preview-next/src/client/blocks/composer/mergeDrafts.ts
8477
8545
  const EMPTY_LINKED_ENTRY_OVERLAY = /* @__PURE__ */ new Map();
8478
8546
  /**
@@ -8689,1636 +8757,280 @@ const RichTextWithEditor = ({ value, path, linkedEntryField, ...rest }) => {
8689
8757
  renderToolbarHost: renderPreviewRichTextToolbarHost,
8690
8758
  doc: value
8691
8759
  });
8692
- return /* @__PURE__ */ jsx(RichText, {
8693
- ...rest,
8694
- path,
8695
- doc: value
8696
- });
8697
- };
8698
- const LinkedEntryEditFrame = ({ target, children }) => {
8699
- const { isEditingMode } = useEditor();
8700
- if (!isEditingMode) return /* @__PURE__ */ jsx(Fragment$1, { children });
8701
- return /* @__PURE__ */ jsxs("div", {
8702
- className: "group/linked-entry-edit relative",
8703
- "data-linked-entry-id": target.entryId,
8704
- "data-linked-entry-type": target.contentTypeKey,
8705
- children: [children, /* @__PURE__ */ jsx("button", {
8706
- type: "button",
8707
- "aria-label": `Edit ${target.contentTypeLabel}: ${target.title}`,
8708
- className: "absolute right-2 top-2 z-20 rounded-full border border-white/80 bg-neutral-950/85 px-3 py-1 text-xs font-medium text-white opacity-0 shadow-sm transition focus:opacity-100 group-hover/linked-entry-edit:opacity-100",
8709
- onClick: (event) => {
8710
- event.preventDefault();
8711
- event.stopPropagation();
8712
- dispatchLinkedEntryEditEvent(target);
8713
- },
8714
- children: "Edit"
8715
- })]
8716
- });
8717
- };
8718
- /**
8719
- * In editing mode, a click on a preview button must not perform its real
8720
- * action (navigate, submit, etc.) — instead it should hand focus to the
8721
- * inline editable label so the author can edit the text. The caller-supplied
8722
- * `onClick` is intentionally not invoked here; outside editing mode the
8723
- * underlying button component receives all props unchanged.
8724
- */
8725
- const ButtonWithEditorInterception = (props) => {
8726
- const { isEditingMode } = useEditor();
8727
- if (!isEditingMode) return /* @__PURE__ */ jsx(ButtonComponent, { ...props });
8728
- const { onClick: _suppressedCallerOnClick, ...rest } = props;
8729
- return /* @__PURE__ */ jsx(ButtonComponent, {
8730
- ...rest,
8731
- onClick: (event) => {
8732
- event.preventDefault();
8733
- event.currentTarget.querySelector("[contenteditable=\"true\"]")?.focus();
8734
- }
8735
- });
8736
- };
8737
- const editorRegistry = {
8738
- ...clientComponentRegistry,
8739
- text: TextWithEditor,
8740
- richText: RichTextWithEditor,
8741
- button: ButtonWithEditorInterception,
8742
- media: requireClientRegistryComponent("media"),
8743
- linkedEntryEditFrame: LinkedEntryEditFrame
8744
- };
8745
- //#endregion
8746
- //#region ../preview-next/src/client/blocks/isRecord.ts
8747
- function isRecord(value) {
8748
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
8749
- }
8750
- //#endregion
8751
- //#region ../preview-next/src/client/blocks/previewCustomizeSelectedMedia.ts
8752
- function selectedImageFromMediaValue(value, index) {
8753
- if (value?.type !== "image") return null;
8754
- const resolved = resolveManagedMediaReference(value, index);
8755
- return resolved.kind === "resolved" ? {
8756
- reference: value,
8757
- imageAsset: resolved.asset
8758
- } : null;
8759
- }
8760
- function selectedImageFromRenderableAsset(source) {
8761
- const asset = renderableMediaAssetSchema$1.parse({
8762
- ...source,
8763
- width: source.width ?? null,
8764
- height: source.height ?? null
8765
- });
8766
- return {
8767
- reference: {
8768
- type: "image",
8769
- identifier: mediaIdentifierSchema$2.parse(asset.identifier)
8770
- },
8771
- imageAsset: asset
8772
- };
8773
- }
8774
- function imagePoolWithSelectedImage(input) {
8775
- const selection = input.selectedImage;
8776
- if (input.override.kind !== "image" || selection?.reference.identifier !== input.override.reference.identifier) return input.imagePool;
8777
- return [{
8778
- reference: input.override.reference,
8779
- source: "general-media",
8780
- mediaAsset: selection.imageAsset
8781
- }, ...input.imagePool.filter((item) => item.reference.identifier !== selection.reference.identifier)];
8782
- }
8783
- function selectedOrPooledImageAssetForReference(input) {
8784
- if (input.selectedImage?.reference.identifier === input.reference.identifier) return input.selectedImage.imageAsset;
8785
- return input.imagePool?.find((item) => item.reference.identifier === input.reference.identifier)?.mediaAsset;
8786
- }
8787
- //#endregion
8788
- //#region ../preview-next/src/client/blocks/previewCustomizeActions.ts
8789
- function cyclePageDesignBlockLayout(block, direction) {
8790
- if (block.layoutChoice.effectiveValue === null) return null;
8791
- const layoutKeys = block.availableLayouts.map((layout) => layout.id);
8792
- const currentIndex = layoutKeys.indexOf(block.layoutChoice.effectiveValue);
8793
- if (currentIndex === -1) return null;
8794
- const layoutVariantKey = layoutKeys[direction === "next" ? (currentIndex + 1) % layoutKeys.length : currentIndex === 0 ? layoutKeys.length - 1 : currentIndex - 1];
8795
- if (!layoutVariantKey) return null;
8796
- return {
8797
- kind: "set-layout",
8798
- blockId: block.blockId,
8799
- layoutVariantKey,
8800
- baseContentId: block.contentRevision?.contentId ?? null
8801
- };
8802
- }
8803
- function cyclePageDesignBlockLook(block, direction) {
8804
- if (block.lookAvailability.kind !== "available" || block.availableLooks.length <= 1) return null;
8805
- const values = [null, ...block.availableLooks.map((look) => look.id)];
8806
- const currentIndex = cycleChoiceIndex(block.look, values, direction);
8807
- if (currentIndex === -1) return null;
8808
- const appearancePresetId = values[direction === "next" ? (currentIndex + 1) % values.length : currentIndex === 0 ? values.length - 1 : currentIndex - 1];
8809
- if (appearancePresetId === void 0) return null;
8810
- return {
8811
- kind: "set-look",
8812
- blockId: block.blockId,
8813
- appearancePresetId
8814
- };
8815
- }
8816
- function cyclePageDesignBlockFacet(input) {
8817
- const definition = systemCustomizeFacetDefinitionsForBlock(input.block.blockKind).find((candidate) => candidate.id === input.facetId) ?? null;
8818
- if (!definition) return null;
8819
- const value = systemCustomizeFacetNextValue(definition, input.currentValue, input.direction);
8820
- if (!value) return null;
8821
- return {
8822
- kind: "set-block-facet",
8823
- blockId: input.block.blockId,
8824
- facetId: input.facetId,
8825
- value,
8826
- fromValue: input.currentValue,
8827
- baseContentId: input.block.contentRevision?.contentId ?? null
8828
- };
8829
- }
8830
- function setPageDesignBlockBackground(input) {
8831
- const current = input.currentContent ? parseBackgroundOverrideFromContent(input.currentContent) : {
8832
- kind: "supported",
8833
- override: input.fromOverride ?? { kind: "default" }
8834
- };
8835
- const imagePool = imagePoolWithSelectedImage({
8836
- imagePool: input.imagePool ?? imagePoolForOverride(input.override),
8837
- override: input.override,
8838
- selectedImage: input.selectedImage
8839
- });
8840
- const plan = planBackgroundOverride(current, resolveBackgroundCapability({
8841
- block: input.block,
8842
- imagePool
8843
- }), input.override);
8844
- if (plan.kind !== "apply") return null;
8845
- const imageAsset = plan.override.kind === "image" ? selectedOrPooledImageAssetForReference({
8846
- imagePool: input.imagePool,
8847
- reference: plan.override.reference,
8848
- selectedImage: input.selectedImage
8849
- }) : void 0;
8850
- return {
8851
- kind: "set-background",
8852
- blockId: input.block.blockId,
8853
- override: plan.override,
8854
- fromOverride: plan.fromOverride,
8855
- baseContentId: input.block.contentRevision?.contentId ?? null,
8856
- ...imageAsset ? { imageAsset } : {}
8857
- };
8858
- }
8859
- function cycleChoiceIndex(choice, values, direction) {
8860
- if (choice.kind === "user-pinned" && choice.status === "supported") return values.findIndex((value) => value === choice.effectiveValue);
8861
- if ((choice.kind === "auto" || choice.kind === "user-pinned" && choice.status === "unsupported") && choice.effectiveValue === values[1]) {
8862
- if (values.length <= 2) return -1;
8863
- return direction === "next" ? 1 : 0;
8864
- }
8865
- return 0;
8866
- }
8867
- //#endregion
8868
- //#region ../preview-next/src/client/blocks/customizeFacetControls.ts
8869
- function previewCustomizeFacetControlsFor(blockKind, content, designBlock) {
8870
- if (!designBlock || designBlock.blockKind !== blockKind) return [];
8871
- return systemCustomizeFacetDefinitionsForBlock(blockKind).filter((definition) => systemCustomizeFacetAppliesToLayoutVariant(definition, designBlock.layoutChoice.effectiveValue ?? null)).map((definition) => {
8872
- const value = systemCustomizeFacetCurrentValue(definition, content);
8873
- return {
8874
- facetId: definition.id,
8875
- label: definition.label,
8876
- value,
8877
- valueLabel: systemCustomizeFacetLabelForValue(definition, value)
8878
- };
8879
- });
8880
- }
8881
- //#endregion
8882
- //#region ../preview-next/src/client/blocks/blockCustomizePopoverRows.ts
8883
- function buildBlockCustomizeBuiltinRows({ designBlock, facetControls, hasLayoutControls, hasLookControls, hasBackgroundControls }) {
8884
- const rows = [];
8885
- if (designBlock?.layout && hasLayoutControls) rows.push({
8886
- kind: "variant",
8887
- block: designBlock
8888
- });
8889
- if (designBlock?.layout?.status === "unsupported") rows.push({ kind: "unsupported-variant-warning" });
8890
- if (designBlock && hasLookControls) rows.push({
8891
- kind: "look",
8892
- block: designBlock
8893
- });
8894
- if (hasBackgroundControls) rows.push({ kind: "background" });
8895
- rows.push(...facetControls.map((control) => ({
8896
- kind: "facet",
8897
- control
8898
- })));
8899
- return rows;
8900
- }
8901
- function blockCustomizeBuiltinRowBudget(rows) {
8902
- return rows.length;
8903
- }
8904
- //#endregion
8905
- //#region ../preview-next/src/client/blocks/ArrangementLookControls.tsx
8906
- const darkPill = "flex items-center overflow-hidden rounded-full bg-black/80 text-xs text-white shadow";
8907
- const darkPillButton = "grid h-7 w-7 shrink-0 place-items-center hover:bg-black disabled:cursor-not-allowed disabled:opacity-40";
8908
- function ArrangementModeSwitchPill({ blockLabel, mode, onChoose }) {
8909
- return /* @__PURE__ */ jsxs("div", {
8910
- className: `${darkPill} gap-0.5 py-0.5 pl-2.5 pr-0.5`,
8911
- role: "group",
8912
- "aria-label": `What the ${blockLabel.toLowerCase()} shows`,
8913
- children: [/* @__PURE__ */ jsx("span", {
8914
- className: "pr-1 text-white/70",
8915
- children: "Shows"
8916
- }), mode.options.map((option) => /* @__PURE__ */ jsx("button", {
8917
- type: "button",
8918
- "aria-pressed": option.mode === mode.current,
8919
- className: `rounded-full px-2 py-1 ${option.mode === mode.current ? "bg-white text-black" : "hover:bg-black"}`,
8920
- onClick: (event) => {
8921
- event.preventDefault();
8922
- event.stopPropagation();
8923
- if (option.mode !== mode.current) onChoose(option.mode);
8924
- },
8925
- children: option.label
8926
- }, option.mode))]
8927
- });
8928
- }
8929
- function ArrangementLookPill({ look, canCycle, onCycle }) {
8930
- const arrow = (direction) => /* @__PURE__ */ jsx("button", {
8931
- type: "button",
8932
- className: darkPillButton,
8933
- "aria-label": direction === "prev" ? "Previous Look" : "Next Look",
8934
- disabled: !canCycle,
8935
- onClick: (event) => {
8936
- event.preventDefault();
8937
- event.stopPropagation();
8938
- onCycle(direction);
8939
- },
8940
- children: direction === "prev" ? /* @__PURE__ */ jsx(ChevronLeft, { size: 14 }) : /* @__PURE__ */ jsx(ChevronRight, { size: 14 })
8941
- });
8942
- return /* @__PURE__ */ jsxs("div", {
8943
- className: `${darkPill} min-w-0 shrink`,
8944
- role: "group",
8945
- "aria-label": "Look",
8946
- children: [
8947
- arrow("prev"),
8948
- /* @__PURE__ */ jsxs("span", {
8949
- className: "flex min-w-0 max-w-[16rem] items-baseline gap-1.5 px-1 py-1",
8950
- "aria-live": "polite",
8951
- children: [
8952
- lookIsAutomatic(look) ? /* @__PURE__ */ jsx("span", {
8953
- className: "shrink-0 text-white/70",
8954
- children: "Automatic ·"
8955
- }) : null,
8956
- /* @__PURE__ */ jsx("span", {
8957
- className: "truncate font-medium",
8958
- children: look.lookName
8959
- }),
8960
- lookPosition(look) ? /* @__PURE__ */ jsx("span", {
8961
- className: "shrink-0 text-white/70",
8962
- children: lookPosition(look)
8963
- }) : null
8964
- ]
8965
- }),
8966
- arrow("next")
8967
- ]
8968
- });
8969
- }
8970
- function ArrangementOptionsButton({ open, controlsId, buttonRef, onClick }) {
8971
- return /* @__PURE__ */ jsxs("button", {
8972
- ref: buttonRef,
8973
- type: "button",
8974
- className: `${previewCustomizePillButtonClassName} inline-flex items-center gap-1`,
8975
- "aria-expanded": open,
8976
- "aria-haspopup": "dialog",
8977
- "aria-controls": open ? controlsId : void 0,
8978
- onClick,
8979
- children: [/* @__PURE__ */ jsx(SlidersHorizontal, {
8980
- size: 12,
8981
- "aria-hidden": "true"
8982
- }), "Options"]
8983
- });
8984
- }
8985
- /** Says why the block shows a different Look from the one the owner chose. */
8986
- function ArrangementLookNote({ look, styleName }) {
8987
- const message = look ? arrangementLookNote(look, styleName) : null;
8988
- if (!message) return null;
8989
- return /* @__PURE__ */ jsxs("p", {
8990
- className: "flex max-w-xs gap-1.5 rounded-lg border bg-background px-2.5 py-2 text-xs leading-4 text-foreground shadow",
8991
- children: [/* @__PURE__ */ jsx(Info, {
8992
- size: 13,
8993
- className: "mt-px shrink-0 text-muted-foreground",
8994
- "aria-hidden": "true"
8995
- }), /* @__PURE__ */ jsx("span", { children: message })]
8996
- });
8997
- }
8998
- function ArrangementOptionsBody({ controls, styleName, background, onChooseKnob, onChooseSurface, onEditHeadline }) {
8999
- const choices = controls.knobs.filter((control) => control.kind === "choice");
9000
- const flourishes = controls.knobs.filter((control) => control.kind === "text");
9001
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
9002
- controls.headlineHint ? /* @__PURE__ */ jsx(HeadlineHint, {
9003
- length: controls.headlineHint.length,
9004
- onEdit: onEditHeadline
9005
- }) : null,
9006
- choices.length > 0 ? /* @__PURE__ */ jsx("div", {
9007
- className: "space-y-3",
9008
- children: choices.map((control) => /* @__PURE__ */ jsx(KnobChoice, {
9009
- control,
9010
- styleName,
9011
- onChoose: onChooseKnob
9012
- }, control.facetId))
9013
- }) : null,
9014
- flourishes.length > 0 ? /* @__PURE__ */ jsxs("div", {
9015
- className: "space-y-3 border-t pt-3",
9016
- children: [/* @__PURE__ */ jsx("p", {
9017
- className: "text-xs font-medium text-muted-foreground",
9018
- children: "Short text for this Look"
9019
- }), flourishes.map((control) => /* @__PURE__ */ jsx(KnobText, {
9020
- control,
9021
- onChange: onChooseKnob
9022
- }, control.facetId))]
9023
- }) : null,
9024
- controls.knobs.length === 0 ? /* @__PURE__ */ jsx("p", {
9025
- className: "text-xs text-muted-foreground",
9026
- children: "This Look has no options."
9027
- }) : null,
9028
- background ? /* @__PURE__ */ jsx(SectionBackgroundChoice, {
9029
- background,
9030
- onChoose: onChooseSurface
9031
- }) : null
9032
- ] });
9033
- }
9034
- function HeadlineHint({ length, onEdit }) {
9035
- return /* @__PURE__ */ jsxs("p", {
9036
- className: "flex gap-1.5 rounded-md bg-muted/60 p-2 text-xs leading-4",
9037
- children: [/* @__PURE__ */ jsx(Info, {
9038
- size: 13,
9039
- className: "mt-px shrink-0 text-muted-foreground",
9040
- "aria-hidden": "true"
9041
- }), /* @__PURE__ */ jsxs("span", { children: [
9042
- "This Look suits a shorter headline. Yours is ",
9043
- length,
9044
- ", so it’s set a size smaller.",
9045
- " ",
9046
- /* @__PURE__ */ jsx("button", {
9047
- type: "button",
9048
- className: "font-medium underline underline-offset-2",
9049
- onClick: onEdit,
9050
- children: "Edit the headline"
9051
- })
9052
- ] })]
9053
- });
9054
- }
9055
- function KnobChoice({ control, styleName, onChoose }) {
9056
- return /* @__PURE__ */ jsxs("div", { children: [
9057
- /* @__PURE__ */ jsx("div", {
9058
- className: "mb-1 text-xs font-medium text-slate-500",
9059
- children: control.label
9060
- }),
9061
- /* @__PURE__ */ jsx("div", {
9062
- className: "flex flex-wrap gap-1 rounded-lg border border-slate-200 bg-slate-50 p-1",
9063
- role: "group",
9064
- "aria-label": control.label,
9065
- children: control.options.map((option) => /* @__PURE__ */ jsx("button", {
9066
- type: "button",
9067
- "aria-pressed": option.value === control.value,
9068
- className: segmentClassName(option.value === control.value),
9069
- onClick: (event) => {
9070
- event.preventDefault();
9071
- event.stopPropagation();
9072
- if (option.value !== control.value) onChoose(control, option.value);
9073
- },
9074
- children: option.label
9075
- }, option.value))
9076
- }),
9077
- control.description ? /* @__PURE__ */ jsx("p", {
9078
- className: "mt-1 text-xs text-muted-foreground",
9079
- children: control.description
9080
- }) : null,
9081
- control.cappedBy ? /* @__PURE__ */ jsxs("p", {
9082
- className: "mt-1 text-[11px] text-muted-foreground",
9083
- children: [
9084
- control.cappedBy === "style" ? styleName : "This Look",
9085
- " goes up to ",
9086
- control.options[control.options.length - 1]?.label,
9087
- ", so that’s what shows."
9088
- ]
9089
- }) : null
9090
- ] });
9091
- }
9092
- function KnobText({ control, onChange }) {
9093
- const inputId = React.useId();
9094
- const countId = `${inputId}-count`;
9095
- return /* @__PURE__ */ jsxs("div", { children: [
9096
- /* @__PURE__ */ jsx("label", {
9097
- htmlFor: inputId,
9098
- className: "mb-1 block text-xs font-medium text-slate-500",
9099
- children: control.label
9100
- }),
9101
- /* @__PURE__ */ jsxs("div", {
9102
- className: "flex items-center gap-2",
9103
- children: [/* @__PURE__ */ jsx("input", {
9104
- id: inputId,
9105
- type: "text",
9106
- value: control.value,
9107
- maxLength: control.maxLength,
9108
- "aria-describedby": countId,
9109
- className: "min-w-0 flex-1 rounded-md border bg-background px-2 py-1.5 text-sm",
9110
- onChange: (event) => onChange(control, event.currentTarget.value.slice(0, control.maxLength))
9111
- }), /* @__PURE__ */ jsxs("span", {
9112
- id: countId,
9113
- className: "shrink-0 text-xs tabular-nums text-muted-foreground",
9114
- children: [
9115
- control.value.length,
9116
- "/",
9117
- control.maxLength
9118
- ]
9119
- })]
9120
- }),
9121
- /* @__PURE__ */ jsx("p", {
9122
- className: "mt-1 text-[11px] text-muted-foreground",
9123
- children: "Leave it empty and nothing shows."
9124
- })
9125
- ] });
9126
- }
9127
- function SectionBackgroundChoice({ background, onChoose }) {
9128
- if (background.kind === "held-by-photo") return /* @__PURE__ */ jsxs("div", {
9129
- className: "border-t pt-3",
9130
- children: [/* @__PURE__ */ jsx("div", {
9131
- className: "mb-1 text-xs font-medium text-slate-500",
9132
- children: "Section background"
9133
- }), /* @__PURE__ */ jsx("p", {
9134
- className: "text-xs text-muted-foreground",
9135
- children: "This section’s background is its photo for now."
9136
- })]
9137
- });
9138
- const swatch = (key, selected, label, color, value) => /* @__PURE__ */ jsxs("button", {
9139
- type: "button",
9140
- "aria-pressed": selected,
9141
- className: `flex items-center gap-2 rounded-md border px-2 py-1.5 text-left text-xs ${value === null ? "col-span-2" : ""} ${selected ? "border-foreground ring-1 ring-foreground" : "bg-background hover:bg-muted"}`,
9142
- onClick: (event) => {
9143
- event.preventDefault();
9144
- event.stopPropagation();
9145
- if (!selected) onChoose(value);
9146
- },
9147
- children: [/* @__PURE__ */ jsx("span", {
9148
- "aria-hidden": "true",
9149
- className: "h-5 w-7 shrink-0 rounded border",
9150
- style: color ? { backgroundColor: color } : { backgroundImage: "linear-gradient(135deg, rgb(var(--tb-background)) 50%, rgb(var(--tb-muted)) 50%)" }
9151
- }), /* @__PURE__ */ jsx("span", {
9152
- className: "min-w-0 truncate",
9153
- children: label
9154
- })]
9155
- }, key);
9156
- return /* @__PURE__ */ jsxs("div", {
9157
- className: "border-t pt-3",
9158
- children: [/* @__PURE__ */ jsx("div", {
9159
- className: "mb-1 text-xs font-medium text-slate-500",
9160
- children: "Section background"
9161
- }), /* @__PURE__ */ jsxs("div", {
9162
- className: "grid grid-cols-2 gap-1.5",
9163
- role: "group",
9164
- "aria-label": "Section background",
9165
- children: [swatch("rhythm", background.selected === null, "From the page rhythm", null, null), background.options.map((option) => swatch(option.name, background.selected === option.name, option.label, `rgb(var(--tb-${option.token}))`, option.name))]
9166
- })]
9167
- });
9168
- }
9169
- function segmentClassName(active) {
9170
- return ["min-h-8 flex-1 rounded-md px-2.5 text-xs font-medium transition focus:outline-none focus:ring-2 focus:ring-sky-400", active ? "bg-slate-950 text-white shadow-sm" : "bg-transparent text-slate-600 hover:bg-white hover:text-slate-950"].join(" ");
9171
- }
9172
- /** Unpinned blocks, and pins the current mode can't show, render the automatic Look. */
9173
- function lookIsAutomatic(look) {
9174
- return look.kind === "automatic" || look.kind === "mode-mismatch";
9175
- }
9176
- function lookPosition(look) {
9177
- return look.kind === "pinned" || look.kind === "style-fallback" ? `${look.position} of ${look.total}` : null;
9178
- }
9179
- function arrangementLookNote(look, styleName) {
9180
- switch (look.kind) {
9181
- case "automatic":
9182
- case "pinned": return null;
9183
- case "style-fallback": return `${styleName} doesn’t offer ${look.requestedName}, so this section shows ${look.lookName}. Your choice is kept and comes back if you switch style again.`;
9184
- case "mode-mismatch": return `${look.requestedName} is for the ${look.requestedModeLabel.toLowerCase()} view, so this section shows ${look.lookName}. Switch back and your choice returns.`;
9185
- }
9186
- }
9187
- //#endregion
9188
- //#region ../preview-next/src/client/blocks/ArrangementBlockToolbar.tsx
9189
- /**
9190
- * The block toolbar's state and actions on a style built from arrangement
9191
- * Looks. Every change goes through the customise history the legacy controls
9192
- * use: Looks as set-look, modes as set-layout, knobs as set-block-facet and
9193
- * backgrounds as set-background. Null on a legacy style.
9194
- */
9195
- function useArrangementToolbar(input) {
9196
- const { designBlock, content } = input;
9197
- const controls = useMemo(() => designBlock ? arrangementBlockControlsFor({
9198
- block: designBlock,
9199
- content
9200
- }) : null, [content, designBlock]);
9201
- const background = useMemo(() => designBlock && controls ? arrangementBackgroundControlFor({
9202
- block: designBlock,
9203
- content
9204
- }) : null, [
9205
- content,
9206
- controls,
9207
- designBlock
9208
- ]);
9209
- const [modeNotice, setModeNotice] = useState(null);
9210
- if (!designBlock || !controls) return null;
9211
- const baseContentId = designBlock.contentRevision?.contentId ?? null;
9212
- return {
9213
- controls,
9214
- background,
9215
- styleName: styleNameFor(input.pageDesignState),
9216
- modeNotice: input.selected ? modeNotice : null,
9217
- cycleLook: (direction) => {
9218
- const appearancePresetId = nextArrangementLookPin(controls, designBlock, direction);
9219
- if (appearancePresetId === void 0) return;
9220
- setModeNotice(null);
9221
- input.save({
9222
- kind: "set-look",
9223
- blockId: designBlock.blockId,
9224
- appearancePresetId
9225
- });
9226
- },
9227
- chooseMode: (mode) => {
9228
- setModeNotice(mode);
9229
- input.save({
9230
- kind: "set-layout",
9231
- blockId: designBlock.blockId,
9232
- layoutVariantKey: asLayoutVariantKey(mode),
9233
- baseContentId
9234
- });
9235
- },
9236
- chooseKnob: (control, value) => {
9237
- input.save({
9238
- kind: "set-block-facet",
9239
- blockId: designBlock.blockId,
9240
- facetId: control.facetId,
9241
- value,
9242
- fromValue: control.stored,
9243
- baseContentId
9244
- });
9245
- },
9246
- chooseSurface: (surfaceName) => {
9247
- const option = background?.kind === "surfaces" ? background.options.find((candidate) => candidate.name === surfaceName) : void 0;
9248
- if (surfaceName === null) input.chooseBackground({ kind: "default" });
9249
- else if (option) input.chooseBackground({
9250
- kind: "color",
9251
- token: option.token
9252
- });
9253
- },
9254
- editHeadline: () => input.openField(headlineFieldPath(designBlock.blockKind))
9255
- };
9256
- }
9257
- function ArrangementControlsRow({ toolbar, blockName, blockTitle, popover, onToggleOptions, editButton }) {
9258
- const { controls } = toolbar;
9259
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
9260
- /* @__PURE__ */ jsxs("div", {
9261
- role: "group",
9262
- "aria-label": `${blockTitle} controls`,
9263
- className: "flex min-w-0 items-center justify-end gap-1 sm:flex-wrap",
9264
- "data-preview-chrome-row": "",
9265
- children: [
9266
- blockName,
9267
- controls.mode ? /* @__PURE__ */ jsx(ArrangementModeSwitchPill, {
9268
- blockLabel: blockTitle,
9269
- mode: controls.mode,
9270
- onChoose: toolbar.chooseMode
9271
- }) : null,
9272
- controls.look ? /* @__PURE__ */ jsx(ArrangementLookPill, {
9273
- look: controls.look,
9274
- canCycle: controls.cycle.length > 1,
9275
- onCycle: toolbar.cycleLook
9276
- }) : null,
9277
- /* @__PURE__ */ jsx(ArrangementOptionsButton, {
9278
- open: popover.open,
9279
- controlsId: popover.panelId,
9280
- buttonRef: popover.buttonRef,
9281
- onClick: onToggleOptions
9282
- }),
9283
- editButton
9284
- ]
9285
- }),
9286
- /* @__PURE__ */ jsx(ArrangementLookNote, {
9287
- look: controls.look,
9288
- styleName: toolbar.styleName
9289
- }),
9290
- /* @__PURE__ */ jsx(ModeSwitchNotice, { toolbar })
9291
- ] });
9292
- }
9293
- function ArrangementOptionsCard({ toolbar, blockTitle, popover, historyFailure }) {
9294
- return /* @__PURE__ */ jsxs(CustomizePopoverShell, {
9295
- panelId: popover.panelId,
9296
- descriptionId: popover.descriptionId,
9297
- dialogLabel: `${blockTitle} options`,
9298
- eyebrow: blockTitle,
9299
- title: toolbar.controls.look?.lookName ?? blockTitle,
9300
- dialogRef: popover.dialogRef,
9301
- closeButtonRef: popover.registerInitialFocus,
9302
- onClose: popover.close,
9303
- onKeyDown: popover.handleDialogKeyDown,
9304
- desktopPlacement: "flow",
9305
- children: [/* @__PURE__ */ jsx(ArrangementOptionsBody, {
9306
- controls: toolbar.controls,
9307
- styleName: toolbar.styleName,
9308
- background: toolbar.background,
9309
- onChooseKnob: toolbar.chooseKnob,
9310
- onChooseSurface: toolbar.chooseSurface,
9311
- onEditHeadline: toolbar.editHeadline
9312
- }), historyFailure ? /* @__PURE__ */ jsx("p", {
9313
- className: "text-xs text-red-700",
9314
- children: historyFailure
9315
- }) : null]
9316
- });
9317
- }
9318
- /** Switching mode lands on a Look for that mode, and says which. */
9319
- function ModeSwitchNotice({ toolbar }) {
9320
- const { controls, modeNotice } = toolbar;
9321
- if (!modeNotice || controls.mode?.current !== modeNotice) return null;
9322
- const label = (controls.mode.options.find((option) => option.mode === modeNotice)?.label ?? modeNotice).toLowerCase();
9323
- return /* @__PURE__ */ jsx("p", {
9324
- role: "status",
9325
- className: "max-w-xs rounded-lg border bg-background px-2.5 py-2 text-xs leading-4 text-foreground shadow",
9326
- children: controls.look ? `Now showing ${label}, as ${controls.look.lookName}. The arrows step through Looks for ${label}.` : `Now showing ${label}. This style has no Looks for it yet, so it uses the plain version.`
9327
- });
9328
- }
9329
- function styleNameFor(state) {
9330
- return (state.kind === "loaded" ? getCuratedSiteStyle(state.editorModel.siteStyleId)?.name : null) ?? "This style";
9331
- }
9332
- function headlineFieldPath(blockKind) {
9333
- const source = getBlockDefinition(blockKind)?.manifest.titleSource;
9334
- return (typeof source === "string" ? source : source?.[0]) ?? "headline";
9335
- }
9336
- //#endregion
9337
- //#region ../preview-next/src/client/blocks/useBlockSelection.ts
9338
- const PHONE_VIEWPORT_QUERY = "(max-width: 639px)";
9339
- /**
9340
- * Click to select: a click anywhere in the block selects it, so its controls
9341
- * stay put instead of only showing on hover. A click on an empty placeholder
9342
- * also opens the side panel on the field that fills it.
9343
- */
9344
- function useBlockSelection(input) {
9345
- const probeRef = useRef(null);
9346
- const selection = usePreviewBlockCustomizeSelectionOptional();
9347
- const selectBlock = selection?.selectBlock;
9348
- const onOpenFieldRef = useRef(input.onOpenField);
9349
- onOpenFieldRef.current = input.onOpenField;
9350
- const phone = useMediaQuery(PHONE_VIEWPORT_QUERY);
9351
- const [blockElement, setBlockElement] = useState(null);
9352
- useEffect(() => {
9353
- const block = probeRef.current?.closest("[data-block-id]") ?? null;
9354
- setBlockElement(block);
9355
- if (!block || !selectBlock) return;
9356
- const handleClick = (event) => {
9357
- selectBlock(input.blockId);
9358
- const fieldPath = (event.target instanceof Element ? event.target.closest("[data-placeholder-field]") : null)?.dataset.placeholderField;
9359
- if (fieldPath) onOpenFieldRef.current(fieldPath);
9360
- };
9361
- block.addEventListener("click", handleClick);
9362
- return () => block.removeEventListener("click", handleClick);
9363
- }, [input.blockId, selectBlock]);
9364
- return {
9365
- probeRef,
9366
- selected: selection?.selectedBlockId === input.blockId,
9367
- blockElement,
9368
- selectedElsewhere: selection?.selectedBlockId != null && selection.selectedBlockId !== input.blockId,
9369
- phone
9370
- };
9371
- }
9372
- function useMediaQuery(query) {
9373
- const [matches, setMatches] = useState(false);
9374
- useEffect(() => {
9375
- if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
9376
- const list = window.matchMedia(query);
9377
- const update = () => setMatches(list.matches);
9378
- update();
9379
- list.addEventListener("change", update);
9380
- return () => list.removeEventListener("change", update);
9381
- }, [query]);
9382
- return matches;
9383
- }
9384
- //#endregion
9385
- //#region ../preview-next/src/client/blocks/BlockBackgroundChooser.tsx
9386
- function BackgroundChooser({ editingSlot, capability, current, imagePoolStatus, onChoose }) {
9387
- const chooseFromClick = (override) => (event) => {
9388
- event.preventDefault();
9389
- event.stopPropagation();
9390
- onChoose(override);
9391
- };
9392
- return /* @__PURE__ */ jsxs("div", {
9393
- className: "mt-2 max-h-80 overflow-y-auto rounded-md border bg-muted/20 p-2",
9394
- children: [
9395
- current.kind === "default" || current.kind === "color" ? /* @__PURE__ */ jsx(BackgroundColourOptions, {
9396
- capability,
9397
- current,
9398
- chooseFromClick
9399
- }) : null,
9400
- current.kind === "gradient" ? /* @__PURE__ */ jsx(BackgroundGradientOptions, {
9401
- capability,
9402
- current,
9403
- chooseFromClick
9404
- }) : null,
9405
- current.kind === "image" ? /* @__PURE__ */ jsx(BackgroundImageOptions, {
9406
- editingSlot,
9407
- capability,
9408
- current,
9409
- imagePoolStatus,
9410
- onChoose,
9411
- chooseFromClick
9412
- }) : null
9413
- ]
9414
- });
9415
- }
9416
- function BackgroundColourOptions({ capability, current, chooseFromClick }) {
9417
- return /* @__PURE__ */ jsx(CustomizeBackgroundColorPicker, {
9418
- title: "Colours",
9419
- selectedToken: current.kind === "color" ? current.token : null,
9420
- recommendedTokens: capability.recommendedColorTokens ?? capability.colorTokens ?? [],
9421
- advancedTokens: capability.advancedColorTokens ?? [],
9422
- defaultSelected: current.kind === "default",
9423
- onChooseDefault: capability.modes.includes("default") ? chooseFromClick(defaultBackgroundOverrideForMode("default", capability)) : void 0,
9424
- labelForToken: formatTokenLabel,
9425
- swatchColorForToken: tokenSwatchCss,
9426
- onChooseToken: (token, event) => {
9427
- chooseFromClick({
9428
- kind: "color",
9429
- token
9430
- })(event);
9431
- }
9432
- });
9433
- }
9434
- function BackgroundGradientOptions({ capability, current, chooseFromClick }) {
9435
- if (!capability.gradientIds?.length) return null;
9436
- return /* @__PURE__ */ jsxs("div", { children: [
9437
- /* @__PURE__ */ jsx("div", {
9438
- className: "mb-1 text-xs font-medium text-muted-foreground",
9439
- children: "Gradients"
9440
- }),
9441
- /* @__PURE__ */ jsx("p", {
9442
- className: "mb-2 text-[11px] leading-4 text-muted-foreground",
9443
- children: "Curated presets use this site's colours. The full section preview shows the final result."
9444
- }),
9445
- /* @__PURE__ */ jsx("div", {
9446
- className: "grid grid-cols-2 gap-2",
9447
- children: capability.gradientIds.map((gradientId) => /* @__PURE__ */ jsx(GradientPresetCard, {
9448
- gradientId,
9449
- selected: current.gradientId === gradientId,
9450
- onClick: chooseFromClick({
9451
- kind: "gradient",
9452
- gradientId
9453
- })
9454
- }, gradientId))
9455
- }),
9456
- /* @__PURE__ */ jsx(SelectedGradient, {
9457
- gradientId: current.gradientId,
9458
- onReset: capability.modes.includes("default") ? chooseFromClick(defaultBackgroundOverrideForMode("default", capability)) : null
9459
- })
9460
- ] });
9461
- }
9462
- function GradientPresetCard({ gradientId, selected, onClick }) {
9463
- const preset = getGradientPreset(gradientId);
9464
- const kindLabel = gradientKindLabel(preset);
9465
- return /* @__PURE__ */ jsxs("button", {
9466
- type: "button",
9467
- "aria-label": `Choose ${preset.name}, ${kindLabel}`,
9468
- "aria-pressed": selected,
9469
- className: `overflow-hidden rounded-md border text-left text-xs transition hover:border-muted-foreground ${selected ? "border-foreground ring-1 ring-foreground" : "bg-background"}`,
9470
- onClick,
9471
- children: [/* @__PURE__ */ jsx("span", {
9472
- "aria-hidden": "true",
9473
- className: "block h-14 w-full border-b",
9474
- style: { backgroundImage: gradientPreviewCss(gradientId) }
9475
- }), /* @__PURE__ */ jsxs("span", {
9476
- className: "relative block min-w-0 px-2 py-1.5",
9477
- children: [
9478
- /* @__PURE__ */ jsx("span", {
9479
- className: "block truncate font-medium",
9480
- children: preset.name
9481
- }),
9482
- /* @__PURE__ */ jsx("span", {
9483
- className: "block text-[10px] text-muted-foreground",
9484
- children: kindLabel
9485
- }),
9486
- selected ? /* @__PURE__ */ jsx("span", {
9487
- "aria-hidden": "true",
9488
- className: "absolute right-2 top-1.5 grid h-4 w-4 place-items-center rounded-full bg-foreground text-[10px] text-background",
9489
- children: "✓"
9490
- }) : null
9491
- ]
9492
- })]
9493
- });
9494
- }
9495
- function SelectedGradient({ gradientId, onReset }) {
9496
- return /* @__PURE__ */ jsxs("div", {
9497
- className: "mt-2 flex items-center justify-between gap-2 border-t pt-2",
9498
- children: [/* @__PURE__ */ jsxs("span", {
9499
- className: "flex min-w-0 items-center gap-2",
9500
- children: [/* @__PURE__ */ jsx("span", {
9501
- "aria-hidden": "true",
9502
- className: "h-7 w-10 shrink-0 rounded border",
9503
- style: { backgroundImage: gradientPreviewCss(gradientId) }
9504
- }), /* @__PURE__ */ jsxs("span", {
9505
- className: "min-w-0",
9506
- children: [/* @__PURE__ */ jsx("span", {
9507
- className: "block truncate text-xs font-medium",
9508
- children: gradientLabel(gradientId)
9509
- }), /* @__PURE__ */ jsx("span", {
9510
- className: "block text-[10px] text-muted-foreground",
9511
- children: "Selected for this section"
9512
- })]
9513
- })]
9514
- }), onReset ? /* @__PURE__ */ jsx("button", {
9515
- type: "button",
9516
- className: "shrink-0 rounded px-1.5 py-1 text-xs font-medium hover:bg-muted",
9517
- onClick: onReset,
9518
- children: "Use the style’s background"
9519
- }) : null]
9520
- });
9521
- }
9522
- function BackgroundImageOptions({ editingSlot, capability, current, imagePoolStatus, onChoose, chooseFromClick }) {
9523
- const mediaEditorContext = useMediaEditorOptional();
9524
- const [mediaPickerOpenKey, setMediaPickerOpenKey] = useState(0);
9525
- if (!capability.modes.includes("image")) return null;
9526
- const images = rankBackgroundImagePoolItems(capability.imagePool ?? []);
9527
- return /* @__PURE__ */ jsxs("div", { children: [
9528
- /* @__PURE__ */ jsx("div", {
9529
- className: "mb-1 text-xs font-medium text-muted-foreground",
9530
- children: "Images"
9531
- }),
9532
- mediaEditorContext ? /* @__PURE__ */ jsx(MediaLibraryButton, { onOpen: () => setMediaPickerOpenKey((key) => key + 1) }) : null,
9533
- images.length ? /* @__PURE__ */ jsx("div", {
9534
- className: "space-y-1",
9535
- children: images.map((item) => /* @__PURE__ */ jsx(ImagePoolButton, {
9536
- item,
9537
- selected: current.reference.identifier === item.reference.identifier,
9538
- thumbnailUrl: backgroundImagePreviewUrl(item, mediaEditorContext),
9539
- onClick: chooseFromClick({
9540
- kind: "image",
9541
- reference: item.reference
9542
- })
9543
- }, `${item.source}:${item.reference.identifier}`))
9544
- }) : /* @__PURE__ */ jsx("p", {
9545
- className: "text-xs text-muted-foreground",
9546
- children: imagePoolStatus === "loading" ? "Loading images..." : "No background-ready images yet."
9547
- }),
9548
- mediaPickerOpenKey > 0 && mediaEditorContext ? /* @__PURE__ */ jsx(BackgroundMediaPicker, {
9549
- editingSlot,
9550
- openKey: mediaPickerOpenKey,
9551
- onChoose,
9552
- onDone: () => setMediaPickerOpenKey(0)
9553
- }) : null
9554
- ] });
9555
- }
9556
- function MediaLibraryButton({ onOpen }) {
9557
- return /* @__PURE__ */ jsxs("button", {
9558
- type: "button",
9559
- className: "mb-2 inline-flex w-full items-center justify-center gap-2 rounded-md border bg-background px-2 py-1.5 text-xs font-medium hover:bg-muted",
9560
- onClick: (event) => {
9561
- event.preventDefault();
9562
- event.stopPropagation();
9563
- onOpen();
9564
- },
9565
- children: [/* @__PURE__ */ jsx(Upload, { size: 13 }), "Media library"]
9566
- });
9567
- }
9568
- function ImagePoolButton({ item, selected, thumbnailUrl, onClick }) {
9569
- return /* @__PURE__ */ jsx("button", {
9570
- type: "button",
9571
- className: `w-full rounded-md border px-2 py-1 text-left text-xs hover:bg-muted ${selected ? "border-foreground" : "bg-background"}`,
9572
- onClick,
9573
- children: /* @__PURE__ */ jsxs("span", {
9574
- className: "flex min-w-0 items-center gap-2",
9575
- children: [/* @__PURE__ */ jsx("span", {
9576
- className: "grid h-7 w-9 shrink-0 place-items-center overflow-hidden rounded border bg-muted",
9577
- children: thumbnailUrl ? /* @__PURE__ */ jsx("img", {
9578
- alt: "",
9579
- className: "h-full w-full object-cover",
9580
- src: thumbnailUrl
9581
- }) : /* @__PURE__ */ jsx(Image, { size: 14 })
9582
- }), /* @__PURE__ */ jsxs("span", {
9583
- className: "min-w-0",
9584
- children: [/* @__PURE__ */ jsx("span", {
9585
- className: "block truncate",
9586
- children: item.label ?? "Image"
9587
- }), /* @__PURE__ */ jsx("span", {
9588
- className: "text-[11px] text-muted-foreground",
9589
- children: imageSourceLabel(item.source)
9590
- })]
9591
- })]
9592
- })
9593
- });
9594
- }
9595
- function BackgroundMediaPicker({ editingSlot, openKey, onChoose, onDone }) {
9596
- const mediaEditorContext = useMediaEditorOptional();
9597
- const chooseMediaValue = (value) => {
9598
- const selectedImage = selectedImageFromMediaValue(value, mediaEditorContext?.imageResolveContext.mediaAssetIndex);
9599
- if (!selectedImage) return;
9600
- onChoose({
9601
- kind: "image",
9602
- reference: selectedImage.reference
9603
- }, { selectedImage });
9604
- onDone();
9605
- };
9606
- return /* @__PURE__ */ jsx("div", {
9607
- onClick: (event) => event.stopPropagation(),
9608
- children: /* @__PURE__ */ jsx(MediaEditor, {
9609
- editingSlot,
9610
- value: void 0,
9611
- onChange: chooseMediaValue,
9612
- allowedKinds: ["image"],
9613
- mediaPickerAutoOpen: true,
9614
- mediaPickerPolicy: { assetSelection: backgroundMediaPickerAssetSelection },
9615
- showPreview: false,
9616
- showAltInput: false,
9617
- uploadIntent: {
9618
- tag: "media-library",
9619
- allowedRenderUses: ["image"]
9620
- },
9621
- onUploadComplete: (asset) => {
9622
- if (backgroundMediaPickerAssetSelection(asset).tag === "disabled") return;
9623
- const selectedImage = selectedImageFromRenderableAsset(asset);
9624
- onChoose({
9625
- kind: "image",
9626
- reference: selectedImage.reference
9627
- }, { selectedImage });
9628
- onDone();
9629
- }
9630
- }, openKey)
9631
- });
9632
- }
9633
- function formatVariantLabel(variantKey) {
9634
- return variantKey.replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").replace(/\s+/g, " ").trim().replace(/^./, (letter) => letter.toUpperCase());
9635
- }
9636
- function BackgroundPreviewSwatch({ override, imagePool }) {
9637
- const mediaEditorContext = useMediaEditorOptional();
9638
- const baseClassName = "grid h-6 w-9 shrink-0 place-items-center overflow-hidden rounded-md border";
9639
- switch (override.kind) {
9640
- case "default": return /* @__PURE__ */ jsx("span", {
9641
- className: `${baseClassName} bg-background`,
9642
- children: /* @__PURE__ */ jsx("span", { className: "h-3 w-3 rounded-full border bg-muted" })
9643
- });
9644
- case "color": return /* @__PURE__ */ jsx("span", {
9645
- className: baseClassName,
9646
- style: { backgroundColor: tokenSwatchCss(override.token) }
9647
- });
9648
- case "gradient": return /* @__PURE__ */ jsx("span", {
9649
- className: baseClassName,
9650
- style: { backgroundImage: gradientPreviewCss(override.gradientId) }
9651
- });
9652
- case "image":
9653
- const imageItem = imagePool.find((item) => item.reference.identifier === override.reference.identifier);
9654
- const thumbnailUrl = imageItem ? backgroundImagePreviewUrl(imageItem, mediaEditorContext) : void 0;
9655
- return /* @__PURE__ */ jsx("span", {
9656
- className: `${baseClassName} bg-muted`,
9657
- children: thumbnailUrl ? /* @__PURE__ */ jsx("img", {
9658
- alt: "",
9659
- className: "h-full w-full object-cover",
9660
- src: thumbnailUrl
9661
- }) : /* @__PURE__ */ jsx(Image, { size: 15 })
9662
- });
9663
- }
9664
- }
9665
- function backgroundImagePreviewUrl(item, mediaEditorContext) {
9666
- const asset = item.mediaAsset;
9667
- if (!asset) return void 0;
9668
- return resolveImageUrlWithContext({
9669
- type: "image",
9670
- asset
9671
- }, {
9672
- width: 72,
9673
- height: 48,
9674
- resize: "cover",
9675
- quality: 70
9676
- }, mediaEditorContext?.imageResolveContext ?? null);
9677
- }
9678
- function backgroundMediaPickerAssetSelection(asset) {
9679
- if (isMarkedBackgroundAsset(asset)) return { tag: "selectable" };
9680
- if (asset.width == null || asset.height == null) return {
9681
- tag: "disabled",
9682
- reason: "This image is missing dimensions, so it cannot be checked for background use."
9683
- };
9684
- if (asset.width < 1920 || asset.height < 900) return {
9685
- tag: "disabled",
9686
- reason: `Background images need to be at least ${SECTION_BACKGROUND_MIN_SOURCE_WIDTH}x900. This image is ${asset.width}x${asset.height}.`
9687
- };
9688
- return { tag: "selectable" };
9689
- }
9690
- function isMarkedBackgroundAsset(asset) {
9691
- return asset.fileUses?.some((fileUse) => fileUse.tag === "site-background-asset") ?? false;
9692
- }
9693
- function gradientLabel(gradientId) {
9694
- return getGradientPreset(gradientId).name;
9695
- }
9696
- function gradientKindLabel(preset) {
9697
- switch (preset.type) {
9698
- case "linear": return "Linear";
9699
- case "radial": return "Radial · top";
9700
- case "conic": return "Conic";
9701
- default: return assertNever$1(preset.type, "Unhandled gradient preset type");
9702
- }
9703
- }
9704
- function imageSourceLabel(source) {
9705
- switch (source) {
9706
- case "current": return "Current";
9707
- case "generated-ambient": return "Generated";
9708
- case "previous-background": return "Previous";
9709
- case "general-media": return "Media library";
9710
- }
9711
- }
9712
- function tokenSwatchCss(token) {
9713
- return `rgb(var(--tb-${token}))`;
9714
- }
9715
- function gradientPreviewCss(gradientId) {
9716
- const preset = getGradientPreset(gradientId);
9717
- return gradientToCss(preset, Object.fromEntries(preset.stops.map((stop) => [stop.color, tokenSwatchCss(stop.color)])));
9718
- }
9719
- /** Background colours by the part they play on the site, not their token names. */
9720
- const backgroundTokenLabels = {
9721
- background: "Page ground",
9722
- surface: "Card colour",
9723
- muted: "Quiet band",
9724
- primary: "Brand colour",
9725
- secondary: "Second brand colour",
9726
- accent: "Accent colour"
9727
- };
9728
- function formatTokenLabel(token) {
9729
- return backgroundTokenLabels[token] ?? formatVariantLabel(token.replace(/\//g, " "));
9730
- }
9731
- //#endregion
9732
- //#region ../preview-next/src/client/blocks/BlockToolbar.tsx
9733
- function isUnknownArray(value) {
9734
- return Array.isArray(value);
9735
- }
9736
- function BlockToolbar({ blockId, blockKind, content, bookingOfferingPresets, theme = null, placement = DEFAULT_PREVIEW_CHROME_FLOATING_PLACEMENT }) {
9737
- const uiStore = useEditorUiStoreInstance();
9738
- const editorBlockId = useMemo(() => unsafeAsEditorBlockId(blockId), [blockId]);
9739
- const draftContent = useEditorUiStore((state) => state.drafts.getCurrentValues(editorBlockId));
9740
- const customizeContent = useMemo(() => isRecord(draftContent) ? draftContent : content, [content, draftContent]);
9741
- const customizeSelection = usePreviewBlockCustomizeSelectionOptional();
9742
- const popover = useCustomizePopoverController();
9743
- const focusTarget = useMemo(() => computeDefaultFocus(blockKind, customizeContent), [blockKind, customizeContent]);
9744
- const [backgroundChooserOpen, setBackgroundChooserOpen] = useState(false);
9745
- const [backgroundColorPalette, setBackgroundColorPalette] = useState(null);
9746
- const { state: pageDesignState, applyAction: applyPageDesignAction, historyFailure, backgroundImagePool = [], backgroundImagePoolStatus = "idle", loadBackgroundImagePool = async () => [] } = usePreviewPageDesignEditorState();
9747
- const designBlock = useMemo(() => {
9748
- if (pageDesignState.kind !== "loaded") return null;
9749
- return pageDesignState.editorModel.blocks.find((block) => block.blockId === blockId) ?? null;
9750
- }, [blockId, pageDesignState]);
9751
- const hasLayoutControls = Boolean(designBlock?.layout && designBlock.availableLayouts.length > 1);
9752
- const hasLookControls = Boolean(designBlock?.lookAvailability.kind === "available");
9753
- const facetControls = useMemo(() => previewCustomizeFacetControlsFor(blockKind, customizeContent, designBlock), [
9754
- blockKind,
9755
- customizeContent,
9756
- designBlock
9757
- ]);
9758
- const hasFacetControls = facetControls.length > 0;
9759
- const currentBackground = useMemo(() => parseBackgroundOverrideFromContent(customizeContent), [customizeContent]);
9760
- const mergedBackgroundImagePool = useMemo(() => rankBackgroundImagePoolItems(dedupeBackgroundImagePool([...currentBackground.kind === "supported" ? imagePoolForOverride(currentBackground.override) : [], ...backgroundImagePool])), [backgroundImagePool, currentBackground]);
9761
- const backgroundCycleImagePool = useMemo(() => {
9762
- if (currentBackground.kind === "supported" && currentBackground.override.kind === "image") {
9763
- const currentOverride = currentBackground.override;
9764
- if (!backgroundImagePool.some((item) => item.reference.identifier === currentOverride.reference.identifier)) return rankBackgroundImagePoolItems(dedupeBackgroundImagePool([...imagePoolForOverride(currentOverride), ...backgroundImagePool]));
9765
- }
9766
- return rankBackgroundImagePoolItems(backgroundImagePool);
9767
- }, [backgroundImagePool, currentBackground]);
9768
- const backgroundCapability = useMemo(() => designBlock ? resolveBackgroundCapability({
9769
- block: designBlock,
9770
- imagePool: mergedBackgroundImagePool,
9771
- palette: backgroundColorPalette
9772
- }) : null, [
9773
- backgroundColorPalette,
9774
- designBlock,
9775
- mergedBackgroundImagePool
9776
- ]);
9777
- const backgroundTransitionCapability = useMemo(() => backgroundCapability ? {
9778
- ...backgroundCapability,
9779
- imagePool: backgroundCycleImagePool
9780
- } : null, [backgroundCapability, backgroundCycleImagePool]);
9781
- const enabledBackgroundModeList = useMemo(() => backgroundCapability ? enabledBackgroundModes(backgroundCapability) : [], [backgroundCapability]);
9782
- const hasBackgroundControls = currentBackground.kind === "supported" && enabledBackgroundModeList.length > 1;
9783
- const builtInCustomizeRows = useMemo(() => buildBlockCustomizeBuiltinRows({
9784
- designBlock,
9785
- facetControls,
9786
- hasLayoutControls,
9787
- hasLookControls,
9788
- hasBackgroundControls
9789
- }), [
9790
- designBlock,
9791
- facetControls,
9792
- hasBackgroundControls,
9793
- hasLayoutControls,
9794
- hasLookControls
9795
- ]);
9796
- const manifestCustomize = useBlockCustomizeControls({
9797
- blockId: editorBlockId,
9798
- blockKind,
9799
- content: customizeContent,
9800
- uiStore,
9801
- theme,
9802
- maxQuickFields: 3,
9803
- maxPopoverRows: 6,
9804
- builtInPopoverRows: blockCustomizeBuiltinRowBudget(builtInCustomizeRows)
9805
- });
9806
- const quickManifestFields = manifestCustomize.quickFields;
9807
- const hasSidebarCustomizeControls = manifestCustomize.hasControls;
9808
- const hasOverflowCustomizeControls = manifestCustomize.hasOverflowControls;
9809
- const quickManifestBackend = manifestCustomize.backend;
9810
- const canCycleBackgroundMode = enabledBackgroundModeList.length > 1;
9811
- const canCycleBackgroundValue = currentBackground.kind === "supported" && backgroundTransitionCapability ? canCycleBackgroundOverrideValue(currentBackground.override, backgroundTransitionCapability) : false;
9812
- const selection = useBlockSelection({
9813
- blockId: editorBlockId,
9814
- onOpenField: (fieldPath) => openField(fieldPath)
9815
- });
9816
- const arrangementToolbar = useArrangementToolbar({
9817
- designBlock,
9818
- content: customizeContent,
9819
- pageDesignState,
9820
- selected: selection.selected,
9821
- save: (action) => saveBlockCustomizeAction(action),
9822
- chooseBackground: (override) => chooseBackgroundOverride(override),
9823
- openField: (fieldPath) => openField(fieldPath)
9824
- });
9825
- const hasCustomizeControls = arrangementToolbar !== null || hasLayoutControls || hasLookControls || hasFacetControls || hasBackgroundControls || quickManifestFields.length > 0 || hasSidebarCustomizeControls;
9826
- useEffect(() => {
9827
- if (!hasCustomizeControls) {
9828
- popover.close();
9829
- setBackgroundChooserOpen(false);
9830
- }
9831
- }, [hasCustomizeControls, popover.close]);
9832
- useEffect(() => {
9833
- if (!popover.open) return;
9834
- setBackgroundColorPalette(readBackgroundColorPaletteSnapshot());
9835
- }, [pageDesignState, popover.open]);
9836
- useEffect(() => {
9837
- if (!popover.open || !backgroundCapability?.modes.includes("image")) return;
9838
- if (backgroundImagePoolStatus !== "idle") return;
9839
- loadBackgroundImagePool();
9840
- }, [
9841
- backgroundCapability,
9842
- backgroundImagePoolStatus,
9843
- loadBackgroundImagePool,
9844
- popover.open
9845
- ]);
9846
- const openField = useCallback((fieldPath) => {
9847
- const state = uiStore.getState();
9848
- state.setPreviewSidebarTab("editor");
9849
- state.setDrawerOpen(true);
9850
- state.requestFocus({
9851
- kind: "main-field",
9852
- blockId: editorBlockId,
9853
- fieldPath: `content.${fieldPath}`
9854
- });
9855
- }, [editorBlockId, uiStore]);
9856
- useEffect(() => {
9857
- if (selection.selectedElsewhere) popover.close();
9858
- }, [popover.close, selection.selectedElsewhere]);
9859
- const handleEdit = (e) => {
9860
- e.preventDefault();
9861
- e.stopPropagation();
9862
- const state = uiStore.getState();
9863
- state.setPreviewSidebarTab("editor");
9864
- state.setDrawerOpen(true);
9865
- const path = typeof focusTarget.itemIndex === "number" && focusTarget.fieldPath ? `${focusTarget.fieldPath}.${focusTarget.itemIndex}` : focusTarget.fieldPath;
9866
- state.requestFocus(path ? {
9867
- kind: "main-field",
9868
- blockId: editorBlockId,
9869
- fieldPath: path
9870
- } : {
9871
- kind: "block",
9872
- blockId: editorBlockId
9873
- });
9874
- };
9875
- const inspectBlock = useCallback(() => {
9876
- customizeSelection?.inspectBlock(unsafeAsEditorBlockId(blockId));
9877
- }, [blockId, customizeSelection]);
9878
- const openSidebarCustomize = useCallback((e) => {
9879
- e.preventDefault();
9880
- e.stopPropagation();
9881
- inspectBlock();
9882
- const state = uiStore.getState();
9883
- state.setPreviewSidebarTab("editor");
9884
- state.setDrawerOpen(true);
9885
- }, [inspectBlock, uiStore]);
9886
- const cycleLayout = (direction) => {
9887
- if (!designBlock) return;
9888
- const action = cyclePageDesignBlockLayout(designBlock, direction);
9889
- if (!action) return;
9890
- saveBlockCustomizeAction(action);
9891
- };
9892
- const cycleLook = (direction) => {
9893
- if (!designBlock) return;
9894
- const action = cyclePageDesignBlockLook(designBlock, direction);
9895
- if (!action) return;
9896
- saveBlockCustomizeAction(action);
9897
- };
9898
- const cycleFacet = (control, direction) => {
9899
- if (!designBlock) return;
9900
- const action = cyclePageDesignBlockFacet({
9901
- block: designBlock,
9902
- facetId: control.facetId,
9903
- currentValue: control.value,
9904
- direction
9905
- });
9906
- if (!action) return;
9907
- saveBlockCustomizeAction(action);
9908
- };
9909
- const handleBackgroundCycle = (action) => (e) => {
9910
- e.preventDefault();
9911
- e.stopPropagation();
9912
- saveBackgroundTransition(action);
9913
- };
9914
- const chooseBackgroundOverride = (override, options) => {
9915
- if (!designBlock) return;
9916
- const action = setPageDesignBlockBackground({
9917
- block: designBlock,
9918
- override,
9919
- currentContent: customizeContent,
9920
- imagePool: mergedBackgroundImagePool,
9921
- selectedImage: options?.selectedImage
9922
- });
9923
- if (!action) return;
9924
- saveBlockCustomizeAction(action);
9925
- setBackgroundChooserOpen(false);
9926
- };
9927
- const saveBackgroundTransition = (transition) => {
9928
- if (!designBlock || !backgroundTransitionCapability || currentBackground.kind !== "supported") return;
9929
- const plan = planBackgroundTransition(currentBackground.override, backgroundTransitionCapability, transition);
9930
- if (plan.kind !== "apply") return;
9931
- const action = setPageDesignBlockBackground({
9932
- block: designBlock,
9933
- override: plan.override,
9934
- currentContent: customizeContent,
9935
- imagePool: mergedBackgroundImagePool
9936
- });
9937
- if (!action) return;
9938
- saveBlockCustomizeAction(action);
9939
- };
9940
- const saveBlockCustomizeAction = (action) => {
9941
- applyPageDesignAction(action, { runtimeContent: customizeContent });
9942
- };
9943
- const toggleCustomize = (e) => {
9944
- if (!popover.open) {
9945
- inspectBlock();
9946
- customizeSelection?.selectBlock(editorBlockId);
9947
- }
9948
- popover.toggle(e);
9949
- };
9950
- const blockTitle = formatBlockKindLabel$1(blockKind);
9951
- const blockName = /* @__PURE__ */ jsx(BlockNamePill, {
9952
- phone: selection.phone,
9953
- label: blockTitle
9954
- });
9955
- const editButton = /* @__PURE__ */ jsx("button", {
9956
- type: "button",
9957
- onClick: handleEdit,
9958
- className: previewCustomizePillButtonClassName,
9959
- children: "Edit"
9960
- });
9961
- const legacyPopover = /* @__PURE__ */ jsx(LegacyCustomisePopover, {
9962
- popover,
9963
- blockTitle,
9964
- rows: builtInCustomizeRows.map((row) => renderBlockCustomizeBuiltinRow(row, {
9965
- backgroundCapability,
9966
- backgroundChooserOpen,
9967
- canCycleBackgroundMode,
9968
- canCycleBackgroundValue,
9969
- currentBackground,
9970
- cycleLayout,
9971
- cycleLook,
9972
- cycleFacet,
9973
- enabledBackgroundModeList,
9974
- handleBackgroundCycle,
9975
- imagePoolStatus: backgroundImagePoolStatus,
9976
- editingSlot: `${blockId}:_sectionStyles.background.image`,
9977
- mergedBackgroundImagePool,
9978
- onChooseBackgroundOverride: chooseBackgroundOverride,
9979
- onToggleBackgroundChooser: () => setBackgroundChooserOpen((open) => !open)
9980
- })),
9981
- quickFields: quickManifestBackend ? /* @__PURE__ */ jsx(QuickManifestFields, {
9982
- fields: quickManifestFields,
9983
- backend: quickManifestBackend,
9984
- blockKind,
9985
- bookingOfferingPresets
9986
- }) : null,
9987
- historyFailure,
9988
- onOpenMoreOptions: hasOverflowCustomizeControls ? openSidebarCustomize : null
8760
+ return /* @__PURE__ */ jsx(RichText, {
8761
+ ...rest,
8762
+ path,
8763
+ doc: value
9989
8764
  });
9990
- return /* @__PURE__ */ jsx(BlockToolbarFrame, {
9991
- selection,
9992
- placement,
9993
- forceVisible: popover.open,
9994
- controls: arrangementToolbar ? /* @__PURE__ */ jsx(ArrangementControlsRow, {
9995
- toolbar: arrangementToolbar,
9996
- blockName,
9997
- blockTitle,
9998
- popover,
9999
- onToggleOptions: toggleCustomize,
10000
- editButton
10001
- }) : /* @__PURE__ */ jsx(LegacyControlsRow, {
10002
- blockName,
10003
- blockTitle,
10004
- popover,
10005
- showCustomise: hasCustomizeControls,
10006
- onToggleCustomise: toggleCustomize,
10007
- editButton
10008
- }),
10009
- popoverPanel: popover.open && arrangementToolbar ? /* @__PURE__ */ jsx(ArrangementOptionsCard, {
10010
- toolbar: arrangementToolbar,
10011
- blockTitle,
10012
- popover,
10013
- historyFailure
10014
- }) : popover.open && (designBlock || hasSidebarCustomizeControls) ? legacyPopover : null
8765
+ };
8766
+ const LinkedEntryEditFrame = ({ target, children }) => {
8767
+ const { isEditingMode } = useEditor();
8768
+ if (!isEditingMode) return /* @__PURE__ */ jsx(Fragment$1, { children });
8769
+ return /* @__PURE__ */ jsxs("div", {
8770
+ className: "group/linked-entry-edit relative",
8771
+ "data-linked-entry-id": target.entryId,
8772
+ "data-linked-entry-type": target.contentTypeKey,
8773
+ children: [children, /* @__PURE__ */ jsx("button", {
8774
+ type: "button",
8775
+ "aria-label": `Edit ${target.contentTypeLabel}: ${target.title}`,
8776
+ className: "absolute right-2 top-2 z-20 rounded-full border border-white/80 bg-neutral-950/85 px-3 py-1 text-xs font-medium text-white opacity-0 shadow-sm transition focus:opacity-100 group-hover/linked-entry-edit:opacity-100",
8777
+ onClick: (event) => {
8778
+ event.preventDefault();
8779
+ event.stopPropagation();
8780
+ dispatchLinkedEntryEditEvent(target);
8781
+ },
8782
+ children: "Edit"
8783
+ })]
10015
8784
  });
10016
- }
8785
+ };
10017
8786
  /**
10018
- * Where a block's controls go: floating with the block on wider screens, or
10019
- * in one dock above the toolbar on a phone (only for the selected section).
8787
+ * In editing mode, a click on a preview button must not perform its real
8788
+ * action (navigate, submit, etc.) — instead it should hand focus to the
8789
+ * inline editable label so the author can edit the text. The caller-supplied
8790
+ * `onClick` is intentionally not invoked here; outside editing mode the
8791
+ * underlying button component receives all props unchanged.
10020
8792
  */
10021
- function BlockToolbarFrame({ selection, placement, forceVisible, controls, popoverPanel }) {
10022
- const dock = selection.phone && selection.selected;
10023
- return /* @__PURE__ */ jsxs(Fragment$1, { children: [
10024
- /* @__PURE__ */ jsx("span", {
10025
- ref: selection.probeRef,
10026
- "aria-hidden": "true",
10027
- style: { display: "contents" }
10028
- }),
10029
- dock ? /* @__PURE__ */ jsxs(PhoneBlockDock, {
10030
- themeSource: selection.blockElement,
10031
- children: [controls, popoverPanel]
10032
- }) : null,
10033
- selection.phone ? null : /* @__PURE__ */ jsxs(PreviewChromeFloatingControl, {
10034
- anchorSelector: "[data-block-id]",
10035
- placement,
10036
- fallbackClassName: "pointer-events-auto absolute z-50 flex flex-col items-end gap-1 opacity-0 transition group-focus-within:opacity-100 group-hover:opacity-100",
10037
- fallbackStyle: {
10038
- top: placement.kind === "anchor-top-right-clamped" ? placement.minTopPx : placement.topPx,
10039
- right: placement.rightPx
10040
- },
10041
- portalClassName: "absolute z-[70] flex flex-col items-end gap-1 transition",
10042
- forceVisible,
10043
- selected: selection.selected,
10044
- stayInsideAnchor: true,
10045
- children: [controls, popoverPanel]
10046
- })
10047
- ] });
10048
- }
10049
- /** Quiet block identity beside either toolbar's controls, omitted in the phone dock. */
10050
- function BlockNamePill({ phone, label }) {
10051
- if (phone) return null;
10052
- return /* @__PURE__ */ jsx("span", {
10053
- className: "shrink-0 rounded-full bg-background/95 px-2.5 py-1 text-xs text-muted-foreground",
10054
- children: label
8793
+ const ButtonWithEditorInterception = (props) => {
8794
+ const { isEditingMode } = useEditor();
8795
+ if (!isEditingMode) return /* @__PURE__ */ jsx(ButtonComponent, { ...props });
8796
+ const { onClick: _suppressedCallerOnClick, ...rest } = props;
8797
+ return /* @__PURE__ */ jsx(ButtonComponent, {
8798
+ ...rest,
8799
+ onClick: (event) => {
8800
+ event.preventDefault();
8801
+ event.currentTarget.querySelector("[contenteditable=\"true\"]")?.focus();
8802
+ }
10055
8803
  });
8804
+ };
8805
+ const editorRegistry = {
8806
+ ...clientComponentRegistry,
8807
+ text: TextWithEditor,
8808
+ richText: RichTextWithEditor,
8809
+ button: ButtonWithEditorInterception,
8810
+ media: requireClientRegistryComponent("media"),
8811
+ linkedEntryEditFrame: LinkedEntryEditFrame
8812
+ };
8813
+ //#endregion
8814
+ //#region ../preview-next/src/client/blocks/useBlockSelection.ts
8815
+ const PHONE_VIEWPORT_QUERY = "(max-width: 639px)";
8816
+ /**
8817
+ * Click to select: a click anywhere in the block selects it, so its controls
8818
+ * stay put instead of only showing on hover. A click on an empty placeholder
8819
+ * also opens the side panel on the field that fills it.
8820
+ */
8821
+ function useBlockSelection(input) {
8822
+ const probeRef = useRef(null);
8823
+ const selection = usePreviewBlockCustomizeSelectionOptional();
8824
+ const selectBlock = selection?.selectBlock;
8825
+ const onOpenFieldRef = useRef(input.onOpenField);
8826
+ onOpenFieldRef.current = input.onOpenField;
8827
+ const phone = useMediaQuery(PHONE_VIEWPORT_QUERY);
8828
+ const [blockElement, setBlockElement] = useState(null);
8829
+ useEffect(() => {
8830
+ const block = probeRef.current?.closest("[data-block-id]") ?? null;
8831
+ setBlockElement(block);
8832
+ if (!block || !selectBlock) return;
8833
+ const handleClick = (event) => {
8834
+ selectBlock(input.blockId);
8835
+ const fieldPath = (event.target instanceof Element ? event.target.closest("[data-placeholder-field]") : null)?.dataset.placeholderField;
8836
+ if (fieldPath) onOpenFieldRef.current(fieldPath);
8837
+ };
8838
+ block.addEventListener("click", handleClick);
8839
+ return () => block.removeEventListener("click", handleClick);
8840
+ }, [input.blockId, selectBlock]);
8841
+ return {
8842
+ probeRef,
8843
+ selected: selection?.selectedBlockId === input.blockId,
8844
+ blockElement,
8845
+ selectedElsewhere: selection?.selectedBlockId != null && selection.selectedBlockId !== input.blockId,
8846
+ phone
8847
+ };
10056
8848
  }
10057
- function LegacyControlsRow({ blockName, blockTitle, popover, showCustomise, onToggleCustomise, editButton }) {
10058
- return /* @__PURE__ */ jsxs("div", {
8849
+ function useMediaQuery(query) {
8850
+ const [matches, setMatches] = useState(false);
8851
+ useEffect(() => {
8852
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") return;
8853
+ const list = window.matchMedia(query);
8854
+ const update = () => setMatches(list.matches);
8855
+ update();
8856
+ list.addEventListener("change", update);
8857
+ return () => list.removeEventListener("change", update);
8858
+ }, [query]);
8859
+ return matches;
8860
+ }
8861
+ //#endregion
8862
+ //#region ../preview-next/src/client/blocks/BlockToolbar.tsx
8863
+ function BlockToolbar({ placement = DEFAULT_PREVIEW_CHROME_FLOATING_PLACEMENT, ...input }) {
8864
+ const { selection, controls, toolbar, open, cycleSdk, cycleLegacy } = useBlockToolbar(input);
8865
+ const name = controls.manifest?.title ?? getBlockDefinition(input.blockKind)?.manifest.title ?? input.blockKind;
8866
+ const row = /* @__PURE__ */ jsxs("div", {
10059
8867
  role: "group",
10060
- "aria-label": `${blockTitle} controls`,
8868
+ "aria-label": `${name} controls`,
10061
8869
  className: "flex items-center gap-1",
10062
8870
  "data-preview-chrome-row": "",
10063
8871
  children: [
10064
- blockName,
10065
- showCustomise ? /* @__PURE__ */ jsx(CustomizePillButton, {
10066
- buttonRef: popover.buttonRef,
10067
- ariaLabel: "Customise",
10068
- open: popover.open,
10069
- controlsId: popover.panelId,
10070
- onClick: onToggleCustomise
8872
+ /* @__PURE__ */ jsx(ToolbarNameButton, {
8873
+ name,
8874
+ open
8875
+ }),
8876
+ toolbar?.controls.mode ? /* @__PURE__ */ jsx(ArrangementModeSwitchPill, {
8877
+ blockLabel: name,
8878
+ mode: toolbar.controls.mode,
8879
+ onChoose: toolbar.chooseMode
10071
8880
  }) : null,
10072
- editButton
8881
+ /* @__PURE__ */ jsx(ToolbarLook, {
8882
+ controls,
8883
+ toolbar,
8884
+ onCycleSdk: cycleSdk,
8885
+ onCycleLegacy: cycleLegacy
8886
+ })
10073
8887
  ]
10074
8888
  });
8889
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("span", {
8890
+ ref: selection.probeRef,
8891
+ "aria-hidden": "true"
8892
+ }), /* @__PURE__ */ jsx(ToolbarPlacement, {
8893
+ blockId: input.blockId,
8894
+ placement,
8895
+ selected: selection.selected,
8896
+ phone: selection.phone,
8897
+ children: row
8898
+ })] });
10075
8899
  }
10076
- function QuickManifestFields({ fields, backend, blockKind, bookingOfferingPresets }) {
10077
- if (fields.length === 0) return null;
10078
- return /* @__PURE__ */ jsx("div", {
10079
- className: "border-t pt-3",
10080
- children: /* @__PURE__ */ jsx(OfferingsPreviewWidgetProvider, {
10081
- bookingOfferingPresets,
10082
- children: /* @__PURE__ */ jsx(FormRenderer, {
10083
- dateContext: civilPickerDisplay.dateContext,
10084
- fields,
10085
- backend,
10086
- widgetOverrides: previewWidgetOverrides,
10087
- showSettingsTrigger: false,
10088
- blockKind,
10089
- className: "space-y-3"
10090
- })
10091
- })
8900
+ function useBlockToolbar(input) {
8901
+ const uiStore = useEditorUiStoreInstance();
8902
+ const editorBlockId = useMemo(() => unsafeAsEditorBlockId(input.blockId), [input.blockId]);
8903
+ const values = useEditorUiStore((state) => state.drafts.getCurrentValues(editorBlockId)) ?? input.content;
8904
+ const { open, openField } = useOpenBlockSidebar(editorBlockId, uiStore);
8905
+ const selection = useBlockSelection({
8906
+ blockId: editorBlockId,
8907
+ onOpenField: openField
8908
+ });
8909
+ const controls = useBlockCustomizeControls({
8910
+ blockId: editorBlockId,
8911
+ blockKind: input.blockKind,
8912
+ content: values,
8913
+ uiStore,
8914
+ theme: input.theme
8915
+ });
8916
+ const { state, applyAction } = usePreviewPageDesignEditorState();
8917
+ const toolbar = useArrangementToolbar({
8918
+ designBlock: controls.designBlock,
8919
+ content: values,
8920
+ pageDesignState: state,
8921
+ selected: selection.selected,
8922
+ save: (action) => {
8923
+ applyAction(action, { runtimeContent: values });
8924
+ },
8925
+ chooseBackground: open,
8926
+ openField
10092
8927
  });
8928
+ const cycleSdk = (direction) => cycleSdkLook(controls, direction);
8929
+ const cycleLegacy = (direction) => {
8930
+ if (!controls.designBlock) return;
8931
+ const action = cyclePageDesignBlockLook(controls.designBlock, direction);
8932
+ if (action) applyAction(action, { runtimeContent: values });
8933
+ };
8934
+ return {
8935
+ selection,
8936
+ controls,
8937
+ toolbar,
8938
+ open,
8939
+ cycleSdk,
8940
+ cycleLegacy
8941
+ };
10093
8942
  }
10094
- /** On a phone the selected section's controls sit in one dock above the toolbar. */
10095
- function PhoneBlockDock({ themeSource, children }) {
10096
- if (typeof document === "undefined") return null;
10097
- return createPortal(/* @__PURE__ */ jsx("div", {
8943
+ function useOpenBlockSidebar(blockId, uiStore) {
8944
+ const selection = usePreviewBlockCustomizeSelectionOptional();
8945
+ const open = () => {
8946
+ selection?.selectBlock(blockId);
8947
+ selection?.inspectBlock(blockId);
8948
+ uiStore.getState().setDrawerOpen(true);
8949
+ };
8950
+ const openField = (fieldPath) => {
8951
+ open();
8952
+ uiStore.getState().requestFocus({
8953
+ kind: "main-field",
8954
+ blockId,
8955
+ fieldPath: fieldPath.startsWith("content.") ? fieldPath : `content.${fieldPath}`
8956
+ });
8957
+ };
8958
+ return {
8959
+ open,
8960
+ openField
8961
+ };
8962
+ }
8963
+ function cycleSdkLook(controls, direction) {
8964
+ const item = controls.lookSource.kind === "sdk" ? controls.lookSource.item : null;
8965
+ if (item?.field.type !== "select" || !controls.backend) return;
8966
+ const options = item.field.options;
8967
+ const current = options.findIndex((option) => option.value === (controls.backend?.getValue(item.path) ?? item.field.defaultValue));
8968
+ const next = options[(Math.max(0, current) + (direction === "next" ? 1 : options.length - 1)) % options.length];
8969
+ if (next) controls.backend.setValue(item.path, next.value);
8970
+ }
8971
+ /** The Look pill shows only while its arrows have somewhere to go. */
8972
+ function ToolbarLook({ controls, toolbar, onCycleSdk, onCycleLegacy }) {
8973
+ if (controls.lookSource.kind === "sdk") {
8974
+ const field = cyclableSdkLookField(controls.lookSource.item);
8975
+ return field && controls.lookSource.item ? /* @__PURE__ */ jsx(SdkToolbarLook, {
8976
+ field,
8977
+ value: controls.backend?.getValue(controls.lookSource.item.path),
8978
+ onCycle: onCycleSdk
8979
+ }) : null;
8980
+ }
8981
+ if (toolbar?.controls.look) return toolbar.controls.tiles.length > 1 ? /* @__PURE__ */ jsx(ArrangementLookPill, {
8982
+ look: toolbar.controls.look,
8983
+ position: lookTilePosition(toolbar.controls.tiles),
8984
+ onCycle: toolbar.cycleLook
8985
+ }) : null;
8986
+ if (!controls.designBlock) return null;
8987
+ const preset = pageDesignLookPosition(controls.designBlock);
8988
+ return preset.canCycle ? /* @__PURE__ */ jsx(LookCyclePill, {
8989
+ lookName: preset.lookName,
8990
+ position: preset.position,
8991
+ onCycle: onCycleLegacy
8992
+ }) : null;
8993
+ }
8994
+ function cyclableSdkLookField(item) {
8995
+ return item?.field.type === "select" && item.field.options.length > 1 ? item.field : null;
8996
+ }
8997
+ function ToolbarPlacement({ blockId, placement, selected, phone, children }) {
8998
+ if (phone && selected && typeof document !== "undefined") return createPortal(/* @__PURE__ */ jsx("div", {
10098
8999
  "data-preview-block-dock": "",
9000
+ className: "builder-dashboard-chrome-theme fixed inset-x-2 bottom-[calc(var(--builder-editor-chrome-offset,0px)+0.5rem)] rounded-xl border bg-background/95 p-2 text-foreground shadow-xl",
10099
9001
  style: {
10100
- ...themeSource ? readThemeCustomProperties(themeSource) : {},
10101
- zIndex: PREVIEW_CHROME_Z_INDEX
9002
+ ...readThemeCustomProperties(document.querySelector(`[data-block-id="${blockId}"]`) ?? document.documentElement),
9003
+ zIndex: 30
10102
9004
  },
10103
- className: "builder-dashboard-chrome-theme fixed inset-x-2 bottom-[calc(var(--builder-editor-chrome-offset,0px)+0.5rem)] flex flex-col items-stretch gap-1.5 rounded-xl border bg-background/95 p-2 text-foreground shadow-xl",
10104
9005
  children
10105
9006
  }), document.body);
10106
- }
10107
- /** The Customise card for legacy styles: today's rows, quick fields and More options. */
10108
- function LegacyCustomisePopover({ popover, blockTitle, rows, quickFields, historyFailure, onOpenMoreOptions }) {
10109
- return /* @__PURE__ */ jsxs(CustomizePopoverShell, {
10110
- panelId: popover.panelId,
10111
- descriptionId: popover.descriptionId,
10112
- dialogLabel: "Customise section",
10113
- eyebrow: "Section",
10114
- title: blockTitle,
10115
- dialogRef: popover.dialogRef,
10116
- closeButtonRef: popover.registerInitialFocus,
10117
- onClose: popover.close,
10118
- onKeyDown: popover.handleDialogKeyDown,
10119
- spacing: "compact",
10120
- children: [
10121
- rows,
10122
- quickFields,
10123
- historyFailure ? /* @__PURE__ */ jsx("p", {
10124
- className: "text-xs text-red-700",
10125
- children: historyFailure
10126
- }) : null,
10127
- onOpenMoreOptions ? /* @__PURE__ */ jsx("div", {
10128
- className: "border-t pt-2",
10129
- children: /* @__PURE__ */ jsx("button", {
10130
- type: "button",
10131
- "aria-label": "Open more options in the side panel",
10132
- className: "w-full rounded-md border bg-background px-3 py-2 text-sm font-medium hover:bg-muted",
10133
- onClick: onOpenMoreOptions,
10134
- children: "More options"
10135
- })
10136
- }) : null
10137
- ]
9007
+ return /* @__PURE__ */ jsx(PreviewChromeFloatingControl, {
9008
+ anchorSelector: `[data-block-id="${blockId}"]`,
9009
+ placement,
9010
+ selected,
9011
+ stayInsideAnchor: true,
9012
+ fallbackClassName: "absolute right-4 top-2",
9013
+ children
10138
9014
  });
10139
9015
  }
10140
- function renderBlockCustomizeBuiltinRow(row, context) {
10141
- switch (row.kind) {
10142
- case "variant": return /* @__PURE__ */ jsx(CustomizeCycleRow, {
10143
- label: "Layout",
10144
- valueLabel: layoutLabel(row.block.availableLayouts, row.block.layoutChoice.effectiveValue ?? ""),
10145
- previousLabel: "Previous layout",
10146
- nextLabel: "Next layout",
10147
- availability: cycleAvailability({ kind: "available" }),
10148
- onPrevious: () => context.cycleLayout("prev"),
10149
- onNext: () => context.cycleLayout("next")
10150
- }, "variant");
10151
- case "unsupported-variant-warning": return /* @__PURE__ */ jsx("p", {
10152
- className: "text-xs text-amber-700",
10153
- children: "This layout is no longer available. The preview is using the closest safe option."
10154
- }, "unsupported-variant-warning");
10155
- case "look": return /* @__PURE__ */ jsx(CustomizeCycleRow, {
10156
- label: "Look",
10157
- valueLabel: lookLabel(row.block),
10158
- previousLabel: "Previous look",
10159
- nextLabel: "Next look",
10160
- availability: cycleAvailability(canCycleLookForRow(row.block) ? { kind: "available" } : { kind: "single-option" }),
10161
- onPrevious: () => context.cycleLook("prev"),
10162
- onNext: () => context.cycleLook("next")
10163
- }, "look");
10164
- case "background":
10165
- if (context.currentBackground.kind !== "supported" || !context.backgroundCapability) return null;
10166
- return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(CustomizeBackgroundControlRows, {
10167
- modeLabel: backgroundModeLabel(context.currentBackground.override.kind),
10168
- valueLabel: backgroundOverrideValueLabel(context.currentBackground.override, context.mergedBackgroundImagePool),
10169
- valueAriaLabel: `Choose background ${backgroundOverrideLabel(context.currentBackground.override).toLowerCase()}`,
10170
- swatch: /* @__PURE__ */ jsx(BackgroundPreviewSwatch, {
10171
- override: context.currentBackground.override,
10172
- imagePool: context.mergedBackgroundImagePool
10173
- }),
10174
- chooserOpen: context.backgroundChooserOpen,
10175
- canCycleMode: context.canCycleBackgroundMode,
10176
- canCycleValue: context.canCycleBackgroundValue,
10177
- onCycleMode: (direction, event) => context.handleBackgroundCycle({
10178
- kind: "cycle-mode",
10179
- direction
10180
- })(event),
10181
- onCycleValue: (direction, event) => context.handleBackgroundCycle({
10182
- kind: "cycle-value",
10183
- direction
10184
- })(event),
10185
- onToggleChooser: (event) => {
10186
- event.preventDefault();
10187
- event.stopPropagation();
10188
- context.onToggleBackgroundChooser();
10189
- },
10190
- chooser: /* @__PURE__ */ jsx(BackgroundChooser, {
10191
- editingSlot: context.editingSlot,
10192
- capability: context.backgroundCapability,
10193
- current: context.currentBackground.override,
10194
- imagePoolStatus: context.imagePoolStatus,
10195
- onChoose: context.onChooseBackgroundOverride
10196
- })
10197
- }) }, "background");
10198
- case "facet": return /* @__PURE__ */ jsx(CustomizeCycleRow, {
10199
- label: row.control.label,
10200
- valueLabel: row.control.valueLabel,
10201
- previousLabel: `Previous ${row.control.label.toLowerCase()}`,
10202
- nextLabel: `Next ${row.control.label.toLowerCase()}`,
10203
- availability: cycleAvailability({ kind: "available" }),
10204
- onPrevious: () => context.cycleFacet(row.control, "prev"),
10205
- onNext: () => context.cycleFacet(row.control, "next")
10206
- }, `facet:${row.control.facetId}`);
10207
- default: return assertNever$1(row, "Unhandled block customize builtin row");
10208
- }
10209
- }
10210
- function canCycleLookForRow(block) {
10211
- return block.lookAvailability.kind === "available" && block.availableLooks.length > 1;
10212
- }
10213
- function computeDefaultFocus(blockKind, content) {
10214
- const definition = getBlockDefinition(blockKind);
10215
- if (!definition?.manifest) return {
10216
- fieldPath: null,
10217
- itemIndex: null
10218
- };
10219
- const result = findFirstFieldPath(definition.manifest.fields, content, []);
10220
- if (!result) return {
10221
- fieldPath: null,
10222
- itemIndex: null
10223
- };
10224
- return {
10225
- fieldPath: result.path ? `content.${result.path}` : null,
10226
- itemIndex: typeof result.itemIndex === "number" ? result.itemIndex : null
10227
- };
10228
- }
10229
- function findFirstFieldPath(fields, data, prefix) {
10230
- for (const field of fields) {
10231
- if (field.ui?.hidden) continue;
10232
- if (Array.isArray(field.visibleRoles) && !field.visibleRoles.includes("author")) continue;
10233
- const nextPrefix = [...prefix, field.id];
10234
- if (field.type === "group") {
10235
- const groupValue = isRecord(data) ? data[field.id] : void 0;
10236
- const nested = findFirstFieldPath(field.schema.fields, groupValue, nextPrefix);
10237
- if (nested) return nested;
10238
- continue;
10239
- }
10240
- if (field.type === "repeater" && field.schema) {
10241
- const collection = isRecord(data) ? data[field.id] : void 0;
10242
- const items = isUnknownArray(collection) ? collection : [];
10243
- if (items.length > 0) {
10244
- const firstItem = items[0];
10245
- const nested = findFirstFieldPath(field.schema.fields, firstItem, [...nextPrefix, "0"]);
10246
- if (nested) return nested;
10247
- return {
10248
- path: nextPrefix.join("."),
10249
- itemIndex: 0
10250
- };
10251
- }
10252
- return {
10253
- path: nextPrefix.join("."),
10254
- itemIndex: 0
10255
- };
10256
- }
10257
- return { path: nextPrefix.join(".") };
10258
- }
10259
- return null;
10260
- }
10261
- function formatBlockKindLabel$1(blockKind) {
10262
- return getBlockDefinition(blockKind)?.manifest.title ?? formatVariantLabel(blockKind.replace(/^block\./, "").replace(/\./g, " "));
10263
- }
10264
- function layoutLabel(layouts, variantKey) {
10265
- return layouts.find((layout) => layout.id === variantKey)?.label ?? formatVariantLabel(variantKey);
10266
- }
10267
- function lookLabel(block) {
10268
- const option = block.availableLooks.find((look) => look.id === block.look.effectiveValue) ?? null;
10269
- if (block.look.kind === "auto" || block.look.status === "unsupported") return option ? `Automatic · ${option.label}` : "Automatic";
10270
- return option?.label ?? "Selected look";
10271
- }
10272
- function backgroundOverrideLabel(override) {
10273
- switch (override.kind) {
10274
- case "default": return "From the style";
10275
- case "color": return `Colour: ${formatTokenLabel(override.token)}`;
10276
- case "gradient": return `Gradient: ${gradientLabel(override.gradientId)}`;
10277
- case "image": return "Image";
10278
- }
10279
- }
10280
- function backgroundOverrideValueLabel(override, imagePool) {
10281
- switch (override.kind) {
10282
- case "default": return "No colour chosen";
10283
- case "color": return formatTokenLabel(override.token);
10284
- case "gradient": return gradientLabel(override.gradientId);
10285
- case "image": return imagePool.find((item) => item.reference.identifier === override.reference.identifier)?.label ?? "Image";
10286
- }
10287
- }
10288
- function backgroundModeLabel(mode) {
10289
- switch (mode) {
10290
- case "default": return "From the style";
10291
- case "color": return "Colour";
10292
- case "gradient": return "Gradient";
10293
- case "image": return "Photo";
10294
- }
9016
+ function ToolbarNameButton({ name, open }) {
9017
+ return /* @__PURE__ */ jsxs("button", {
9018
+ type: "button",
9019
+ className: "flex h-7 shrink-0 items-center rounded-full bg-background/95 px-3 text-xs font-medium text-foreground shadow hover:bg-background",
9020
+ onClick: (event) => {
9021
+ event.stopPropagation();
9022
+ open();
9023
+ },
9024
+ children: [name, " ›"]
9025
+ });
10295
9026
  }
10296
- function readBackgroundColorPaletteSnapshot() {
10297
- if (typeof window === "undefined" || typeof document === "undefined") return null;
10298
- const rootStyle = window.getComputedStyle(document.documentElement);
10299
- const bodyStyle = document.body ? window.getComputedStyle(document.body) : null;
10300
- const entries = backgroundColorTokens.flatMap((token) => {
10301
- const value = rootStyle.getPropertyValue(`--tb-${token}`).trim() || bodyStyle?.getPropertyValue(`--tb-${token}`).trim() || "";
10302
- return value ? [[token, value]] : [];
10303
- });
10304
- return entries.length > 0 ? Object.fromEntries(entries) : null;
10305
- }
10306
- function dedupeBackgroundImagePool(items) {
10307
- return Array.from(items.reduce((pool, item) => {
10308
- const key = item.reference.identifier;
10309
- const existing = pool.get(key);
10310
- const decided = existing ? existing.source === "current" ? {
10311
- ...existing,
10312
- mediaAsset: existing.mediaAsset ?? item.mediaAsset,
10313
- label: existing.label ?? item.label,
10314
- rank: existing.rank ?? item.rank
10315
- } : {
10316
- ...existing,
10317
- label: existing.label ?? item.label,
10318
- rank: existing.rank ?? item.rank
10319
- } : item;
10320
- return new Map([...pool, [key, decided]]);
10321
- }, /* @__PURE__ */ new Map()).values());
9027
+ function SdkToolbarLook({ field, value, onCycle }) {
9028
+ const index = field.options.findIndex((option) => option.value === (value ?? field.defaultValue));
9029
+ return /* @__PURE__ */ jsx(LookCyclePill, {
9030
+ lookName: field.options[index]?.label ?? "Choose a Look",
9031
+ position: lookPositionLabel(index, field.options.length),
9032
+ onCycle
9033
+ });
10322
9034
  }
10323
9035
  //#endregion
10324
9036
  //#region ../preview-next/src/client/blocks/BoundaryControl.tsx
@@ -10777,7 +9489,28 @@ function toPreviewBatchParams(endpoint, params) {
10777
9489
  //#endregion
10778
9490
  //#region ../preview-next/src/client/blocks/EditablePageRenderer.tsx
10779
9491
  const MAX_PREVIEW_BLOCK_DATA_BATCH_SIZE = 25;
9492
+ /** Published requests bypass every editor, draft, AI and design overlay. View presentation of a live draft still uses the draft renderer. */
10780
9493
  function EditablePageRenderer(props) {
9494
+ if (props.dataContext?.previewStage === "published") {
9495
+ const { blockDataApiClient: _blockDataApiClient, previewAs: _previewAs, previewAuthoring: _previewAuthoring, renderJoin: _renderJoin, ...published } = props;
9496
+ const page = published.page ? {
9497
+ ...published.page,
9498
+ blocks: published.page.blocks.map((block) => ({
9499
+ ...block,
9500
+ draftContent: null,
9501
+ publishedPlacement: readPublishedBlockPlacement(typeof block.contentVersionId === "string" ? block.contentVersionId : null, block.content)
9502
+ }))
9503
+ } : null;
9504
+ return /* @__PURE__ */ jsx(EditorPageRenderer, {
9505
+ ...published,
9506
+ page,
9507
+ previewAs: "visitor",
9508
+ previewAuthoring: void 0
9509
+ });
9510
+ }
9511
+ return /* @__PURE__ */ jsx(EditableDraftPageRenderer, { ...props });
9512
+ }
9513
+ function EditableDraftPageRenderer(props) {
10781
9514
  const { blockDataApiClient = null, ...pageRendererProps } = props;
10782
9515
  const { blocks } = useEntryEditorController();
10783
9516
  const uiStore = useEditorUiStoreInstance();
@@ -10799,7 +9532,7 @@ function EditablePageRenderer(props) {
10799
9532
  } };
10800
9533
  }, [activePreviewField, allowInlineEditing]);
10801
9534
  const isEntryTemplatePage = Boolean(pageRendererProps.dataContext?.contentEntry);
10802
- const headerClearance = usePreviewHeaderClearance();
9535
+ const headerClearance = useSiteTopChromeClearance();
10803
9536
  const cacheRef = useRef(/* @__PURE__ */ new Map());
10804
9537
  const renderStateVersion = useEditorUiStore((state) => {
10805
9538
  const snapshots = state.drafts.inspect();
@@ -10839,7 +9572,7 @@ function EditablePageRenderer(props) {
10839
9572
  return applyPreviewStructureProjections(blockItems, aiProjections);
10840
9573
  }, [aiProjections, blockItems]);
10841
9574
  const dateContext = usePreviewDateContext(pageRendererProps.dataContext);
10842
- const renderPage = useMemo(() => {
9575
+ const mergedPage = useMemo(() => {
10843
9576
  return composePageFromBlocks({
10844
9577
  page: pageRendererProps.page,
10845
9578
  dateContext,
@@ -10857,12 +9590,17 @@ function EditablePageRenderer(props) {
10857
9590
  remoteDrafts,
10858
9591
  contentSnapshot,
10859
9592
  renderSource
10860
- ]) ?? {
9593
+ ]);
9594
+ const renderPage = useMemo(() => projectAuthoringLocationMaps(mergedPage ?? {
10861
9595
  name: "",
10862
9596
  path: "",
10863
9597
  purpose: "",
10864
9598
  blocks: []
10865
- };
9599
+ }, pageRendererProps.page, linkedEntryDataContext?.siteCountry), [
9600
+ mergedPage,
9601
+ pageRendererProps.page,
9602
+ linkedEntryDataContext?.siteCountry
9603
+ ]);
10866
9604
  const runtimeJoins = editorRuntimeJoins(runtimeProjection, pageRendererProps.runtimeJoins);
10867
9605
  const renderedBlockById = useMemo(() => {
10868
9606
  return new Map((renderPage?.blocks ?? []).filter((block) => Boolean(block.id)).map((block) => [block.id, block]));
@@ -10933,13 +9671,13 @@ function EditablePageRenderer(props) {
10933
9671
  dataContext: linkedEntryDataContext,
10934
9672
  apiClient: blockDataApiClient
10935
9673
  });
10936
- useLinkedSaveHandoverRetention(uiStore, entryDataContext, liveResolvedData);
9674
+ useLinkedSaveHandoverRetention(uiStore, entryDataContext, liveResolvedData.resolvedData);
10937
9675
  const generatedIconAssetOverlay = useMemo(() => generatedIconAssetsByBlock(uiStore, renderPage.blocks), [
10938
9676
  renderPage.blocks,
10939
9677
  renderStateVersion,
10940
9678
  uiStore
10941
9679
  ]);
10942
- const dataContext = useMemo(() => mergeGeneratedIconAssetsIntoDataContext(applyLinkedEntryRenderOverlayToDataContext(mergeResolvedDataContext(linkedEntryDataContext, liveResolvedData), linkedEntryOverlays), generatedIconAssetOverlay), [
9680
+ const dataContext = useMemo(() => mergeGeneratedIconAssetsIntoDataContext(applyLinkedEntryRenderOverlayToDataContext(mergeLiveLoaderContext(linkedEntryDataContext, liveResolvedData), linkedEntryOverlays), generatedIconAssetOverlay), [
10943
9681
  generatedIconAssetOverlay,
10944
9682
  linkedEntryDataContext,
10945
9683
  liveResolvedData,
@@ -10959,7 +9697,7 @@ function EditablePageRenderer(props) {
10959
9697
  }
10960
9698
  /**
10961
9699
  * Edit mode shows placeholders and block controls; view mode renders the page
10962
- * as visitors see it, with each Look's published fallbacks.
9700
+ * with visitor presentation of the live draft. This does not select publication.
10963
9701
  */
10964
9702
  function editorRenderMode(input) {
10965
9703
  return {
@@ -10976,24 +9714,9 @@ function editorRuntimeJoins(projection, fallback) {
10976
9714
  }
10977
9715
  function usePreviewBlockResolvedData(args) {
10978
9716
  const { page, dataContext, apiClient } = args;
10979
- const cacheKey = useMemo(() => {
10980
- if (!apiClient || !dataContext?.siteId) return null;
10981
- return stableSerialize({
10982
- siteId: dataContext.siteId,
10983
- pageId: dataContext.pageId ?? null,
10984
- previewStage: dataContext.previewStage ?? "published",
10985
- blocks: page.blocks.map((block) => ({
10986
- id: block.id,
10987
- kind: block.kind,
10988
- content: block.content ?? null,
10989
- draftContent: block.draftContent ?? null
10990
- }))
10991
- });
10992
- }, [
9717
+ const cacheKey = useMemo(() => previewBlockDataRequestKey(page, dataContext, apiClient !== null), [
10993
9718
  apiClient,
10994
- dataContext?.pageId,
10995
- dataContext?.previewStage,
10996
- dataContext?.siteId,
9719
+ dataContext,
10997
9720
  page
10998
9721
  ]);
10999
9722
  const [resolvedData, setResolvedData] = useState(null);
@@ -11005,12 +9728,15 @@ function usePreviewBlockResolvedData(args) {
11005
9728
  let cancelled = false;
11006
9729
  const context = buildPreviewBlockDataContext(dataContext);
11007
9730
  const loaderClient = createPreviewBlockDataApiClient(apiClient, context);
11008
- Promise.all([prefetchBlockData(page, context, {
9731
+ Promise.all([prefetchBlockDataWithFailures(page, context, {
11009
9732
  apiClient: loaderClient,
11010
9733
  isValidEndpoint: isSupportedLoaderEndpoint,
11011
9734
  onError: () => {}
11012
9735
  }), prefetchGeneratedIconAssets(page, dataContext.siteId, apiClient).catch(() => ({}))]).then(([data, generatedIconAssets]) => {
11013
- const merged = mergeGeneratedIconAssets(data, generatedIconAssets);
9736
+ const merged = {
9737
+ ...data,
9738
+ resolvedData: mergeGeneratedIconAssets(data.resolvedData, generatedIconAssets)
9739
+ };
11014
9740
  if (!cancelled) setResolvedData({
11015
9741
  key: cacheKey,
11016
9742
  data: merged
@@ -11025,7 +9751,39 @@ function usePreviewBlockResolvedData(args) {
11025
9751
  dataContext,
11026
9752
  page
11027
9753
  ]);
11028
- return resolvedData?.data ?? null;
9754
+ return useMemo(() => {
9755
+ const current = resolvedData?.key === cacheKey ? resolvedData.data : null;
9756
+ return {
9757
+ resolvedData: current?.resolvedData ?? null,
9758
+ loaderFailures: current?.loaderFailures ?? null,
9759
+ prefetchedBlockData: current ?? void 0,
9760
+ loaderSnapshot: current?.loaderSnapshot
9761
+ };
9762
+ }, [cacheKey, resolvedData]);
9763
+ }
9764
+ /** Request identity couples loaded facts to this content selection and its stage. */
9765
+ function previewBlockDataRequestKey(page, context, enabled) {
9766
+ if (!enabled || !context?.siteId) return null;
9767
+ const { siteId, pageId, previewStage } = context;
9768
+ return stableSerialize({
9769
+ siteId,
9770
+ pageId: pageId ?? null,
9771
+ previewStage: previewStage ?? "published",
9772
+ blocks: page.blocks.map((block) => ({
9773
+ id: block.id,
9774
+ kind: block.kind,
9775
+ content: selectBlockContent(block, previewStage)
9776
+ }))
9777
+ });
9778
+ }
9779
+ function mergeLiveLoaderContext(context, live) {
9780
+ const merged = mergeResolvedDataContext(context, live.resolvedData);
9781
+ return merged && live.loaderFailures ? {
9782
+ ...merged,
9783
+ loaderFailures: live.loaderFailures,
9784
+ prefetchedBlockData: live.prefetchedBlockData,
9785
+ loaderSnapshot: live.loaderSnapshot
9786
+ } : merged;
11029
9787
  }
11030
9788
  async function prefetchGeneratedIconAssets(page, siteId, apiClient) {
11031
9789
  const blockRefs = collectGeneratedIconAssetRefs(page);
@@ -11131,65 +9889,6 @@ async function callDirectLoaderApiEndpoint(dashboardApiClient, endpoint, params)
11131
9889
  })));
11132
9890
  }
11133
9891
  }
11134
- function usePreviewHeaderClearance() {
11135
- const [clearance, setClearance] = useState({ kind: "none" });
11136
- useEffect(() => {
11137
- let observedHeader = null;
11138
- let resizeObserver = null;
11139
- const update = () => {
11140
- const header = findPreviewOverlayHeader();
11141
- if (header !== observedHeader) {
11142
- resizeObserver?.disconnect();
11143
- observedHeader = header;
11144
- resizeObserver = header ? new ResizeObserver(update) : null;
11145
- if (header) resizeObserver?.observe(header);
11146
- }
11147
- if (!header) {
11148
- setClearance((current) => current.kind === "none" ? current : { kind: "none" });
11149
- return;
11150
- }
11151
- const style = window.getComputedStyle(header);
11152
- const nextClearance = headerClearanceFromPx(style.position === "fixed" || style.position === "sticky" ? measuredOverlayHeaderClearancePx(header) : 0);
11153
- setClearance((current) => headerClearanceEquals(current, nextClearance) ? current : nextClearance);
11154
- };
11155
- update();
11156
- const mutationObserver = new MutationObserver(update);
11157
- mutationObserver.observe(document.body, {
11158
- attributes: true,
11159
- attributeFilter: ["class"],
11160
- childList: true,
11161
- subtree: true
11162
- });
11163
- window.addEventListener("resize", update);
11164
- return () => {
11165
- resizeObserver?.disconnect();
11166
- mutationObserver.disconnect();
11167
- window.removeEventListener("resize", update);
11168
- };
11169
- }, []);
11170
- return clearance;
11171
- }
11172
- function headerClearanceEquals(left, right) {
11173
- if (left.kind !== right.kind) return false;
11174
- switch (left.kind) {
11175
- case "none": return true;
11176
- case "overlay": return right.kind === "overlay" && left.px === right.px;
11177
- }
11178
- }
11179
- function findPreviewOverlayHeader() {
11180
- return document.querySelector(".block-site-header.rb-fixed, .block-site-header.rb-sticky");
11181
- }
11182
- function measuredOverlayHeaderClearancePx(header) {
11183
- const visibleHeader = findVisibleHeaderMeasurementTarget(header);
11184
- return visibleHeaderClearancePx(visibleHeader ? visibleHeader.getBoundingClientRect() : header.getBoundingClientRect());
11185
- }
11186
- function findVisibleHeaderMeasurementTarget(header) {
11187
- return Array.from(header.querySelectorAll(SITE_CHROME_VISIBLE_HEADER_SELECTOR)).find((candidate) => {
11188
- const style = window.getComputedStyle(candidate);
11189
- const rect = candidate.getBoundingClientRect();
11190
- return style.display !== "none" && rect.height > 0 && rect.bottom > 0;
11191
- }) ?? null;
11192
- }
11193
9892
  function usePreviewDateContext(dataContext) {
11194
9893
  const supplied = dataContext?.dateContext;
11195
9894
  const zone = dataContext?.bookingTimeZone;
@@ -11302,7 +10001,6 @@ function SdkPreviewModeRuntime(props) {
11302
10001
  isSiteLaunched: true,
11303
10002
  maintenanceModeEnabled: false,
11304
10003
  entrySubrouteContext: null,
11305
- assistantPanel: null,
11306
10004
  sdkConfig: sdkConfigForEditor,
11307
10005
  mediaAssets: content.mediaAssets,
11308
10006
  supabaseUrl: content.supabaseUrl,
@@ -11347,7 +10045,7 @@ function sdkPreviewDataContext(props, routeMap) {
11347
10045
  };
11348
10046
  }
11349
10047
  function resolveSdkPreviewRuntimeModel(props) {
11350
- const { apiBaseUrl, content, siteId } = props;
10048
+ const { apiBaseUrl, content } = props;
11351
10049
  const rendering = props.rendering ?? {
11352
10050
  kind: "themed",
11353
10051
  themeRuntime: props.themeRuntime ?? defaultPreviewThemeRuntime