@riverbankcms/sdk 0.182.0 → 0.184.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 (231) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +83 -4
  3. package/dist/_dts/{BlocksIslandsHydrator-Bvw2bUif.d.ts → BlocksIslandsHydrator-DjBTJYiF.d.ts} +1 -1
  4. package/dist/_dts/{Page-B2EAT-bE.d.ts → Page-BpXEM2ET.d.ts} +7 -7
  5. package/dist/_dts/{SdkPreviewMode-D0vww6rh.d.ts → SdkPreviewMode-Bb3h7KRE.d.ts} +2 -2
  6. package/dist/_dts/{client-D6T430bk.d.ts → client-DgTRRtl_.d.ts} +14 -1
  7. package/dist/_dts/{content-types-wZVWccC6.d.ts → content-types-DZQJp_ak.d.ts} +9 -16
  8. package/dist/_dts/{contracts-B-vtOcr8.d.ts → contracts-Ww1fmd-c.d.ts} +3 -3
  9. package/dist/_dts/{generatePageMetadata-CxfwHE6z.d.ts → generatePageMetadata-BGc7dju6.d.ts} +2 -2
  10. package/dist/_dts/{index-CciRW_w1.d.ts → index-BECaUNYs.d.ts} +2 -2
  11. package/dist/_dts/{index-CEyYMhLJ.d.ts → index-Cc85KVLW.d.ts} +3 -3
  12. package/dist/_dts/{index-CQrb3Ccc.d.ts → index-Cni4jykw.d.ts} +4 -4
  13. package/dist/_dts/{index-DIU-wL1M.d.ts → index-DxxTQ_0V.d.ts} +2 -2
  14. package/dist/_dts/{index-Cqxis-nv.d.ts → index-W9-7djG3.d.ts} +1 -1
  15. package/dist/_dts/{index-DqPKdeTk.d.ts → index-ukS-Ffem.d.ts} +1 -1
  16. package/dist/_dts/{loadContent-D0wrxiSp.d.ts → loadContent-BlSWTlbD.d.ts} +7 -7
  17. package/dist/_dts/{request-DEwxUSw8.d.ts → request-CZz2BoXJ.d.ts} +89478 -88093
  18. package/dist/_dts/{resolveBlockData-VaG_MYbN.d.ts → resolveBlockData-D12HXnS3.d.ts} +5 -5
  19. package/dist/_dts/{resolvePageContent-DTwklC_v.d.ts → resolvePageContent-BteMsSGP.d.ts} +1 -1
  20. package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
  21. package/dist/_dts/sdk/src/client/types.d.ts +2 -2
  22. package/dist/_dts/sdk/src/client.d.ts +7 -7
  23. package/dist/_dts/sdk/src/config/index.d.ts +7 -7
  24. package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
  25. package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
  26. package/dist/_dts/sdk/src/data/dataLoaderContext.d.ts +2 -2
  27. package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +1 -1
  28. package/dist/_dts/sdk/src/data/types.d.ts +2 -2
  29. package/dist/_dts/sdk/src/gifting/client.d.ts +1 -1
  30. package/dist/_dts/sdk/src/index.d.ts +8 -8
  31. package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
  32. package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
  33. package/dist/_dts/sdk/src/navigation/index.d.ts +3 -3
  34. package/dist/_dts/sdk/src/next/index.d.ts +7 -7
  35. package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
  36. package/dist/_dts/sdk/src/page-converter/index.d.ts +3 -3
  37. package/dist/_dts/sdk/src/portal/client.d.ts +1 -1
  38. package/dist/_dts/sdk/src/portal/index.d.ts +10 -2
  39. package/dist/_dts/sdk/src/prebuild/index.d.ts +1 -1
  40. package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
  41. package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
  42. package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
  43. package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
  44. package/dist/_dts/sdk/src/rendering/components/pageShared.d.ts +1 -1
  45. package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +1 -1
  46. package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +4 -4
  47. package/dist/_dts/sdk/src/rendering/index.d.ts +6 -6
  48. package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
  49. package/dist/_dts/sdk/src/rendering/server.d.ts +2 -2
  50. package/dist/_dts/sdk/src/rendering/themeAdmission.d.ts +1 -1
  51. package/dist/_dts/sdk/src/routing/index.d.ts +6 -6
  52. package/dist/_dts/sdk/src/server.d.ts +5 -5
  53. package/dist/_dts/sdk/src/spam-protection/index.d.ts +2 -2
  54. package/dist/_dts/sdk/src/theme/index.d.ts +126 -2
  55. package/dist/_dts/{serviceBookingOutline-DtQuFlID.d.ts → serviceBookingOutline-aTlOvO3U.d.ts} +16 -8
  56. package/dist/_dts/{types-B3RjeBLV.d.ts → types-Bi7R07RX.d.ts} +45 -4
  57. package/dist/_dts/{types-BvUSGQrw.d.ts → types-CCcQlRBi.d.ts} +22 -12
  58. package/dist/_dts/{types-CkRFtBqd.d.ts → types-Du4aMnWC.d.ts} +13 -15
  59. package/dist/_dts/{validation-BZA3DhcV.d.ts → validation-CjCWVmwe.d.ts} +4 -4
  60. package/dist/client/{BlocksIslandsHydrator-CQMf0HdN.mjs → BlocksIslandsHydrator-CFLWxjxR.mjs} +22 -18
  61. package/dist/client/{BookingMailingListNote-7kdvuPow.mjs → BookingMailingListNote-C4LcfwyA.mjs} +8 -8
  62. package/dist/client/{BookingQuestionFields-BJI7mZuV.mjs → BookingQuestionFields-DdcmoHqQ.mjs} +2 -2
  63. package/dist/client/{CalendarAction-D_Glwvz2.mjs → CalendarAction-DYGewmvh.mjs} +1 -1
  64. package/dist/client/{CalendarNavigationChevron-DPUD6wjy.mjs → CalendarNavigationChevron-ZfrUiiiI.mjs} +25 -8
  65. package/dist/client/{CheckboxChoice-C8i4NraK.mjs → CheckboxChoice-CTMIII37.mjs} +1 -1
  66. package/dist/client/{DemoBookingPortalAccess-8kwNF9HN.mjs → DemoBookingPortalAccess-pzkGVkgG.mjs} +7 -5
  67. package/dist/client/{EventCalendar.client-Dhb14bcC.mjs → EventCalendar.client-Ct1B3xI4.mjs} +10 -10
  68. package/dist/client/{EventCombined.client-C1jEZBN9.mjs → EventCombined.client-DgfNtcgW.mjs} +9 -9
  69. package/dist/client/{EventEmbeddedCheckoutStep-BGkbUhuw.mjs → EventEmbeddedCheckoutStep-CjoaG1zy.mjs} +1 -1
  70. package/dist/client/{EventItem-Bb0ppG2N.mjs → EventItem-KGKkK19N.mjs} +29 -14
  71. package/dist/client/{EventListWeekNavigation-DMryCaNV.mjs → EventListWeekNavigation-Ba9ezxuC.mjs} +1 -1
  72. package/dist/client/{EventListing.client-BuH5kKA3.mjs → EventListing.client-xFKRDLwC.mjs} +3 -3
  73. package/dist/client/{EventListing.view-DsqvuulZ.mjs → EventListing.view-Dy36vWHi.mjs} +84 -7
  74. package/dist/client/{EventRegistrationPayment-D4FvQSFF.mjs → EventRegistrationPayment-Dth9L00x.mjs} +118 -76
  75. package/dist/client/{Page-sV6BJkXX.mjs → Page-DB5KODiu.mjs} +4491 -1398
  76. package/dist/client/{ProtectedSubmitButton-BNnKuir8.mjs → ProtectedSubmitButton-CY6u5sQa.mjs} +1 -1
  77. package/dist/client/{SiteTermsAgreementField-VfSd6JU-.mjs → SiteTermsAgreementField-BDVP_HeK.mjs} +3 -3
  78. package/dist/client/{StepIndicator-B6o5B7g3.mjs → StepIndicator-CLgDVzCs.mjs} +1 -1
  79. package/dist/client/{StepIndicator-BTqO7cJl.mjs → StepIndicator-DRyZ8igu.mjs} +7 -7
  80. package/dist/client/{ThemedButton-PFOhXktM.mjs → ThemedButton-C4rCsPCt.mjs} +52 -10
  81. package/dist/client/{accessibleSurfaces-BogaGutk.mjs → accessibleSurfaces-CqroimVQ.mjs} +1024 -619
  82. package/dist/client/{accordion-6cuswD_s.mjs → accordion-BQYRP5xV.mjs} +1 -1
  83. package/dist/client/{booking-form.client-BOMe_SKi.mjs → booking-form.client-B7ckDuOC.mjs} +191 -71
  84. package/dist/client/{bookingForm-DSCH-VHo.mjs → bookingForm-BeD4650p.mjs} +7 -6
  85. package/dist/client/bookings.mjs +5 -5
  86. package/dist/client/{boxStyleClassNames-BFuqZCfz.mjs → boxStyleClassNames-CA7FirMH.mjs} +2 -2
  87. package/dist/client/buttonParts-C39GC0kz.mjs +1518 -0
  88. package/dist/client/{carousel-CGyQVV1M.mjs → carousel-DJ9Aa1m3.mjs} +2 -2
  89. package/dist/client/{carousel.client-BtLwHefX.mjs → carousel.client-DKWqVHHh.mjs} +1 -1
  90. package/dist/client/{cart-BYOe7MCh.mjs → cart-DdCenbTy.mjs} +3 -3
  91. package/dist/client/{cart.client-BKFkaXdV.mjs → cart.client-BQm06qNw.mjs} +1 -1
  92. package/dist/client/{checkout-Dwd7Di77.mjs → checkout-45wPQULN.mjs} +3 -3
  93. package/dist/client/{checkout.client-C25hpi-z.mjs → checkout.client-bSv4cc5z.mjs} +1 -1
  94. package/dist/client/{checkoutUrls-tG788sw0.mjs → checkoutUrls-CwlaMl3W.mjs} +1 -1
  95. package/dist/client/client.mjs +460 -119
  96. package/dist/client/{constants-DdxFG3Ic.mjs → constants-DXV4KR7l.mjs} +1 -1
  97. package/dist/client/{context-Hi1RuYEM.mjs → context-lCPfX-xe.mjs} +15 -5
  98. package/dist/client/{dateFormatting-C8vBCHuo.mjs → dateFormatting-HvfmS_cH.mjs} +1 -1
  99. package/dist/client/{demoPortalMagicLink-BAL5UIDG.mjs → demoPortalMagicLink-Ce3Gyin_.mjs} +1 -1
  100. package/dist/client/{enhanceHeaderSection-Dv1Lr9kJ.mjs → enhanceHeaderSection-CGcDE9aE.mjs} +4 -4
  101. package/dist/client/{event-registration.client-dB_Z7bb-.mjs → event-registration.client-DlPfn4YG.mjs} +52 -29
  102. package/dist/client/{eventCalendar-CQnRA4Ww.mjs → eventCalendar-CioAdryV.mjs} +4 -4
  103. package/dist/client/{eventCombined-BDOG1hVp.mjs → eventCombined-Dwt0G6ez.mjs} +4 -4
  104. package/dist/client/{eventListing-DSVmhy9n.mjs → eventListing-B3H9ifOC.mjs} +4 -4
  105. package/dist/client/{eventRegistration-CD5mRtEH.mjs → eventRegistration-Do7cAhXb.mjs} +7 -6
  106. package/dist/client/{form-DWnlEVSK.mjs → form-CsqzgC6v.mjs} +3 -3
  107. package/dist/client/{form.client-D7zmeqNI.mjs → form.client-DVDB7hY6.mjs} +5 -5
  108. package/dist/client/{form.parts-C-G6N_MK.mjs → form.parts-1q2rzSYt.mjs} +3 -3
  109. package/dist/client/gifting/client.mjs +16 -9
  110. package/dist/client/{gifting-Cn0jidP5.mjs → gifting-BrXQGX-k.mjs} +4 -4
  111. package/dist/client/{gifting.client-DVo1YFLs.mjs → gifting.client--zAjnY5N.mjs} +155 -85
  112. package/dist/client/gifting.interactive-CrwHpUJG.mjs +207 -0
  113. package/dist/client/gifting.parts-CcKdDaQq.mjs +124 -0
  114. package/dist/client/{headerSection-DjQuj_6v.mjs → headerSection-DlcDH4bi.mjs} +2 -2
  115. package/dist/client/{noop-jesvJXEE.mjs → islands-dMh0Oxli.mjs} +16103 -7965
  116. package/dist/client/{newsletter-form.client-rIYPziZC.mjs → newsletter-form.client-BxA1PsdS.mjs} +6 -6
  117. package/dist/client/{newsletter-form.interactive-DVt3enLr.mjs → newsletter-form.interactive-D0iRg7p2.mjs} +229 -197
  118. package/dist/client/{newsletter-form.parts-CH6dGfdn.mjs → newsletter-form.parts-Dmuklz0r.mjs} +2 -2
  119. package/dist/client/{newsletterForm-Cg8cBDHd.mjs → newsletterForm-CBzvgIfg.mjs} +3 -3
  120. package/dist/client/portal/client.mjs +51 -35
  121. package/dist/client/{portalOrders-oEoTvzkW.mjs → portalOrders-tCxS04g0.mjs} +3 -2
  122. package/dist/client/{portalRoutes-ByyVZfVq.mjs → portalRoutes-DiGibcZI.mjs} +31 -9
  123. package/dist/client/portalSession-0XhXyTxT.mjs +41 -0
  124. package/dist/client/{product-detail.client-5aHq-vuu.mjs → product-detail.client-D9MP8hvH.mjs} +1 -1
  125. package/dist/client/{product-list.client-CyAk5rnC.mjs → product-list.client-wCz1qcUY.mjs} +1 -1
  126. package/dist/client/{productDetail-B8aZ2mqY.mjs → productDetail-D9-fCY6c.mjs} +3 -3
  127. package/dist/client/{productList-BuLemmod.mjs → productList-PJyxXSac.mjs} +3 -3
  128. package/dist/client/{propsDecoder-0Unsqn3R.mjs → propsDecoder-B8lrKGPw.mjs} +4 -2
  129. package/dist/client/{registry.server-DzvtVVD0.mjs → registry.server-CI63JVHW.mjs} +2444 -1078
  130. package/dist/client/rendering/client.mjs +32 -28
  131. package/dist/client/rendering/islands.mjs +1 -1
  132. package/dist/client/rendering.mjs +5 -5
  133. package/dist/client/{richText-coerce-Bnng7JFA.mjs → richText-coerce-Jt9hDHdh.mjs} +2 -2
  134. package/dist/client/{routeIslandApiConfig-BGfcc9sk.mjs → routeIslandApiConfig-ZSPcJWx1.mjs} +1 -1
  135. package/dist/client/runtimeResponse-DlPBWBd9.mjs +3 -0
  136. package/dist/client/{runtimeResponse-DAPVRToN.mjs → runtimeResponse-_iW9oEYc.mjs} +1 -1
  137. package/dist/client/{shop-GuMqnDL-.mjs → shop-CbdJlWOw.mjs} +3 -3
  138. package/dist/client/{shop-commerce-D5bDY1o1.mjs → shop-commerce-BqLbzUUn.mjs} +47 -28
  139. package/dist/client/{shop-commerce-store-B7sHnLwI.mjs → shop-commerce-store-BT0-zRqN.mjs} +1 -1
  140. package/dist/client/{shop-discount-apply.state-Dos2zdC2.mjs → shop-discount-apply.state-Cws0lnSb.mjs} +2 -2
  141. package/dist/client/{shop.client-uvj5GDZb.mjs → shop.client-0cNErhJT.mjs} +54 -24
  142. package/dist/client/{shopShared-3giNWE3H.mjs → shopShared-COuQ2MhQ.mjs} +2 -2
  143. package/dist/client/spam-protection.mjs +1 -1
  144. package/dist/client/{src-CmXh3JWs.mjs → src-Do_s2lqH.mjs} +11 -18
  145. package/dist/client/{timetableModel-GA-hn1qM.mjs → timetableModel-DqI6U1BS.mjs} +11 -8
  146. package/dist/client/{urlParams-C2QHo1Pa.mjs → useAutomaticDiscountPreview-CeVUVzGf.mjs} +44 -1
  147. package/dist/client/{useAvailableSlots-CBneCxbG.mjs → useAvailableSlots-B0mjVhZr.mjs} +2 -2
  148. package/dist/client/{useDiscountCodeUi-D0kGF0C7.mjs → useDiscountCodeUi-B_hfgdAP.mjs} +6 -2
  149. package/dist/client/{useEventPagination-xX8n_Tuu.mjs → useEventPagination-Ct4A6iR1.mjs} +14 -16
  150. package/dist/client/{view-DOyZc-DF.mjs → view-Cj151w4m.mjs} +24 -9
  151. package/dist/client/{wizardSteps-B952ify5.mjs → wizardSteps-B3gsXNnb.mjs} +283 -222
  152. package/dist/preview-next/client/{EventEmbeddedCheckoutStep-aRJjq4x8.mjs → EventEmbeddedCheckoutStep-CVy9oapv.mjs} +1 -1
  153. package/dist/preview-next/client/{LocationPickerEnvironment-BW3dRFIv.mjs → LocationPickerEnvironment-DuRUwUrK.mjs} +1 -1
  154. package/dist/preview-next/client/{MapLibreEditMap-Db9BHyXh.mjs → MapLibreEditMap-CdSDYBq9.mjs} +2 -2
  155. package/dist/preview-next/client/{PageSectionToolbar-BI3UCdpu.mjs → PageSectionToolbar-Dv4CW0AQ.mjs} +952 -138
  156. package/dist/preview-next/client/{PreviewEditorSidebar-jkfLVOgY.mjs → PreviewEditorSidebar-B7WW58uE.mjs} +4774 -2040
  157. package/dist/preview-next/client/{PreviewEditorUI-DwJQs4hM.mjs → PreviewEditorUI-BnJ1ughv.mjs} +71 -47
  158. package/dist/preview-next/client/{PreviewShell-BAxAkuz8.mjs → PreviewShell-C7qWzAe4.mjs} +72 -40
  159. package/dist/preview-next/client/{SdkPreviewModeRuntime-0UVB-39f.mjs → SdkPreviewModeRuntime-CYi4UHtG.mjs} +135 -30
  160. package/dist/preview-next/client/{ThemedButton-CVYz7h68.mjs → ThemedButton-CRgbU75r.mjs} +799 -17
  161. package/dist/preview-next/client/{lucide-react-00FF_oar.mjs → lucide-react-B4c6U3ZU.mjs} +11 -1
  162. package/dist/preview-next/client/{previewAssistantSlot-BgiYk3PB.mjs → previewAssistantSlot-DrUoRNu9.mjs} +24203 -9291
  163. package/dist/preview-next/client/{previewChromeRoot-tieNdF3E.mjs → previewChromeRoot-CEYp90mM.mjs} +3 -90
  164. package/dist/preview-next/client/runtime.mjs +3 -3
  165. package/dist/preview-next/client/{sdk-runtime-DXb_Evl0.mjs → sdk-runtime-DnO2_c0A.mjs} +2 -2
  166. package/dist/preview-next/client/{siteStyleAccess-BlN0jt2c.mjs → siteStyleAccess-B3PwHw2z.mjs} +46 -11
  167. package/dist/preview-next/client/{useAutosaveStatus-BUEPA4oL.mjs → useAutosaveStatus-DrdQ4ier.mjs} +49 -3
  168. package/dist/preview-next/client/{useOpenBlockForSetup-BVfr5P--.mjs → useOpenBlockForSetup-kuGRKaRL.mjs} +2008 -448
  169. package/dist/preview-next/container-responsive.css +469 -2
  170. package/dist/preview-next/editor-chrome.css +23 -2
  171. package/dist/preview-next/keepAlive.mjs +1 -1
  172. package/dist/preview-next/middleware.mjs +1 -1
  173. package/dist/preview-next/{route-contract-BHTBA48n.mjs → route-contract-CwrXkLT3.mjs} +177 -43
  174. package/dist/server/{Block.shared-hGoyEdjJ.mjs → Block.shared-C5ucphCJ.mjs} +5 -5
  175. package/dist/server/{ThemeScopeCore-BfUCTOwj.mjs → ThemeScopeCore-DvbqYXdK.mjs} +46 -10
  176. package/dist/server/{accessibleSurfaces-Dskni4Xj.mjs → accessibleSurfaces-CAcf1lHT.mjs} +732 -176
  177. package/dist/server/{accordions-By_0Ykks.mjs → accordions-DjcsqjCK.mjs} +1 -1
  178. package/dist/server/{bindings-DMJH4bvo.mjs → bindings-CFw4M-gZ.mjs} +69 -248
  179. package/dist/server/{client-DrwlRNAH.mjs → client-D0XCgITW.mjs} +488 -119
  180. package/dist/server/config-validation.mjs +1 -1
  181. package/dist/server/config.mjs +2 -2
  182. package/dist/server/{constants-CeMywaiD.mjs → constants-BZduY8jG.mjs} +31 -8
  183. package/dist/server/data/resolveBlockData.mjs +1 -1
  184. package/dist/server/index.mjs +4 -4
  185. package/dist/server/{loadContent-D0prFflT.mjs → loadContent-C-qyB8Tq.mjs} +11 -10
  186. package/dist/server/{loadPage-CBLke9pJ.mjs → loadPage-BpKKmi8E.mjs} +3 -3
  187. package/dist/server/lookMediaFrame-EFws7tAj.mjs +31835 -0
  188. package/dist/server/manifest.mjs +2 -2
  189. package/dist/server/{navigation-wrcuWmgp.mjs → navigation-DYkuiNXa.mjs} +1 -1
  190. package/dist/server/navigation.mjs +1 -1
  191. package/dist/server/next.mjs +9 -9
  192. package/dist/server/{overrideResolution-DUgCEH8z.mjs → overrideResolution-DmZn4xUE.mjs} +1 -1
  193. package/dist/server/page-converter.mjs +18 -5
  194. package/dist/server/{pageRenderPlan-BHrmogsW.mjs → pageRenderPlan-DRB7cUZ0.mjs} +674 -298
  195. package/dist/server/{pageRuntimeSupport-D2-YMRei.mjs → pageRuntimeSupport-Uv1xDieJ.mjs} +13 -6
  196. package/dist/server/{pageShared-CG8O31Eo.mjs → pageShared-BdQF875z.mjs} +911 -516
  197. package/dist/server/{parseThemeForPersistence-CrPlbJEN.mjs → parseThemeForPersistence-CwcWZL7u.mjs} +3 -3
  198. package/dist/server/{portal-pG_uhsI2.mjs → portal-BQ8qiQnk.mjs} +22 -2
  199. package/dist/server/portal.mjs +3 -3
  200. package/dist/server/{prebuild-C8Amvzce.mjs → prebuild-B51QZVNe.mjs} +1 -1
  201. package/dist/server/prebuild.mjs +1 -1
  202. package/dist/server/{prefetchBlockData-BxUETRIZ.mjs → prefetchBlockData-CppDAfJW.mjs} +4 -4
  203. package/dist/server/{registry-Cc88-23f.mjs → registry-Bf4W8Qa7.mjs} +7585 -24378
  204. package/dist/server/rendering/components/pageShared.mjs +1 -1
  205. package/dist/server/rendering/helpers/loadPage.mjs +1 -1
  206. package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +1 -1
  207. package/dist/server/rendering/server.mjs +4 -4
  208. package/dist/server/rendering.mjs +10 -10
  209. package/dist/server/{resolveBlockData-OG3KOkig.mjs → resolveBlockData-DMHAZooQ.mjs} +2 -2
  210. package/dist/server/{expandPalette-ehuW8r2g.mjs → resolveButtonColourStates-BMtAAPzp.mjs} +1670 -1346
  211. package/dist/server/{responseMedia-IfH65QAH.mjs → responseMedia-DKYfR518.mjs} +1 -1
  212. package/dist/server/{schema-CwfxQjc4.mjs → schema-DGaihVwp.mjs} +300 -29
  213. package/dist/server/server.mjs +3 -3
  214. package/dist/server/{servicePageContent-BcFuhhD7.mjs → servicePageContent-CRvmreX7.mjs} +40 -16
  215. package/dist/server/theme-bridge.mjs +5 -4
  216. package/dist/server/theme.mjs +2 -2
  217. package/dist/server/{three-pass-converter-DPaUPTfl.mjs → three-pass-converter-mcy2E1Yd.mjs} +2 -2
  218. package/dist/server/{titleSourceSchema-NhK6azFS.mjs → titleSourceSchema-B2qFOUwZ.mjs} +4 -5
  219. package/dist/server/{typeGuards-CTW_9AXq.mjs → typeGuards-DZOaGTEv.mjs} +126 -126
  220. package/dist/server/{types-BKaBZFjD.mjs → types-C_S0pWbR.mjs} +487 -9
  221. package/dist/server/{validation-BovmbS8N.mjs → validation-CUtNT_EZ.mjs} +14 -10
  222. package/dist/server/{version-hws4hgyX.mjs → version-DebJQ4zn.mjs} +1 -1
  223. package/dist/server/{video-Cdr3wh-q.mjs → video-DBaeSawZ.mjs} +1 -1
  224. package/dist/styles/index.css +2987 -168
  225. package/package.json +1 -1
  226. package/dist/client/gifting.parts-Bak93gD2.mjs +0 -86
  227. package/dist/client/runtimeResponse-nXT8VAMl.mjs +0 -3
  228. package/dist/client/types-BEaKfam_.mjs +0 -778
  229. package/dist/server/customCss-C9kgPHvr.mjs +0 -247
  230. package/dist/server/lookMediaFrame-H0fi4bJk.mjs +0 -2701
  231. package/dist/server/media-gvfIw3z8.mjs +0 -216
@@ -1,8 +1,8 @@
1
1
  "use client";
2
- import { $c as useCallbackRef, Bc as createRovingFocusGroupScope, Bi as systemCustomizeFacetStoredValue, Ca as eventCalendarListGroupingDecision, Dc as usePortalContainer, Fi as resolveArrangementKnobs, Fo as decideSectionPhoto, Gc as Content, Hc as Portal$2, I as lookTilesFor, Ii as isSystemCustomizeFacetId, Io as sectionPhotoPresence, Is as augmentManifestWithStyleGroups, Jn as manifestFieldSectionOptions, Kc as Root2$1, Kn as createManifestFormAdapter, Ko as lookDefinitionForId, Kr as fieldsNotShownIn, Lc as hideOthers, Li as systemCustomizeFacetAppliesToLayoutVariant, M as usePreviewRenderReadiness, Mo as resolveVisiblePromotedFieldPathsForEditorBlock, Oc as ReactRemoveScroll, Pi as arrangementKnobChoices, Qc as DismissableLayer, Qs as Root$1, Qu as syncStateOf, Rc as Item, Ri as systemCustomizeFacetDefinitionForBlock, Tc as menuTriggerInteractionClassName, Tn as shouldRevealAllBlockFieldValidation, Uc as Anchor, Vc as Presence, Vt as derivePromotedFieldPlan, Wc as Arrow, Xc as FocusScope, Yc as useId$1, Zc as useFocusGuards, Zo as getCuratedSiteStyle, _s as isThemeV2NormalEditorRawStyleFieldName, al as composeEventHandlers, br as mergeManifestWithSdkOptions, bs as lookModes, cr as parseCanonicalSectionBackground, dl as cva, el as useDirection, fl as createSlot, gi as eventCalendarPagingFields, gl as cn, hl as useComposedRefs, hu as asSiteStyleId, i as usePreviewSidebarNavigation, ii as getBlockDefinition, il as createContextScope, ml as composeRefs, ni as fieldPathsOwnedBy, nl as useControllableState, o as usePreviewPageDesignEditorState, ol as Primitive, or as parseBackgroundColorToken, pl as createSlottable, qc as createPopperScope, qo as readStoredMode, ri as resolveFieldOwnership, sl as dispatchDiscreteCustomEvent, tl as createCollection, vr as createCustomBlockRegistry, vs as isThemeV2NormalEditorRawStylePath, wc as menuItemInteractionClassName, xn as useEditorUiStoreInstance, yr as mergeBlockDescriptorsWithRegistry, zc as Root, zi as systemCustomizeFacetDefinitionsForBlock, zo as resolveEditorArrangementLook } from "./previewAssistantSlot-BgiYk3PB.mjs";
3
- import { it as Circle, pt as Check, ut as ChevronRight } from "./lucide-react-00FF_oar.mjs";
2
+ import { $l as createSlottable, Al as Arrow, Bi as systemCustomizeFacetDefinitionsForBlock, Bl as useDirection, Cl as hideOthers, Dl as Presence, El as createRovingFocusGroupScope, En as shouldRevealAllBlockFieldValidation, Fi as resolveArrangementKnobs, Fl as useId$1, Fs as getCuratedSiteStyle, Gi as fieldsNotShownIn, Gl as composeEventHandlers, Hl as useControllableState, Ii as shownKnobValues, Il as FocusScope, Jn as createManifestFormAdapter, Kd as syncStateOf, Kl as Primitive, Ll as useFocusGuards, Lr as getAtPath, Ml as Root2$1, Nl as createPopperScope, Ol as Portal$2, Pa as classPriceItemKinds, Ql as createSlot, Rc as Root$1, Ri as systemCustomizeFacetAppliesToLayoutVariant, Rl as DismissableLayer, Sn as useEditorUiStoreInstance, Su as unavailableSiteFacts, Tl as Root, Vl as createCollection, Wl as createContextScope, Zl as cva, Zs as isThemeV2NormalEditorRawStyleFieldName, _c as augmentManifestWithStyleGroups, _r as createCustomBlockRegistry, _s as sectionPhotoPresence, _u as matchVisibleWhen, ai as getBlockDefinition, br as mergeManifestWithSdkOptions, bs as resolveEditorArrangementLook, bu as unknownBlockObservations, dl as menuTriggerInteractionClassName, ds as decideSectionPhoto, du as matchSummaryPart, eu as composeRefs, fu as placedEditingPaths, hs as sectionPhotoFieldShown, i as usePreviewSidebarNavigation, ii as resolveFieldOwnership, jc as unwrapResponse, jl as Content, js as readStoredMode, jt as useEditorPageTemplate, k as usePreviewRenderReadiness, kl as Anchor, ld as asSiteStyleId, ml as ReactRemoveScroll, ms as sectionPhotoFieldLabel, ni as fieldPathsOwnedBy, nu as cn, o as usePreviewPageDesignEditorState, pl as usePortalContainer, ps as sectionPhotoFieldHint, ql as dispatchDiscreteCustomEvent, ri as isDedicatedStyleField, tu as useComposedRefs, uf as assertNever, ul as menuItemInteractionClassName, uu as editingGroups, vr as mergeBlockDescriptorsWithRegistry, wl as Item, xu as readConditionFact, yr as blockEditingIssues, zl as useCallbackRef } from "./previewAssistantSlot-DrUoRNu9.mjs";
3
+ import { ft as ChevronRight, ht as Check, ot as Circle } from "./lucide-react-B4c6U3ZU.mjs";
4
4
  import * as React$1 from "react";
5
- import { createContext, useContext, useMemo } from "react";
5
+ import { createContext, useContext, useEffect, useMemo, useRef, useState } from "react";
6
6
  import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import deepEqual from "fast-deep-equal";
8
8
  //#region ../../node_modules/.pnpm/@radix-ui+react-menu@2.1.18_@types+react-dom@19.3.0_@types+react@19.3.0__@types+react@1_f24ea5a0a00ace27996dbef7fb5354f4/node_modules/@radix-ui/react-menu/dist/index.mjs
@@ -1741,7 +1741,13 @@ const READINESS_REASON_COPY = {
1741
1741
  members_empty: "Add someone to show here. Until you do, this block stays hidden from visitors.",
1742
1742
  product_not_chosen: "Choose a product. Until you do, this block stays hidden from visitors.",
1743
1743
  product_gone: "The product this block showed is no longer available. Choose another one. Until you do, this block stays hidden from visitors.",
1744
- gallery_empty: "Add a photo. Until you do, this gallery stays hidden from visitors."
1744
+ gallery_empty: "Add a photo. Until you do, this gallery stays hidden from visitors.",
1745
+ video_grid_empty: "Add a video. Until you do, this block stays hidden from visitors.",
1746
+ audio_not_chosen: "Choose an audio file. Until you do, this player stays hidden from visitors.",
1747
+ file_not_chosen: "Choose a file. Until you do, this block stays hidden from visitors.",
1748
+ shop_nothing_on_sale: "You don't have a pass or a membership on sale yet. Until you have one, this block stays hidden from visitors.",
1749
+ shop_nothing_chosen: "Choose whether to show passes, memberships or both. Until you do, this block stays hidden from visitors.",
1750
+ gifting_nothing_on_offer: "You don't have a gift card or a voucher on offer yet. Until you have one, this block stays hidden from visitors."
1745
1751
  };
1746
1752
  const HIDDEN_REASON_COPY = {
1747
1753
  events_empty: "Nothing's scheduled here yet, so visitors won't see this section. It'll appear once you add something.",
@@ -1803,24 +1809,1401 @@ function normalizeCustomBlockEntries(customBlocks) {
1803
1809
  });
1804
1810
  }
1805
1811
  //#endregion
1806
- //#region ../editor-blocks/src/block-editor/colourFieldVisibility.ts
1812
+ //#region ../block-form/src/utils/fieldHelpers.ts
1813
+ const VALID_FIELD_INTENTS = [
1814
+ "content",
1815
+ "display",
1816
+ "behavior",
1817
+ "style"
1818
+ ];
1819
+ /**
1820
+ * Get the ui object from a field config, properly typed.
1821
+ */
1822
+ function getFieldUi(field) {
1823
+ return field.ui;
1824
+ }
1825
+ function parseFieldIntent(value) {
1826
+ if (typeof value !== "string") return null;
1827
+ return VALID_FIELD_INTENTS.includes(value) ? value : null;
1828
+ }
1829
+ /**
1830
+ * Check if a field should render in the block header.
1831
+ * Header fields are rendered in the collapsed block header area.
1832
+ */
1833
+ function isHeaderField(field) {
1834
+ return getFieldUi(field)?.renderInHeader === true;
1835
+ }
1836
+ /**
1837
+ * Check if a field is hidden.
1838
+ */
1839
+ function isHiddenField(field) {
1840
+ return getFieldUi(field)?.hidden === true;
1841
+ }
1842
+ /**
1843
+ * Check if a field has visibility conditions.
1844
+ */
1845
+ function hasVisibilityConditions(field) {
1846
+ const ui = getFieldUi(field);
1847
+ return ui?.hidden === true || ui?.visibleWhen !== void 0;
1848
+ }
1849
+ /**
1850
+ * Get the widget hint from a field, if present.
1851
+ * Falls back to field.type if no widget is specified.
1852
+ */
1853
+ function getWidgetKey(field) {
1854
+ return getFieldUi(field)?.widget ?? field.type;
1855
+ }
1856
+ /**
1857
+ * Resolve semantic intent for top-level form routing.
1858
+ * Priority:
1859
+ * 1) ui.intent (if valid)
1860
+ * 2) default content
1861
+ */
1862
+ function getFieldIntent(field) {
1863
+ const rawIntent = field.ui?.intent;
1864
+ const parsedIntent = parseFieldIntent(rawIntent);
1865
+ if (parsedIntent) return parsedIntent;
1866
+ if (typeof rawIntent === "string") console.warn(`[fieldHelpers] Invalid ui.intent "${rawIntent}" on field "${field.id}", falling back to "content"`);
1867
+ return "content";
1868
+ }
1869
+ function partitionFieldsByIntent(fields) {
1870
+ const result = {
1871
+ content: [],
1872
+ display: [],
1873
+ behavior: [],
1874
+ style: []
1875
+ };
1876
+ for (const field of fields) result[getFieldIntent(field)].push(field);
1877
+ return result;
1878
+ }
1879
+ /**
1880
+ * Check if a single value is "non-empty" (meaningful).
1881
+ * Returns false for null, undefined, empty string, false, and empty objects/arrays.
1882
+ */
1883
+ function isNonEmptyValue(value) {
1884
+ if (value == null || value === "" || value === false) return false;
1885
+ if (typeof value === "object") {
1886
+ if (Array.isArray(value)) return value.length > 0;
1887
+ return Object.keys(value).length > 0;
1888
+ }
1889
+ return true;
1890
+ }
1891
+ //#endregion
1892
+ //#region ../block-form/src/utils/computeWatchedPath.ts
1893
+ /**
1894
+ * Builds the absolute path for a watched field from a relative reference
1895
+ *
1896
+ * @param currentPath - Current field's absolute path (e.g., "background.scale")
1897
+ * @param relativeField - Relative field reference from visibleWhen (e.g., "objectFit")
1898
+ * Prefix with `$root.` to read from the form root instead of a sibling.
1899
+ * @returns Absolute path to watched field (e.g., "background.objectFit")
1900
+ *
1901
+ * @example
1902
+ * computeWatchedPath('background.scale', 'objectFit')
1903
+ * // => 'background.objectFit' (sibling field)
1904
+ *
1905
+ * computeWatchedPath('items.0.settings.customColor', 'useCustom')
1906
+ * // => 'items.0.settings.useCustom' (sibling in nested structure)
1907
+ *
1908
+ * computeWatchedPath('subtitle', 'showSubtitle')
1909
+ * // => 'showSubtitle' (top-level sibling)
1910
+ */
1911
+ function computeWatchedPath(currentPath, relativeField) {
1912
+ if (!relativeField) return null;
1913
+ if (relativeField.startsWith("$root.")) return relativeField.slice(6) || null;
1914
+ const parentSegments = currentPath.split(".").slice(0, -1);
1915
+ const watchFieldSegments = relativeField.split(".");
1916
+ return [...parentSegments, ...watchFieldSegments].filter((s) => s.length > 0).join(".");
1917
+ }
1918
+ //#endregion
1919
+ //#region ../block-form/src/utils/visibleWhen.ts
1920
+ /** Effective presentation values override stored values for visibility only. */
1921
+ function withVisibilityValues(reader, values) {
1922
+ return {
1923
+ ...reader,
1924
+ getValue: (path) => Object.prototype.hasOwnProperty.call(values, path) ? values[path] : reader.getValue(path)
1925
+ };
1926
+ }
1927
+ /** The tests on other fields' values in a condition: what a widget watches to re-evaluate it. */
1928
+ function getVisibleWhenPredicates(visibleWhen) {
1929
+ const nested = (conditions) => conditions.flatMap((condition) => [...getVisibleWhenPredicates(condition)]);
1930
+ return matchVisibleWhen(visibleWhen, {
1931
+ field: (condition) => [condition],
1932
+ fact: () => [],
1933
+ look: () => [],
1934
+ knob: () => [],
1935
+ template: () => [],
1936
+ observation: () => [],
1937
+ allOf: nested,
1938
+ anyOf: nested
1939
+ });
1940
+ }
1941
+ /**
1942
+ * Three-valued, so an unread fact can't hide a field by accident. `allOf`
1943
+ * fails if any part fails, and is otherwise unknown if any part is; `anyOf`
1944
+ * is met if any part is, and otherwise unknown if any part is.
1945
+ */
1946
+ function evaluateVisibleWhen(visibleWhen, evaluate) {
1947
+ const results = (conditions) => conditions.map((condition) => evaluateVisibleWhen(condition, evaluate));
1948
+ return matchVisibleWhen(visibleWhen, {
1949
+ field: (condition) => evaluate.field(condition) ? "met" : "failed",
1950
+ fact: evaluate.fact,
1951
+ look: evaluate.look,
1952
+ knob: evaluate.knob,
1953
+ template: evaluate.template,
1954
+ observation: evaluate.observation,
1955
+ allOf: (conditions) => combined(results(conditions), "failed", "met"),
1956
+ anyOf: (conditions) => conditions.length === 0 ? "met" : combined(results(conditions), "met", "failed")
1957
+ });
1958
+ }
1959
+ /** `decisive` settles it on its own; failing that, one unknown part leaves the whole unknown. */
1960
+ function combined(results, decisive, otherwise) {
1961
+ if (results.includes(decisive)) return decisive;
1962
+ return results.includes("unknown") ? "unknown" : otherwise;
1963
+ }
1964
+ /** A field shows unless its condition has failed: an unknown condition leaves it showing. */
1965
+ function conditionShows(result) {
1966
+ return result !== "failed";
1967
+ }
1968
+ function evaluateFactPredicate(condition, siteFacts) {
1969
+ const fact = readConditionFact(siteFacts, condition.fact);
1970
+ if (fact.kind === "Unavailable") return "unknown";
1971
+ return fact.value === condition.is ? "met" : "failed";
1972
+ }
1973
+ function evaluateLookPredicate(condition, look) {
1974
+ if (look.kind === "Unavailable") return "unknown";
1975
+ return look.value.state === condition.look ? "met" : "failed";
1976
+ }
1977
+ /**
1978
+ * Met when a Look draws the knob with one of the values; failed with no Look,
1979
+ * or a value outside them. A knob the block doesn't have can't be read, so
1980
+ * that's unknown rather than a reason to hide.
1981
+ */
1982
+ function evaluateKnobPredicate(condition, look) {
1983
+ if (look.kind === "Unavailable") return "unknown";
1984
+ if (look.value.state === "none") return "failed";
1985
+ const value = look.value.knobs[condition.knob];
1986
+ if (value === void 0) return "unknown";
1987
+ return condition.oneOf.includes(value) ? "met" : "failed";
1988
+ }
1989
+ function evaluateTemplatePredicate(condition, block) {
1990
+ if (block.template.kind === "Unavailable") return "unknown";
1991
+ return block.template.value.kind === condition.template ? "met" : "failed";
1992
+ }
1993
+ /** Met when what the block's selection resolves to includes the value; unknown until it has loaded. */
1994
+ function evaluateObservationPredicate(condition, block) {
1995
+ const observed = block.observations[condition.observation];
1996
+ if (observed.kind === "Unavailable") return "unknown";
1997
+ return observed.value.includes(condition.includes) ? "met" : "failed";
1998
+ }
1999
+ function evaluateVisibleWhenPredicate(condition, watchedValue) {
2000
+ if (condition.equals !== void 0) return watchedValue === condition.equals;
2001
+ if (condition.notEquals !== void 0) return watchedValue !== condition.notEquals;
2002
+ if (condition.oneOf !== void 0) return condition.oneOf.includes(watchedValue);
2003
+ if (condition.notIn !== void 0) return !condition.notIn.includes(watchedValue);
2004
+ if (condition.minItems !== void 0) return Array.isArray(watchedValue) && watchedValue.length >= condition.minItems;
2005
+ if (condition.maxItems !== void 0) return Array.isArray(watchedValue) && watchedValue.length <= condition.maxItems;
2006
+ if (condition.hasValue !== void 0) return hasValue(watchedValue) === condition.hasValue;
2007
+ return true;
2008
+ }
2009
+ /** Whether there's something there: text, a link, a photo, a list item. An empty rich text document isn't. */
2010
+ function hasValue(value) {
2011
+ if (value === null || value === void 0 || value === false) return false;
2012
+ if (typeof value === "string") return value.trim() !== "";
2013
+ if (Array.isArray(value)) return value.length > 0;
2014
+ if (typeof value === "object") return hasContent(value);
2015
+ return true;
2016
+ }
2017
+ function hasContent(value) {
2018
+ if ("type" in value && value.type === "doc") return richTextHasText(value);
2019
+ return Object.values(value).some(hasValue);
2020
+ }
2021
+ function richTextHasText(node) {
2022
+ if ("text" in node && typeof node.text === "string" && node.text.trim() !== "") return true;
2023
+ return ("content" in node && Array.isArray(node.content) ? node.content : []).some((child) => typeof child === "object" && child !== null && richTextHasText(child));
2024
+ }
2025
+ //#endregion
2026
+ //#region ../block-form/src/utils/evaluateVisibility.ts
2027
+ function collectVisibleWhenWatchPaths(field, path) {
2028
+ const visibleWhen = field.ui?.visibleWhen;
2029
+ if (!visibleWhen) return [];
2030
+ return getVisibleWhenPredicates(visibleWhen).map((condition) => computeWatchedPath(path, condition.field)).filter((watchedPath) => Boolean(watchedPath));
2031
+ }
2032
+ /**
2033
+ * Evaluates whether a field should be visible based on its configuration
2034
+ *
2035
+ * @param field - The field configuration containing ui.hidden and ui.visibleWhen
2036
+ * @param reader - Other fields' values, and what the site has
2037
+ * @param path - Current field's absolute path (e.g., "items.0.title")
2038
+ * @returns true if field should be visible, false if it should be hidden
2039
+ *
2040
+ * @example
2041
+ * // Field with conditional visibility
2042
+ * const field = {
2043
+ * id: 'scale',
2044
+ * ui: {
2045
+ * visibleWhen: { field: 'objectFit', equals: 'custom' }
2046
+ * }
2047
+ * }
2048
+ *
2049
+ * // At path "background.scale", watches "background.objectFit"
2050
+ * const visible = evaluateVisibility(field, reader, 'background.scale')
2051
+ *
2052
+ * A condition that turns on a site fact that couldn't be read leaves the
2053
+ * field visible.
2054
+ */
2055
+ function evaluateVisibility(field, reader, path) {
2056
+ if (field.ui?.hidden) return false;
2057
+ const visibleWhen = field.ui?.visibleWhen;
2058
+ if (!visibleWhen) return true;
2059
+ return conditionShows(evaluateVisibleWhen(visibleWhen, {
2060
+ field: (condition) => evaluateFieldCondition(condition, reader, path),
2061
+ fact: (condition) => evaluateFactPredicate(condition, reader.siteFacts),
2062
+ look: (condition) => evaluateLookPredicate(condition, reader.block.look),
2063
+ knob: (condition) => evaluateKnobPredicate(condition, reader.block.look),
2064
+ template: (condition) => evaluateTemplatePredicate(condition, reader.block),
2065
+ observation: (condition) => evaluateObservationPredicate(condition, reader.block)
2066
+ }));
2067
+ }
2068
+ function evaluateFieldCondition(condition, reader, path) {
2069
+ const absolutePath = computeWatchedPath(path, condition.field);
2070
+ if (!absolutePath) return true;
2071
+ return evaluateVisibleWhenPredicate(condition, reader.getValue(absolutePath));
2072
+ }
2073
+ //#endregion
2074
+ //#region ../block-form/src/utils/resolvePromotedFields.ts
2075
+ function ancestorsOf(ref) {
2076
+ return ref.ancestors ?? [];
2077
+ }
2078
+ function isGroupField(field) {
2079
+ return field.type === "group";
2080
+ }
2081
+ function isModalField(field) {
2082
+ return field.type === "modal";
2083
+ }
2084
+ function isRepeaterField(field) {
2085
+ return field.type === "repeater";
2086
+ }
2087
+ function isNumericSegment(segment) {
2088
+ return Boolean(segment && /^\d+$/.test(segment));
2089
+ }
2090
+ function getNestedFields(field) {
2091
+ if (isGroupField(field)) return field.fields;
2092
+ if (isModalField(field)) return field.schema?.fields ?? [];
2093
+ if (isRepeaterField(field)) {
2094
+ if (field.polymorphic && field.itemTypes) {
2095
+ const all = [];
2096
+ for (const itemType of Object.values(field.itemTypes)) all.push(...itemType.fields ?? []);
2097
+ return all;
2098
+ }
2099
+ return field.fields ?? [];
2100
+ }
2101
+ return [];
2102
+ }
2103
+ function getChildren(parent, parentPath, getValue) {
2104
+ const { field, tabSelections, sdkSectionOption } = parent;
2105
+ const ancestors = [...ancestorsOf(parent), {
2106
+ field,
2107
+ path: parentPath
2108
+ }];
2109
+ if (field.type === "tabGroup") {
2110
+ const activeTab = field.activeTabField ? getValue(`${parentPath}.${field.activeTabField}`) : void 0;
2111
+ return [...field.tabs].sort((a, b) => Number(b.id === activeTab) - Number(a.id === activeTab)).flatMap((tab) => tab.fields.map((child) => ({
2112
+ ancestors,
2113
+ field: child,
2114
+ sdkSectionOption: tab.sdkSectionOption ?? sdkSectionOption,
2115
+ tabSelections: field.activeTabField ? [...tabSelections, {
2116
+ parentPath,
2117
+ controlField: field.activeTabField,
2118
+ tabId: tab.id
2119
+ }] : tabSelections
2120
+ })));
2121
+ }
2122
+ return getNestedFields(field).map((child) => ({
2123
+ ancestors,
2124
+ field: child,
2125
+ sdkSectionOption,
2126
+ tabSelections
2127
+ }));
2128
+ }
2129
+ function findGreedyChild(children, segments, startIndex) {
2130
+ const max = segments.length;
2131
+ for (let end = max; end > startIndex; end -= 1) {
2132
+ const candidateId = segments.slice(startIndex, end).join(".");
2133
+ const match = children.find((c) => c.field.id === candidateId);
2134
+ if (match) return {
2135
+ child: match,
2136
+ consumed: end - startIndex
2137
+ };
2138
+ }
2139
+ return null;
2140
+ }
2141
+ function defaultPromotedLabel(path, field) {
2142
+ if (path.endsWith(".background.image")) return field.type === "media" && field.mediaKinds?.includes("video") ? "Background video" : "Background image";
2143
+ return null;
2144
+ }
2145
+ /**
2146
+ * Resolve a list of promoted field paths into renderable field configs.
2147
+ *
2148
+ * Notes:
2149
+ * - This is a render-only shortcut. The returned `field` is *not* added to the
2150
+ * manifest/schema; it should be rendered at `path` while continuing to store
2151
+ * data within the existing nested object shape.
2152
+ * - Field IDs in manifests can contain dots (e.g. `overlay.color`). This resolver
2153
+ * uses greedy matching against child IDs to support those paths.
2154
+ * - Array indexes in paths (e.g. `items.0.title`) are ignored for matching.
2155
+ */
2156
+ function resolvePromotedFields(fields, promotedPaths, getValue) {
2157
+ if (!promotedPaths || promotedPaths.length === 0) return [];
2158
+ const unique = Array.from(new Set(promotedPaths.map((p) => p.trim()).filter((p) => p.length > 0)));
2159
+ const resolved = [];
2160
+ for (const path of unique) {
2161
+ const segments = path.split(".").filter((s) => s.length > 0);
2162
+ if (segments.length === 0) continue;
2163
+ let children = fields.map((field) => ({
2164
+ field,
2165
+ tabSelections: []
2166
+ }));
2167
+ let activeSdkOption;
2168
+ let current = null;
2169
+ let i = 0;
2170
+ while (i < segments.length) {
2171
+ const seg = segments[i];
2172
+ if (isNumericSegment(seg)) {
2173
+ i += 1;
2174
+ continue;
2175
+ }
2176
+ const match = findGreedyChild(children, segments, i);
2177
+ if (!match) {
2178
+ current = null;
2179
+ break;
2180
+ }
2181
+ current = match.child;
2182
+ if (current.sdkSectionOption) activeSdkOption = current.sdkSectionOption;
2183
+ i += match.consumed;
2184
+ if (i >= segments.length) break;
2185
+ children = getChildren(current, segments.slice(0, i).join("."), getValue);
2186
+ if (isNumericSegment(segments[i])) i += 1;
2187
+ }
2188
+ if (!current) continue;
2189
+ const labelOverride = defaultPromotedLabel(path, current.field);
2190
+ const promotedField = labelOverride ? {
2191
+ ...current.field,
2192
+ label: labelOverride
2193
+ } : current.field;
2194
+ resolved.push({
2195
+ path,
2196
+ tabSelections: current.tabSelections,
2197
+ ancestors: ancestorsOf(current),
2198
+ field: promotedField,
2199
+ sdkSectionOption: activeSdkOption
2200
+ });
2201
+ }
2202
+ return resolved;
2203
+ }
2204
+ //#endregion
2205
+ //#region ../block-form/src/editing/derivedSummary.ts
2206
+ /**
2207
+ * The line for a group nobody wrote a summary for: "More settings" today, and
2208
+ * the two derived groups of a block that hasn't declared its own. It reads
2209
+ * field labels, so it's only as good as they are.
2210
+ */
2211
+ function derivedSettingsSummary(items, getValue) {
2212
+ const summaries = items.flatMap(({ field, path }) => {
2213
+ const value = getValue(path) ?? field.defaultValue;
2214
+ if (typeof value === "boolean") return value ? [field.label] : [];
2215
+ const label = settingsValueLabel(field, value);
2216
+ return label ? [`${field.label}: ${label}`] : [];
2217
+ });
2218
+ return [...summaries.slice(0, 3), ...summaries.length > 3 ? [`and ${summaries.length - 3} more`] : []].join(" · ");
2219
+ }
2220
+ function isSummaryScalar(value) {
2221
+ return value !== "" && (typeof value === "string" || typeof value === "number");
2222
+ }
2223
+ /** Multi-select labels form one summary value, using the same option lookup as scalars. */
2224
+ function settingsValueLabel(field, value) {
2225
+ const values = Array.isArray(value) ? value.filter(isSummaryScalar) : isSummaryScalar(value) ? [value] : [];
2226
+ if (Array.isArray(value) && field.type !== "select") return void 0;
2227
+ return values.map((selected) => field.type === "select" ? field.options.find((option) => option.value === selected)?.label ?? String(selected) : String(selected)).join(", ") || void 0;
2228
+ }
2229
+ //#endregion
2230
+ //#region ../block-form/src/editing/groupSummary.ts
2231
+ function summariseGroup(summary, reader) {
2232
+ const said = summary.parts.filter((part) => reader.isVisible(part.field)).map((part) => ({
2233
+ path: part.field,
2234
+ ...sayPart(part, reader)
2235
+ }));
2236
+ const phrases = said.flatMap((entry) => entry.phrase ? [entry.phrase] : []);
2237
+ return {
2238
+ line: phrases.length > 0 ? capitalised(phrases.join(", ")) : summary.none,
2239
+ unphrased: said.flatMap((entry) => entry.unphrased === void 0 ? [] : [{
2240
+ path: entry.path,
2241
+ value: entry.unphrased
2242
+ }])
2243
+ };
2244
+ }
2245
+ function sayPart(part, reader) {
2246
+ const value = reader.getValue(part.field);
2247
+ return matchSummaryPart(part, {
2248
+ on: ({ on }) => ({ phrase: value === true ? on : null }),
2249
+ options: ({ options }) => sayOption(options, value),
2250
+ text: ({ text }) => ({ phrase: typeof value === "string" && value.trim() !== "" ? `${text.before ?? ""}${value.trim()}${text.after ?? ""}` : text.empty ?? null }),
2251
+ set: ({ set, unset }) => ({ phrase: hasValue(value) ? set : unset ?? null }),
2252
+ count: ({ count }) => ({ phrase: sayCount(count, value) }),
2253
+ chosen: ({ chosen }) => ({ phrase: hasValue(value) ? `${chosen.before ?? ""}${reader.chosenLabel?.(part.field, value) ?? chosen.fallback}${chosen.after ?? ""}` : null })
2254
+ });
2255
+ }
2256
+ function sayOption(options, value) {
2257
+ if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean") return { phrase: null };
2258
+ const key = String(value);
2259
+ return Object.prototype.hasOwnProperty.call(options, key) ? { phrase: options[key] ?? null } : {
2260
+ phrase: null,
2261
+ unphrased: key
2262
+ };
2263
+ }
2264
+ function sayCount(count, value) {
2265
+ const size = Array.isArray(value) ? value.length : 0;
2266
+ if (size === 0) return null;
2267
+ return size === 1 ? count.one : count.many.split("{n}").join(String(size));
2268
+ }
2269
+ function capitalised(line) {
2270
+ return line.charAt(0).toUpperCase() + line.slice(1);
2271
+ }
2272
+ //#endregion
2273
+ //#region ../block-form/src/manifest/filterSdkTabs.ts
2274
+ function isSdkSectionOptionEnabled(sdkSectionOption, isSdkSite, sectionOptions) {
2275
+ if (!isSdkSite || !sectionOptions) return true;
2276
+ if (!sdkSectionOption) return true;
2277
+ return sectionOptions[sdkSectionOption] !== false;
2278
+ }
2279
+ /**
2280
+ * Filters tabs based on SDK section options.
2281
+ *
2282
+ * This pure function handles the filtering logic that was previously embedded
2283
+ * in TabGroupField. It's designed to be testable and reusable.
2284
+ *
2285
+ * ## Filtering Rules
2286
+ *
2287
+ * - If not an SDK site or no sectionOptions exist, all tabs are returned
2288
+ * - Tabs without `sdkSectionOption` are always visible
2289
+ * - Tabs with `sdkSectionOption` are visible unless explicitly disabled
2290
+ * - A disabled option is when `sectionOptions[key] === false`
2291
+ *
2292
+ * @param tabs - Array of tabs to filter
2293
+ * @param isSdkSite - Whether this is an SDK-configured site
2294
+ * @param sectionOptions - SDK section options (may be null)
2295
+ * @returns Filtered array of visible tabs
2296
+ *
2297
+ * @example
2298
+ * ```typescript
2299
+ * const visibleTabs = filterTabsBySdkOptions(
2300
+ * config.tabs,
2301
+ * isSdkSite,
2302
+ * sectionOptions
2303
+ * )
2304
+ * ```
2305
+ */
2306
+ function filterTabsBySdkOptions(tabs, isSdkSite, sectionOptions) {
2307
+ return tabs.filter((tab) => isSdkSectionOptionEnabled(tab.sdkSectionOption, isSdkSite, sectionOptions));
2308
+ }
2309
+ /**
2310
+ * The tab a tab group shows: the one its control field names, or the first
2311
+ * the site offers. Null when the site offers none, and the group draws nothing.
2312
+ * TabGroupField draws from this, and the editing plan reads it to say which
2313
+ * fields are on screen.
2314
+ */
2315
+ function shownTab(tabs, controlValue, sdk) {
2316
+ const visibleTabs = filterTabsBySdkOptions(tabs, sdk.isSdkSite, sdk.sectionOptions);
2317
+ const active = visibleTabs.find((tab) => tab.id === controlValue) ?? visibleTabs[0];
2318
+ return active ? {
2319
+ visibleTabs,
2320
+ active
2321
+ } : null;
2322
+ }
2323
+ //#endregion
2324
+ //#region ../block-form/src/widgets/groupFieldHelpers.ts
2325
+ /** The one nested placement rule, shared by GroupField and the repeater row that hoists a group's settings. */
2326
+ function splitGroupFields(config, path) {
2327
+ const { content, display, behavior, style } = partitionFieldsByIntent(config.fields);
2328
+ const flatten = shouldFlattenInRepeater(path, config);
2329
+ return {
2330
+ content,
2331
+ settings: [
2332
+ ...display,
2333
+ ...behavior,
2334
+ ...style
2335
+ ].map((field) => resolveFieldPlacement(field, path, flatten))
2336
+ };
2337
+ }
2338
+ function groupSettingsHost(config, path) {
2339
+ return shouldHideLabel(config) && isDirectlyInRepeaterItem(path) ? "repeater-row" : "group";
2340
+ }
2341
+ function groupPresentation(config) {
2342
+ if (getLayout(config) === "grid") return "grid";
2343
+ return getWidgetPreset(config) === "disclosure" ? "disclosure" : "stack";
2344
+ }
2345
+ function layoutGroupFields(config, path) {
2346
+ const presentation = groupPresentation(config);
2347
+ const flatten = shouldFlattenInRepeater(path, config);
2348
+ const place = (field) => resolveFieldPlacement(field, path, flatten);
2349
+ const fields = config.fields.map(place);
2350
+ if (presentation === "disclosure") return {
2351
+ presentation,
2352
+ inline: fields,
2353
+ ownSettings: [],
2354
+ fields
2355
+ };
2356
+ const split = splitGroupFields(config, path);
2357
+ return {
2358
+ presentation,
2359
+ fields,
2360
+ inline: split.content.map(place),
2361
+ ownSettings: groupSettingsHost(config, path) === "group" ? split.settings : []
2362
+ };
2363
+ }
2364
+ /** The fields a group or modal field shows in its dialog (ModalGroupField). */
2365
+ function modalGroupFields(config, path) {
2366
+ return (config.type === "modal" ? config.schema.fields : config.schema?.fields ?? config.fields ?? []).map((field) => resolveFieldPlacement(field, path, false));
2367
+ }
2368
+ function isDirectlyInRepeaterItem(path) {
2369
+ const segments = path.split(".");
2370
+ return segments.length >= 2 && /^\d+$/.test(segments[segments.length - 2] ?? "");
2371
+ }
2372
+ function resolveFieldPlacement(field, basePath, flatten) {
2373
+ return {
2374
+ field,
2375
+ path: buildChildPath(basePath, field.id, flatten)
2376
+ };
2377
+ }
2378
+ /**
2379
+ * Determines if a group field should flatten its children when inside a repeater
2380
+ *
2381
+ * @param path - Current field path (e.g., "items.0.meta")
2382
+ * @param config - Group field configuration
2383
+ * @returns true if the group should flatten (children rendered at parent level)
2384
+ */
2385
+ function shouldFlattenInRepeater(path, config) {
2386
+ return Boolean(config.ui?.flattenInRepeater) && isDirectlyInRepeaterItem(path);
2387
+ }
2388
+ /**
2389
+ * Extracts the group preset from field configuration.
2390
+ *
2391
+ * @param config - Group field configuration
2392
+ * @returns Preset name or null
2393
+ */
2394
+ function getWidgetPreset(config) {
2395
+ return config.ui?.preset ?? null;
2396
+ }
2397
+ /**
2398
+ * Builds a child field path, accounting for flattening behavior
2399
+ *
2400
+ * @param basePath - Base path for the group field
2401
+ * @param childId - Child field ID
2402
+ * @param shouldFlatten - Whether the group is flattened
2403
+ * @returns Full path to the child field
2404
+ */
2405
+ function buildChildPath(basePath, childId, shouldFlatten) {
2406
+ if (shouldFlatten) {
2407
+ const parentPath = basePath.split(".").slice(0, -1).join(".");
2408
+ return parentPath ? `${parentPath}.${childId}` : childId;
2409
+ }
2410
+ return basePath ? `${basePath}.${childId}` : childId;
2411
+ }
2412
+ /**
2413
+ * Checks if label should be hidden
2414
+ */
2415
+ function shouldHideLabel(config) {
2416
+ return Boolean(config.ui?.hideLabel);
2417
+ }
2418
+ /**
2419
+ * Gets the layout mode for a group field
2420
+ */
2421
+ function getLayout(config) {
2422
+ return config.ui?.layout === "grid" ? "grid" : "stack";
2423
+ }
2424
+ /**
2425
+ * Gets the number of columns for grid layout
2426
+ */
2427
+ function getColumns(config) {
2428
+ const columns = config.ui?.columns;
2429
+ if (typeof columns === "number" && columns >= 2 && columns <= 4) return columns;
2430
+ return 2;
2431
+ }
2432
+ /**
2433
+ * Validates and clamps colSpan to valid range
2434
+ */
2435
+ function getValidColSpan(colSpan, columns) {
2436
+ if (!colSpan || colSpan < 1) return 1;
2437
+ if (colSpan > columns) {
2438
+ console.warn(`[GroupField] colSpan ${colSpan} exceeds columns ${columns}, clamping`);
2439
+ return columns;
2440
+ }
2441
+ return colSpan;
2442
+ }
2443
+ /**
2444
+ * Groups fields by their ui.row property
2445
+ * Fields without a row property each get their own row
2446
+ */
2447
+ function groupFieldsByRow(fields) {
2448
+ const rowMap = /* @__PURE__ */ new Map();
2449
+ const orderedRows = [];
2450
+ for (const field of fields) {
2451
+ const rowKey = field.ui?.row ?? `__single_${field.id}`;
2452
+ if (!rowMap.has(rowKey)) {
2453
+ rowMap.set(rowKey, []);
2454
+ orderedRows.push(rowKey);
2455
+ }
2456
+ const row = rowMap.get(rowKey);
2457
+ if (row) row.push(field);
2458
+ }
2459
+ return orderedRows.map((key) => rowMap.get(key) ?? []);
2460
+ }
2461
+ //#endregion
2462
+ //#region ../block-form/src/widgets/RepeaterField/utils/getRepeaterItemFields.ts
2463
+ /**
2464
+ * Get the fields for a specific repeater item.
2465
+ *
2466
+ * For monomorphic repeaters, returns config.fields.
2467
+ * For polymorphic repeaters, looks up the item's _type and returns
2468
+ * the fields from the corresponding itemType schema.
2469
+ *
2470
+ * @param config - Repeater field configuration
2471
+ * @param backend - Form backend for reading values
2472
+ * @param basePath - Base path to the repeater array
2473
+ * @param index - Index of the item in the array
2474
+ * @returns Array of field configs for this item
2475
+ */
2476
+ function getRepeaterItemFields(config, backend, basePath, index) {
2477
+ if (config.polymorphic && config.itemTypes) {
2478
+ const itemValue = backend.getValue(`${basePath}.${index}`);
2479
+ const itemType = typeof itemValue?._type === "string" ? itemValue._type : Object.keys(config.itemTypes)[0] ?? "";
2480
+ return (itemType ? config.itemTypes[itemType] : void 0)?.fields ?? [];
2481
+ }
2482
+ return config.fields ?? [];
2483
+ }
2484
+ //#endregion
2485
+ //#region ../block-form/src/widgets/RepeaterField/utils/getRepeaterItemFieldGroups.ts
2486
+ /** A row's own settings fields go in its settings; an unlabelled group's settings join them. */
2487
+ function deriveFieldPlacement(field, rowPath) {
2488
+ const placement = resolveFieldPlacement(field, rowPath, false);
2489
+ if (getFieldIntent(field) !== "content") return {
2490
+ content: [],
2491
+ settings: [placement],
2492
+ excludedId: [field.id]
2493
+ };
2494
+ const hoisted = field.type === "group" && groupSettingsHost(field, placement.path) === "repeater-row" ? splitGroupFields(field, placement.path).settings : [];
2495
+ return {
2496
+ content: [field],
2497
+ settings: hoisted,
2498
+ excludedId: []
2499
+ };
2500
+ }
2501
+ function getRepeaterItemFieldGroups(config, backend, basePath, index) {
2502
+ const placements = getRepeaterItemFields(config, backend, basePath, index).map((field) => deriveFieldPlacement(field, `${basePath}.${index}`));
2503
+ return {
2504
+ contentFields: placements.flatMap(({ content }) => content),
2505
+ settingsFields: placements.flatMap(({ settings }) => settings),
2506
+ settingsFieldIds: new Set(placements.flatMap(({ excludedId }) => excludedId))
2507
+ };
2508
+ }
2509
+ //#endregion
2510
+ //#region ../block-form/src/editing/nestedPlacement.ts
2511
+ function revealStepKey(step) {
2512
+ return `${step.kind}:${step.path}`;
2513
+ }
2514
+ /**
2515
+ * The steps that bring `target` on screen, for a field the form draws at
2516
+ * `path`. Null when this field doesn't draw it: the target is elsewhere, its
2517
+ * condition hides it, its row or item type doesn't exist, it sits in a tab
2518
+ * that isn't showing, or its owner took it out of the form.
2519
+ *
2520
+ * It follows a field by its type. A host widget that draws a group or
2521
+ * repeater its own way gets the same steps and may not act on them.
2522
+ */
2523
+ function revealStepsWithin(field, path, target, context) {
2524
+ const container = containerOf(field);
2525
+ switch (container.kind) {
2526
+ case "leaf": return target === path || target.startsWith(`${path}.`) ? [] : null;
2527
+ case "group": return withinGroup(container.field, path, target, context);
2528
+ case "modal": {
2529
+ const open = {
2530
+ kind: "modal",
2531
+ path
2532
+ };
2533
+ if (target === path) return [open];
2534
+ return after([open], revealStepsAmong(modalGroupFields(container.field, path), target, context));
2535
+ }
2536
+ case "tabGroup": return withinTabGroup(container.field, path, target, context);
2537
+ case "repeater": return withinRepeater(container.field, path, target, context);
2538
+ default: return assertNever(container);
2539
+ }
2540
+ }
2541
+ /** The first of these placements that draws `target`, skipping any its condition hides. */
2542
+ function revealStepsAmong(placements, target, context) {
2543
+ for (const { field, path } of placements) {
2544
+ if (!evaluateVisibility(field, context, path)) continue;
2545
+ const steps = revealStepsWithin(field, path, target, context);
2546
+ if (steps) return steps;
2547
+ }
2548
+ return null;
2549
+ }
2550
+ function containerOf(field) {
2551
+ if (field.type === "modal") return {
2552
+ kind: "modal",
2553
+ field
2554
+ };
2555
+ if (field.type === "group") return getWidgetKey(field) === "modal" ? {
2556
+ kind: "modal",
2557
+ field
2558
+ } : {
2559
+ kind: "group",
2560
+ field
2561
+ };
2562
+ if (field.type === "tabGroup") return {
2563
+ kind: "tabGroup",
2564
+ field
2565
+ };
2566
+ if (field.type === "repeater") return {
2567
+ kind: "repeater",
2568
+ field
2569
+ };
2570
+ return { kind: "leaf" };
2571
+ }
2572
+ function after(steps, rest) {
2573
+ return rest ? [...steps, ...rest] : null;
2574
+ }
2575
+ function withinGroup(field, path, target, context) {
2576
+ const layout = layoutGroupFields(field, path);
2577
+ const own = layout.presentation === "disclosure" ? [{
2578
+ kind: "group-disclosure",
2579
+ path
2580
+ }] : [];
2581
+ if (target === path) return own;
2582
+ return after(own, revealStepsAmong(layout.inline, target, context)) ?? after([...own, {
2583
+ kind: "group-settings",
2584
+ path
2585
+ }], revealStepsAmong(layout.ownSettings, target, context));
2586
+ }
2587
+ function withinTabGroup(field, path, target, context) {
2588
+ const controlValue = field.activeTabField ? context.getValue(`${path}.${field.activeTabField}`) : void 0;
2589
+ const shown = shownTab(field.tabs, controlValue, context.sdk);
2590
+ if (!shown) return null;
2591
+ if (target === path) return [];
2592
+ return revealStepsAmong(shown.active.fields.map((child) => resolveFieldPlacement(child, path, false)), target, context);
2593
+ }
2594
+ function withinRepeater(field, path, target, context) {
2595
+ const list = {
2596
+ kind: "repeater-list",
2597
+ path
2598
+ };
2599
+ if (target === path) return [list];
2600
+ const index = rowIndexOf(path, target);
2601
+ const rows = context.getValue(path);
2602
+ if (index === null || !Array.isArray(rows) || index >= rows.length) return null;
2603
+ const rowPath = `${path}.${index}`;
2604
+ const row = [list, {
2605
+ kind: "repeater-row",
2606
+ path: rowPath
2607
+ }];
2608
+ if (target === rowPath) return row;
2609
+ const groups = getRepeaterItemFieldGroups(field, context, path, index);
2610
+ return after(row, revealStepsAmong(groups.contentFields.map((child) => resolveFieldPlacement(child, rowPath, false)), target, context)) ?? after([...row, {
2611
+ kind: "row-settings",
2612
+ path: rowPath
2613
+ }], revealStepsAmong(groups.settingsFields, target, context));
2614
+ }
2615
+ function rowIndexOf(repeaterPath, target) {
2616
+ if (!target.startsWith(`${repeaterPath}.`)) return null;
2617
+ const segment = target.slice(repeaterPath.length + 1).split(".")[0] ?? "";
2618
+ return /^\d+$/u.test(segment) ? Number(segment) : null;
2619
+ }
2620
+ const derivedGroups = {
2621
+ whatItShows: {
2622
+ id: "derived:what-it-shows",
2623
+ title: "What it shows"
2624
+ },
2625
+ moreSettings: {
2626
+ id: "derived:more-settings",
2627
+ title: "More settings"
2628
+ }
2629
+ };
2630
+ /**
2631
+ * The allocation rule. A declared field goes where it's declared. Every system
2632
+ * block declares all its own fields, so the derived rule only places SDK
2633
+ * fields: a custom block's, or ones an SDK extension appends. It puts content
2634
+ * fields, and required display or behaviour fields with no default, with the
2635
+ * content, other behaviour in "What it shows", the rest in "More settings",
2636
+ * after any declared groups. The Look's fields and the style groups are taken
2637
+ * out first, so no declaration moves them.
2638
+ */
2639
+ function layoutBlockEditing(input) {
2640
+ const offered = offeredFields(input.sections);
2641
+ const placed = placeFields(offered.own, input.editing);
2642
+ const entries = [...placed.settings.flatMap((entry) => "group" in entry ? declaredGroup(entry.group, entry.fields, input) : [plainEntry(entry)]), ...["whatItShows", "moreSettings"].flatMap((place) => derivedGroup(place, placed.derived(place), input.getValue))];
2643
+ return {
2644
+ layout: {
2645
+ look: offered.look,
2646
+ content: placed.content,
2647
+ settings: settingsFor(entries.map(({ entry }) => entry), placed.declaredContent, input.lookOwnsFields && offered.styles.length === 0),
2648
+ styles: offered.styles
2649
+ },
2650
+ unphrased: entries.flatMap(({ unphrased }) => unphrased)
2651
+ };
2652
+ }
2653
+ /** The Look's fields and the style groups come out first; the rest are the block's own, to be placed. */
2654
+ function offeredFields(sections) {
2655
+ const body = sections.flatMap((entry) => {
2656
+ const section = entry.section;
2657
+ return section === "look" ? [] : entry.fields.map((field) => ({
2658
+ field,
2659
+ section
2660
+ }));
2661
+ });
2662
+ return {
2663
+ look: sections.find((entry) => entry.section === "look")?.fields ?? [],
2664
+ styles: body.filter(({ field }) => isDedicatedStyleField(field.path)).map(({ field }) => field),
2665
+ own: body.filter(({ field }) => !isDedicatedStyleField(field.path))
2666
+ };
2667
+ }
2668
+ /** Declared paths the form isn't offering now (hidden by a condition, owned by the Look) are simply absent. */
2669
+ function placeFields(own, editing) {
2670
+ const present = (paths) => paths.flatMap((path) => own.find(({ field }) => field.path === path)?.field ?? []);
2671
+ const declared = new Set(editing ? placedEditingPaths(editing) : []);
2672
+ const derived = (place) => own.filter(({ field, section }) => !declared.has(field.path) && derivedPlace(field, section) === place).map(({ field }) => field);
2673
+ const declaredContent = present(editing?.content ?? []);
2674
+ return {
2675
+ declaredContent,
2676
+ content: [...declaredContent, ...derived("content")],
2677
+ settings: (editing?.settings ?? []).flatMap((entry) => typeof entry === "string" ? present([entry]) : [{
2678
+ group: entry,
2679
+ fields: present(entry.fields)
2680
+ }]),
2681
+ derived
2682
+ };
2683
+ }
2684
+ function plainEntry(field) {
2685
+ return {
2686
+ entry: {
2687
+ kind: "field",
2688
+ field
2689
+ },
2690
+ unphrased: []
2691
+ };
2692
+ }
2693
+ /** The derived rule, for SDK fields only (system blocks declare theirs): content, and what must be filled in, sits with the content. */
2694
+ function derivedPlace(field, section) {
2695
+ switch (section) {
2696
+ case "whatItShows":
2697
+ case "text": return "content";
2698
+ case "moreSettings": return getFieldIntent(field.field) === "behavior" ? "whatItShows" : "moreSettings";
2699
+ default: return assertNever(section);
2700
+ }
2701
+ }
2702
+ function declaredGroup(group, fields, input) {
2703
+ if (fields.length === 0) return [];
2704
+ const said = summariseGroup(group.summary, {
2705
+ getValue: (path) => input.getValue(path) ?? nestedDefault(input.fields, path, input.getValue),
2706
+ isVisible: (path) => revealStepsAmong(fields, path, input.nested) !== null,
2707
+ chosenLabel: input.chosenLabel
2708
+ });
2709
+ return [{
2710
+ entry: {
2711
+ kind: "group",
2712
+ group: {
2713
+ id: group.id,
2714
+ title: group.title,
2715
+ summary: said.line,
2716
+ fields
2717
+ }
2718
+ },
2719
+ unphrased: said.unphrased.map((entry) => ({
2720
+ groupId: group.id,
2721
+ ...entry
2722
+ }))
2723
+ }];
2724
+ }
2725
+ /**
2726
+ * What a field inside a group shows before anything is stored for it: its own
2727
+ * default, or its place in a containing group's. The widgets fall back the
2728
+ * same way, so a line and the switch it describes agree.
2729
+ */
2730
+ function nestedDefault(fields, path, getValue) {
2731
+ const resolved = resolvePromotedFields([...fields], [path], getValue)[0];
2732
+ if (!resolved) return void 0;
2733
+ const innermostFirst = [...resolved.ancestors].reverse();
2734
+ return resolved.field.defaultValue ?? innermostFirst.map((ancestor) => getAtPath(ancestor.field.defaultValue, path.slice(ancestor.path.length + 1))).find((value) => value !== void 0);
2735
+ }
2736
+ function derivedGroup(place, fields, getValue) {
2737
+ if (fields.length === 0) return [];
2738
+ return [{
2739
+ entry: {
2740
+ kind: "group",
2741
+ group: {
2742
+ ...derivedGroups[place],
2743
+ summary: derivedSettingsSummary(fields, getValue),
2744
+ fields
2745
+ }
2746
+ },
2747
+ unphrased: []
2748
+ }];
2749
+ }
2750
+ function entryFields(entry) {
2751
+ switch (entry.kind) {
2752
+ case "field": return [entry.field];
2753
+ case "group": return entry.group.fields;
2754
+ default: return assertNever(entry);
2755
+ }
2756
+ }
2757
+ /** Decided from what's left after the Look and conditions, so a block with few settings on this site has no rows. */
2758
+ function settingsFor(entries, declaredContent, lookTookTheRest) {
2759
+ const fields = entries.flatMap(entryFields);
2760
+ if (fields.length === 0 && lookTookTheRest) return { kind: "set-by-look" };
2761
+ if (fields.length <= 3) return {
2762
+ kind: "plain",
2763
+ fields
2764
+ };
2765
+ const list = declaredContent.find((item) => item.field.type === "repeater");
2766
+ return {
2767
+ kind: "rows",
2768
+ entries,
2769
+ position: list ? {
2770
+ kind: "before-content-field",
2771
+ path: list.path
2772
+ } : { kind: "after-content" }
2773
+ };
2774
+ }
2775
+ /** The part of the layout that draws this path, with the steps to it inside that field. */
2776
+ function destinationInLayout(layout, fieldPath, context) {
2777
+ const within = (fields) => revealStepsAmong(fields, fieldPath, context);
2778
+ const look = within(layout.look);
2779
+ if (look) return {
2780
+ kind: "look",
2781
+ reveal: look
2782
+ };
2783
+ const ownView = within([
2784
+ ...layout.content,
2785
+ ...ownViewSettings(layout.settings),
2786
+ ...layout.styles
2787
+ ]);
2788
+ if (ownView) return {
2789
+ kind: "content",
2790
+ reveal: ownView
2791
+ };
2792
+ const inGroup = rowGroups(layout.settings).map((group) => ({
2793
+ group,
2794
+ reveal: within(group.fields)
2795
+ })).find((candidate) => candidate.reveal !== null);
2796
+ return inGroup?.reveal ? {
2797
+ kind: "group",
2798
+ groupId: inGroup.group.id,
2799
+ reveal: inGroup.reveal
2800
+ } : { kind: "unavailable" };
2801
+ }
2802
+ function ownViewSettings(settings) {
2803
+ switch (settings.kind) {
2804
+ case "plain": return settings.fields;
2805
+ case "rows": return settings.entries.flatMap((entry) => entry.kind === "field" ? [entry.field] : []);
2806
+ case "set-by-look": return [];
2807
+ default: return assertNever(settings);
2808
+ }
2809
+ }
2810
+ function rowGroups(settings) {
2811
+ switch (settings.kind) {
2812
+ case "plain":
2813
+ case "set-by-look": return [];
2814
+ case "rows": return settings.entries.flatMap((entry) => entry.kind === "group" ? [entry.group] : []);
2815
+ default: return assertNever(settings);
2816
+ }
2817
+ }
2818
+ function blockViewParts(layout) {
2819
+ const content = contentAroundRows(layout.content, layout.settings);
2820
+ return [
2821
+ {
2822
+ kind: "look",
2823
+ fields: layout.look
2824
+ },
2825
+ {
2826
+ kind: "content",
2827
+ fields: content.before
2828
+ },
2829
+ ...settingsParts(layout.settings),
2830
+ ...fieldsPart(content.after),
2831
+ ...layout.styles.length > 0 ? [{
2832
+ kind: "styles",
2833
+ fields: layout.styles
2834
+ }] : []
2835
+ ];
2836
+ }
2837
+ function fieldsPart(fields) {
2838
+ return fields.length > 0 ? [{
2839
+ kind: "fields",
2840
+ fields
2841
+ }] : [];
2842
+ }
2843
+ /** The content either side of the rows: all of it before them, unless they sit above the block's list. */
2844
+ function contentAroundRows(content, settings) {
2845
+ const above = settings.kind === "rows" && settings.position.kind === "before-content-field" ? settings.position.path : null;
2846
+ const at = above === null ? -1 : content.findIndex((item) => item.path === above);
2847
+ return at < 0 ? {
2848
+ before: content,
2849
+ after: []
2850
+ } : {
2851
+ before: content.slice(0, at),
2852
+ after: content.slice(at)
2853
+ };
2854
+ }
2855
+ function settingsParts(settings) {
2856
+ switch (settings.kind) {
2857
+ case "plain": return fieldsPart(settings.fields);
2858
+ case "set-by-look": return [{ kind: "set-by-look" }];
2859
+ case "rows": return settings.entries.reduce(withEntry, []);
2860
+ default: return assertNever(settings);
2861
+ }
2862
+ }
2863
+ /** Neighbouring groups share one list of rows; a setting between them is drawn in place, where it was declared. */
2864
+ function withEntry(parts, entry) {
2865
+ const last = parts.at(-1);
2866
+ switch (entry.kind) {
2867
+ case "group": return last?.kind === "rows" ? [...parts.slice(0, -1), {
2868
+ kind: "rows",
2869
+ groups: [...last.groups, entry.group]
2870
+ }] : [...parts, {
2871
+ kind: "rows",
2872
+ groups: [entry.group]
2873
+ }];
2874
+ case "field": return last?.kind === "fields" ? [...parts.slice(0, -1), {
2875
+ kind: "fields",
2876
+ fields: [...last.fields, entry.field]
2877
+ }] : [...parts, {
2878
+ kind: "fields",
2879
+ fields: [entry.field]
2880
+ }];
2881
+ default: return assertNever(entry);
2882
+ }
2883
+ }
2884
+ /** Every field the form places, in any view: the Look, the content, the settings and the style groups. */
2885
+ function placedFields(layout) {
2886
+ const { look, content, settings, styles } = layout;
2887
+ return [
2888
+ ...look,
2889
+ ...content,
2890
+ ...ownViewSettings(settings),
2891
+ ...rowGroups(settings).flatMap((group) => group.fields),
2892
+ ...styles
2893
+ ];
2894
+ }
2895
+ //#endregion
2896
+ //#region ../block-form/src/editing/fieldSections.ts
2897
+ /** The four sections, always in this order. */
2898
+ const blockFieldSectionOrder = [
2899
+ "look",
2900
+ "whatItShows",
2901
+ "text",
2902
+ "moreSettings"
2903
+ ];
2904
+ /** A manifest's own Look field, or its named layouts standing in for Looks, become tiles in the Look section. */
2905
+ function manifestFieldSectionOptions(manifest, options = {}) {
2906
+ const layoutField = !manifest.lookField && manifest.variantMeaning.kind === "arrangement" ? "variant" : void 0;
2907
+ return {
2908
+ ...options,
2909
+ lookField: manifest.lookField,
2910
+ layoutField,
2911
+ lookOwnedPaths: manifest.lookField ? [] : [...options.lookOwnedPaths ?? [], ...layoutField ? [layoutField] : []]
2912
+ };
2913
+ }
2914
+ function hasSatisfyingDefault(field) {
2915
+ const value = field.defaultValue;
2916
+ if (typeof value === "boolean") return true;
2917
+ if (typeof value === "number") return Number.isFinite(value);
2918
+ if (typeof value === "string") return value.trim().length > 0;
2919
+ if (Array.isArray(value)) return value.length > 0;
2920
+ return Boolean(value && typeof value === "object" && Object.keys(value).length > 0);
2921
+ }
2922
+ function isAutomaticallyPromotable(field) {
2923
+ const intent = getFieldIntent(field);
2924
+ return field.required === true && !hasSatisfyingDefault(field) && !isHiddenField(field) && !isHeaderField(field) && (intent === "display" || intent === "behavior");
2925
+ }
2926
+ function sectionFor(item, promoted, look) {
2927
+ if (look.has(item.path)) return "look";
2928
+ if (promoted.has(item.path)) return "whatItShows";
2929
+ return getFieldIntent(item.field) === "content" ? "text" : "moreSettings";
2930
+ }
2931
+ /** The one allocation rule. Callers supply the prepared fields and effective visibility values. */
2932
+ function allocateFieldSections(suppliedFields, reader, options = {}) {
2933
+ const { getValue } = reader;
2934
+ const fields = prunePromotedFields(suppliedFields, new Set(options.excludedFieldIds ?? []));
2935
+ const look = lookPathsFor(options);
2936
+ const requested = [...fields.filter(isAutomaticallyPromotable).map((field) => field.id), ...look];
2937
+ const lifted = (options.liftedPaths ?? []).filter((path) => !fields.some((field) => field.id === path));
2938
+ const shortcuts = resolvePromotedFields(fields, [...requested, ...lifted], getValue).filter((item) => !isHiddenField(item.field) && evaluateVisibility(item.field, reader, item.path) && item.ancestors.every((ancestor) => conditionAllows(ancestor.field, ancestor.path, reader)));
2939
+ const drawnOut = new Set(shortcuts.map((item) => item.path));
2940
+ const promotedPaths = new Set(requested.filter((path) => drawnOut.has(path)));
2941
+ const ordinary = prunePromotedFields(fields, drawnOut).filter((field) => !isHiddenField(field) && !isHeaderField(field)).filter((field) => evaluateVisibility(field, reader, field.id)).map((field) => ({
2942
+ field,
2943
+ path: field.id,
2944
+ tabSelections: [],
2945
+ ancestors: []
2946
+ }));
2947
+ const items = [...disjointPromotions(shortcuts, drawnOut), ...ordinary].map((item) => ({
2948
+ ...item,
2949
+ field: decidedVisibility(item.field)
2950
+ }));
2951
+ return {
2952
+ sections: blockFieldSectionOrder.map((section) => ({
2953
+ section,
2954
+ fields: items.filter((item) => sectionFor(item, promotedPaths, look) === section)
2955
+ })),
2956
+ tilePaths: new Set([options.lookField, options.layoutField].filter((path) => path !== void 0))
2957
+ };
2958
+ }
2959
+ /** An SDK site can turn off a section option (a background colour, say); its shortcut goes with it. */
2960
+ function withSdkSectionOptions(allocated, sdk) {
2961
+ return {
2962
+ ...allocated,
2963
+ sections: allocated.sections.map((entry) => ({
2964
+ ...entry,
2965
+ fields: entry.fields.filter((item) => isSdkSectionOptionEnabled(item.sdkSectionOption, sdk.isSdkSite, sdk.sectionOptions))
2966
+ }))
2967
+ };
2968
+ }
2969
+ /** The section whose field draws this path, with the steps to it inside that field. */
2970
+ function destinationIn(sections, fieldPath, context) {
2971
+ for (const { section, fields } of sections) {
2972
+ const reveal = revealStepsAmong(fields, fieldPath, context);
2973
+ if (reveal) return section === "look" ? {
2974
+ kind: "look",
2975
+ reveal
2976
+ } : {
2977
+ kind: "section",
2978
+ section,
2979
+ reveal
2980
+ };
2981
+ }
2982
+ return { kind: "unavailable" };
2983
+ }
2984
+ /**
2985
+ * The layout of a manifest form outside the block editors (ManifestForm):
2986
+ * the same allocation rule, with no block preparation or page design.
2987
+ */
2988
+ function layoutManifestForm(input) {
2989
+ const allocated = withSdkSectionOptions(allocateFieldSections(input.fields, {
2990
+ getValue: (path) => input.getValue(path) ?? input.fields.find((field) => field.id === path)?.defaultValue,
2991
+ siteFacts: input.siteFacts,
2992
+ block: input.block
2993
+ }, input.options), input.sdk);
2994
+ const context = {
2995
+ getValue: input.getValue,
2996
+ siteFacts: input.siteFacts,
2997
+ block: input.block,
2998
+ sdk: input.sdk
2999
+ };
3000
+ return {
3001
+ ...allocated,
3002
+ destinationOf: (fieldPath) => destinationIn(allocated.sections, fieldPath, context)
3003
+ };
3004
+ }
3005
+ /**
3006
+ * A container's condition goes with a field drawn out of it. Its `hidden`
3007
+ * flag doesn't: a shortcut is how a hidden style group's photo, or a
3008
+ * header-drawn group's field, reaches the form on purpose.
3009
+ */
3010
+ function conditionAllows(container, path, reader) {
3011
+ if (!container.ui || !("visibleWhen" in container.ui)) return true;
3012
+ return evaluateVisibility({
3013
+ ...container,
3014
+ ui: {
3015
+ ...container.ui,
3016
+ hidden: false
3017
+ }
3018
+ }, reader, path);
3019
+ }
3020
+ function lookPathsFor(options) {
3021
+ return /* @__PURE__ */ new Set([...options.lookOwnedPaths ?? [], ...options.lookField ? [options.lookField] : []]);
3022
+ }
3023
+ function disjointPromotions(items, promotedPaths) {
3024
+ return items.flatMap((item) => {
3025
+ const descendants = new Set([...promotedPaths].filter((path) => path.startsWith(`${item.path}.`)).map(toFieldConfigPath));
3026
+ const parentPath = item.path.split(".").slice(0, -1).join(".");
3027
+ const field = prunePromotedField(item.field, descendants, parentPath);
3028
+ return field ? [{
3029
+ ...item,
3030
+ field
3031
+ }] : [];
3032
+ });
3033
+ }
3034
+ function prunePromotedField(field, promotedSchemaPaths, parentPath) {
3035
+ const path = parentPath ? `${parentPath}.${field.id}` : field.id;
3036
+ if (promotedSchemaPaths.has(path)) return null;
3037
+ const container = pruneContainerField(field, promotedSchemaPaths, path);
3038
+ if (container.handled) return container.field;
3039
+ if (field.type === "repeater" && !field.polymorphic) {
3040
+ const fields = prunePromotedFieldsAtPath(field.fields ?? [], promotedSchemaPaths, path);
3041
+ return fields.length > 0 ? {
3042
+ ...field,
3043
+ fields
3044
+ } : null;
3045
+ }
3046
+ if (field.type === "repeater" && field.polymorphic && field.itemTypes) return prunePolymorphicRepeater(field, promotedSchemaPaths, path);
3047
+ if (field.type === "tabGroup") {
3048
+ const tabs = field.tabs.flatMap((tab) => {
3049
+ const fields = prunePromotedFieldsAtPath(tab.fields, promotedSchemaPaths, path);
3050
+ return fields.length > 0 ? [{
3051
+ ...tab,
3052
+ fields
3053
+ }] : [];
3054
+ });
3055
+ return tabs.length > 0 ? {
3056
+ ...field,
3057
+ tabs
3058
+ } : null;
3059
+ }
3060
+ return field;
3061
+ }
3062
+ function pruneContainerField(field, promotedPaths, path) {
3063
+ if (field.type === "group") {
3064
+ const fields = prunePromotedFieldsAtPath(field.fields, promotedPaths, path);
3065
+ return {
3066
+ handled: true,
3067
+ field: fields.length > 0 ? {
3068
+ ...field,
3069
+ fields
3070
+ } : null
3071
+ };
3072
+ }
3073
+ if (field.type === "modal") {
3074
+ const fields = prunePromotedFieldsAtPath(field.schema.fields, promotedPaths, path);
3075
+ return {
3076
+ handled: true,
3077
+ field: fields.length > 0 ? {
3078
+ ...field,
3079
+ schema: {
3080
+ ...field.schema,
3081
+ fields
3082
+ }
3083
+ } : null
3084
+ };
3085
+ }
3086
+ return { handled: false };
3087
+ }
3088
+ function prunePolymorphicRepeater(field, promotedPaths, path) {
3089
+ if (!field.itemTypes) return field;
3090
+ const itemTypes = Object.fromEntries(Object.entries(field.itemTypes).flatMap(([key, item]) => {
3091
+ const fields = prunePromotedFieldsAtPath(item.fields ?? [], promotedPaths, path);
3092
+ return fields.length > 0 ? [[key, {
3093
+ ...item,
3094
+ fields
3095
+ }]] : [];
3096
+ }));
3097
+ return Object.keys(itemTypes).length > 0 ? {
3098
+ ...field,
3099
+ itemTypes
3100
+ } : null;
3101
+ }
3102
+ function prunePromotedFieldsAtPath(fields, promotedSchemaPaths, parentPath) {
3103
+ return fields.flatMap((field) => {
3104
+ const pruned = prunePromotedField(field, promotedSchemaPaths, parentPath);
3105
+ return pruned ? [pruned] : [];
3106
+ });
3107
+ }
3108
+ function toFieldConfigPath(path) {
3109
+ return path.split(".").filter((segment) => !/^\d+$/u.test(segment)).join(".");
3110
+ }
3111
+ function prunePromotedFields(fields, promotedPaths, parentPath = "") {
3112
+ return prunePromotedFieldsAtPath(fields, new Set([...promotedPaths].map(toFieldConfigPath)), parentPath);
3113
+ }
3114
+ function decidedVisibility(field) {
3115
+ if (!field.ui || !("visibleWhen" in field.ui)) return field;
3116
+ const { visibleWhen: _condition, ...ui } = field.ui;
3117
+ return {
3118
+ ...field,
3119
+ ui
3120
+ };
3121
+ }
3122
+ //#endregion
3123
+ //#region ../block-form/src/editing/pageDesignContext.ts
3124
+ /**
3125
+ * Fields kept out of the block form on a newer style: the arrangement and its
3126
+ * knobs, which the Look section edits, and, once a Look resolves, the
3127
+ * presentation it owns. The field ownership decision says which those are.
3128
+ */
3129
+ function arrangementOwnedFieldIds(block) {
3130
+ if (!block?.arrangementLookSelection) return [];
3131
+ const manifest = getBlockDefinition(block.blockKind)?.manifest;
3132
+ if (!manifest) return [];
3133
+ const ownership = resolveFieldOwnership({
3134
+ blockKind: block.blockKind,
3135
+ manifest,
3136
+ arrangementLook: true
3137
+ });
3138
+ const owners = arrangementVisibilityValues(block) ? [
3139
+ "knob",
3140
+ "arrangement",
3141
+ "look"
3142
+ ] : ["knob", "arrangement"];
3143
+ const modeField = manifest.variantMeaning?.kind === "mode" ? ["variant"] : [];
3144
+ return [...fieldPathsOwnedBy(ownership, owners), ...modeField];
3145
+ }
3146
+ /** Content fields the block's current Look leaves out; the form keeps them, with a note. */
3147
+ function lookNotShownFieldIds(block) {
3148
+ const arrangement = arrangementVisibilityValues(block)?.arrangement ?? null;
3149
+ return block ? fieldsNotShownIn(block.blockKind, arrangement) : [];
3150
+ }
3151
+ function arrangementLookResolution(block) {
3152
+ const selection = block.arrangementLookSelection;
3153
+ return selection ? {
3154
+ ...resolveEditorArrangementLook(selection, arrangementBlockMode(block), block.look.kind === "user-pinned" ? block.look.value : null),
3155
+ skin: selection.style.skin
3156
+ } : null;
3157
+ }
3158
+ function arrangementBlockMode(block) {
3159
+ const meaning = getBlockDefinition(block.blockKind)?.manifest.variantMeaning;
3160
+ return meaning?.kind === "mode" ? readStoredMode({
3161
+ keys: [],
3162
+ defaultKey: null,
3163
+ variantMeaning: meaning
3164
+ }, { variant: block.layoutChoice.effectiveValue }) : null;
3165
+ }
3166
+ function arrangementVisibilityValues(block) {
3167
+ if (!block) return null;
3168
+ const resolved = arrangementLookResolution(block);
3169
+ if (!resolved || resolved.kind === "none" || resolved.kind === "recipe") return null;
3170
+ const meaning = getBlockDefinition(block.blockKind)?.manifest.variantMeaning;
3171
+ const arrangementField = meaning?.kind === "mode" ? meaning.arrangementField : "variant";
3172
+ const arrangement = resolved.look.structure.byMode[arrangementBlockMode(block) ?? "default"];
3173
+ return arrangement ? {
3174
+ lookId: resolved.look.id,
3175
+ arrangementField,
3176
+ arrangement,
3177
+ mediaLook: editorMediaLook(block, resolved.look, resolved.skin)
3178
+ } : null;
3179
+ }
3180
+ /** Keep the style's knob restrictions with the Look until live field values are available. */
3181
+ function editorMediaLook(block, look, skin) {
3182
+ const offer = block.arrangementLookSelection?.style.offers.find((entry) => entry.id === look.id);
3183
+ return {
3184
+ look,
3185
+ skin,
3186
+ removeKnobs: offer?.removeKnobs ?? [],
3187
+ addKnobs: offer?.addKnobs ?? [],
3188
+ knobValues: offer?.knobValues ?? {}
3189
+ };
3190
+ }
3191
+ /** Legacy Look knobs keep their ordinary manifest fields in Look, without a second widget inventory. */
3192
+ function blockLookOwnedFieldPaths(block) {
3193
+ if (!block || block.arrangementLookSelection) return [];
3194
+ return systemCustomizeFacetDefinitionsForBlock(block.blockKind).filter((facet) => systemCustomizeFacetAppliesToLayoutVariant(facet, block.layoutChoice.effectiveValue ?? null)).map((facet) => facet.target.kind === "content-field" ? facet.target.field : "listLayout");
3195
+ }
3196
+ //#endregion
3197
+ //#region ../block-form/src/editing/colourFieldVisibility.ts
1807
3198
  /** Only changes form presentation; the validation manifest and saved data stay intact. */
1808
3199
  function hideUnavailableColourFields(manifest, options) {
1809
3200
  if (options.colour && options.gradient) return manifest;
1810
- const hiddenPaths = [];
1811
- const visit = (fields, parent) => fields.flatMap((field) => {
1812
- const path = parent ? `${parent}.${field.id}` : field.id;
3201
+ const visit = (fields) => fields.flatMap((field) => {
1813
3202
  const widget = field.ui?.widget;
1814
- if (widget === "backgroundColor" && !options.colour || widget === "backgroundGradient" && !options.gradient) {
1815
- hiddenPaths.push(path);
1816
- return [];
1817
- }
3203
+ if (widget === "backgroundColor" && !options.colour || widget === "backgroundGradient" && !options.gradient) return [];
1818
3204
  if (field.type === "group" || field.type === "modal") {
1819
- const children = visit(field.schema.fields, path);
1820
- if (!children.length) {
1821
- hiddenPaths.push(path);
1822
- return [];
1823
- }
3205
+ const children = visit(field.schema.fields);
3206
+ if (!children.length) return [];
1824
3207
  return [{
1825
3208
  ...field,
1826
3209
  schema: {
@@ -1833,26 +3216,23 @@ function hideUnavailableColourFields(manifest, options) {
1833
3216
  ...field,
1834
3217
  ...field.schema ? { schema: {
1835
3218
  ...field.schema,
1836
- fields: visit(field.schema.fields, path)
3219
+ fields: visit(field.schema.fields)
1837
3220
  } } : {},
1838
3221
  ...field.itemTypes ? { itemTypes: Object.fromEntries(Object.entries(field.itemTypes).map(([id, item]) => [id, {
1839
3222
  ...item,
1840
- fields: visit(item.fields, path)
3223
+ fields: visit(item.fields)
1841
3224
  }])) } : {}
1842
3225
  }];
1843
3226
  if (field.type === "tabGroup") {
1844
3227
  const tabs = field.tabs.flatMap((tab) => {
1845
- const children = visit(tab.fields, path);
3228
+ const children = visit(tab.fields);
1846
3229
  const unavailableTab = tab.sdkSectionOption === "backgroundColor" && !options.colour || tab.sdkSectionOption === "backgroundGradient" && !options.gradient;
1847
3230
  return children.length && !unavailableTab ? [{
1848
3231
  ...tab,
1849
3232
  fields: children
1850
3233
  }] : [];
1851
3234
  });
1852
- if (!tabs.length) {
1853
- hiddenPaths.push(path);
1854
- return [];
1855
- }
3235
+ if (!tabs.length) return [];
1856
3236
  return [{
1857
3237
  ...field,
1858
3238
  tabs
@@ -1860,24 +3240,16 @@ function hideUnavailableColourFields(manifest, options) {
1860
3240
  }
1861
3241
  return [field];
1862
3242
  });
1863
- const fields = visit(manifest.fields, "");
1864
3243
  return {
1865
3244
  ...manifest,
1866
- fields,
1867
- promotedFields: manifest.promotedFields?.filter((path) => !hiddenPaths.some((hidden) => path === hidden || path.startsWith(`${hidden}.`)))
3245
+ fields: visit(manifest.fields)
1868
3246
  };
1869
3247
  }
1870
3248
  //#endregion
1871
- //#region ../editor-blocks/src/block-editor/settingsIntent.ts
3249
+ //#region ../block-form/src/editing/rawStyleFields.ts
1872
3250
  function isThemeV2NormalEditorRawStyleField(field) {
1873
3251
  return isThemeV2NormalEditorRawStyleFieldName(field.id);
1874
3252
  }
1875
- function filterThemeV2NormalEditorRawPromotedFields(promotedFields, allowedFieldPaths = void 0) {
1876
- if (!promotedFields) return void 0;
1877
- const allowedFieldPathSet = new Set(allowedFieldPaths ?? []);
1878
- const filtered = promotedFields.filter((fieldPath) => !isThemeV2NormalEditorRawStylePath(fieldPath) || allowedFieldPathSet.has(fieldPath));
1879
- return filtered.length > 0 ? filtered : void 0;
1880
- }
1881
3253
  function hideThemeV2NormalEditorRawStyleFieldsInRenderFields(fields) {
1882
3254
  return fields.map((field) => {
1883
3255
  if (!isThemeV2NormalEditorRawStyleField(field)) return field;
@@ -1891,31 +3263,44 @@ function hideThemeV2NormalEditorRawStyleFieldsInRenderFields(fields) {
1891
3263
  });
1892
3264
  }
1893
3265
  //#endregion
1894
- //#region ../editor-blocks/src/block-editor/preparedManifest.ts
1895
- const showRawStyleFields = { kind: "show-raw-style-fields" };
1896
- const hideThemeV2RawStyleFields = { kind: "hide-theme-v2-raw-style-fields" };
1897
- const EDITOR_OWNED_FEATURE_CARD_FIELD_IDS = /* @__PURE__ */ new Set(["_generatedIconSizePx"]);
1898
- function hideEditorOwnedFields(manifest, blockKind) {
1899
- if (blockKind !== "block.feature-cards") return manifest;
3266
+ //#region ../block-form/src/editing/preparedManifest.ts
3267
+ /** A host with nothing but the form: every field the block offers is in it. */
3268
+ const FORM_ONLY_HOST = { featureCardIconSize: false };
3269
+ /** The fields a host's own commands edit, for this block. The plan is the only place that decides it. */
3270
+ function hostEditedFieldIds(blockKind, commands) {
3271
+ return blockKind === "block.feature-cards" && commands.featureCardIconSize ? ["_generatedIconSizePx"] : [];
3272
+ }
3273
+ function hideHostEditedFields(manifest, fieldIds) {
3274
+ if (fieldIds.length === 0) return manifest;
1900
3275
  return {
1901
3276
  ...manifest,
1902
- fields: manifest.fields?.map((field) => EDITOR_OWNED_FEATURE_CARD_FIELD_IDS.has(field.id) ? {
3277
+ fields: manifest.fields?.map((field) => fieldIds.includes(field.id) ? {
1903
3278
  ...field,
1904
3279
  ui: {
1905
3280
  ...field.ui ?? {},
1906
3281
  hidden: true
1907
3282
  }
1908
- } : field),
1909
- promotedFields: manifest.promotedFields?.filter((fieldPath) => !EDITOR_OWNED_FEATURE_CARD_FIELD_IDS.has(fieldPath))
3283
+ } : field)
3284
+ };
3285
+ }
3286
+ /** The SDK merge and the theme's style groups: what validation checks a block's content against. */
3287
+ function mergedAndValidationManifests(input) {
3288
+ const merged = mergeManifestWithSdkOptions(input.manifest, input.blockKind, input.blockFieldOptions, input.blockFieldExtensions);
3289
+ return {
3290
+ merged,
3291
+ validation: augmentManifestWithStyleGroups(merged, input.theme?.styleGroups, input.blockKind)
1910
3292
  };
1911
3293
  }
3294
+ /** The manifest a block's content is validated against, for hosts that only validate. */
3295
+ function deriveBlockValidationManifest(input) {
3296
+ return mergedAndValidationManifests(input).validation;
3297
+ }
1912
3298
  function prepareBlockEditorManifest(input) {
1913
- const mergedManifest = mergeManifestWithSdkOptions(input.manifest, input.blockKind, input.blockFieldOptions, input.blockFieldExtensions);
1914
- const validationManifest = augmentManifestWithStyleGroups(mergedManifest, input.theme?.styleGroups, input.blockKind);
3299
+ const { merged: mergedManifest, validation: validationManifest } = mergedAndValidationManifests(input);
1915
3300
  const renderManifest = editorRenderManifest(input, mergedManifest, validationManifest);
1916
3301
  return {
1917
3302
  validationManifest,
1918
- renderManifest: noteFieldsNotShown(hideCalendarGroupingField(hideEditorOwnedFields(input.colourFieldOptions ? hideUnavailableColourFields(renderManifest, input.colourFieldOptions) : renderManifest, input.blockKind), input.theme?.siteStyleId), input.notShownFieldIds ?? [])
3303
+ renderManifest: noteFieldsNotShown(hideHostEditedFields(input.colourFieldOptions ? hideUnavailableColourFields(renderManifest, input.colourFieldOptions) : renderManifest, hostEditedFieldIds(input.blockKind, input.hostCommands)), input.notShownFieldIds ?? [])
1919
3304
  };
1920
3305
  }
1921
3306
  const lookNotShownNote = "Not shown in this Look.";
@@ -1930,108 +3315,296 @@ function noteFieldsNotShown(manifest, fieldIds) {
1930
3315
  } : field)
1931
3316
  };
1932
3317
  }
1933
- /** Preserve validation/stored intent while limiting weekly presentation, and its unpaged list, to arrangement styles. */
1934
- function hideCalendarGroupingField(manifest, siteStyleId) {
1935
- if (manifest.name !== "block.event-calendar") return manifest;
1936
- if (eventCalendarListGroupingDecision({
1937
- arrangementLooks: (siteStyleId ? getCuratedSiteStyle(asSiteStyleId(siteStyleId)) : void 0)?.looks.kind === "offers",
1938
- variant: "list"
1939
- }).available) return manifest;
1940
- const upcomingPaging = new Map(eventCalendarPagingFields(false).map((field) => [field.id, field]));
1941
- return {
1942
- ...manifest,
1943
- fields: manifest.fields.map((field) => field.id === "listBy" ? {
1944
- ...field,
1945
- ui: {
1946
- ...field.ui,
1947
- hidden: true
1948
- }
1949
- } : upcomingPaging.get(field.id) ?? field),
1950
- promotedFields: manifest.promotedFields?.filter((path) => path !== "listBy")
1951
- };
1952
- }
1953
3318
  /** Form presentation uses the merged manifest; synthetic style groups remain validation-only. */
1954
3319
  function editorRenderManifest(input, merged, validation) {
1955
- if (input.visibilityPolicy.kind !== "hide-theme-v2-raw-style-fields") return validation;
3320
+ if (input.rawStyleFields !== "hide-theme-v2") return validation;
1956
3321
  return {
1957
3322
  ...merged,
1958
- fields: hideThemeV2NormalEditorRawStyleFieldsInRenderFields(merged.fields),
1959
- promotedFields: filterThemeV2NormalEditorRawPromotedFields(merged.promotedFields, input.allowedPromotedFieldPaths)
3323
+ fields: hideThemeV2NormalEditorRawStyleFieldsInRenderFields(merged.fields)
1960
3324
  };
1961
3325
  }
1962
3326
  //#endregion
1963
- //#region ../editor-blocks/src/block-editor/blockFieldSectionContext.ts
3327
+ //#region ../block-form/src/editing/blockEditingPlan.ts
3328
+ /** Not exported: only this module can make a plan. */
3329
+ const ownedPlan = Symbol("BlockEditingPlan");
1964
3330
  /**
1965
- * Fields kept out of the block form on a newer style: the arrangement and its
1966
- * knobs, which the Look section edits, and, once a Look resolves, the
1967
- * presentation it owns. The field ownership decision says which those are.
3331
+ * The single owner of where a block's fields go, in every editor. It takes
3332
+ * the block's manifest as registered and its current draft values, and does
3333
+ * all the preparation: SDK options and extensions, style groups, raw style
3334
+ * fields, colour options, the section photo, notes for content the Look
3335
+ * leaves out, whether a Look shapes the block, and what the Look owns. Then
3336
+ * it places what's left by the block's `editing` declaration.
1968
3337
  */
1969
- function arrangementOwnedFieldIds(block) {
1970
- if (!block?.arrangementLookSelection) return [];
1971
- const manifest = getBlockDefinition(block.blockKind)?.manifest;
1972
- if (!manifest) return [];
1973
- const ownership = resolveFieldOwnership({
1974
- blockKind: block.blockKind,
3338
+ function deriveBlockEditingPlan(input) {
3339
+ const { context } = input;
3340
+ const photo = sectionPhotoFor(input.manifest, input.values, context);
3341
+ const prepared = prepareForContext(input.manifest, context);
3342
+ const fields = createManifestFormAdapter(prepared.renderManifest, { role: context.role }).fields;
3343
+ const visibilityValues = arrangementVisibilityValues(context.pageDesignBlock);
3344
+ const block = {
3345
+ look: blockLookFact(context, visibilityValues, input.values),
3346
+ template: context.pageTemplate,
3347
+ observations: context.observations
3348
+ };
3349
+ const shownValues = shownValueReader(input.values, visibilityValues, context.siteFacts, block);
3350
+ const effectiveValue = (path) => shownValues.getValue(path) ?? fields.find((field) => field.id === path)?.defaultValue;
3351
+ const editing = prepared.renderManifest.editing;
3352
+ const offered = withSectionPhotoCopy(withSdkSectionOptions(allocateFieldSections(fields, {
3353
+ getValue: effectiveValue,
3354
+ siteFacts: context.siteFacts,
3355
+ block
3356
+ }, manifestFieldSectionOptions(prepared.renderManifest, {
3357
+ excludedFieldIds: arrangementOwnedFieldIds(context.pageDesignBlock),
3358
+ lookOwnedPaths: blockLookOwnedFieldPaths(context.pageDesignBlock),
3359
+ liftedPaths: editing ? placedEditingPaths(editing).filter((path) => path !== "_sectionStyles.background.image" || photo.offered) : []
3360
+ })), context.sdk), photo);
3361
+ const lookSource = lookSourceOf(prepared.renderManifest, offered.sections);
3362
+ const lookInForm = context.lookFields === "in-form" || lookSource.kind === "sdk";
3363
+ const nested = {
3364
+ getValue: shownValues.getValue,
3365
+ siteFacts: context.siteFacts,
3366
+ block,
3367
+ sdk: context.sdk
3368
+ };
3369
+ const placed = layoutBlockEditing({
3370
+ sections: offered.sections,
3371
+ editing,
3372
+ fields,
3373
+ getValue: effectiveValue,
3374
+ chosenLabel: context.chosenLabel,
3375
+ nested,
3376
+ lookOwnsFields: lookSource.kind === "built-in" && lookOwnsFields(context.pageDesignBlock)
3377
+ });
3378
+ const layout = lookInForm ? placed.layout : {
3379
+ ...placed.layout,
3380
+ look: []
3381
+ };
3382
+ return {
3383
+ [ownedPlan]: true,
3384
+ blockKind: context.blockKind,
3385
+ layout,
3386
+ viewParts: blockViewParts(layout),
3387
+ destinationOf: (fieldPath) => destinationWith(placed.layout, fieldPath, lookInForm, nested),
3388
+ issues: [...declarationIssues(input.manifest, context), ...placed.unphrased.map(unphrasedIssue)],
3389
+ tilePaths: offered.tilePaths,
3390
+ visibilityValues,
3391
+ siteFacts: context.siteFacts,
3392
+ block,
3393
+ fields,
3394
+ renderManifest: prepared.renderManifest,
3395
+ validationManifest: prepared.validationManifest,
3396
+ lookSource
3397
+ };
3398
+ }
3399
+ /** Checked against the manifest as registered with the site's SDK options and extensions merged in, as the form is. */
3400
+ function declarationIssues(manifest, context) {
3401
+ return blockEditingIssues({
3402
+ blockKind: context.blockKind,
1975
3403
  manifest,
1976
- arrangementLook: true
3404
+ sdkBlockFieldOptions: context.sdk.blockFieldOptions,
3405
+ sdkBlockFieldExtensions: context.sdk.blockFieldExtensions
1977
3406
  });
1978
- const owners = arrangementVisibilityValues(block) ? [
1979
- "knob",
1980
- "arrangement",
1981
- "look"
1982
- ] : ["knob", "arrangement"];
1983
- const modeField = manifest.variantMeaning?.kind === "mode" ? ["variant"] : [];
1984
- return [...fieldPathsOwnedBy(ownership, owners), ...modeField];
1985
3407
  }
1986
- /** Content fields the block's current Look leaves out; the form keeps them, with a note. */
1987
- function lookNotShownFieldIds(block) {
1988
- const arrangement = arrangementVisibilityValues(block)?.arrangement ?? null;
1989
- return block ? fieldsNotShownIn(block.blockKind, arrangement) : [];
3408
+ function unphrasedIssue(value) {
3409
+ return {
3410
+ kind: "value-without-phrase",
3411
+ ...value
3412
+ };
1990
3413
  }
1991
- function arrangementLookResolution(block) {
1992
- const selection = block.arrangementLookSelection;
1993
- return selection ? {
1994
- ...resolveEditorArrangementLook(selection, arrangementBlockMode(block), block.look.kind === "user-pinned" ? block.look.value : null),
1995
- skin: selection.style.skin
1996
- } : null;
3414
+ const BLOCK_VIEW = { kind: "block" };
3415
+ /**
3416
+ * What a host shows for the view it has open. When the open group is no
3417
+ * longer in the plan (a choice or an Undo hid its last field, or the settings
3418
+ * now show plainly), it falls back to the block's own view.
3419
+ */
3420
+ function resolveOpenView(plan, openView) {
3421
+ if (openView.kind === "block") return BLOCK_VIEW;
3422
+ const group = rowGroups(plan.layout.settings).find((entry) => entry.id === openView.groupId);
3423
+ return group ? {
3424
+ kind: "group",
3425
+ group
3426
+ } : BLOCK_VIEW;
1997
3427
  }
1998
- function arrangementBlockMode(block) {
1999
- const meaning = getBlockDefinition(block.blockKind)?.manifest.variantMeaning;
2000
- return meaning?.kind === "mode" ? readStoredMode({
2001
- keys: [],
2002
- defaultKey: null,
2003
- variantMeaning: meaning
2004
- }, { variant: block.layoutChoice.effectiveValue }) : null;
3428
+ /** The person closed the open group's view: back to the block's own, with focus owed to that group's row. */
3429
+ function closeGroupView(openView) {
3430
+ return openView.kind === "group" ? {
3431
+ kind: "block",
3432
+ closedGroupId: openView.groupId
3433
+ } : { kind: "block" };
2005
3434
  }
2006
- function arrangementVisibilityValues(block) {
2007
- if (!block) return null;
2008
- const resolved = arrangementLookResolution(block);
2009
- if (!resolved || resolved.kind === "none" || resolved.kind === "recipe") return null;
2010
- const meaning = getBlockDefinition(block.blockKind)?.manifest.variantMeaning;
2011
- const arrangementField = meaning?.kind === "mode" ? meaning.arrangementField : "variant";
2012
- const arrangement = resolved.look.structure.byMode[arrangementBlockMode(block) ?? "default"];
2013
- return arrangement ? {
2014
- lookId: resolved.look.id,
2015
- arrangementField,
2016
- arrangement,
2017
- mediaLook: editorMediaLook(block, resolved.look, resolved.skin)
2018
- } : null;
3435
+ /**
3436
+ * The view a field's destination is in, for a host asked to focus that field:
3437
+ * a group's own view for a field in a group, the block's own view for its
3438
+ * content, plain settings, styles and Look. A field the form doesn't offer
3439
+ * leaves the open view as it is. Going to the block's view this way isn't
3440
+ * closing a group, so no row is owed focus.
3441
+ */
3442
+ function openViewForDestination(destination, current) {
3443
+ switch (destination.kind) {
3444
+ case "group": return {
3445
+ kind: "group",
3446
+ groupId: destination.groupId
3447
+ };
3448
+ case "content":
3449
+ case "look": return { kind: "block" };
3450
+ case "unavailable": return current;
3451
+ default: return assertNever(destination);
3452
+ }
2019
3453
  }
2020
- /** Keep the style's knob restrictions with the Look until live field values are available. */
2021
- function editorMediaLook(block, look, skin) {
2022
- const offer = block.arrangementLookSelection?.style.offers.find((entry) => entry.id === look.id);
3454
+ /** Whether two states show the same view, however each was reached. */
3455
+ function sameOpenView(left, right) {
3456
+ return left.kind === "group" ? right.kind === "group" && right.groupId === left.groupId : right.kind === "block";
3457
+ }
3458
+ function prepareForContext(manifest, context) {
3459
+ return prepareBlockEditorManifest({
3460
+ manifest,
3461
+ blockKind: context.blockKind,
3462
+ theme: context.theme,
3463
+ colourFieldOptions: context.colourFieldOptions,
3464
+ blockFieldOptions: context.sdk.blockFieldOptions,
3465
+ blockFieldExtensions: context.sdk.blockFieldExtensions,
3466
+ rawStyleFields: context.rawStyleFields,
3467
+ notShownFieldIds: lookNotShownFieldIds(context.pageDesignBlock),
3468
+ hostCommands: context.hostCommands
3469
+ });
3470
+ }
3471
+ function sectionPhotoFor(manifest, values, context) {
3472
+ const declared = manifest.sectionPhoto;
3473
+ if (!declared) return {
3474
+ offered: false,
3475
+ copy: null
3476
+ };
3477
+ if (context.rawStyleFields === "show") return {
3478
+ offered: true,
3479
+ copy: null
3480
+ };
3481
+ if (!context.pageDesignBlock) return {
3482
+ offered: false,
3483
+ copy: null
3484
+ };
3485
+ const decision = decideSectionPhoto({
3486
+ block: context.pageDesignBlock,
3487
+ sectionPhoto: declared,
3488
+ draftPhoto: sectionPhotoPresence(values)
3489
+ });
2023
3490
  return {
2024
- look,
2025
- skin,
2026
- removeKnobs: offer?.removeKnobs ?? [],
2027
- addKnobs: offer?.addKnobs ?? [],
2028
- knobValues: offer?.knobValues ?? {}
3491
+ offered: sectionPhotoFieldShown(decision),
3492
+ copy: decision.kind === "arrangement" ? { hint: sectionPhotoFieldHint(decision) } : null
2029
3493
  };
2030
3494
  }
2031
- /** Legacy Look knobs keep their ordinary manifest fields in Look, without a second widget inventory. */
2032
- function blockLookOwnedFieldPaths(block) {
2033
- if (!block || block.arrangementLookSelection) return [];
2034
- return systemCustomizeFacetDefinitionsForBlock(block.blockKind).filter((facet) => systemCustomizeFacetAppliesToLayoutVariant(facet, block.layoutChoice.effectiveValue ?? null)).map((facet) => facet.target.kind === "content-field" ? facet.target.field : "listLayout");
3495
+ /** On an arrangement Look the section photo is called Photo wherever it's placed, with the Look's line under it. */
3496
+ function withSectionPhotoCopy(allocated, photo) {
3497
+ const copy = photo.copy;
3498
+ if (!copy) return allocated;
3499
+ const relabel = (item) => item.path === "_sectionStyles.background.image" ? {
3500
+ ...item,
3501
+ field: {
3502
+ ...item.field,
3503
+ label: sectionPhotoFieldLabel,
3504
+ ...copy.hint ? { description: copy.hint } : {}
3505
+ }
3506
+ } : item;
3507
+ return {
3508
+ ...allocated,
3509
+ sections: allocated.sections.map((entry) => ({
3510
+ ...entry,
3511
+ fields: entry.fields.map(relabel)
3512
+ }))
3513
+ };
3514
+ }
3515
+ /**
3516
+ * The draft with the Look's effective arrangement over it: what the nested
3517
+ * widgets read for visibility. Placing top-level fields also falls back to
3518
+ * each field's default.
3519
+ */
3520
+ function shownValueReader(values, visibilityValues, siteFacts, block) {
3521
+ return withVisibilityValues({
3522
+ getValue: (path) => getAtPath(values, path),
3523
+ siteFacts,
3524
+ block
3525
+ }, visibilityOverrides(visibilityValues));
3526
+ }
3527
+ /**
3528
+ * Whether a Look shapes the block, and the knob values it draws with, for the
3529
+ * conditions that turn on them. With the block's page design it's whether a
3530
+ * Look resolves for the block, as the page renders it, and its knobs come
3531
+ * from the resolver the renderer uses, over the draft. Without one, a style
3532
+ * that offers no Looks still settles it; otherwise (a block not yet on a
3533
+ * page, a template) it's unknown, and such a condition leaves its field
3534
+ * showing.
3535
+ */
3536
+ function blockLookFact(context, visibilityValues, values) {
3537
+ if (context.pageDesignBlock) {
3538
+ if (!visibilityValues) return {
3539
+ kind: "Loaded",
3540
+ value: { state: "none" }
3541
+ };
3542
+ return {
3543
+ kind: "Loaded",
3544
+ value: {
3545
+ state: "applies",
3546
+ knobs: visibilityValues.mediaLook ? shownKnobValues(context.blockKind, resolveArrangementKnobs({
3547
+ blockKind: context.blockKind,
3548
+ look: visibilityValues.mediaLook,
3549
+ content: values
3550
+ }).knobs) : {}
3551
+ }
3552
+ };
3553
+ }
3554
+ const siteStyleId = context.theme?.siteStyleId;
3555
+ const style = siteStyleId ? getCuratedSiteStyle(asSiteStyleId(siteStyleId)) : void 0;
3556
+ return style && style.looks.kind !== "offers" ? {
3557
+ kind: "Loaded",
3558
+ value: { state: "none" }
3559
+ } : { kind: "Unavailable" };
3560
+ }
3561
+ function visibilityOverrides(visibilityValues) {
3562
+ return visibilityValues ? {
3563
+ blockLook: visibilityValues.lookId,
3564
+ [visibilityValues.arrangementField]: visibilityValues.arrangement
3565
+ } : {};
3566
+ }
3567
+ function lookSourceOf(manifest, sections) {
3568
+ if (!manifest.lookField) return { kind: "built-in" };
3569
+ return {
3570
+ kind: "sdk",
3571
+ item: (sections.find((entry) => entry.section === "look")?.fields ?? []).find((item) => item.path === manifest.lookField) ?? null
3572
+ };
3573
+ }
3574
+ /** Whether the block's Look, or its arrangement, has taken any of the block's fields out of the form. */
3575
+ function lookOwnsFields(block) {
3576
+ return arrangementOwnedFieldIds(block).length + blockLookOwnedFieldPaths(block).length > 0;
3577
+ }
3578
+ /** Destinations come from the placement before a Look edited elsewhere takes its fields, so they don't fall to a parent. */
3579
+ function destinationWith(placed, fieldPath, lookInForm, nested) {
3580
+ const destination = destinationInLayout(placed, fieldPath, nested);
3581
+ return destination.kind === "look" && !lookInForm ? { kind: "unavailable" } : destination;
3582
+ }
3583
+ //#endregion
3584
+ //#region ../block-form/src/editing/chosenFields.ts
3585
+ /**
3586
+ * The fields a block's summaries name the chosen item of, so an editor knows
3587
+ * which names to look up before it derives the plan. Empty for a block whose
3588
+ * lines name nothing.
3589
+ */
3590
+ function chosenSummaryFields(manifest) {
3591
+ const paths = manifest.editing ? editingGroups(manifest.editing).flatMap((group) => group.summary.parts.flatMap(chosenPath)) : [];
3592
+ if (paths.length === 0) return [];
3593
+ return resolvePromotedFields(createManifestFormAdapter(manifest).fields, [...paths], () => void 0).map(({ path, field }) => ({
3594
+ path,
3595
+ field
3596
+ }));
3597
+ }
3598
+ function chosenPath(part) {
3599
+ const none = () => [];
3600
+ return matchSummaryPart(part, {
3601
+ on: none,
3602
+ options: none,
3603
+ text: none,
3604
+ set: none,
3605
+ count: none,
3606
+ chosen: ({ field }) => [field]
3607
+ });
2035
3608
  }
2036
3609
  //#endregion
2037
3610
  //#region ../block-form/src/sdk-config/SdkConfigContext.tsx
@@ -2302,7 +3875,7 @@ function createStoreBackend(options) {
2302
3875
  setFocus: (path) => {
2303
3876
  if (scope !== "blocks") return;
2304
3877
  getStoreState().requestFocus?.({
2305
- kind: "main-field",
3878
+ kind: "field",
2306
3879
  blockId: getBlockId(),
2307
3880
  fieldPath: path
2308
3881
  });
@@ -2370,250 +3943,316 @@ function createStoreBackend(options) {
2370
3943
  }), backend.subscribe, (value) => value));
2371
3944
  }
2372
3945
  //#endregion
2373
- //#region ../preview-next/src/client/blocks/arrangementControlsModel.ts
3946
+ //#region ../block-form/src/context/DisplayLabelResolverContext.tsx
3947
+ const DisplayLabelResolverContext = createContext({});
2374
3948
  /**
2375
- * Decides the arrangement-Look controls for one block from the editor read
2376
- * model and the content the editor holds. Null means the block's style uses
2377
- * the legacy catalogue, so the legacy controls apply unchanged.
3949
+ * Access the display label resolver map.
3950
+ * Returns an empty map when no provider is present (resolvers are optional).
2378
3951
  */
2379
- function arrangementBlockControlsFor(input) {
2380
- const selection = input.block.arrangementLookSelection;
2381
- if (!selection) return null;
2382
- const mode = arrangementBlockMode(input.block);
2383
- const pin = pinnedLookId(input.block);
2384
- const offered = offeredLooksForMode(selection, mode);
2385
- const resolved = resolveEditorArrangementLook(selection, mode, pin);
2386
- const effective = resolved.kind === "none" || resolved.kind === "recipe" ? null : resolved.look;
2387
- const knobState = effective ? resolveArrangementKnobs({
2388
- blockKind: input.block.blockKind,
2389
- look: compiledKnobLook(selection.style.offers, effective),
2390
- content: input.content
2391
- }) : null;
2392
- return {
2393
- look: lookPosition(resolved, input.block),
2394
- tiles: lookTilesFor({
2395
- looks: offered,
2396
- defaultLookId: resolvedLookId(resolveEditorArrangementLook(selection, mode, null)),
2397
- shownLookId: effective?.id ?? null
2398
- }),
2399
- mode: modeSwitch(input.block, selection.available, mode),
2400
- knobs: knobState ? knobControls(input.block.blockKind, knobState.exposure, knobState.knobs, input.content, effective?.structure.knobDescriptions) : [],
2401
- headlineHint: knobState ? headlineHint(knobState.knobs, knobState.length) : null
2402
- };
3952
+ function useDisplayLabelResolvers() {
3953
+ return useContext(DisplayLabelResolverContext);
2403
3954
  }
2404
- /** The name of the Look a block shows, for the page outline. Null on a legacy style. */
2405
- function arrangementLookNameFor(block) {
2406
- const selection = block.arrangementLookSelection;
2407
- if (!selection) return null;
2408
- return lookPosition(resolveEditorArrangementLook(selection, arrangementBlockMode(block), pinnedLookId(block)), block)?.lookName ?? null;
3955
+ //#endregion
3956
+ //#region ../editor-blocks/src/block-editor/ColourFieldOptionsProvider.tsx
3957
+ const ColourFieldOptionsContext = createContext(void 0);
3958
+ function useColourFieldOptions() {
3959
+ return useContext(ColourFieldOptionsContext);
3960
+ }
3961
+ //#endregion
3962
+ //#region ../editor-blocks/src/block-editor/useChosenLabels.ts
3963
+ const NO_LABELS = {};
3964
+ function labelKey(path, value) {
3965
+ return `${path}:${JSON.stringify(value) ?? ""}`;
2409
3966
  }
2410
- /** The Look a resolution renders; unpinned, that's the style's own pick. */
2411
- function resolvedLookId(resolved) {
2412
- return resolved.kind === "none" || resolved.kind === "recipe" ? null : resolved.look.id;
3967
+ function hasChoice(value) {
3968
+ return value !== null && value !== void 0 && value !== "" && !(Array.isArray(value) && value.length === 0);
2413
3969
  }
2414
- function pinnedLookId(block) {
2415
- return block.look.kind === "user-pinned" ? block.look.value : null;
3970
+ function siblingPath(path, fieldId) {
3971
+ const parent = path.split(".").slice(0, -1).join(".");
3972
+ return parent ? `${parent}.${fieldId}` : fieldId;
2416
3973
  }
2417
- /** Offer order, as the resolver uses it, for the Looks that support the mode. */
2418
- function offeredLooksForMode(selection, mode) {
2419
- return selection.style.offers.flatMap((offer) => {
2420
- const look = selection.available.find((candidate) => candidate.id === offer.id);
2421
- return look && lookModes(look).includes(mode) ? [look] : [];
3974
+ /**
3975
+ * The names of what a block's picker fields have chosen, for the editing
3976
+ * plan's summary lines ("with Anna"). They come from the editor's existing
3977
+ * display-label resolvers, the ones that name a repeater's rows. A name that
3978
+ * hasn't loaded, or an editor with no resolver for the field, gives null and
3979
+ * the line says the block's own phrase. Null for a block whose lines name
3980
+ * nothing, so its plan isn't rederived when labels load elsewhere.
3981
+ */
3982
+ function useChosenLabels(manifest, values) {
3983
+ const resolvers = useDisplayLabelResolvers();
3984
+ const chosen = useMemo(() => manifest ? chosenSummaryFields(manifest) : [], [manifest]);
3985
+ const [labels, setLabels] = useState(NO_LABELS);
3986
+ const wantedKey = chosen.map(({ path }) => labelKey(path, getAtPath(values, path))).join("|");
3987
+ const latestValues = useRef(values);
3988
+ useEffect(() => {
3989
+ latestValues.current = values;
2422
3990
  });
3991
+ useEffect(() => {
3992
+ const request = { cancelled: false };
3993
+ const current = latestValues.current;
3994
+ const lookUp = ({ path, field }) => {
3995
+ const value = getAtPath(current, path);
3996
+ const resolve = resolvers[field.type];
3997
+ if (!resolve || !hasChoice(value)) return;
3998
+ resolve(value, field, { getSiblingValue: (fieldId) => getAtPath(current, siblingPath(path, fieldId)) }).then((label) => {
3999
+ if (label && !request.cancelled) setLabels((known) => ({
4000
+ ...known,
4001
+ [labelKey(path, value)]: label
4002
+ }));
4003
+ }).catch(() => void 0);
4004
+ };
4005
+ chosen.forEach(lookUp);
4006
+ return () => {
4007
+ request.cancelled = true;
4008
+ };
4009
+ }, [
4010
+ chosen,
4011
+ resolvers,
4012
+ wantedKey
4013
+ ]);
4014
+ return useMemo(() => chosen.length === 0 ? null : (path, value) => labels[labelKey(path, value)] ?? null, [chosen, labels]);
2423
4015
  }
2424
- function compiledKnobLook(offers, look) {
2425
- const offer = offers.find((candidate) => candidate.id === look.id);
4016
+ //#endregion
4017
+ //#region ../editor-blocks/src/block-editor/blockObservations.ts
4018
+ function createBlockLoaderReader(siteId, client) {
2426
4019
  return {
2427
- look,
2428
- addKnobs: offer?.addKnobs ?? [],
2429
- removeKnobs: offer?.removeKnobs ?? [],
2430
- knobValues: offer?.knobValues ?? {}
4020
+ siteId,
4021
+ read: async (request) => {
4022
+ const result = unwrapResponse(await client()({
4023
+ endpoint: "batchBlockLoaders",
4024
+ params: {
4025
+ siteId,
4026
+ stage: "preview"
4027
+ },
4028
+ body: { requests: [request] }
4029
+ })).results[request.id];
4030
+ if (!result?.ok) throw new Error(`Block loader ${request.endpoint} failed`);
4031
+ return result.data;
4032
+ }
2431
4033
  };
2432
4034
  }
2433
- function lookPosition(resolved, block) {
2434
- switch (resolved.kind) {
2435
- case "offered": return resolved.source === "auto" ? {
2436
- kind: "automatic",
2437
- lookName: resolved.look.label
2438
- } : {
2439
- kind: "pinned",
2440
- lookName: resolved.look.label
4035
+ const observationLoaders = { "block.class-prices": {
4036
+ field: "seriesId",
4037
+ load: async (seriesId, reader) => typeof seriesId === "string" && seriesId !== "" ? { "classPrices.items": classPriceItemKinds(await reader.read({
4038
+ id: "observation",
4039
+ endpoint: "getPublicEventDetails",
4040
+ params: {
4041
+ seriesId,
4042
+ limit: "1"
4043
+ }
4044
+ })) } : {}
4045
+ } };
4046
+ /**
4047
+ * What the block's own selection resolves to, for its conditions. Loaded
4048
+ * again whenever the observed field changes; until it has loaded for the
4049
+ * current value, or if the read fails, or outside an editor, every
4050
+ * observation is unknown and the fields it guards stay in the form.
4051
+ */
4052
+ function useBlockObservations(reader, blockKind, values) {
4053
+ const loader = observationLoaders[blockKind];
4054
+ const value = loader ? getAtPath(values, loader.field) : void 0;
4055
+ const key = loader && reader ? `${reader.siteId}:${blockKind}:${JSON.stringify(value) ?? ""}` : null;
4056
+ const [loaded, setLoaded] = useState(null);
4057
+ const latestValue = useRef(value);
4058
+ useEffect(() => {
4059
+ latestValue.current = value;
4060
+ });
4061
+ useEffect(() => {
4062
+ if (!loader || !reader || key === null) return;
4063
+ const request = { cancelled: false };
4064
+ loader.load(latestValue.current, reader).then((found) => {
4065
+ if (!request.cancelled) setLoaded({
4066
+ key,
4067
+ observations: {
4068
+ ...unknownBlockObservations,
4069
+ ...found
4070
+ }
4071
+ });
4072
+ }).catch(() => void 0);
4073
+ return () => {
4074
+ request.cancelled = true;
2441
4075
  };
2442
- case "style-fallback": return {
2443
- kind: "style-fallback",
2444
- requestedName: lookName(resolved.requested),
2445
- lookName: resolved.look.label
4076
+ }, [
4077
+ key,
4078
+ loader,
4079
+ reader
4080
+ ]);
4081
+ return loaded?.key === key ? loaded.observations : unknownBlockObservations;
4082
+ }
4083
+ //#endregion
4084
+ //#region ../editor-blocks/src/block-editor/EditorSiteFactsProvider.tsx
4085
+ const EditorSiteFactsContext = createContext(unavailableSiteFacts);
4086
+ const EditorBlockLoaderContext = createContext(null);
4087
+ /**
4088
+ * What the site has (passes on sale, say), read once for the editor so every
4089
+ * block form's conditions use the same facts. Until they arrive, or if the
4090
+ * read fails, every fact is unavailable, and a field a fact condition guards
4091
+ * stays in the form.
4092
+ *
4093
+ * It also lends block forms the site's public block loaders, so a block's
4094
+ * observations (the price items for its chosen class) load through the same
4095
+ * client. Its client must reach both, so a host that mounts it can't leave
4096
+ * observations out.
4097
+ */
4098
+ function EditorSiteFactsProvider({ siteId, apiClient, children }) {
4099
+ const [loaded, setLoaded] = useState(null);
4100
+ const latestClient = useRef(apiClient);
4101
+ useEffect(() => {
4102
+ latestClient.current = apiClient;
4103
+ });
4104
+ useEffect(() => {
4105
+ const request = { cancelled: false };
4106
+ loadEditorSiteFacts({
4107
+ apiClient: latestClient.current,
4108
+ siteId
4109
+ }).then((facts) => {
4110
+ if (!request.cancelled) setLoaded({
4111
+ siteId,
4112
+ facts
4113
+ });
4114
+ }).catch(() => void 0);
4115
+ return () => {
4116
+ request.cancelled = true;
2446
4117
  };
2447
- case "mode-mismatch": return {
2448
- kind: "mode-mismatch",
2449
- requestedName: lookName(resolved.requested),
2450
- requestedModeLabel: requestedModeLabel(block, resolved.requested),
2451
- lookName: resolved.look.label
4118
+ }, [siteId, useTabReturns()]);
4119
+ const facts = loaded?.siteId === siteId ? loaded.facts : unavailableSiteFacts;
4120
+ const reader = useMemo(() => createBlockLoaderReader(siteId, () => latestClient.current), [siteId]);
4121
+ return /* @__PURE__ */ jsx(EditorSiteFactsContext.Provider, {
4122
+ value: facts,
4123
+ children: /* @__PURE__ */ jsx(EditorBlockLoaderContext.Provider, {
4124
+ value: reader,
4125
+ children
4126
+ })
4127
+ });
4128
+ }
4129
+ /** Counts the times the person comes back to this tab. */
4130
+ function useTabReturns() {
4131
+ const [returns, setReturns] = useState(0);
4132
+ useEffect(() => {
4133
+ const onVisible = () => {
4134
+ if (document.visibilityState === "visible") setReturns((count) => count + 1);
2452
4135
  };
2453
- case "recipe":
2454
- case "none": return null;
2455
- }
4136
+ document.addEventListener("visibilitychange", onVisible);
4137
+ return () => document.removeEventListener("visibilitychange", onVisible);
4138
+ }, []);
4139
+ return returns;
2456
4140
  }
2457
- /** The requested Look may be one this style doesn't offer, so read the shared catalogue. */
2458
- function lookName(id) {
2459
- return lookDefinitionForId(id)?.label ?? "your chosen Look";
2460
- }
2461
- function requestedModeLabel(block, id) {
2462
- const look = lookDefinitionForId(id);
2463
- const mode = look ? lookModes(look).find((candidate) => candidate !== null) : void 0;
2464
- return mode ? modeLabel(block, mode) : "another";
2465
- }
2466
- function modeSwitch(block, available, current) {
2467
- if (current === null) return null;
2468
- const modesWithLooks = available.flatMap((look) => lookModes(look)).filter((mode) => mode !== null);
2469
- const modes = [...new Set(modesWithLooks)];
2470
- return modes.length > 1 ? {
2471
- current,
2472
- options: modes.map((mode) => ({
2473
- mode,
2474
- label: modeLabel(block, mode)
2475
- }))
2476
- } : null;
4141
+ function useEditorSiteFacts() {
4142
+ return useContext(EditorSiteFactsContext);
2477
4143
  }
2478
- function modeLabel(block, mode) {
2479
- const meaning = getBlockDefinition(block.blockKind)?.manifest.variantMeaning;
2480
- return (meaning?.kind === "mode" ? meaning.modeLabels?.[mode] : void 0) ?? block.availableLayouts.find((layout) => layout.id === mode)?.label ?? mode.charAt(0).toUpperCase() + mode.slice(1);
2481
- }
2482
- function knobControls(blockKind, exposure, knobs, content, descriptions = {}) {
2483
- return exposure.flatMap((entry) => {
2484
- const knob = knobs[entry.definition.id];
2485
- const facet = shownKnobFacet(blockKind, entry, knob);
2486
- if (!facet || !knob || knob.kind === "kept") return [];
2487
- const control = knobControl(entry, knob, facet, systemCustomizeFacetStoredValue(facet, { ...content }));
2488
- const description = descriptions[entry.definition.id] ?? facet.description;
2489
- return [control.kind === "choice" && description !== void 0 ? {
2490
- ...control,
2491
- description
2492
- } : control];
2493
- });
2494
- }
2495
- /** Only knobs the current Look exposes and doesn't force get a control. */
2496
- function shownKnobFacet(blockKind, entry, knob) {
2497
- const id = entry.definition.id;
2498
- if (entry.definition.textMaxLength === void 0 && arrangementKnobChoices(entry).length <= 1 || !entry.exposed || entry.forced !== void 0 || !knob || knob.kind === "kept" || !isSystemCustomizeFacetId(id)) return null;
2499
- return systemCustomizeFacetDefinitionForBlock(blockKind, id);
2500
- }
2501
- function knobControl(entry, knob, facet, stored) {
2502
- if (entry.definition.textMaxLength !== void 0) return {
2503
- kind: "text",
2504
- facetId: facet.id,
2505
- label: facet.label,
2506
- value: knob.value,
2507
- stored,
2508
- maxLength: entry.definition.textMaxLength
2509
- };
2510
- const choices = arrangementKnobChoices(entry);
2511
- const preference = knob.kind === "clamped" && knob.reason === "length" && choices.includes(knob.stored) ? knob.stored : knob.value;
2512
- const labelOf = (value) => facet.values.find((option) => option.value === value)?.label ?? value;
2513
- return {
2514
- kind: "choice",
2515
- presentation: knobPresentation(facet, choices),
2516
- facetId: facet.id,
2517
- label: facet.label,
2518
- value: preference,
2519
- stored,
2520
- notOffered: knob.kind === "clamped" && knob.reason !== "length" ? {
2521
- by: knob.reason,
2522
- choice: labelOf(knob.stored),
2523
- shows: labelOf(knob.value)
2524
- } : null,
2525
- options: choices.map((value) => ({
2526
- value,
2527
- label: labelOf(value)
2528
- }))
2529
- };
4144
+ /** The site's public block loaders, or null outside an editor, where every observation stays unknown. */
4145
+ function useEditorBlockLoaderReader() {
4146
+ return useContext(EditorBlockLoaderContext);
2530
4147
  }
2531
- /** On/off knobs store `'true'` and `'false'`; the switch is on for `'true'`. */
2532
- function knobPresentation(facet, choices) {
2533
- if (facet.target.kind === "content-field" && facet.target.boolean === true && choices.length === 2 && choices.includes("true") && choices.includes("false")) return "switch";
2534
- return choices.length <= 3 ? "segments" : "menu";
4148
+ async function loadEditorSiteFacts(input) {
4149
+ return unwrapResponse(await input.apiClient({
4150
+ endpoint: "getEditorSiteFacts",
4151
+ params: { siteId: input.siteId }
4152
+ }));
2535
4153
  }
2536
- function headlineHint(knobs, length) {
2537
- const headline = knobs.titleSize;
2538
- return headline?.kind === "clamped" && headline.reason === "length" && length !== null && length !== "short" ? { length } : null;
4154
+ //#endregion
4155
+ //#region ../editor-blocks/src/block-editor/useBlockEditingPlan.ts
4156
+ function useBlockEditingPlan(input) {
4157
+ const context = useBlockEditingContext(input);
4158
+ const { manifest, values } = input;
4159
+ return useMemo(() => manifest ? deriveBlockEditingPlan({
4160
+ manifest,
4161
+ values,
4162
+ context
4163
+ }) : null, [
4164
+ context,
4165
+ manifest,
4166
+ values
4167
+ ]);
2539
4168
  }
2540
4169
  /**
2541
- * Section backgrounds for an arrangement-Look style: the style's own surfaces
2542
- * by plain name, plus the page rhythm. A background is never a Look. A Look
2543
- * that paints its photo behind the text has no Background row, because the
2544
- * photo is the background. Any other Look offers the surfaces until the
2545
- * section has a photo, which replaces the colour choice.
4170
+ * The context every plan in this editor is derived with, from the editor's
4171
+ * providers. Setup before a block is added derives its questions from the
4172
+ * same providers (`setupEditingContext`), so they follow the same conditions
4173
+ * as the block's form.
2546
4174
  */
2547
- function arrangementBackgroundControlFor(input) {
2548
- const selection = input.block.arrangementLookSelection;
2549
- if (!selection || input.block.backgroundSupport.kind === "unsupported") return null;
2550
- const photo = decideSectionPhoto({
2551
- block: input.block,
2552
- promotedFieldPaths: getBlockDefinition(input.block.blockKind)?.manifest.promotedFields,
2553
- draftPhoto: sectionPhotoPresence(input.content)
2554
- });
2555
- if (photo.kind === "arrangement" && photo.use === "behind") return null;
2556
- if (photo.kind === "arrangement" && photo.photo === "present") return {
2557
- kind: "held-by-photo",
2558
- photo: "section-photo"
2559
- };
2560
- const options = arrangementSurfaceOptions(selection.style);
2561
- const stored = storedSurfaceChoice(parseCanonicalSectionBackground({ ...input.content }), options);
2562
- return stored.kind === "held-by-photo" ? stored : {
2563
- kind: "surfaces",
2564
- selected: stored.selected,
2565
- options,
2566
- rhythm: options.find((option) => option.token === input.decidedBackground) ?? null
2567
- };
2568
- }
2569
- function arrangementSurfaceOptions(style) {
2570
- return Object.entries(style.surfaces).flatMap(([name, spec]) => {
2571
- const token = spec.kind === "token" && !spec.roleOnly ? parseBackgroundColorToken(spec.token) : null;
2572
- return token ? [{
2573
- name,
2574
- label: arrangementSurfaceLabel(name),
2575
- token
2576
- }] : [];
2577
- });
4175
+ function useBlockEditingContext(input) {
4176
+ const environment = useEditorPlanEnvironment();
4177
+ const { manifest, blockKind, values, theme, hideThemeV2RawStyleFields, pageDesignBlock, lookFields, hostCommands } = input;
4178
+ const chosenLabel = useChosenLabels(manifest, values);
4179
+ const observations = useBlockObservations(useEditorBlockLoaderReader(), blockKind, values);
4180
+ return useMemo(() => editingContextFor(environment, {
4181
+ blockKind,
4182
+ theme,
4183
+ hideThemeV2RawStyleFields,
4184
+ pageDesignBlock,
4185
+ lookFields,
4186
+ hostCommands,
4187
+ chosenLabel,
4188
+ observations
4189
+ }), [
4190
+ environment,
4191
+ blockKind,
4192
+ theme,
4193
+ hideThemeV2RawStyleFields,
4194
+ pageDesignBlock,
4195
+ lookFields,
4196
+ hostCommands,
4197
+ chosenLabel,
4198
+ observations
4199
+ ]);
2578
4200
  }
2579
- /** Which surface the stored background shows as chosen, once the section has no photo of its own. */
2580
- function storedSurfaceChoice(stored, options) {
2581
- switch (stored.kind) {
2582
- case "none": return {
2583
- kind: "surface",
2584
- selected: null
2585
- };
2586
- case "block-authored":
2587
- if (stored.background.type === "image" || stored.background.type === "video") return {
2588
- kind: "held-by-photo",
2589
- photo: "older-style-photo"
2590
- };
2591
- return {
2592
- kind: "surface",
2593
- selected: stored.background.type === "color" ? surfaceForToken(options, stored.background.color) : null
2594
- };
2595
- case "page-design-override": {
2596
- const override = stored.parsed.kind === "supported" ? stored.parsed.override : null;
2597
- return {
2598
- kind: "surface",
2599
- selected: override?.kind === "color" ? surfaceForToken(options, override.token) : null
2600
- };
2601
- }
2602
- }
4201
+ function useEditorPlanEnvironment() {
4202
+ const { blockFieldOptions, blockFieldExtensions, isSdkSite, sectionOptions } = useSdkConfig();
4203
+ const colourFieldOptions = useColourFieldOptions();
4204
+ const siteFacts = useEditorSiteFacts();
4205
+ const pageTemplate = useEditorPageTemplate();
4206
+ return useMemo(() => ({
4207
+ sdk: {
4208
+ blockFieldOptions,
4209
+ blockFieldExtensions,
4210
+ isSdkSite,
4211
+ sectionOptions
4212
+ },
4213
+ colourFieldOptions,
4214
+ siteFacts,
4215
+ pageTemplate
4216
+ }), [
4217
+ blockFieldExtensions,
4218
+ blockFieldOptions,
4219
+ colourFieldOptions,
4220
+ isSdkSite,
4221
+ sectionOptions,
4222
+ siteFacts,
4223
+ pageTemplate
4224
+ ]);
2603
4225
  }
2604
- const arrangementSurfaceLabels = {
2605
- base: "Page ground",
2606
- band: "Quiet band",
2607
- brand: "Brand colour",
2608
- deep: "Deepest tone",
2609
- inverse: "Opposite ground",
2610
- pop: "Pop colour"
2611
- };
2612
- function arrangementSurfaceLabel(name) {
2613
- return arrangementSurfaceLabels[name] ?? name.charAt(0).toUpperCase() + name.slice(1).replace(/[-_]+/g, " ");
4226
+ function editingContextFor(environment, input) {
4227
+ return {
4228
+ ...environment,
4229
+ blockKind: input.blockKind,
4230
+ theme: input.theme,
4231
+ rawStyleFields: input.hideThemeV2RawStyleFields ? "hide-theme-v2" : "show",
4232
+ pageDesignBlock: input.pageDesignBlock,
4233
+ lookFields: input.lookFields,
4234
+ hostCommands: input.hostCommands,
4235
+ chosenLabel: input.chosenLabel,
4236
+ observations: input.observations
4237
+ };
2614
4238
  }
2615
- function surfaceForToken(options, token) {
2616
- return options.find((option) => option.token === token)?.name ?? null;
4239
+ /**
4240
+ * The context setup questions are decided in: the block isn't on the page
4241
+ * yet, so it has no page design of its own, and the setup form is the only
4242
+ * host. Picking a block and the setup view both use this, so they agree on
4243
+ * whether there's anything to ask.
4244
+ */
4245
+ function setupEditingContext(environment, input) {
4246
+ return editingContextFor(environment, {
4247
+ blockKind: input.blockKind,
4248
+ theme: input.theme,
4249
+ hideThemeV2RawStyleFields: false,
4250
+ pageDesignBlock: null,
4251
+ lookFields: "in-form",
4252
+ hostCommands: FORM_ONLY_HOST,
4253
+ chosenLabel: null,
4254
+ observations: unknownBlockObservations
4255
+ });
2617
4256
  }
2618
4257
  //#endregion
2619
4258
  //#region ../preview-next/src/client/blocks/blockNeedsSetup.ts
@@ -2656,89 +4295,26 @@ function needsSetupAsk(needs) {
2656
4295
  return READINESS_REASON_COPY[needs.reason].split(" Until ")[0] ?? READINESS_REASON_COPY[needs.reason];
2657
4296
  }
2658
4297
  //#endregion
2659
- //#region ../preview-next/src/client/blocks/sectionPhotoField.ts
2660
- /**
2661
- * Arrangement Looks call the section photo's field Photo. Looks that show it
2662
- * say what the section shows until one is added; a Look that doesn't show it
2663
- * only lists the field while a photo is stored, so the owner can remove it.
2664
- * Older recipe Looks keep the field as it is.
2665
- */
2666
- function sectionPhotoFieldCopy(photo) {
2667
- if (photo.kind !== "arrangement") return null;
2668
- if (photo.use === "none") return photo.photo === "present" ? {
2669
- label: "Photo",
2670
- hint: "This Look doesn’t show the photo. Remove it to choose a background colour."
2671
- } : null;
2672
- if (photo.photo === "present") return {
2673
- label: "Photo",
2674
- hint: null
2675
- };
2676
- return {
2677
- label: "Photo",
2678
- hint: photo.withoutPhoto === "shows-another-look" ? "Add a photo. Until you do, this section shows the title on its own." : "Add a photo. This Look is built around one, so it can look a little bare without it."
2679
- };
2680
- }
2681
- /** Applies the Photo copy to the promoted photo field in the Look section. */
2682
- function withSectionPhotoField(plan, photo) {
2683
- const copy = sectionPhotoFieldCopy(photo);
2684
- if (copy === null) return plan;
2685
- const look = plan.sections.look.map((item) => item.path === "_sectionStyles.background.image" ? {
2686
- ...item,
2687
- field: {
2688
- ...item.field,
2689
- label: copy.label,
2690
- description: copy.hint ?? void 0
2691
- }
2692
- } : item);
2693
- return {
2694
- ...plan,
2695
- sections: {
2696
- ...plan.sections,
2697
- look
2698
- }
2699
- };
2700
- }
2701
- //#endregion
2702
4298
  //#region ../preview-next/src/client/blocks/useBlockCustomizeControls.ts
4299
+ const NO_LOOK = { kind: "built-in" };
2703
4300
  function useBlockCustomizeControls({ blockId, blockKind, content, uiStore, theme, sdkConfig }) {
2704
- const { blockFieldOptions, blockFieldExtensions, sdkConfig: contextSdkConfig } = useSdkConfig();
4301
+ const { sdkConfig: contextSdkConfig } = useSdkConfig();
2705
4302
  const effectiveSdkConfig = sdkConfig ?? contextSdkConfig;
2706
4303
  const manifest = useMemo(() => resolveBlockManifest(blockKind, effectiveSdkConfig ?? null), [blockKind, effectiveSdkConfig]);
2707
4304
  const { state: pageDesignState } = usePreviewPageDesignEditorState();
2708
4305
  const designBlock = useMemo(() => pageDesignState.kind === "loaded" ? pageDesignState.editorModel.blocks.find((block) => String(block.blockId) === String(blockId)) ?? null : null, [blockId, pageDesignState]);
2709
- const draftPhoto = sectionPhotoPresence(content);
2710
- const preparedManifest = useMemo(() => {
2711
- if (!manifest) return null;
2712
- return prepareBlockEditorManifest({
2713
- manifest,
2714
- blockKind,
2715
- theme,
2716
- blockFieldOptions,
2717
- blockFieldExtensions,
2718
- visibilityPolicy: hideThemeV2RawStyleFields,
2719
- allowedPromotedFieldPaths: designBlock ? resolveVisiblePromotedFieldPathsForEditorBlock({
2720
- block: designBlock,
2721
- promotedFieldPaths: manifest.promotedFields,
2722
- draftPhoto
2723
- }) : void 0
2724
- });
2725
- }, [
2726
- designBlock,
2727
- draftPhoto,
2728
- blockFieldExtensions,
2729
- blockFieldOptions,
2730
- blockKind,
4306
+ const plan = useBlockEditingPlan({
2731
4307
  manifest,
2732
- theme
2733
- ]);
2734
- const ownedFieldIds = useMemo(() => arrangementOwnedFieldIds(designBlock), [designBlock]);
2735
- const visibilityValues = useMemo(() => arrangementVisibilityValues(designBlock), [designBlock]);
2736
- const fields = useMemo(() => {
2737
- if (!preparedManifest) return [];
2738
- return createManifestFormAdapter(preparedManifest.renderManifest).fields.filter((field) => !ownedFieldIds.includes(field.id));
2739
- }, [ownedFieldIds, preparedManifest]);
4308
+ blockKind,
4309
+ values: content,
4310
+ theme,
4311
+ hideThemeV2RawStyleFields: true,
4312
+ pageDesignBlock: designBlock,
4313
+ lookFields: "in-form",
4314
+ hostCommands: FORM_ONLY_HOST
4315
+ });
2740
4316
  const backend = useMemo(() => {
2741
- if (!preparedManifest) return null;
4317
+ if (!manifest) return null;
2742
4318
  return createStoreBackend({
2743
4319
  scope: "blocks",
2744
4320
  store: uiStore,
@@ -2746,36 +4322,20 @@ function useBlockCustomizeControls({ blockId, blockKind, content, uiStore, theme
2746
4322
  });
2747
4323
  }, [
2748
4324
  blockId,
2749
- preparedManifest,
4325
+ manifest,
2750
4326
  uiStore
2751
4327
  ]);
2752
- const getValue = (path) => visibilityValues && path === "blockLook" ? visibilityValues.lookId : visibilityValues && path === visibilityValues.arrangementField ? visibilityValues.arrangement : backend?.getValue(path) ?? content[path] ?? fields.find((field) => field.id === path)?.defaultValue;
2753
- const sectionOptions = preparedManifest ? manifestFieldSectionOptions(preparedManifest.renderManifest, { lookOwnedPaths: blockLookOwnedFieldPaths(designBlock) }) : {};
2754
- const plan = derivePromotedFieldPlan(fields, preparedManifest?.renderManifest.promotedFields, getValue, sectionOptions);
2755
- const sectionPlan = designBlock && manifest ? withSectionPhotoField(plan, decideSectionPhoto({
2756
- block: designBlock,
2757
- promotedFieldPaths: manifest.promotedFields,
2758
- draftPhoto
2759
- })) : plan;
2760
- const renderManifest = preparedManifest?.renderManifest ?? null;
2761
4328
  return {
2762
- manifest: renderManifest,
2763
- fields,
2764
- sectionPlan,
4329
+ plan,
4330
+ lookSource: plan?.lookSource ?? NO_LOOK,
4331
+ manifest,
2765
4332
  backend,
2766
- designBlock,
2767
- lookSource: resolveBlockLookSource(renderManifest, sectionPlan)
4333
+ designBlock
2768
4334
  };
2769
4335
  }
2770
4336
  function resolveBlockManifest(blockKind, sdkConfig) {
2771
4337
  return getBlockManifestFromSdkConfig(blockKind, sdkConfig) ?? getBlockDefinition(blockKind)?.manifest ?? null;
2772
4338
  }
2773
- function resolveBlockLookSource(manifest, plan) {
2774
- return manifest?.lookField ? {
2775
- kind: "sdk",
2776
- item: plan.sections.look.find((item) => item.path === manifest.lookField) ?? null
2777
- } : { kind: "built-in" };
2778
- }
2779
4339
  //#endregion
2780
4340
  //#region ../preview-next/src/client/blocks/useOpenBlockForSetup.ts
2781
4341
  /**
@@ -2789,7 +4349,7 @@ function useOpenBlockForSetup() {
2789
4349
  const openField = (blockId, fieldPath) => {
2790
4350
  open(blockId);
2791
4351
  uiStore.getState().requestFocus({
2792
- kind: "main-field",
4352
+ kind: "field",
2793
4353
  blockId,
2794
4354
  fieldPath: fieldPath.startsWith("content.") ? fieldPath : `content.${fieldPath}`
2795
4355
  });
@@ -2802,4 +4362,4 @@ function useOpenBlockForSetup() {
2802
4362
  };
2803
4363
  }
2804
4364
  //#endregion
2805
- export { Tooltip as A, DropdownMenuRadioItem as B, blockLookOwnedFieldPaths as C, showRawStyleFields as D, prepareBlockEditorManifest as E, DropdownMenu as F, DropdownMenuTrigger as H, DropdownMenuContent as I, DropdownMenuItem as L, TooltipProvider as M, TooltipTrigger as N, getBlockManifestFromSdkConfig as O, Badge as P, DropdownMenuLabel as R, arrangementVisibilityValues as S, hideThemeV2RawStyleFields as T, DropdownMenuSeparator as V, createFieldObservation as _, blockNoticeAction as a, arrangementLookResolution as b, needsSetupAsk as c, arrangementBackgroundControlFor as d, arrangementBlockControlsFor as f, isRecord as g, isObjectRecord as h, NEEDS_SETUP_LABEL as i, TooltipContent as j, mergeBlockDescriptors as k, needsSetupOf as l, createStoreBackend as m, resolveBlockManifest as n, blockNoticeLabel as o, arrangementLookNameFor as p, useBlockCustomizeControls as r, blockNoticeMessage as s, useOpenBlockForSetup as t, useBlockNotice as u, SdkConfigProvider as v, lookNotShownFieldIds as w, arrangementOwnedFieldIds as x, useSdkConfig as y, DropdownMenuRadioGroup as z };
4365
+ export { hasVisibilityConditions as $, arrangementBlockMode as A, getColumns as B, closeGroupView as C, sameOpenView as D, resolveOpenView as E, revealStepKey as F, shouldHideLabel as G, groupFieldsByRow as H, revealStepsAmong as I, resolvePromotedFields as J, shownTab as K, getRepeaterItemFieldGroups as L, layoutManifestForm as M, manifestFieldSectionOptions as N, visibilityOverrides as O, placedFields as P, getWidgetKey as Q, getRepeaterItemFields as R, useSdkConfig as S, openViewForDestination as T, layoutGroupFields as U, getValidColSpan as V, modalGroupFields as W, evaluateVisibility as X, collectVisibleWhenWatchPaths as Y, withVisibilityValues as Z, createStoreBackend as _, DropdownMenuTrigger as _t, blockNoticeAction as a, Tooltip as at, createFieldObservation as b, needsSetupAsk as c, TooltipTrigger as ct, setupEditingContext as d, DropdownMenuContent as dt, isNonEmptyValue as et, useBlockEditingPlan as f, DropdownMenuItem as ft, useDisplayLabelResolvers as g, DropdownMenuSeparator as gt, useEditorSiteFacts as h, DropdownMenuRadioItem as ht, NEEDS_SETUP_LABEL as i, READINESS_REASON_COPY as it, arrangementLookResolution as j, deriveBlockValidationManifest as k, needsSetupOf as l, Badge as lt, EditorSiteFactsProvider as m, DropdownMenuRadioGroup as mt, resolveBlockManifest as n, mergeBlockDescriptors as nt, blockNoticeLabel as o, TooltipContent as ot, useEditorPlanEnvironment as p, DropdownMenuLabel as pt, derivedSettingsSummary as q, useBlockCustomizeControls as r, HIDDEN_REASON_COPY as rt, blockNoticeMessage as s, TooltipProvider as st, useOpenBlockForSetup as t, getBlockManifestFromSdkConfig as tt, useBlockNotice as u, DropdownMenu as ut, isObjectRecord as v, deriveBlockEditingPlan as w, SdkConfigProvider as x, isRecord as y, buildChildPath as z };