@riverbankcms/sdk 0.167.0 → 0.169.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 (235) hide show
  1. package/dist/_dts/{BlocksIslandsHydrator-Dgb-ptph.d.ts → BlocksIslandsHydrator-DpROiz12.d.ts} +1 -1
  2. package/dist/_dts/{Page-Bs3WxFgr.d.ts → Page-DHBBDRC_.d.ts} +7 -6
  3. package/dist/_dts/{SdkPreviewMode-DtUCsaHY.d.ts → SdkPreviewMode-CG7Qib7u.d.ts} +2 -2
  4. package/dist/_dts/{client-CwsI23pj.d.ts → client-MURxFla9.d.ts} +90 -418
  5. package/dist/_dts/{content-types-CAeP_-cV.d.ts → content-types-ClBGjxBV.d.ts} +2 -2
  6. package/dist/_dts/{contracts-BXHCiF-b.d.ts → contracts-CHNvzh0y.d.ts} +6 -4
  7. package/dist/_dts/{footerPageOutline-Bb2gbppW.d.ts → footerPageOutline-DQM934Fm.d.ts} +6 -6
  8. package/dist/_dts/{generatePageMetadata-DaBBDx7M.d.ts → generatePageMetadata-ConZaEqB.d.ts} +2 -2
  9. package/dist/_dts/{index-CS6b1B-c.d.ts → index-BaDqRekr.d.ts} +4 -4
  10. package/dist/_dts/{index-bDln38Hm.d.ts → index-CVB5wgbz.d.ts} +2 -2
  11. package/dist/_dts/{index-D7EbliE3.d.ts → index-CiR_oPYT.d.ts} +3 -3
  12. package/dist/_dts/{index-5_jf52sZ.d.ts → index-CovKPftP.d.ts} +2 -2
  13. package/dist/_dts/{index-C20yUyob.d.ts → index-DCw8LO4M.d.ts} +1 -1
  14. package/dist/_dts/index-DDaX-K2D.d.ts +14 -0
  15. package/dist/_dts/{index-DeHDwMfu.d.ts → index-rfAssXq0.d.ts} +3 -3
  16. package/dist/_dts/{loadContent-CTqcL7CS.d.ts → loadContent-CRLKVVDP.d.ts} +7 -7
  17. package/dist/_dts/previewCompiler-BVVgDSdq.d.ts +1 -0
  18. package/dist/_dts/{index-ChpjHK0U.d.ts → request-DeVetKBr.d.ts} +81273 -46979
  19. package/dist/_dts/{resolveBlockData-C3s9WMPs.d.ts → resolveBlockData-C5KYFeig.d.ts} +5 -5
  20. package/dist/_dts/{resolvePageContent-JPwgRxwh.d.ts → resolvePageContent-D8MZWyNO.d.ts} +2 -2
  21. package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
  22. package/dist/_dts/sdk/src/client/types.d.ts +2 -2
  23. package/dist/_dts/sdk/src/client.d.ts +7 -7
  24. package/dist/_dts/sdk/src/config/index.d.ts +6 -6
  25. package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
  26. package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
  27. package/dist/_dts/sdk/src/data/dataLoaderContext.d.ts +2 -2
  28. package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +1 -1
  29. package/dist/_dts/sdk/src/data/types.d.ts +2 -2
  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 +2 -2
  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/prebuild/index.d.ts +1 -1
  39. package/dist/_dts/sdk/src/preview-next/before-render.d.ts +2 -2
  40. package/dist/_dts/sdk/src/preview-next/client/index.d.ts +2 -2
  41. package/dist/_dts/sdk/src/preview-next/client/runtime.d.ts +1 -1
  42. package/dist/_dts/sdk/src/rendering/client.d.ts +2 -2
  43. package/dist/_dts/sdk/src/rendering/components/pageShared.d.ts +1 -1
  44. package/dist/_dts/sdk/src/rendering/helpers/loadPage.d.ts +1 -1
  45. package/dist/_dts/sdk/src/rendering/helpers/pageRuntimeSupport.d.ts +4 -5
  46. package/dist/_dts/sdk/src/rendering/index.d.ts +6 -6
  47. package/dist/_dts/sdk/src/rendering/islands/client.d.ts +1 -1
  48. package/dist/_dts/sdk/src/rendering/server.d.ts +2 -2
  49. package/dist/_dts/sdk/src/rendering/themeAdmission.d.ts +1 -1
  50. package/dist/_dts/sdk/src/routing/index.d.ts +5 -5
  51. package/dist/_dts/sdk/src/server.d.ts +5 -5
  52. package/dist/_dts/sdk/src/spam-protection/index.d.ts +2 -2
  53. package/dist/_dts/sdk/src/theme/index.d.ts +1 -1
  54. package/dist/_dts/{types-BlaCuPLr.d.ts → types-B4MBlP_B.d.ts} +4 -2
  55. package/dist/_dts/{types-D-WElMCy.d.ts → types-Fj31kIi2.d.ts} +7 -7
  56. package/dist/_dts/{types-CwtTcaQP.d.ts → types-OwqfS8Gn.d.ts} +3 -3
  57. package/dist/_dts/{validation-Y5wD9fGK.d.ts → validation-B1Fa8o_b.d.ts} +4 -4
  58. package/dist/client/{BlocksIslandsHydrator-DFqkx158.mjs → BlocksIslandsHydrator-qq4Vhs7k.mjs} +21 -21
  59. package/dist/client/BookingMailingListNote-y3qWjnOo.mjs +957 -0
  60. package/dist/client/BookingQuestionFields-DjLjd0vc.mjs +359 -0
  61. package/dist/client/{CalendarNavigationChevron-DQwJ7BPx.mjs → CalendarNavigationChevron-VM7C2fdh.mjs} +8 -8
  62. package/dist/client/{CheckboxChoice-CZ-anOqV.mjs → CheckboxChoice-W_uiRgDK.mjs} +1 -1
  63. package/dist/client/{DemoBookingPortalAccess-DdkY86qI.mjs → DemoBookingPortalAccess-C2QCj_Ta.mjs} +68 -12
  64. package/dist/client/{EventCalendar.client-DAeQPV76.mjs → EventCalendar.client-DDjz7tuX.mjs} +10 -10
  65. package/dist/client/{EventCombined.client-Bus9R0bj.mjs → EventCombined.client-CeYbNsch.mjs} +9 -9
  66. package/dist/client/{EventEmbeddedCheckoutStep-D_14yqAU.mjs → EventEmbeddedCheckoutStep-Cf-HRHtb.mjs} +1 -1
  67. package/dist/client/{EventItem-DPBLjGwj.mjs → EventItem-B5J0IeF4.mjs} +37 -15
  68. package/dist/client/{EventListWeekNavigation-D6cwU82_.mjs → EventListWeekNavigation-eH04D8-V.mjs} +1 -1
  69. package/dist/client/{EventListing.client-Bogi_SnJ.mjs → EventListing.client-slpvrTrM.mjs} +3 -3
  70. package/dist/client/{EventListing.view-CEumpN7i.mjs → EventListing.view-BYBaElec.mjs} +34 -16
  71. package/dist/client/{EventRegistrationPayment-CIQw6vNy.mjs → EventRegistrationPayment-Do7Q0wRG.mjs} +362 -90
  72. package/dist/client/{LocationMapActions-BVO-qx4q.mjs → LocationMapActions-BFp2uQQQ.mjs} +2 -2
  73. package/dist/client/{MapDrawingSvg-CcGaFawl.mjs → MapDrawingSvg-DDWfmgpA.mjs} +1 -1
  74. package/dist/client/{Page-D4_H_u9V.mjs → Page-Dv9eIOGr.mjs} +4475 -1600
  75. package/dist/client/{ProtectedSubmitButton-8DuDw2ag.mjs → ProtectedSubmitButton-C3H26pN9.mjs} +1 -1
  76. package/dist/client/{StepIndicator-Dptantmg.mjs → StepIndicator-BZNUd0-v.mjs} +3 -3
  77. package/dist/client/{TabBarFragment-BxEGsKUx.mjs → TabBarFragment-DkVKtK5a.mjs} +1 -1
  78. package/dist/client/{ThemedButton-8jUc02mZ.mjs → ThemedButton-BdnEwA38.mjs} +2 -5
  79. package/dist/client/accessibleSurfaces-chpD4C2c.mjs +4278 -0
  80. package/dist/client/{accordion--EUHmEGa.mjs → accordion-BCtVxnDZ.mjs} +1 -1
  81. package/dist/client/{booking-form.client-BCXwOnhc.mjs → booking-form.client-Cr5G-HHO.mjs} +1323 -567
  82. package/dist/client/{bookingForm-sHHcdism.mjs → bookingForm-B1Fc62Sl.mjs} +9 -5
  83. package/dist/client/bookingQuestions-BHq83mzS.mjs +13 -0
  84. package/dist/client/{bookingRoute-Bqlyu5Vb.mjs → bookingRoute-D6DlxYx6.mjs} +6 -2
  85. package/dist/client/bookings.mjs +28 -20
  86. package/dist/client/{carousel-Cp9xPBFZ.mjs → carousel-DW-HgjvT.mjs} +3 -3
  87. package/dist/client/{carousel.client-BO7sCEpH.mjs → carousel.client-BD4DXMtI.mjs} +62 -16
  88. package/dist/client/{carousel.shared-DBnWEJzo.mjs → carousel.shared-BFQ3kBEw.mjs} +6 -3
  89. package/dist/client/{cart-CCZZC-Lq.mjs → cart-D1zWe4R7.mjs} +3 -3
  90. package/dist/client/{cart.client-B7JfA19I.mjs → cart.client-CIfbTLHS.mjs} +1 -1
  91. package/dist/client/{checkout-CipmYL4A.mjs → checkout-fDCNZ3IT.mjs} +3 -3
  92. package/dist/client/{checkout.client-DraalWdH.mjs → checkout.client-C4l2KjtV.mjs} +1 -1
  93. package/dist/client/{checkoutUrls-CYj06rX1.mjs → checkoutUrls-cWL6I-Vz.mjs} +3 -2
  94. package/dist/client/client.mjs +287 -63
  95. package/dist/client/{context-Cv3QHjAF.mjs → context-DQnTyApV.mjs} +320 -4
  96. package/dist/client/creditProducts-CMOmhWm2.mjs +364 -0
  97. package/dist/client/{cta-P2vJVTEn.mjs → cta-Bj5WHgcv.mjs} +2 -2
  98. package/dist/client/{dateFormatting-D8D47VT4.mjs → dateFormatting-Bv6kjUW3.mjs} +1 -1
  99. package/dist/client/{demoPortalMagicLink-CXWZoV-d.mjs → demoPortalMagicLink-3uVu3WgG.mjs} +1 -1
  100. package/dist/client/{site-styles-D56hT2u1.mjs → display-CT8KMSpH.mjs} +19832 -17912
  101. package/dist/client/{enhanceHeaderSection-BkAro1DJ.mjs → enhanceHeaderSection-B27KFGDv.mjs} +4 -3
  102. package/dist/client/{event-details.client-dLmyuPap.mjs → event-details.client-CL4Lqz2c.mjs} +1 -1
  103. package/dist/client/{event-registration.client-BEhC2_-Y.mjs → event-registration.client-Dj3Kyp5X.mjs} +118 -241
  104. package/dist/client/{eventCalendar-FBMS2Cpb.mjs → eventCalendar-DGsdSF8J.mjs} +4 -4
  105. package/dist/client/{eventCombined-BrBhUvGe.mjs → eventCombined-DFSVDJ3D.mjs} +4 -4
  106. package/dist/client/{eventDetails-C7WUrbZ2.mjs → eventDetails-DzMskXYA.mjs} +2 -2
  107. package/dist/client/{eventListing-Bih-BgQM.mjs → eventListing-CpFFcAUr.mjs} +4 -4
  108. package/dist/client/{eventRegistration-DfTlqGbl.mjs → eventRegistration-BipMUOCw.mjs} +8 -5
  109. package/dist/client/{form-Bw1uuiUs.mjs → form-57k2JQnm.mjs} +3 -3
  110. package/dist/client/{form.client-pZ-9gN33.mjs → form.client-CCl6CpRJ.mjs} +5 -5
  111. package/dist/client/{form.parts-PXlu6XQO.mjs → form.parts-BOJ1yDDf.mjs} +3 -3
  112. package/dist/client/{formatDate-DI3DP48e.mjs → formatDate-BGlhrmhF.mjs} +1 -1
  113. package/dist/client/gifting/client.mjs +3 -3
  114. package/dist/client/{headerSection-BpJYUMd6.mjs → headerSection-q_bEzfhW.mjs} +2 -2
  115. package/dist/client/{mediaAssets-DpPauppt.mjs → mediaAssets-B99AP7ai.mjs} +1 -1
  116. package/dist/client/{mediaContext-BLo4NtjP.mjs → mediaContext-Fusweriw.mjs} +1 -1
  117. package/dist/client/{newsletter-form.client-CSoP0cGR.mjs → newsletter-form.client-CiqKAmPs.mjs} +6 -6
  118. package/dist/client/{newsletter-form.parts-DDbX_Sj0.mjs → newsletter-form.parts-x1RzAMNO.mjs} +2 -2
  119. package/dist/client/{newsletterForm-vCxYRar_.mjs → newsletterForm-Cn7h4zFe.mjs} +3 -3
  120. package/dist/client/{noop-ByVtIWf4.mjs → noop-B_f7RqLD.mjs} +544 -494
  121. package/dist/client/portal/client.mjs +86 -231
  122. package/dist/client/{product-detail.client-7Pi6avM-.mjs → product-detail.client-rWUvpVvZ.mjs} +1 -1
  123. package/dist/client/{product-list.client-DEad-Pma.mjs → product-list.client-J0wDOmKv.mjs} +1 -1
  124. package/dist/client/{productDetail-G1SMXG13.mjs → productDetail-LtCkMrJ0.mjs} +3 -3
  125. package/dist/client/{productList-B21TGdpT.mjs → productList-C0MLeh-v.mjs} +3 -3
  126. package/dist/client/{propsDecoder-B3vIBkex.mjs → propsDecoder-CAmEkJ6Y.mjs} +5 -4
  127. package/dist/client/{registry.server-B8aQhJpO.mjs → registry.server-Bf2YX_4v.mjs} +2218 -2435
  128. package/dist/client/{surfaceTransportMarker-BXepAVF6.mjs → renderableMediaAssetAdmission-BlfqYLJW.mjs} +1 -18
  129. package/dist/client/rendering/client.mjs +30 -30
  130. package/dist/client/rendering/islands.mjs +1 -1
  131. package/dist/client/rendering.mjs +10 -9
  132. package/dist/client/{richText-coerce-DHkBtO0G.mjs → richText-coerce-BTurYEao.mjs} +1 -1
  133. package/dist/client/{routeIslandApiConfig-DbHX4JOS.mjs → routeIslandApiConfig-UdAlnZGQ.mjs} +1 -1
  134. package/dist/client/runtimeResponse-BP-L6exS.mjs +3 -0
  135. package/dist/client/runtimeResponse-Dg4XFsuM.mjs +9 -0
  136. package/dist/client/{shop-mqyoOvOK.mjs → shop-Dkn6EasY.mjs} +3 -3
  137. package/dist/client/{shop-commerce-B2UmrQg_.mjs → shop-commerce-bo0Z6kwf.mjs} +13 -13
  138. package/dist/client/{shop-commerce-store-B7n-Z7nY.mjs → shop-commerce-store-Ckxa4_jI.mjs} +1 -1
  139. package/dist/client/{shop.client-BH-BBnA9.mjs → shop.client-B_GqU6_U.mjs} +111 -32
  140. package/dist/client/{shop.interactive-mdM3UMWG.mjs → shop.interactive-C6L_Ig5F.mjs} +87 -528
  141. package/dist/client/{shopShared-CXF5wxdg.mjs → shopShared-CO1Y8lFd.mjs} +2 -2
  142. package/dist/client/spam-protection.mjs +1 -1
  143. package/dist/client/src-BozhJ43Z.mjs +3 -0
  144. package/dist/client/{src-1PJxc8KO.mjs → src-xrjaKaCj.mjs} +6 -8
  145. package/dist/client/surfaceTransportMarker-BuwkYxsI.mjs +19 -0
  146. package/dist/client/{timetableModel-CrC80EOG.mjs → timetableModel-D62jfOxZ.mjs} +12 -12
  147. package/dist/client/{types-sF-IrGQr.mjs → types-5fOsPIpL.mjs} +248 -111
  148. package/dist/client/{useAvailableSlots-C4LOaI_Z.mjs → useAvailableSlots-CStfVmyY.mjs} +3 -3
  149. package/dist/client/{useDiscountApply-6Q0nToVA.mjs → useDiscountApply-Ca2pHUDu.mjs} +6 -4
  150. package/dist/client/{useDiscountCodeUi-CM-DTX5X.mjs → useDiscountCodeUi-AEifktGO.mjs} +1 -1
  151. package/dist/client/{useEventPagination-Bcs89BR5.mjs → useEventPagination-uxnUWI2v.mjs} +7 -7
  152. package/dist/client/{view-BN-fxyfq.mjs → view-B6KSxQMO.mjs} +11 -7
  153. package/dist/client/{view-Dh2tGoS0.mjs → view-SVnWic7i.mjs} +3 -4
  154. package/dist/preview-next/client/{ArrangementLookControls-D4VjPs-r.mjs → ArrangementLookControls-kbdqYkWM.mjs} +26 -17
  155. package/dist/preview-next/client/{EventEmbeddedCheckoutStep-C_h1cMYm.mjs → EventEmbeddedCheckoutStep-8-qtHjpb.mjs} +1 -1
  156. package/dist/preview-next/client/{LocationPickerEnvironment-D56RD3e_.mjs → LocationPickerEnvironment-CZQ4vkRe.mjs} +1 -1
  157. package/dist/preview-next/client/{MapLibreEditMap-DFnyCckr.mjs → MapLibreEditMap-CP4w7T_0.mjs} +2 -2
  158. package/dist/preview-next/client/{PreviewEditorSidebar-Ckr2zk_L.mjs → PreviewEditorSidebar-DI_LhsMQ.mjs} +212 -55
  159. package/dist/preview-next/client/{PreviewEditorUI-KOZgw_gS.mjs → PreviewEditorUI-yyD-ZREP.mjs} +6 -6
  160. package/dist/preview-next/client/{PreviewShell-CyO2V4kB.mjs → PreviewShell-YauP65Gi.mjs} +199 -155
  161. package/dist/preview-next/client/{SdkPreviewModeRuntime-DW3uKvNF.mjs → SdkPreviewModeRuntime-Bl7jQMI1.mjs} +32 -32
  162. package/dist/preview-next/client/{SiteChromeCustomizeButton-CU9VD-7O.mjs → SiteChromeCustomizeButton-CQFRP9aM.mjs} +4772 -3687
  163. package/dist/preview-next/client/{ThemedButton-C0dgGJ5k.mjs → ThemedButton-BQU45t-E.mjs} +260 -121
  164. package/dist/preview-next/client/{lucide-react-CPBCf6QT.mjs → lucide-react-DkZ8fO-G.mjs} +1 -1
  165. package/dist/preview-next/client/{previewAssistantSlot-DBi-WybM.mjs → previewAssistantSlot-DSR0IdAw.mjs} +16547 -13046
  166. package/dist/preview-next/client/{previewChromeSurface-BhkUJst9.mjs → previewChromeSurface-uSnVzeNs.mjs} +1 -1
  167. package/dist/preview-next/client/runtime.mjs +3 -3
  168. package/dist/preview-next/client/{sdk-runtime-BjCb6lOn.mjs → sdk-runtime-6Q0RVJTQ.mjs} +2 -2
  169. package/dist/preview-next/client/{src-DY8JCJdE.mjs → src-DzXUmsyK.mjs} +6 -8
  170. package/dist/preview-next/client/src-LUhVXBEQ.mjs +3 -0
  171. package/dist/preview-next/client/{useAutosaveStatus-CKxTaC3j.mjs → useAutosaveStatus-Cdx3kAGm.mjs} +2 -2
  172. package/dist/preview-next/client/{useBlockCustomizeControls-B7MLTjBX.mjs → useBlockCustomizeControls-ZrWdhcB6.mjs} +2 -2
  173. package/dist/preview-next/client/{useOpenBlockForSetup-BTUc0g9X.mjs → useOpenBlockForSetup-CK-GWb9k.mjs} +1 -1
  174. package/dist/preview-next/keepAlive.mjs +1 -1
  175. package/dist/preview-next/middleware.mjs +1 -1
  176. package/dist/preview-next/{route-contract-Bv3nkdpV.mjs → route-contract-BU1m9SV3.mjs} +212 -0
  177. package/dist/server/{Block.shared-4fMqzltx.mjs → Block.shared-4vx7wzxj.mjs} +5 -5
  178. package/dist/server/{ThemeScopeCore-C72VC_lR.mjs → ThemeScopeCore-C3HLgqBF.mjs} +463 -127
  179. package/dist/server/{accessibleSurfaces-B_Y_dA20.mjs → accessibleSurfaces-108nxyGc.mjs} +319 -131
  180. package/dist/server/{bindings-ConMYJ2U.mjs → bindings-TAQbo2P5.mjs} +2 -2
  181. package/dist/server/{booking-form.reserved-fields-BWRF7509.mjs → booking-form.reserved-fields-Cqp13TKc.mjs} +1 -0
  182. package/dist/server/{client-Cot-H5fQ.mjs → client-DzCxEl3L.mjs} +308 -61
  183. package/dist/server/config-validation.mjs +1 -1
  184. package/dist/server/config.mjs +1 -1
  185. package/dist/server/{validation-CDd6m8Ry.mjs → customCss-QymcmOZ-.mjs} +12 -55
  186. package/dist/server/data/resolveBlockData.mjs +1 -1
  187. package/dist/server/headerVariant-8O5MvxIU.mjs +464 -0
  188. package/dist/server/{identity-Bn9OQiT1.mjs → identity-20XHqyuO.mjs} +1 -1
  189. package/dist/server/index.mjs +3 -3
  190. package/dist/server/{loadContent-BkaWYEwt.mjs → loadContent-BO1M9Hdf.mjs} +4 -5
  191. package/dist/server/{loadPage-kviUdH8c.mjs → loadPage-BvWzmZcD.mjs} +2 -2
  192. package/dist/server/manifest.mjs +1 -1
  193. package/dist/server/{media-DnlczCMA.mjs → media-Brn9FW5s.mjs} +15 -1
  194. package/dist/server/{mode-Cv_TG9gP.mjs → mode-bkFS8glh.mjs} +4 -2
  195. package/dist/server/next.mjs +6 -6
  196. package/dist/server/{opaqueSurface-BTnS09GS.mjs → opaqueSurface-BawlEAd_.mjs} +6 -6
  197. package/dist/server/{overrideResolution-itXZCXs7.mjs → overrideResolution-fxuB1zZg.mjs} +1 -1
  198. package/dist/server/page-converter.mjs +3 -3
  199. package/dist/server/{pageRenderPlan-CDyn7iLy.mjs → pageRenderPlan-DzduDSqY.mjs} +255 -158
  200. package/dist/server/{pageRuntimeSupport-DZ6cLxrM.mjs → pageRuntimeSupport-BU8pwTNx.mjs} +291 -5
  201. package/dist/server/{pageShared-Q_Vij87H.mjs → pageShared-CSOJ8p8E.mjs} +1303 -907
  202. package/dist/server/{schema-DEizlyi4.mjs → parseThemeForPersistence-BebSeE17.mjs} +593 -1592
  203. package/dist/server/{prebuild-DOG4MkOy.mjs → prebuild-C5ZYo7wA.mjs} +1 -1
  204. package/dist/server/prebuild.mjs +1 -1
  205. package/dist/server/{prefetchBlockData-DlprLLsc.mjs → prefetchBlockData-BvbxqeKn.mjs} +5 -4
  206. package/dist/server/{registry-BPFcpn6k.mjs → registry-Fv-7D8o2.mjs} +4595 -4045
  207. package/dist/server/rendering/components/pageShared.mjs +1 -1
  208. package/dist/server/rendering/helpers/loadPage.mjs +1 -1
  209. package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +1 -1
  210. package/dist/server/rendering/server.mjs +3 -3
  211. package/dist/server/rendering.mjs +8 -8
  212. package/dist/server/{resolveBlockData-BHvfGD4y.mjs → resolveBlockData-xPgkvoWS.mjs} +1 -1
  213. package/dist/server/{resolveButtonColourStates-OXFRGn5M.mjs → resolveButtonColourStates-Cn6j8Ee0.mjs} +399 -518
  214. package/dist/server/{responseMedia-D8J3VAFs.mjs → responseMedia-t6gs0cB7.mjs} +2 -2
  215. package/dist/server/{richTextSchema-Euhuj-7V.mjs → richTextSchema-DQ2NBP0n.mjs} +5 -16
  216. package/dist/server/server.mjs +3 -3
  217. package/dist/server/theme-bridge.mjs +2 -3
  218. package/dist/server/theme.mjs +1 -2
  219. package/dist/server/{three-pass-converter-_j2UE2tR.mjs → three-pass-converter-CQWdnfjV.mjs} +1 -1
  220. package/dist/server/{validation-bl6WcAi_.mjs → validation-DddhgNdb.mjs} +58 -9
  221. package/dist/server/{version-BLXZ31S-.mjs → version-D_W2mt8w.mjs} +1 -1
  222. package/dist/styles/index.css +342 -67
  223. package/package.json +4 -3
  224. package/dist/_dts/index-CXsnaCGe.d.ts +0 -10
  225. package/dist/_dts/index-RugyUnqR.d.ts +0 -31535
  226. package/dist/client/BookingMailingListNote-CCVXX1LN.mjs +0 -331
  227. package/dist/client/DemoPortalSignInLink-B9YrzZt2.mjs +0 -19
  228. package/dist/client/creditProducts-BOWi1QLp.mjs +0 -62
  229. package/dist/client/site-styles-CMCUxsIM.mjs +0 -3
  230. package/dist/client/src-CdRISvQp.mjs +0 -3
  231. package/dist/client/src-DjnxOjXG.mjs +0 -217
  232. package/dist/client/useBookingNowIso-BDmWkYUW.mjs +0 -58
  233. package/dist/client/wizardSteps-DtkhwKXK.mjs +0 -6933
  234. package/dist/preview-next/client/src-BP8771hw.mjs +0 -3
  235. package/dist/server/parseThemeForPersistence-CDrF51tJ.mjs +0 -52
@@ -1,24 +1,25 @@
1
1
  "use client";
2
- import { $n as selectedBookingCollectionOptionKind, B as paymentChoiceDetails, Bn as getBookingServiceSlidingScale, Fn as readOverrideServiceCategories, Gn as normalizeBookingFormConfig, In as deriveBookingFormViewState, Jn as prepareBookingSubmission, Kn as normalizeBookingServices, Kr as resolveBookingSignupOffer, Ln as formatBookingCentsAsCurrencyInput, Pn as buildBookingFormInteractiveIslandProps, Qn as resolveDefaultBookingServiceId, R as buildBookingPaymentSelectionViewModel, Rn as formatBookingSubmissionPreparationError, V as paymentChoicePrice, Vn as getBookingSuccessCopy, Wn as isBookingServiceSlidingAmountInRange, Xn as resolveBookingPaymentStep, Yn as resolveAppointmentCheckoutVerificationState, Zn as resolveBookingSiteId, br as resolveDateRuntimeContext, er as toSelectedCollectionOptionKind, li as unsafeAsSiteId, nr as resolveSelectedAppointmentConsent, qn as parseBookingCurrencyInputToCents, rr as BOOKING_FORM_DATA_RESERVED_KEYS, tr as projectSelectedAppointmentConsentIntoForm, yr as readRuntimeNow, z as buildReviewedBookingPaymentViewModel, zn as getBookingRedirectStateFromLocation } from "./wizardSteps-DtkhwKXK.mjs";
3
- import { Bt as formatCurrencyAmount, Ft as parseUtcIsoDateTimeString, It as toUtcIsoDateTimeString, Mt as resolveBookingBusinessTimeZone, Nt as resolveBookingTimeZoneId, Z as isBookingRequirementConsentFieldId, _t as formatTime, gt as formatDateTimeRange, pt as formatDate, t as logger, xt as resolveBookingDisplayContext, yt as formatTimeZoneCityLabel } from "./noop-ByVtIWf4.mjs";
4
- import { a as formatTime$1, c as unsafeAsAppointmentServiceId, i as formatDatePillParts, n as useAvailableDates, o as getRuntimeTimeZone, r as formatDate$1, s as unsafeAsAppointmentResourceId, t as useAvailableSlots } from "./useAvailableSlots-C4LOaI_Z.mjs";
5
- import { a as clearWorkflowFeedback, i as okWith, n as err, o as reportWorkflowError, s as reportWorkflowSuccess, t as assertNever } from "./src-DjnxOjXG.mjs";
6
- import { d as DiscountCodeDisclosure, i as SiteTermsChangedNotice, o as useSiteTermsAgreement, r as SiteTermsAgreementField, t as BookingConfirmation } from "./DemoBookingPortalAccess-DdkY86qI.mjs";
2
+ import { $r as bookingRequiresResourceSelection, Ai as leavePage, Ar as selectedBookingCollectionOptionKind, Br as bookingQuestionsAnswerDraftSchema, Ci as readRuntimeNow, Cr as parseBookingCurrencyInputToCents, Dr as resolveBookingSelectedService, Er as resolveBookingPaymentStep, Fr as applyAppointmentBookingQuestionsEvent, Gr as restoreBookingQuestionsAnswers, Hr as decideBookingQuestionsRestoration, Ir as appointmentQuestionsRefusal, Jr as BOOKING_FORM_DATA_RESERVED_KEYS, Kr as toBookingQuestionsAnswerDraft, Lr as deriveAppointmentBookingQuestions, Mr as projectSelectedAppointmentConsentIntoForm, Nr as resolveSelectedAppointmentConsent, Or as resolveBookingSiteId, Pr as EMPTY_APPOINTMENT_BOOKING_QUESTIONS, Qr as bookingPackageRequestKey, Rr as isAppointmentBookingQuestionsEvent, So as resolveBookingSignupOffer, Sr as normalizeBookingServices, Tr as resolveAppointmentCheckoutVerificationState, Xr as applyBookingPaymentAdmission, Zr as bookingHasPackagePaymentChoices, _r as getBookingSuccessCopy, ai as resolveBookingPaymentMode, at as buildReviewedBookingPaymentViewModel, br as isBookingServiceSlidingAmountInRange, ci as getBookingServiceSlidingScale, dr as buildBookingFormInteractiveIslandProps, ei as reconcileBookingPackagePurchase, fr as readOverrideServiceCategories, gr as getBookingRedirectStateFromLocation, hr as formatBookingSubmissionPreparationError, ii as resolveBookingPaymentChoice, it as buildBookingPaymentSelectionViewModel, jr as toSelectedCollectionOptionKind, kr as resolveDefaultBookingServiceId, l as formatValidity, mr as formatBookingCentsAsCurrencyInput, ni as resolveBookingPackageSources, oi as resolveBookingPurchasablePackages, ot as paymentChoiceDetails, pn as createSignInReturnDraftStore, pr as deriveBookingFormViewState, ri as resolveBookingPaymentAvailability, si as toBookingPurchasablePackages, st as paymentChoicePrice, ti as resolveBookingPackagePaymentSelection, wi as resolveDateRuntimeContext, wr as prepareBookingSubmission, xr as normalizeBookingFormConfig, zo as unsafeAsSiteId, zr as needsAppointmentQuestionsRefresh } from "./display-CT8KMSpH.mjs";
3
+ import { Bt as resolveBookingDisplayContext, Ft as formatDateTimeRange, It as formatTime, Mt as formatDate, Qt as resolveBookingTimeZoneId, Rt as formatTimeZoneCityLabel, U as isBookingRequirementConsentFieldId, Zt as resolveBookingBusinessTimeZone, en as parseUtcIsoDateTimeString, on as formatCurrencyAmount, t as logger, tn as toUtcIsoDateTimeString } from "./noop-B_f7RqLD.mjs";
4
+ import { a as formatTime$1, c as unsafeAsAppointmentServiceId, i as formatDatePillParts, n as useAvailableDates, o as getRuntimeTimeZone, r as formatDate$1, s as unsafeAsAppointmentResourceId, t as useAvailableSlots } from "./useAvailableSlots-CStfVmyY.mjs";
5
+ import { b as reportWorkflowError, c as checkBookingQuestionsAnswered, g as err, h as assertNever, v as okWith, x as reportWorkflowSuccess, y as clearWorkflowFeedback } from "./creditProducts-CMOmhWm2.mjs";
6
+ import { c as NavigationHandOffPanel, f as DiscountCodeDisclosure, i as SiteTermsChangedNotice, o as useSiteTermsAgreement, r as SiteTermsAgreementField, t as BookingConfirmation } from "./DemoBookingPortalAccess-C2QCj_Ta.mjs";
7
7
  import { t as layoutServicesByCategory } from "./appointment-service-categories-Cl2pqw-z.mjs";
8
- import { r as ThemedButton, u as SpinnerNode } from "./ThemedButton-8jUc02mZ.mjs";
9
- import { t as buildCheckoutReturnUrls } from "./checkoutUrls-CYj06rX1.mjs";
8
+ import { n as useBlockApi, t as BlockApiProvider } from "./context-DQnTyApV.mjs";
9
+ import { l as SpinnerNode, r as ThemedButton } from "./ThemedButton-BdnEwA38.mjs";
10
+ import { t as buildCheckoutReturnUrls } from "./checkoutUrls-cWL6I-Vz.mjs";
10
11
  import { t as scrollToBlock } from "./scrollToBlock-DrgKE0qZ.mjs";
11
- import { t as CheckboxChoice } from "./CheckboxChoice-CZ-anOqV.mjs";
12
+ import { t as CheckboxChoice } from "./CheckboxChoice-W_uiRgDK.mjs";
12
13
  import { t as CheckIcon } from "./CheckIcon-CVcKteXH.mjs";
13
14
  import { n as getFieldValidationControlProps, t as FieldValidationMessage } from "./FieldValidationMessage-CsqxShw4.mjs";
14
15
  import { t as FeedbackMessage } from "./FeedbackMessage-CSJrAuXH.mjs";
15
- import { n as TerminalPanel, r as StateIcon, t as useDiscountCodeUi } from "./useDiscountCodeUi-CM-DTX5X.mjs";
16
- import { i as PaymentChoiceRows, n as BookingConsentAgreement, r as usePolling, t as BookingMailingListNote } from "./BookingMailingListNote-CCVXX1LN.mjs";
16
+ import { i as useBookingNowIso, n as OptionalMark, r as parseBookingSubmissionFailure } from "./BookingQuestionFields-DjLjd0vc.mjs";
17
+ import { n as TerminalPanel, r as StateIcon, t as useDiscountCodeUi } from "./useDiscountCodeUi-AEifktGO.mjs";
18
+ import { a as usePolling, c as useBookingQuestionsRefresh, i as BookingConsentAgreement, l as PaymentChoiceRows, n as BookingQuestionSections, o as portalSessionIdentity, s as useSignInReturn, t as BookingMailingListNote } from "./BookingMailingListNote-y3qWjnOo.mjs";
17
19
  import { t as StepIndicator } from "./StepIndicator-BK0GEDoP.mjs";
18
- import { n as useBlockApi, t as BlockApiProvider } from "./context-Cv3QHjAF.mjs";
19
- import { t as useBookingNowIso } from "./useBookingNowIso-BDmWkYUW.mjs";
20
- import { s as storeDemoBookingPassIfAvailable } from "./demoPortalMagicLink-CXWZoV-d.mjs";
20
+ import { s as storeDemoBookingPassIfAvailable } from "./demoPortalMagicLink-3uVu3WgG.mjs";
21
21
  import React, { useCallback, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState } from "react";
22
+ import { z } from "zod";
22
23
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
23
24
  //#region ../core/src/branded/entitlements.ts
24
25
  const unsafeAsPassId = (id) => id;
@@ -70,6 +71,222 @@ function useSelectedAppointmentConsentForm(form, selectedService) {
70
71
  return useMemo(() => projectSelectedAppointmentConsentIntoForm(form, resolveSelectedAppointmentConsent(selectedService)), [form, selectedService]);
71
72
  }
72
73
  //#endregion
74
+ //#region ../blocks/src/system/runtime/nodes/booking-form.field-values.ts
75
+ function collectInitialBookingFieldValues(initialData) {
76
+ const values = {};
77
+ for (const [key, value] of Object.entries(initialData)) if (!BOOKING_FORM_DATA_RESERVED_KEYS.has(key) && !isBookingRequirementConsentFieldId(key) && isBookingFieldValue(value)) values[key] = value;
78
+ return values;
79
+ }
80
+ function omitBookingConsentEntries(record) {
81
+ return Object.fromEntries(Object.entries(record).filter(([key]) => !isBookingRequirementConsentFieldId(key)));
82
+ }
83
+ function isBookingFieldValue(value) {
84
+ return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || Array.isArray(value) && value.every((item) => typeof item === "string");
85
+ }
86
+ //#endregion
87
+ //#region ../blocks/src/system/runtime/nodes/booking-form.sign-in-return.ts
88
+ const packagePurchaseSchema = z.discriminatedUnion("kind", [z.object({ kind: z.literal("none") }), z.object({
89
+ kind: z.literal("selected"),
90
+ package: z.object({
91
+ id: z.string(),
92
+ name: z.string(),
93
+ price: z.number(),
94
+ currency: z.string(),
95
+ creditsTotal: z.number(),
96
+ validDays: z.number().nullable(),
97
+ heldWithTeamMember: z.object({
98
+ id: z.string(),
99
+ name: z.string()
100
+ }).nullable()
101
+ })
102
+ })]);
103
+ /** The appointment form's drafts, for the shared `useSignInReturn` owner. */
104
+ const bookingSignInDraftStore = createSignInReturnDraftStore(z.object({
105
+ nonce: z.string().min(1),
106
+ email: z.string(),
107
+ currentStepId: z.enum([
108
+ "service-selection",
109
+ "datetime-selection",
110
+ "payment-selection",
111
+ "custom-fields"
112
+ ]),
113
+ selectedServiceId: z.string().optional(),
114
+ selectedResourceId: z.string().optional(),
115
+ selectedDate: z.string().optional(),
116
+ selectedSlot: z.object({
117
+ startAt: z.string(),
118
+ endAt: z.string(),
119
+ resourceId: z.string(),
120
+ resourceName: z.string().optional(),
121
+ label: z.string().optional()
122
+ }).nullable(),
123
+ fieldValues: z.record(z.string(), z.union([
124
+ z.string(),
125
+ z.number(),
126
+ z.boolean(),
127
+ z.null(),
128
+ z.array(z.string())
129
+ ])),
130
+ mailingListOptIn: z.boolean(),
131
+ selectedSlidingAmountInput: z.string(),
132
+ selectedCollectionOptionKind: z.enum([
133
+ "upfront",
134
+ "deferred_manual",
135
+ "instalment_plan",
136
+ "flexible_balance"
137
+ ]).optional(),
138
+ selectedAppointmentPackageId: z.string().optional(),
139
+ packagePurchase: packagePurchaseSchema,
140
+ discountCode: z.string(),
141
+ questions: bookingQuestionsAnswerDraftSchema
142
+ }));
143
+ /** The booker's progress, minus consent ticks, which they give again on return. */
144
+ function toBookingSignInDraft(state, attempt) {
145
+ return {
146
+ nonce: attempt.nonce,
147
+ email: attempt.email,
148
+ currentStepId: state.currentStepId,
149
+ selectedServiceId: state.selectedServiceId,
150
+ selectedResourceId: state.selectedResourceId,
151
+ selectedDate: state.selectedDate,
152
+ selectedSlot: state.selectedSlot ? {
153
+ startAt: state.selectedSlot.startAt,
154
+ endAt: state.selectedSlot.endAt,
155
+ resourceId: state.selectedSlot.resourceId,
156
+ ...state.selectedSlot.resourceName ? { resourceName: state.selectedSlot.resourceName } : {},
157
+ ...state.selectedSlot.label ? { label: state.selectedSlot.label } : {}
158
+ } : null,
159
+ fieldValues: omitBookingConsentEntries(state.fieldValues),
160
+ mailingListOptIn: state.mailingListOptIn,
161
+ selectedSlidingAmountInput: state.selectedSlidingAmountInput,
162
+ selectedCollectionOptionKind: state.selectedCollectionOptionKind,
163
+ selectedAppointmentPackageId: state.selectedAppointmentPackageId,
164
+ packagePurchase: state.packagePurchase,
165
+ discountCode: state.discountCode,
166
+ questions: toBookingQuestionsAnswerDraft(state.bookingQuestions)
167
+ };
168
+ }
169
+ /**
170
+ * Puts the booker back where they were, once `useSignInReturn` has matched the
171
+ * return to the signed-in profile. Field values they typed win over the page's
172
+ * prefill; the availability check then drops the slot if it's gone. The
173
+ * answers come back only as `decideBookingQuestionsRestoration` decided.
174
+ */
175
+ function restoreBookingSignInDraft(state, draft, questions) {
176
+ const slot = draft.selectedSlot ? {
177
+ ...draft.selectedSlot,
178
+ key: `${draft.selectedSlot.startAt}|${draft.selectedSlot.endAt}|${draft.selectedSlot.resourceId}`,
179
+ resourceId: unsafeAsAppointmentResourceId(draft.selectedSlot.resourceId)
180
+ } : null;
181
+ return {
182
+ ...state,
183
+ currentStepId: draft.currentStepId,
184
+ selectedServiceId: draft.selectedServiceId ? unsafeAsAppointmentServiceId(draft.selectedServiceId) : state.selectedServiceId,
185
+ selectedResourceId: draft.selectedResourceId ? unsafeAsAppointmentResourceId(draft.selectedResourceId) : void 0,
186
+ selectedDate: draft.selectedDate,
187
+ selectedSlot: slot,
188
+ fieldValues: {
189
+ ...state.fieldValues,
190
+ ...draft.fieldValues
191
+ },
192
+ mailingListOptIn: draft.mailingListOptIn,
193
+ selectedSlidingAmountInput: draft.selectedSlidingAmountInput,
194
+ selectedCollectionOptionKind: draft.selectedCollectionOptionKind,
195
+ selectedAppointmentPackageId: draft.selectedAppointmentPackageId ? unsafeAsCustomerPassId(draft.selectedAppointmentPackageId) : void 0,
196
+ packagePurchase: draft.packagePurchase,
197
+ discountCode: draft.discountCode,
198
+ bookingQuestions: restoreBookingQuestionsAnswers(state.bookingQuestions, questions)
199
+ };
200
+ }
201
+ //#endregion
202
+ //#region ../blocks/src/system/runtime/hooks/useAppointmentBookingQuestions.ts
203
+ /** Completing the booking ends every draft; changing service leaves this tab's attempt behind. */
204
+ function appointmentSignInEnds(previous, next) {
205
+ if (next.phase === "completed" && previous.phase !== "completed") return "finished";
206
+ return previous.selectedServiceId !== next.selectedServiceId ? "abandoned" : null;
207
+ }
208
+ /** The signed-in read for the selected service, once per service and session. */
209
+ function useAppointmentQuestionsRefresh(input) {
210
+ const { api, state, selectedService, identity, dispatch } = input;
211
+ const serviceId = needsAppointmentQuestionsRefresh({
212
+ service: selectedService,
213
+ identity,
214
+ refreshed: state.bookingQuestions.refreshed
215
+ }) ? selectedService?.id ?? null : null;
216
+ useBookingQuestionsRefresh({
217
+ api,
218
+ target: serviceId ? {
219
+ kind: "appointment_service",
220
+ serviceId
221
+ } : null,
222
+ targetKey: serviceId,
223
+ identity,
224
+ dispatch
225
+ });
226
+ }
227
+ /**
228
+ * The appointment flow's during-booking questions: what to show, the
229
+ * authenticated refresh, and keeping progress across a sign-in link.
230
+ */
231
+ function useAppointmentBookingQuestions(input) {
232
+ const { state, selectedService, identity, dispatch } = input;
233
+ const view = useMemo(() => deriveAppointmentBookingQuestions(state.bookingQuestions, selectedService, identity), [
234
+ identity,
235
+ selectedService,
236
+ state.bookingQuestions
237
+ ]);
238
+ useAppointmentQuestionsRefresh(input);
239
+ const signIn = useSignInReturn({
240
+ siteId: input.siteId,
241
+ formId: input.formId,
242
+ state,
243
+ store: bookingSignInDraftStore,
244
+ toDraft: toBookingSignInDraft,
245
+ ends: appointmentSignInEnds,
246
+ session: {
247
+ api: input.api,
248
+ identity
249
+ },
250
+ ready: true,
251
+ restore: (draft, verifiedIdentity) => dispatch({
252
+ type: "sign-in-draft-restored",
253
+ draft,
254
+ questions: decideBookingQuestionsRestoration({
255
+ kind: "sign_in_draft",
256
+ draft: draft.questions,
257
+ verifiedIdentity
258
+ })
259
+ })
260
+ });
261
+ const { scope } = view;
262
+ const answer = useCallback((fieldId, value) => dispatch({
263
+ type: "booking-question-answered",
264
+ scope,
265
+ fieldId,
266
+ value
267
+ }), [dispatch, scope]);
268
+ const chooseAnswerMode = useCallback((mode) => dispatch({
269
+ type: "booking-questions-answer-mode-set",
270
+ scope,
271
+ mode
272
+ }), [dispatch, scope]);
273
+ const keepRefused = useCallback(() => dispatch({
274
+ type: "booking-questions-keep-refused",
275
+ scope
276
+ }), [dispatch, scope]);
277
+ return {
278
+ presentation: view.presentation,
279
+ values: view.values,
280
+ answerMode: view.answerMode,
281
+ submission: view.submission,
282
+ fieldErrors: state.questionFieldErrors,
283
+ answer,
284
+ chooseAnswerMode,
285
+ keepRefused,
286
+ ...signIn
287
+ };
288
+ }
289
+ //#endregion
73
290
  //#region ../blocks/src/system/runtime/hooks/useBookingSubmission.state.ts
74
291
  const initialBookingSubmissionState = {
75
292
  status: { tag: "idle" },
@@ -154,12 +371,12 @@ function useBookingSubmission(_siteId, terms) {
154
371
  return okWith(response);
155
372
  } catch (error) {
156
373
  console.error("Booking submission error:", error);
157
- const message = error instanceof Error ? error.message : "Failed to book appointment";
374
+ const failure = parseBookingSubmissionFailure(error, "Failed to book appointment");
158
375
  dispatch({
159
376
  type: "submission-failed",
160
- message
377
+ message: failure.message
161
378
  });
162
- return err(message);
379
+ return err(failure);
163
380
  }
164
381
  };
165
382
  return {
@@ -181,6 +398,7 @@ function executeBookingSubmission$1(api, data) {
181
398
  startAt: data.startAt,
182
399
  endAt: data.endAt,
183
400
  customFields: data.customFields,
401
+ bookingQuestions: data.bookingQuestions,
184
402
  mailingListOptIn: data.mailingListOptIn,
185
403
  timezone: data.timezone,
186
404
  customerPassId: data.customerPassId
@@ -191,8 +409,10 @@ function executeBookingSubmission$1(api, data) {
191
409
  startAt: data.startAt,
192
410
  endAt: data.endAt,
193
411
  customFields: data.customFields,
412
+ bookingQuestions: data.bookingQuestions,
194
413
  mailingListOptIn: data.mailingListOptIn,
195
414
  timezone: data.timezone,
415
+ ...data.kind === "package_purchase" ? { purchasePassId: data.purchasePassId } : {},
196
416
  shownTerms: data.shownTerms,
197
417
  discountCode: data.discountCode,
198
418
  selectedSlidingAmount: data.selectedSlidingAmount,
@@ -277,24 +497,12 @@ function applyBookingContactEvent(state, event) {
277
497
  }
278
498
  }
279
499
  //#endregion
280
- //#region ../blocks/src/system/runtime/nodes/booking-form.field-values.ts
281
- function collectInitialBookingFieldValues(initialData) {
282
- const values = {};
283
- for (const [key, value] of Object.entries(initialData)) if (!BOOKING_FORM_DATA_RESERVED_KEYS.has(key) && !isBookingRequirementConsentFieldId(key) && isBookingFieldValue(value)) values[key] = value;
284
- return values;
285
- }
286
- function omitBookingConsentEntries(record) {
287
- return Object.fromEntries(Object.entries(record).filter(([key]) => !isBookingRequirementConsentFieldId(key)));
288
- }
289
- function isBookingFieldValue(value) {
290
- return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean" || Array.isArray(value) && value.every((item) => typeof item === "string");
291
- }
292
- //#endregion
293
500
  //#region ../blocks/src/system/runtime/nodes/booking-form.headless.state.ts
294
501
  const unsafeAsBookingFieldId = (id) => id;
295
502
  function createInitialBookingFlowReducerState(input) {
296
503
  const initialData = input.initialData ?? {};
297
504
  return {
505
+ packagePurchase: { kind: "none" },
298
506
  phase: "editing",
299
507
  currentStepId: "service-selection",
300
508
  selectedServiceId: toOptionalAppointmentServiceId(toOptionalString(initialData.serviceId) ?? input.defaultServiceId),
@@ -310,6 +518,8 @@ function createInitialBookingFlowReducerState(input) {
310
518
  selectedCollectionOptionKind: toSelectedCollectionOptionKind(initialData.selectedCollectionOptionKind),
311
519
  selectedAppointmentPackageId: toOptionalCustomerPassId(toOptionalString(initialData.selectedAppointmentPackageId)),
312
520
  review: null,
521
+ bookingQuestions: EMPTY_APPOINTMENT_BOOKING_QUESTIONS,
522
+ questionFieldErrors: {},
313
523
  validationErrors: createEmptyBookingValidationErrors(),
314
524
  feedback: { kind: "none" }
315
525
  };
@@ -357,11 +567,17 @@ function applyAvailabilitySelectionInvalidation(state, invalidation) {
357
567
  function reduceBookingFlowEvent(state, event) {
358
568
  if (isBookingContactEvent(event)) return applyBookingContactEvent(state, event);
359
569
  if (isBookingPaymentEvent(event)) return applyBookingPaymentEvent(state, event);
570
+ if (isAppointmentBookingQuestionsEvent(event)) return applyBookingQuestionsFlowEvent(state, event);
360
571
  switch (event.type) {
361
572
  case "resources-received": return planBookingResourceAcceptance({
362
573
  ...event,
363
574
  state
364
575
  }).reduce(reduceBookingFlowEvent, state);
576
+ case "purchasable-packages-received": return applyBookingPackagePurchaseRefresh(state, event.packages);
577
+ case "unrestricted-held-packages-received": return {
578
+ ...state,
579
+ unrestrictedHeldPackageServiceId: event.serviceId
580
+ };
365
581
  case "packages-received": return planBookingPackageAcceptance({
366
582
  ...event,
367
583
  state
@@ -370,6 +586,7 @@ function reduceBookingFlowEvent(state, event) {
370
586
  case "resource-selected": return {
371
587
  ...state,
372
588
  selectedResourceId: event.resourceId ?? void 0,
589
+ packagePurchase: { kind: "none" },
373
590
  selectedDate: void 0,
374
591
  selectedSlot: null,
375
592
  validationErrors: clearBookingFormError(state.validationErrors)
@@ -403,6 +620,16 @@ function reduceBookingFlowEvent(state, event) {
403
620
  ...state,
404
621
  validationErrors: event.errors
405
622
  };
623
+ case "submission-failed": return {
624
+ ...state,
625
+ phase: "editing",
626
+ questionFieldErrors: event.failure.questionFieldErrors,
627
+ feedback: {
628
+ kind: "error",
629
+ scope: "submission",
630
+ message: event.failure.message
631
+ }
632
+ };
406
633
  case "feedback-set": return {
407
634
  ...state,
408
635
  phase: event.feedback.kind === "success" ? "completed" : "editing",
@@ -412,7 +639,8 @@ function reduceBookingFlowEvent(state, event) {
412
639
  case "feedback-cleared": return {
413
640
  ...state,
414
641
  phase: "editing",
415
- feedback: { kind: "none" }
642
+ feedback: { kind: "none" },
643
+ questionFieldErrors: {}
416
644
  };
417
645
  case "review-required": return {
418
646
  ...state,
@@ -426,6 +654,7 @@ function reduceBookingFlowEvent(state, event) {
426
654
  review: null,
427
655
  paymentChoices: event.paymentChoices,
428
656
  selectedCollectionOptionKind: void 0,
657
+ packagePurchase: { kind: "none" },
429
658
  currentStepId: "payment-selection",
430
659
  feedback: {
431
660
  kind: "error",
@@ -435,20 +664,49 @@ function reduceBookingFlowEvent(state, event) {
435
664
  };
436
665
  case "submission-started": return {
437
666
  ...state,
438
- phase: "submitting"
667
+ phase: "submitting",
668
+ questionFieldErrors: {}
439
669
  };
440
670
  case "submission-finished": return state.phase === "submitting" ? {
441
671
  ...state,
442
672
  phase: "editing"
443
673
  } : state;
674
+ case "sign-in-draft-restored": return restoreBookingSignInDraft(state, event.draft, event.questions);
444
675
  case "reset": return event.initial;
445
676
  default: return assertNever(event);
446
677
  }
447
678
  }
679
+ /** Changed purchase facts invalidate a price review; identical refreshes preserve the current intent. */
680
+ function applyBookingPackagePurchaseRefresh(state, packages) {
681
+ const packagePurchase = reconcileBookingPackagePurchase(state.packagePurchase, packages);
682
+ return packagePurchase === state.packagePurchase ? state : {
683
+ ...state,
684
+ packagePurchase,
685
+ review: null
686
+ };
687
+ }
688
+ /** Answering a question clears the server's complaint about that question. */
689
+ function applyBookingQuestionsFlowEvent(state, event) {
690
+ const bookingQuestions = applyAppointmentBookingQuestionsEvent(state.bookingQuestions, event);
691
+ if (event.type !== "booking-question-answered" || !(event.fieldId in state.questionFieldErrors)) return {
692
+ ...state,
693
+ bookingQuestions
694
+ };
695
+ const { [event.fieldId]: _answered, ...questionFieldErrors } = state.questionFieldErrors;
696
+ return {
697
+ ...state,
698
+ bookingQuestions,
699
+ questionFieldErrors
700
+ };
701
+ }
448
702
  function applyBookingServiceSelection(state, serviceId) {
449
703
  return {
450
704
  ...state,
705
+ packagePurchase: { kind: "none" },
706
+ bookingQuestions: EMPTY_APPOINTMENT_BOOKING_QUESTIONS,
707
+ questionFieldErrors: {},
451
708
  selectedServiceId: serviceId,
709
+ unrestrictedHeldPackageServiceId: void 0,
452
710
  selectedResourceId: void 0,
453
711
  selectedDate: void 0,
454
712
  selectedSlot: null,
@@ -519,6 +777,7 @@ function toBookingFormData(state) {
519
777
  discountCode: state.discountCode || void 0,
520
778
  selectedSlidingAmountInput: state.selectedSlidingAmountInput || void 0,
521
779
  selectedCollectionOptionKind: state.selectedCollectionOptionKind,
780
+ ...state.packagePurchase.kind === "selected" ? { packagePurchase: state.packagePurchase } : {},
522
781
  selectedAppointmentPackageId: state.selectedAppointmentPackageId
523
782
  };
524
783
  }
@@ -539,12 +798,12 @@ function buildBookingStepResolution(input) {
539
798
  steps: [
540
799
  {
541
800
  id: "service-selection",
542
- label: "Select Service",
801
+ label: "Service",
543
802
  visible: needsServiceSelection
544
803
  },
545
804
  {
546
805
  id: "datetime-selection",
547
- label: "Select Date & Time",
806
+ label: "Date and time",
548
807
  visible: true
549
808
  },
550
809
  {
@@ -554,7 +813,7 @@ function buildBookingStepResolution(input) {
554
813
  },
555
814
  {
556
815
  id: "custom-fields",
557
- label: "Your Information",
816
+ label: "Your details",
558
817
  visible: hasFields
559
818
  }
560
819
  ],
@@ -563,10 +822,14 @@ function buildBookingStepResolution(input) {
563
822
  }
564
823
  function resolveBookingStepVisibility(input, defaultServiceId, payment) {
565
824
  const hasValidConfiguredService = Boolean(defaultServiceId) && input.services.some((service) => service.id === defaultServiceId);
825
+ const service = resolveBookingSelectedService({
826
+ ...input,
827
+ defaultServiceId
828
+ });
566
829
  return {
567
830
  needsServiceSelection: [
568
831
  input.requiresServiceSelection,
569
- input.requiresResourceSelection,
832
+ bookingRequiresResourceSelection(service, input.requiresResourceSelection),
570
833
  !hasValidConfiguredService && input.services.length > 1,
571
834
  (input.form?.settings?.serviceIds?.length ?? 0) > 1
572
835
  ].some(Boolean),
@@ -575,12 +838,24 @@ function resolveBookingStepVisibility(input, defaultServiceId, payment) {
575
838
  };
576
839
  }
577
840
  function needsBookingPaymentStep(input, payment) {
578
- return Boolean(getBookingServiceSlidingScale(payment.service)) || payment.mode !== "hidden" || Boolean(input.enableAppointmentPackages && (payment.service?.priceAmount ?? 0) > 0);
841
+ if (input.form?.settings?.requiresApproval) return false;
842
+ return [
843
+ bookingHasPackagePaymentChoices(payment.service),
844
+ getBookingServiceSlidingScale(payment.service),
845
+ payment.mode !== "hidden",
846
+ input.enableAppointmentPackages && (payment.service?.priceAmount ?? 0) > 0
847
+ ].some(Boolean);
848
+ }
849
+ /** The service step needs a service, and a practitioner when the form insists on one. */
850
+ function serviceSelectionMessage(input) {
851
+ if (bookingRequiresResourceSelection(resolveBookingSelectedService(input), input.requiresResourceSelection) && !(input.data.resourceId ?? input.defaultResourceId)) return "Please select a practitioner";
852
+ return input.data.serviceId ? null : "Please select a service";
579
853
  }
580
854
  function validateBookingStep(input) {
855
+ const refusal = input.questionsRefusal ?? null;
581
856
  switch (input.stepId) {
582
- case "service-selection": return bookingStepValidationFromMessage(input.requiresResourceSelection && !(input.data.resourceId ?? input.defaultResourceId) ? "Please select a practitioner" : !input.data.serviceId ? "Please select a service" : null);
583
- case "datetime-selection": return bookingStepValidationFromMessage(input.data.selectedSlot ? null : "Please select a date and time");
857
+ case "service-selection": return bookingStepValidationFromMessage(refusal ?? serviceSelectionMessage(input));
858
+ case "datetime-selection": return bookingStepValidationFromMessage(refusal ?? (input.data.selectedSlot ? null : "Please select a date and time"));
584
859
  case "payment-selection": return validateBookingPaymentStep(input);
585
860
  case "custom-fields": {
586
861
  const errors = validateBookingFields({
@@ -602,7 +877,8 @@ function bookingStepValidationFromMessage(message) {
602
877
  } : { ok: true };
603
878
  }
604
879
  function validateBookingPaymentStep(input) {
605
- if (input.data.selectedAppointmentPackageId) return { ok: true };
880
+ const packageValidation = validateBookingPackagePayment(input);
881
+ if (packageValidation) return packageValidation;
606
882
  const resolution = input.paymentResolution ?? resolveBookingPaymentStep(input);
607
883
  const slidingScale = getBookingServiceSlidingScale(resolution.service);
608
884
  if (slidingScale && !isBookingServiceSlidingAmountInRange(slidingScale, parseBookingCurrencyInputToCents(input.data.selectedSlidingAmountInput))) return bookingStepValidationFromMessage("Please choose an amount within the sliding scale");
@@ -708,11 +984,16 @@ function buildBookingAvailabilityQuery(input) {
708
984
  timezone: input.timezone
709
985
  };
710
986
  }
987
+ /** The contact email says what it's for unless the site form gives it its own hint. */
988
+ const CONTACT_EMAIL_HINT = "We’ll send your confirmation here.";
989
+ function defaultBookingFieldHint(field) {
990
+ return field.id === "email" && field.type === "email" ? CONTACT_EMAIL_HINT : null;
991
+ }
711
992
  function deriveBookingFieldViews(input) {
712
993
  return (input.form?.schema?.fields ?? []).map((field) => {
713
994
  const fieldId = unsafeAsBookingFieldId(field.id);
714
995
  const inputId = `${input.idPrefix}-${fieldId}`;
715
- const helpText = field.type === "booking_requirement_consent" ? null : field.helpText ?? null;
996
+ const helpText = field.type === "booking_requirement_consent" ? null : field.helpText ?? defaultBookingFieldHint(field);
716
997
  const helpTextId = helpText ? `${inputId}-help` : null;
717
998
  const fieldValue = input.values[field.id] ?? null;
718
999
  const localError = input.touched?.[field.id] ? validateBookingField(field, fieldValue) : null;
@@ -738,10 +1019,17 @@ function deriveBookingFieldViews(input) {
738
1019
  });
739
1020
  }
740
1021
  function buildBookingSubmitPlan(input) {
1022
+ const refusal = appointmentQuestionsRefusal(input.bookingQuestions.presentation);
1023
+ if (refusal) return {
1024
+ ok: false,
1025
+ errors: createFormBookingValidationError(refusal),
1026
+ message: refusal
1027
+ };
741
1028
  const invalid = validateBookingSubmissionContact(input);
742
1029
  if (invalid) return invalid;
743
1030
  const prepared = prepareBookingSubmission({
744
1031
  shownTerms: input.shownTerms,
1032
+ bookingQuestions: input.bookingQuestions.submission,
745
1033
  promisedDiscountId: input.promisedDiscountId,
746
1034
  formId: input.formId,
747
1035
  nowIso: input.nowIso,
@@ -761,12 +1049,15 @@ function buildBookingSubmitPlan(input) {
761
1049
  }
762
1050
  return {
763
1051
  ok: true,
764
- redirect: input.redirect,
765
1052
  value: finalizeBookingSubmissionCommand(prepared.value, input)
766
1053
  };
767
1054
  }
768
1055
  function validateBookingSubmissionContact(input) {
769
- if (input.requiresResourceSelection && !(input.state.selectedResourceId ?? input.defaultResourceId)) {
1056
+ if (bookingRequiresResourceSelection(resolveBookingSelectedService({
1057
+ services: input.services,
1058
+ data: toBookingFormData(input.state),
1059
+ defaultServiceId: input.defaultServiceId
1060
+ }), input.requiresResourceSelection) && !(input.state.selectedResourceId ?? input.defaultResourceId)) {
770
1061
  const message = "Please select a practitioner";
771
1062
  return {
772
1063
  ok: false,
@@ -910,7 +1201,8 @@ function resolveAppointmentPackagesModel(input) {
910
1201
  value: items
911
1202
  },
912
1203
  items,
913
- selected
1204
+ selected,
1205
+ heldWithTeamMembers: input.heldWithTeamMembers ?? []
914
1206
  };
915
1207
  }
916
1208
  default: return assertNever(input.state);
@@ -1100,6 +1392,8 @@ function planBookingSubmissionStart(input) {
1100
1392
  ...input,
1101
1393
  shownTerms: input.intent.kind === "accept-review" ? input.intent.review.terms : void 0
1102
1394
  });
1395
+ const unanswered = planUnansweredBookingQuestions(input.bookingQuestions, plan);
1396
+ if (unanswered) return unanswered;
1103
1397
  return plan.ok ? {
1104
1398
  kind: "submit",
1105
1399
  plan,
@@ -1117,6 +1411,31 @@ function planBookingSubmissionStart(input) {
1117
1411
  }
1118
1412
  };
1119
1413
  }
1414
+ /** Point at unanswered questions before a round trip, alongside any other highlighted fields. */
1415
+ function planUnansweredBookingQuestions(bookingQuestions, plan) {
1416
+ const questions = checkBookingQuestionsAnswered(bookingQuestions);
1417
+ if (questions.kind !== "unanswered") return null;
1418
+ const failure = {
1419
+ message: questions.message,
1420
+ questionFieldErrors: questions.fieldErrors,
1421
+ answersNeeded: false
1422
+ };
1423
+ return {
1424
+ kind: "invalid",
1425
+ events: [...plan.ok ? [] : [{
1426
+ type: "validation-errors-set",
1427
+ errors: plan.errors
1428
+ }], {
1429
+ type: "submission-failed",
1430
+ failure
1431
+ }],
1432
+ result: {
1433
+ ok: false,
1434
+ reason: "submission-failed",
1435
+ ...failure
1436
+ }
1437
+ };
1438
+ }
1120
1439
  /** Reset from the same accepted resource facts as initial loading, scoped to the reset service. */
1121
1440
  function planBookingFlowReset(input) {
1122
1441
  const { initialState, resourceFacts } = input;
@@ -1142,7 +1461,7 @@ function planBookingPackageAcceptance(input) {
1142
1461
  }] : [];
1143
1462
  }
1144
1463
  function isBookingPaymentEvent(event) {
1145
- return event.type === "payment-option-selected" || event.type === "sliding-amount-changed" || event.type === "appointment-package-selected" || event.type === "discount-code-changed";
1464
+ return event.type === "payment-option-selected" || event.type === "sliding-amount-changed" || event.type === "appointment-package-selected" || event.type === "purchase-package-selected" || event.type === "discount-code-changed";
1146
1465
  }
1147
1466
  function applyBookingPaymentEvent(state, event) {
1148
1467
  const change = bookingPaymentEventChange(event);
@@ -1155,17 +1474,28 @@ function applyBookingPaymentEvent(state, event) {
1155
1474
  function bookingPaymentEventChange(event) {
1156
1475
  switch (event.type) {
1157
1476
  case "payment-option-selected": return {
1477
+ packagePurchase: { kind: "none" },
1158
1478
  selectedCollectionOptionKind: event.kind ?? void 0,
1159
1479
  selectedAppointmentPackageId: void 0
1160
1480
  };
1161
1481
  case "sliding-amount-changed": return {
1482
+ packagePurchase: { kind: "none" },
1162
1483
  selectedSlidingAmountInput: event.value,
1163
1484
  selectedAppointmentPackageId: void 0
1164
1485
  };
1165
1486
  case "appointment-package-selected": return {
1487
+ packagePurchase: { kind: "none" },
1166
1488
  selectedAppointmentPackageId: event.packageId ?? void 0,
1167
1489
  selectedCollectionOptionKind: void 0
1168
1490
  };
1491
+ case "purchase-package-selected": return {
1492
+ packagePurchase: event.package ? {
1493
+ kind: "selected",
1494
+ package: event.package
1495
+ } : { kind: "none" },
1496
+ selectedAppointmentPackageId: void 0,
1497
+ selectedCollectionOptionKind: void 0
1498
+ };
1169
1499
  case "discount-code-changed": return { discountCode: event.code };
1170
1500
  }
1171
1501
  }
@@ -1173,7 +1503,8 @@ function changesBookingIntent(event) {
1173
1503
  return changesBookingPaymentFacts(event) || [
1174
1504
  "field-updated",
1175
1505
  "discount-code-changed",
1176
- "appointment-package-selected"
1506
+ "appointment-package-selected",
1507
+ "purchase-package-selected"
1177
1508
  ].includes(event.type);
1178
1509
  }
1179
1510
  /** Applies server-owned recovery facts to the existing catalogue model. */
@@ -1183,8 +1514,16 @@ function applyBookingPaymentChoices(services, choices) {
1183
1514
  ...choices
1184
1515
  } : service) : services;
1185
1516
  }
1517
+ function validateBookingPackagePayment(input) {
1518
+ switch (resolveBookingPackagePaymentSelection(input.data, resolveBookingSelectedService(input))) {
1519
+ case "selected": return { ok: true };
1520
+ case "required": return bookingStepValidationFromMessage("Please choose a payment option");
1521
+ case "per_session": return null;
1522
+ }
1523
+ }
1186
1524
  //#endregion
1187
1525
  //#region ../blocks/src/system/runtime/hooks/useBookingChoices.ts
1526
+ const NO_PACKAGES = { packages: [] };
1188
1527
  /** Accept remote facts here; payment/navigation controllers do not own request lifetime. */
1189
1528
  function useBookingChoices(input) {
1190
1529
  const latest = useRef(input);
@@ -1197,9 +1536,23 @@ function useBookingChoices(input) {
1197
1536
  label: item.label
1198
1537
  }));
1199
1538
  }, [input.api]);
1200
- const loadPackages = useCallback(async (serviceId) => {
1201
- return (await input.api.getEligibleAppointmentPackages({ serviceId })).packages;
1202
- }, [input.api]);
1539
+ const loadPurchasablePackages = useCallback(async (_key) => {
1540
+ if (!input.serviceId) return [];
1541
+ return toBookingPurchasablePackages((await input.api.listPublicPasses({
1542
+ serviceId: input.serviceId,
1543
+ ...input.selectedResourceId ? { teamMemberId: input.selectedResourceId } : {}
1544
+ })).passes);
1545
+ }, [
1546
+ input.api,
1547
+ input.serviceId,
1548
+ input.selectedResourceId
1549
+ ]);
1550
+ const acceptPurchasablePackages = useCallback((packages) => {
1551
+ latest.current.dispatch({
1552
+ type: "purchasable-packages-received",
1553
+ packages
1554
+ });
1555
+ }, []);
1203
1556
  const acceptResources = useCallback((resources) => {
1204
1557
  const current = latest.current;
1205
1558
  current.dispatch({
@@ -1209,26 +1562,76 @@ function useBookingChoices(input) {
1209
1562
  autoSelect: current.autoSelectSingleResource
1210
1563
  });
1211
1564
  }, []);
1212
- const acceptPackages = useCallback((packages) => {
1213
- latest.current.dispatch({
1214
- type: "packages-received",
1215
- packages
1216
- });
1217
- }, []);
1218
1565
  const resources = useBookingChoicesRequest(input.serviceId ?? null, loadResources, acceptResources, "Failed to load booking resources.");
1219
- const packages = useBookingChoicesRequest(input.canLoadPackages ? input.serviceId ?? null : null, loadPackages, acceptPackages, "Could not check package credits.");
1566
+ const packagesResponse = useBookingPackageEligibility(input);
1567
+ const purchasablePackages = useBookingChoicesRequest(bookingPackageRequestKey(input.canLoadPurchasablePackages, input.serviceId, input.selectedResourceId), loadPurchasablePackages, acceptPurchasablePackages, "Failed to load packages.");
1220
1568
  useEffect(() => {
1221
- if (!input.canLoadPackages) acceptPackages([]);
1222
- }, [input.canLoadPackages, acceptPackages]);
1569
+ if (!input.canLoadPurchasablePackages) acceptPurchasablePackages([]);
1570
+ }, [input.canLoadPurchasablePackages, acceptPurchasablePackages]);
1223
1571
  return {
1224
1572
  resources,
1225
- packages,
1573
+ packages: useMemo(() => packagesResponse.tag === "loaded" ? {
1574
+ tag: "loaded",
1575
+ value: packagesResponse.value.packages
1576
+ } : packagesResponse, [packagesResponse]),
1577
+ purchasablePackages,
1578
+ heldPackageTeamMembers: packagesResponse.tag === "loaded" && !input.selectedResourceId ? packagesResponse.value.heldPackageTeamMembers ?? [] : [],
1226
1579
  resourceFacts: input.serviceId && resources.tag === "loaded" ? {
1227
1580
  serviceId: input.serviceId,
1228
1581
  resources: resources.value
1229
1582
  } : null
1230
1583
  };
1231
1584
  }
1585
+ /** Unscoped eligibility resolves practitioner admission independently of the selected practitioner. */
1586
+ function useBookingPackageEligibility(input) {
1587
+ const latest = useRef(input);
1588
+ useLayoutEffect(() => {
1589
+ latest.current = input;
1590
+ }, [input]);
1591
+ const loadAny = useCallback(async () => input.serviceId ? input.api.getEligibleAppointmentPackages({ serviceId: input.serviceId }) : NO_PACKAGES, [input.api, input.serviceId]);
1592
+ const loadScoped = useCallback(async () => input.serviceId && input.selectedResourceId ? input.api.getEligibleAppointmentPackages({
1593
+ serviceId: input.serviceId,
1594
+ teamMemberId: input.selectedResourceId
1595
+ }) : NO_PACKAGES, [
1596
+ input.api,
1597
+ input.serviceId,
1598
+ input.selectedResourceId
1599
+ ]);
1600
+ const accept = useCallback((response) => {
1601
+ latest.current.dispatch({
1602
+ type: "packages-received",
1603
+ packages: response.packages
1604
+ });
1605
+ }, []);
1606
+ const acceptAny = useCallback((response) => {
1607
+ const current = latest.current;
1608
+ current.dispatch({
1609
+ type: "unrestricted-held-packages-received",
1610
+ serviceId: response.packages.length ? current.serviceId : void 0
1611
+ });
1612
+ if (!current.selectedResourceId) accept(response);
1613
+ }, [accept]);
1614
+ const any = useBookingChoicesRequest(bookingPackageRequestKey(input.canLoadPackages, input.serviceId, null), loadAny, acceptAny, "Could not check package credits.");
1615
+ const scoped = useBookingChoicesRequest(bookingPackageRequestKey(input.canLoadPackages && !!input.selectedResourceId, input.serviceId, input.selectedResourceId), loadScoped, accept, "Could not check package credits.");
1616
+ useEffect(() => {
1617
+ if (!input.canLoadPackages) {
1618
+ accept(NO_PACKAGES);
1619
+ acceptAny(NO_PACKAGES);
1620
+ }
1621
+ }, [
1622
+ input.canLoadPackages,
1623
+ accept,
1624
+ acceptAny
1625
+ ]);
1626
+ useEffect(() => {
1627
+ if (!input.selectedResourceId && any.tag === "loaded") accept(any.value);
1628
+ }, [
1629
+ input.selectedResourceId,
1630
+ any,
1631
+ accept
1632
+ ]);
1633
+ return input.selectedResourceId ? scoped : any;
1634
+ }
1232
1635
  function useBookingChoicesRequest(key, load, accept, errorMessage) {
1233
1636
  const [receipt, setReceipt] = useState({
1234
1637
  key: null,
@@ -1278,7 +1681,6 @@ function useBookingChoicesRequest(key, load, accept, errorMessage) {
1278
1681
  function planBookingSubmissionCompletion(input) {
1279
1682
  const { data } = input;
1280
1683
  if (data.type === "review_required") return {
1281
- navigation: { kind: "none" },
1282
1684
  events: [{
1283
1685
  type: "review-required",
1284
1686
  review: data.review
@@ -1290,7 +1692,6 @@ function planBookingSubmissionCompletion(input) {
1290
1692
  }
1291
1693
  };
1292
1694
  if (data.type === "payment_choice_required") return {
1293
- navigation: { kind: "none" },
1294
1695
  events: [{
1295
1696
  type: "payment-choice-required",
1296
1697
  paymentChoices: data.paymentChoices
@@ -1308,10 +1709,6 @@ function planBookingSubmissionCompletion(input) {
1308
1709
  };
1309
1710
  if (data.type === "checkout_redirect") return {
1310
1711
  events: [],
1311
- navigation: input.redirect === "auto" ? {
1312
- kind: "checkout",
1313
- url: data.checkoutUrl
1314
- } : { kind: "none" },
1315
1712
  result: {
1316
1713
  ok: true,
1317
1714
  outcome: {
@@ -1323,7 +1720,6 @@ function planBookingSubmissionCompletion(input) {
1323
1720
  }
1324
1721
  };
1325
1722
  if (data.type === "requested") return {
1326
- navigation: { kind: "none" },
1327
1723
  events: [{
1328
1724
  type: "feedback-set",
1329
1725
  feedback: {
@@ -1348,7 +1744,6 @@ function planBookingSubmissionCompletion(input) {
1348
1744
  }
1349
1745
  };
1350
1746
  return {
1351
- navigation: { kind: "none" },
1352
1747
  events: [{
1353
1748
  type: "feedback-set",
1354
1749
  feedback: bookingSuccessFeedback(data, input.successMessage)
@@ -1377,7 +1772,6 @@ function bookingSuccessFeedback(data, successMessage) {
1377
1772
  function completeBookingSubmission(input) {
1378
1773
  const plan = planBookingSubmissionCompletion(input);
1379
1774
  plan.events.forEach(input.dispatch);
1380
- if (plan.navigation.kind === "checkout" && typeof window !== "undefined") input.navigateToCheckout(plan.navigation.url);
1381
1775
  return plan.result;
1382
1776
  }
1383
1777
  //#endregion
@@ -1400,6 +1794,14 @@ function useBookingFlowController(input) {
1400
1794
  }, [latestRef]);
1401
1795
  return useMemo(() => ({
1402
1796
  ...bookingEditActions(input.dispatch),
1797
+ selectPackageToBuy: (passId) => {
1798
+ const source = latestRef.current.purchasablePackages;
1799
+ const product = source.tag === "loaded" ? source.value.find((product) => product.id === passId) ?? null : null;
1800
+ input.dispatch({
1801
+ type: "purchase-package-selected",
1802
+ package: product
1803
+ });
1804
+ },
1403
1805
  next: async () => navigate("next"),
1404
1806
  back: () => {
1405
1807
  navigate("back");
@@ -1425,6 +1827,7 @@ function useBookingFlowController(input) {
1425
1827
  latestRef.current.setDiscountCode("");
1426
1828
  },
1427
1829
  reset: () => {
1830
+ latestRef.current.endSignInReturn?.();
1428
1831
  input.dispatch({
1429
1832
  type: "reset",
1430
1833
  initial: latestRef.current.resetState
@@ -1453,7 +1856,6 @@ function useBookingSubmitAction(latestRef) {
1453
1856
  ...latest.state,
1454
1857
  discountCode: latest.discountCode
1455
1858
  },
1456
- redirect: options?.redirect ?? "manual",
1457
1859
  successUrl: options?.successUrl,
1458
1860
  cancelUrl: options?.cancelUrl
1459
1861
  });
@@ -1482,12 +1884,14 @@ async function executeBookingSubmission(start, latest, latestRef) {
1482
1884
  reason: "blocked",
1483
1885
  message: "booking-details-changed"
1484
1886
  };
1485
- if (!result.ok) return failBookingSubmission(result.error, latest.dispatch);
1887
+ if (!result.ok) {
1888
+ if (result.error.answersNeeded) latest.bookingQuestions.keepRefused();
1889
+ return failBookingSubmission(result.error, latest.dispatch);
1890
+ }
1891
+ if (result.data.type !== "review_required" && result.data.type !== "payment_choice_required") latest.endSignInReturn?.();
1486
1892
  return completeBookingSubmission({
1487
1893
  data: result.data,
1488
- redirect: start.plan.redirect,
1489
1894
  successMessage: latest.successMessage,
1490
- navigateToCheckout: latest.navigateToCheckout,
1491
1895
  dispatch: latest.dispatch
1492
1896
  });
1493
1897
  }
@@ -1536,23 +1940,29 @@ function bookingEditActions(dispatch) {
1536
1940
  })
1537
1941
  };
1538
1942
  }
1539
- function failBookingSubmission(message, dispatch) {
1943
+ function failBookingSubmission(failure, dispatch) {
1540
1944
  dispatch({
1541
- type: "feedback-set",
1542
- feedback: {
1543
- kind: "error",
1544
- scope: "submission",
1545
- message
1546
- }
1945
+ type: "submission-failed",
1946
+ failure
1547
1947
  });
1548
1948
  return {
1549
1949
  ok: false,
1550
1950
  reason: "submission-failed",
1551
- message
1951
+ ...failure
1552
1952
  };
1553
1953
  }
1554
1954
  function sameBookingIntent(left, right) {
1555
- return left.selectedServiceId === right.selectedServiceId && left.selectedResourceId === right.selectedResourceId && left.selectedSlot?.key === right.selectedSlot?.key && left.selectedSlidingAmountInput === right.selectedSlidingAmountInput && left.selectedCollectionOptionKind === right.selectedCollectionOptionKind && left.selectedAppointmentPackageId === right.selectedAppointmentPackageId && left.discountCode === right.discountCode && left.fieldValues === right.fieldValues;
1955
+ return [
1956
+ left.selectedServiceId === right.selectedServiceId,
1957
+ left.selectedResourceId === right.selectedResourceId,
1958
+ left.selectedSlot?.key === right.selectedSlot?.key,
1959
+ left.selectedSlidingAmountInput === right.selectedSlidingAmountInput,
1960
+ left.selectedCollectionOptionKind === right.selectedCollectionOptionKind,
1961
+ left.selectedAppointmentPackageId === right.selectedAppointmentPackageId,
1962
+ left.packagePurchase === right.packagePurchase,
1963
+ left.discountCode === right.discountCode,
1964
+ left.fieldValues === right.fieldValues
1965
+ ].every(Boolean);
1556
1966
  }
1557
1967
  function isOutdatedBookingReview(result, submitted, current) {
1558
1968
  return result.ok && (result.data.type === "review_required" || result.data.type === "payment_choice_required") && !sameBookingIntent(submitted, current);
@@ -1584,14 +1994,19 @@ function useHeadlessBookingFlow(options) {
1584
1994
  options.services
1585
1995
  ]);
1586
1996
  const [state, dispatch] = useReducer((previous, event) => bookingFlowReducer(previous, event, {
1587
- services: applyBookingPaymentChoices(options.services, previous.paymentChoices),
1997
+ services: applyBookingPaymentAdmission(applyBookingPaymentChoices(options.services, previous.paymentChoices), Boolean(options.form?.settings?.requiresApproval), previous.unrestrictedHeldPackageServiceId),
1588
1998
  defaultServiceId,
1589
1999
  nowIso: bookingNowIso
1590
2000
  }), initialState);
1591
2001
  const api = useBlockApi();
1592
2002
  const selectedServiceId = state.selectedServiceId ?? defaultServiceId;
1593
2003
  const selectedResourceId = state.selectedResourceId ?? defaultResourceId;
1594
- const services = useMemo(() => applyBookingPaymentChoices(options.services, state.paymentChoices), [options.services, state.paymentChoices]);
2004
+ const services = useMemo(() => applyBookingPaymentAdmission(applyBookingPaymentChoices(options.services, state.paymentChoices), Boolean(options.form?.settings?.requiresApproval), state.unrestrictedHeldPackageServiceId), [
2005
+ options.services,
2006
+ options.form?.settings?.requiresApproval,
2007
+ state.paymentChoices,
2008
+ state.unrestrictedHeldPackageServiceId
2009
+ ]);
1595
2010
  const selectedService = services.find((service) => service.id === selectedServiceId) ?? null;
1596
2011
  const siteTerms = useSiteTermsAgreement({
1597
2012
  terms: options.siteTerms,
@@ -1601,33 +2016,48 @@ function useHeadlessBookingFlow(options) {
1601
2016
  }
1602
2017
  });
1603
2018
  const runtimeForm = useSelectedAppointmentConsentForm(options.form, selectedService);
1604
- const hasPortalBearerAuth = (api.config.authOverrides?.portal ?? api.config.auth).type === "bearer";
2019
+ const portalIdentity = portalSessionIdentity(api.config);
2020
+ const hasPortalBearerAuth = portalIdentity !== null;
2021
+ const questions = useAppointmentBookingQuestions({
2022
+ api,
2023
+ siteId: options.siteId,
2024
+ formId: options.formId,
2025
+ state,
2026
+ selectedService,
2027
+ identity: portalIdentity,
2028
+ dispatch
2029
+ });
2030
+ const questionsRefusal = appointmentQuestionsRefusal(questions.presentation);
2031
+ const requiresResourceSelection = bookingRequiresResourceSelection(selectedService, options.requiresResourceSelection);
2032
+ const packageSources = resolveBookingPackageSources(selectedService, Boolean(options.enableAppointmentPackages), hasPortalBearerAuth);
2033
+ const { packageOnly, canBuy: canLoadPurchasablePackages } = packageSources;
1605
2034
  const selectedServiceSlidingScale = getBookingServiceSlidingScale(selectedService);
1606
2035
  const selectedSlidingAmount = parseBookingCurrencyInputToCents(state.selectedSlidingAmountInput);
1607
2036
  const selectedAppointmentPriceAmount = selectedServiceSlidingScale && selectedSlidingAmount !== null ? selectedSlidingAmount : selectedService?.priceAmount ?? 0;
1608
- const canLoadAppointmentPackages = Boolean(options.enableAppointmentPackages && hasPortalBearerAuth && selectedService && !selectedServiceSlidingScale && (selectedService.priceAmount ?? 0) > 0);
1609
- const appointmentPackagesUnavailableReason = !options.enableAppointmentPackages ? "disabled" : !selectedService || selectedServiceSlidingScale || (selectedService.priceAmount ?? 0) <= 0 ? "missing-priced-service" : !hasPortalBearerAuth ? "missing-portal-auth" : null;
2037
+ const canLoadAppointmentPackages = packageSources.held === "enabled";
2038
+ const appointmentPackagesUnavailableReason = packageSources.held === "enabled" ? null : packageSources.held;
1610
2039
  const data = useMemo(() => toBookingFormData(state), [state]);
1611
2040
  const mailingList = resolveBookingSignupOffer(options.mailingList, options.siteName);
1612
2041
  const mailingListEligible = mailingList !== null;
2042
+ const availabilityServiceId = requiresResourceSelection && !selectedResourceId ? void 0 : selectedServiceId;
1613
2043
  const availabilityDatesQuery = useMemo(() => buildBookingAvailabilityQuery({
1614
- serviceId: selectedServiceId,
2044
+ serviceId: availabilityServiceId,
1615
2045
  resourceId: selectedResourceId,
1616
2046
  timezone: availabilityTimeZone
1617
2047
  }), [
1618
2048
  selectedResourceId,
1619
- selectedServiceId,
2049
+ availabilityServiceId,
1620
2050
  availabilityTimeZone
1621
2051
  ]);
1622
2052
  const availabilitySlotsQuery = useMemo(() => buildBookingAvailabilityQuery({
1623
- serviceId: selectedServiceId,
2053
+ serviceId: availabilityServiceId,
1624
2054
  resourceId: selectedResourceId,
1625
2055
  selectedDate: state.selectedDate,
1626
2056
  timezone: availabilityTimeZone,
1627
2057
  requireDate: true
1628
2058
  }), [
1629
2059
  selectedResourceId,
1630
- selectedServiceId,
2060
+ availabilityServiceId,
1631
2061
  state.selectedDate,
1632
2062
  availabilityTimeZone
1633
2063
  ]);
@@ -1641,10 +2071,12 @@ function useHeadlessBookingFlow(options) {
1641
2071
  defaultResourceId,
1642
2072
  currentStepId: state.currentStepId,
1643
2073
  requiresServiceSelection: options.requiresServiceSelection,
1644
- requiresResourceSelection: options.requiresResourceSelection,
2074
+ requiresResourceSelection,
1645
2075
  enableAppointmentPackages: options.enableAppointmentPackages,
1646
- attemptedStepIds: state.attemptedStepIds
2076
+ attemptedStepIds: state.attemptedStepIds,
2077
+ questionsRefusal
1647
2078
  }), [
2079
+ questionsRefusal,
1648
2080
  data,
1649
2081
  bookingNowIso,
1650
2082
  state.attemptedStepIds,
@@ -1652,7 +2084,7 @@ function useHeadlessBookingFlow(options) {
1652
2084
  defaultResourceId,
1653
2085
  options.enableAppointmentPackages,
1654
2086
  runtimeForm,
1655
- options.requiresResourceSelection,
2087
+ requiresResourceSelection,
1656
2088
  options.requiresServiceSelection,
1657
2089
  services,
1658
2090
  state.paymentChoices,
@@ -1720,21 +2152,32 @@ function useHeadlessBookingFlow(options) {
1720
2152
  const choices = useBookingChoices({
1721
2153
  api,
1722
2154
  serviceId: selectedServiceId,
2155
+ selectedResourceId: selectedResourceId ?? null,
1723
2156
  defaultResourceId,
1724
2157
  canLoadPackages: canLoadAppointmentPackages,
2158
+ canLoadPurchasablePackages,
1725
2159
  autoSelectSingleResource: options.shouldAutoSelectSingleResource !== false,
1726
2160
  dispatch
1727
2161
  });
1728
2162
  const resourcesState = choices.resources;
1729
2163
  const appointmentPackages = choices.packages;
1730
2164
  const resources = resourcesState.tag === "loaded" ? resourcesState.value : [];
2165
+ const purchase = state.packagePurchase;
2166
+ const paymentPriceAmount = purchase.kind === "selected" ? purchase.package.price : selectedAppointmentPriceAmount;
1731
2167
  const discountUi = useDiscountCodeUi({
1732
2168
  api,
1733
- discountContext: useMemo(() => selectedService && selectedAppointmentPriceAmount > 0 ? {
2169
+ discountContext: useMemo(() => purchase.kind === "selected" ? {
2170
+ type: "pass",
2171
+ passId: purchase.package.id
2172
+ } : selectedService && selectedAppointmentPriceAmount > 0 ? {
1734
2173
  type: "appointment",
1735
2174
  serviceId: selectedService.id
1736
- } : null, [selectedAppointmentPriceAmount, selectedService?.id]),
1737
- subtotalCents: selectedAppointmentPriceAmount
2175
+ } : null, [
2176
+ purchase,
2177
+ selectedAppointmentPriceAmount,
2178
+ selectedService?.id
2179
+ ]),
2180
+ subtotalCents: paymentPriceAmount
1738
2181
  });
1739
2182
  const { submit, clearFeedback } = useBookingSubmission(options.siteId, siteTerms);
1740
2183
  const actions = useBookingFlowController({
@@ -1744,9 +2187,10 @@ function useHeadlessBookingFlow(options) {
1744
2187
  formId: formKey,
1745
2188
  services,
1746
2189
  promisedDiscountId: resolveDisclosedBookingDiscountId(discountUi),
2190
+ purchasablePackages: choices.purchasablePackages,
1747
2191
  defaultServiceId,
1748
2192
  defaultResourceId,
1749
- requiresResourceSelection: options.requiresResourceSelection,
2193
+ requiresResourceSelection,
1750
2194
  successMessage: options.successMessage,
1751
2195
  viewerTimeZone,
1752
2196
  discountCode: discountUi.discountCode,
@@ -1754,7 +2198,6 @@ function useHeadlessBookingFlow(options) {
1754
2198
  requireSiteTerms: siteTerms.requireAgreement,
1755
2199
  clearFeedback,
1756
2200
  setDiscountCode: discountUi.setDiscountCode,
1757
- navigateToCheckout: options.navigateToCheckout ?? navigateToCheckout,
1758
2201
  steps: stepState.steps,
1759
2202
  currentStep: stepState.currentStep,
1760
2203
  currentStepIndex: stepState.currentStepIndex,
@@ -1766,6 +2209,8 @@ function useHeadlessBookingFlow(options) {
1766
2209
  autoSelect: options.shouldAutoSelectSingleResource !== false
1767
2210
  }),
1768
2211
  mailingListEligible,
2212
+ bookingQuestions: questions,
2213
+ endSignInReturn: questions.endSignInReturn,
1769
2214
  dispatch
1770
2215
  });
1771
2216
  const paymentResolution = stepState.paymentResolution;
@@ -1786,7 +2231,7 @@ function useHeadlessBookingFlow(options) {
1786
2231
  const paymentConfirmationSummary = resolveBookingPaymentConfirmationSummary({
1787
2232
  service: selectedService,
1788
2233
  priceAmount: selectedAppointmentPriceAmount,
1789
- hasSelectedAppointmentPackage: Boolean(state.selectedAppointmentPackageId),
2234
+ hasSelectedAppointmentPackage: Boolean(state.selectedAppointmentPackageId) || purchase.kind === "selected",
1790
2235
  paymentResolution
1791
2236
  });
1792
2237
  const availabilityDisplay = resolveBookingFormDateDisplay({
@@ -1805,14 +2250,22 @@ function useHeadlessBookingFlow(options) {
1805
2250
  feedback: state.feedback
1806
2251
  });
1807
2252
  const appointmentPackagesModel = resolveAppointmentPackagesModel({
1808
- enabled: Boolean(options.enableAppointmentPackages),
2253
+ enabled: packageSources.held !== "disabled",
1809
2254
  canLoad: canLoadAppointmentPackages,
1810
2255
  unavailableReason: appointmentPackagesUnavailableReason,
1811
2256
  state: appointmentPackages,
1812
2257
  items: appointmentPackageItems,
1813
- selected: selectedAppointmentPackage
2258
+ selected: selectedAppointmentPackage,
2259
+ heldWithTeamMembers: choices.heldPackageTeamMembers
1814
2260
  });
1815
- const payment = paymentResolution.kind === "unavailable" ? {
2261
+ const purchasablePackages = resolveBookingPurchasablePackages(canLoadPurchasablePackages, choices.purchasablePackages);
2262
+ const packagePaymentModel = {
2263
+ choice: resolveBookingPaymentChoice(state.packagePurchase, state.selectedAppointmentPackageId, packageOnly ? void 0 : selectedCollectionOptionKind),
2264
+ purchasablePackages,
2265
+ availability: resolveBookingPaymentAvailability(!packageOnly && paymentResolution.kind !== "unavailable", appointmentPackagesModel, purchasablePackages)
2266
+ };
2267
+ const payment = paymentResolution.kind === "unavailable" && packagePaymentModel.availability.kind === "no_choices" ? {
2268
+ ...packagePaymentModel,
1816
2269
  kind: "unsupported",
1817
2270
  mode: "unsupported",
1818
2271
  selection: null,
@@ -1825,8 +2278,9 @@ function useHeadlessBookingFlow(options) {
1825
2278
  errorMessage: paymentResolution.errorMessage,
1826
2279
  confirmationSummary: null
1827
2280
  } : {
2281
+ ...packagePaymentModel,
1828
2282
  kind: "ok",
1829
- mode: paymentResolution.mode,
2283
+ mode: resolveBookingPaymentMode(selectedService, paymentResolution),
1830
2284
  selection: paymentSelection,
1831
2285
  selectedCollectionOptionKind,
1832
2286
  selectedAppointmentPackageId: state.selectedAppointmentPackageId,
@@ -1860,7 +2314,8 @@ function useHeadlessBookingFlow(options) {
1860
2314
  selected: resources.find((resource) => resource.id === selectedResourceId) ?? null,
1861
2315
  selectedResourceId,
1862
2316
  state: resourcesState,
1863
- requiresSelection: Boolean(options.requiresResourceSelection)
2317
+ requiresSelection: requiresResourceSelection,
2318
+ configuredRequiresSelection: Boolean(options.requiresResourceSelection)
1864
2319
  },
1865
2320
  availability: {
1866
2321
  selectedDate: state.selectedDate,
@@ -1906,6 +2361,8 @@ function useHeadlessBookingFlow(options) {
1906
2361
  clear: actions.clearDiscountCode
1907
2362
  },
1908
2363
  feedback: state.feedback,
2364
+ questions,
2365
+ questionFieldErrors: state.questionFieldErrors,
1909
2366
  actions
1910
2367
  };
1911
2368
  }
@@ -1913,9 +2370,6 @@ const EMPTY_SERVICE_CATEGORIES = [];
1913
2370
  function readServiceCategories(options) {
1914
2371
  return options.serviceCategories ?? EMPTY_SERVICE_CATEGORIES;
1915
2372
  }
1916
- function navigateToCheckout(checkoutUrl) {
1917
- window.location.href = checkoutUrl;
1918
- }
1919
2373
  function resolveDisclosedBookingDiscountId(discount) {
1920
2374
  return discount.discountsAvailableLoading || discount.discountCode.trim() ? void 0 : discount.autoAppliedDiscount?.id;
1921
2375
  }
@@ -1974,14 +2428,12 @@ function useAppointmentCheckoutVerificationWithDeps(config, deps) {
1974
2428
  * states. Selection uses button-toggle semantics: each pill is a button with
1975
2429
  * aria-pressed and a full accessible date name, inside a labelled group.
1976
2430
  */
1977
- function DateFieldLabel({ labelId, required }) {
1978
- return /* @__PURE__ */ jsxs("span", {
2431
+ /** Required state is on the grid (aria-required); the label carries no asterisk. */
2432
+ function DateFieldLabel({ labelId }) {
2433
+ return /* @__PURE__ */ jsx("span", {
1979
2434
  className: "form-label",
1980
2435
  id: labelId,
1981
- children: ["Select Date", required && /* @__PURE__ */ jsx("span", {
1982
- className: "required-marker",
1983
- children: "*"
1984
- })]
2436
+ children: "Select Date"
1985
2437
  });
1986
2438
  }
1987
2439
  /** Focus is the only effect: newly loaded dates continue keyboard selection. */
@@ -2077,10 +2529,7 @@ const DatePicker = (props) => {
2077
2529
  return /* @__PURE__ */ jsxs("div", {
2078
2530
  className: "rb-reg-stack rb-reg-stack--sm",
2079
2531
  children: [
2080
- /* @__PURE__ */ jsx(DateFieldLabel, {
2081
- labelId,
2082
- required
2083
- }),
2532
+ /* @__PURE__ */ jsx(DateFieldLabel, { labelId }),
2084
2533
  state === "loading" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", { className: "rb-shell-block" }), /* @__PURE__ */ jsx("p", {
2085
2534
  className: "ab-text ab-text--sm rb-on-surface--muted",
2086
2535
  children: "Loading available dates..."
@@ -2146,13 +2595,10 @@ const TimeSlotSelector = ({ value, onChange, slots, isLoading, dateContext, zone
2146
2595
  return /* @__PURE__ */ jsxs("div", {
2147
2596
  className: "rb-reg-stack rb-reg-stack--sm",
2148
2597
  children: [
2149
- /* @__PURE__ */ jsxs("span", {
2598
+ /* @__PURE__ */ jsx("span", {
2150
2599
  className: "form-label",
2151
2600
  id: labelId,
2152
- children: ["Select Time", required && /* @__PURE__ */ jsx("span", {
2153
- className: "required-marker",
2154
- children: "*"
2155
- })]
2601
+ children: "Select Time"
2156
2602
  }),
2157
2603
  /* @__PURE__ */ jsx(TimeSlotZoneNote, {
2158
2604
  id: noteId,
@@ -2183,25 +2629,6 @@ const TimeSlotSelector = ({ value, onChange, slots, isLoading, dateContext, zone
2183
2629
  });
2184
2630
  };
2185
2631
  //#endregion
2186
- //#region ../blocks/src/system/runtime/nodes/booking-form.mailing-list-choice.tsx
2187
- function BookingMailingListChoice({ booking }) {
2188
- const id = React.useId();
2189
- if (!booking.mailingList) return null;
2190
- return /* @__PURE__ */ jsxs("div", {
2191
- className: "rb-space-y-2",
2192
- children: [/* @__PURE__ */ jsx(CheckboxChoice, {
2193
- id,
2194
- name: "mailingListOptIn",
2195
- checked: booking.mailingListOptIn,
2196
- onChange: (event) => booking.actions.setMailingListOptIn(event.target.checked),
2197
- label: `Email me news and updates from ${booking.mailingList.siteName}.`
2198
- }), /* @__PURE__ */ jsx("p", {
2199
- className: "rb-caption status-muted",
2200
- children: "Optional. You can unsubscribe at any time."
2201
- })]
2202
- });
2203
- }
2204
- //#endregion
2205
2632
  //#region ../blocks/src/system/runtime/nodes/booking-form.service-choices.tsx
2206
2633
  function optionCardClassName(isSelected) {
2207
2634
  return `rb-option-card${isSelected ? " rb-option-card--selected" : ""}`;
@@ -2224,15 +2651,9 @@ function DefaultServiceChoices({ booking }) {
2224
2651
  categoryId: service.categoryId ?? null
2225
2652
  })), { keepEmptyGroups: false });
2226
2653
  switch (layout.kind) {
2227
- case "uncategorized-site": return /* @__PURE__ */ jsxs("div", {
2228
- className: "rb-reg-stack rb-reg-stack--sm",
2229
- children: [/* @__PURE__ */ jsx("span", {
2230
- className: "ab-subtitle",
2231
- children: "Service"
2232
- }), /* @__PURE__ */ jsx(ServiceChoiceGrid, {
2233
- booking,
2234
- choices: layout.services
2235
- })]
2654
+ case "uncategorized-site": return /* @__PURE__ */ jsx(ServiceChoiceGrid, {
2655
+ booking,
2656
+ choices: layout.services
2236
2657
  });
2237
2658
  case "categorized-site": return /* @__PURE__ */ jsx("div", {
2238
2659
  className: "rb-reg-stack",
@@ -2295,7 +2716,7 @@ function ServiceChoiceGrid({ booking, choices }) {
2295
2716
  //#region ../blocks/src/system/runtime/nodes/booking-form.submit-actions.tsx
2296
2717
  function resolvePrimaryActionLabel(isLastStep, requiresPayment) {
2297
2718
  if (!isLastStep) return "Continue";
2298
- return requiresPayment ? "Continue to payment" : "Complete";
2719
+ return requiresPayment ? "Continue to payment" : "Confirm booking";
2299
2720
  }
2300
2721
  /** Only the date step and explicit review identity display the selected stored slot. */
2301
2722
  function resolveBookingConfirmationSlot(booking, includeSelection) {
@@ -2435,64 +2856,540 @@ function BookingReviewIdentity({ booking }) {
2435
2856
  });
2436
2857
  }
2437
2858
  //#endregion
2438
- //#region ../blocks/src/system/runtime/nodes/booking-form.default-ui.tsx
2439
- function formatBookingAmount(amount, currency) {
2440
- return formatCurrencyAmount(amount, currency, { decimals: "auto" });
2859
+ //#region ../blocks/src/system/runtime/nodes/booking-form.payment-packages.tsx
2860
+ /** Copy for one package the client can buy and use for this booking. */
2861
+ function purchasablePackageRowCopy(item, serviceTitle) {
2862
+ const heldWith = item.heldWithTeamMember;
2863
+ const sessions = item.creditsTotal === 1 ? "1 session" : `${item.creditsTotal} sessions`;
2864
+ return {
2865
+ label: heldWith ? `${item.name} with ${heldWith.name}` : item.name,
2866
+ details: [
2867
+ `${sessions}. This booking uses one.`,
2868
+ heldWith ? `Use them with ${heldWith.name}.` : `Use them with anyone who offers ${serviceTitle}.`,
2869
+ ...item.validDays ? [`${formatValidity(item.validDays)} from when you buy it.`] : []
2870
+ ],
2871
+ price: formatCurrencyAmount(item.price, item.currency, { decimals: "auto" })
2872
+ };
2441
2873
  }
2442
- function HeadlessBookingDefaultForm({ booking, onSubmit }) {
2443
- const currentStep = booking.currentStep;
2444
- const errorSummaryId = React.useId();
2445
- const currentStepIndex = currentStep?.visibleIndex ?? 0;
2446
- if (!currentStep) return /* @__PURE__ */ jsx("div", {
2447
- className: "rb-text-center rb-py-12",
2448
- children: /* @__PURE__ */ jsx("p", {
2449
- className: "status-muted",
2450
- children: "No steps available"
2451
- })
2452
- });
2874
+ function heldPackageRows(booking) {
2875
+ return booking.payment.appointmentPackages.items.map((held) => ({
2876
+ id: held.customerPassId,
2877
+ label: held.passName,
2878
+ details: ["Use 1 package credit", `Balance: ${held.creditsRemaining} of ${held.creditsTotal} credits remaining`],
2879
+ price: "1 credit",
2880
+ selected: booking.payment.choice.kind === "held_package" && booking.payment.choice.customerPassId === held.customerPassId,
2881
+ onSelect: () => booking.actions.selectAppointmentPackage(held.customerPassId)
2882
+ }));
2883
+ }
2884
+ function purchasableItems(payment) {
2885
+ return payment.purchasablePackages.kind === "ready" ? payment.purchasablePackages.items : [];
2886
+ }
2887
+ function hasPurchasablePackages(payment) {
2888
+ return purchasableItems(payment).length > 0;
2889
+ }
2890
+ /** "Or buy a package and use it now", below the other ways to pay. */
2891
+ function PurchasablePackageChoices(props) {
2892
+ const { payment, actions } = props.booking;
2893
+ const items = purchasableItems(payment);
2894
+ if (items.length === 0) return null;
2895
+ const heading = props.hasOtherChoices ? "Or buy a package and use it now" : "Buy a package to book this";
2453
2896
  return /* @__PURE__ */ jsxs("div", {
2454
- className: "multi-step-form",
2455
- children: [
2456
- booking.steps.length > 1 ? /* @__PURE__ */ jsx(StepIndicator, {
2457
- currentStep: currentStepIndex + 1,
2458
- totalSteps: booking.steps.length,
2459
- stepLabels: booking.steps.map((step) => step.label),
2460
- emitSharedClasses: true
2461
- }) : null,
2462
- /* @__PURE__ */ jsx("div", {
2463
- className: "step-content",
2464
- children: /* @__PURE__ */ jsx(DefaultBookingStepContent, {
2465
- booking,
2466
- errorSummaryId
2467
- })
2468
- }),
2469
- /* @__PURE__ */ jsx(DefaultBookingErrorSummary, {
2470
- errors: currentStep.errors,
2471
- id: errorSummaryId
2472
- }),
2473
- /* @__PURE__ */ jsx(BookingFormSubmitActions, {
2474
- booking,
2475
- onSubmit
2476
- }),
2477
- /* @__PURE__ */ jsx(DefaultBookingDiscount, { booking }),
2478
- /* @__PURE__ */ jsx(DefaultBookingFeedback, { booking })
2479
- ]
2897
+ className: "rb-reg-stack rb-reg-stack--sm",
2898
+ children: [/* @__PURE__ */ jsx("span", {
2899
+ className: "ab-subtitle",
2900
+ children: heading
2901
+ }), /* @__PURE__ */ jsx(PaymentChoiceRows, {
2902
+ label: heading,
2903
+ rows: items.map((item) => ({
2904
+ id: item.id,
2905
+ ...purchasablePackageRowCopy(item, props.serviceTitle),
2906
+ selected: payment.choice.kind === "buy_package" && payment.choice.package.id === item.id,
2907
+ onSelect: () => actions.selectPackageToBuy(item.id)
2908
+ }))
2909
+ })]
2480
2910
  });
2481
2911
  }
2482
- function DefaultBookingStepContent({ booking, errorSummaryId }) {
2483
- const stepId = booking.currentStep?.id;
2484
- if (!stepId) return null;
2485
- switch (stepId) {
2486
- case "service-selection": return /* @__PURE__ */ jsx(DefaultServiceSelectionStep, { booking });
2487
- case "datetime-selection": return /* @__PURE__ */ jsx(DefaultDateTimeSelectionStep, {
2488
- booking,
2489
- errorSummaryId
2912
+ /** Explains a packages-only service while packages load, or when there's nothing to use or buy. */
2913
+ function PackagePaymentAvailabilityNotice(props) {
2914
+ switch (props.payment.availability.kind) {
2915
+ case "available": return null;
2916
+ case "loading": return /* @__PURE__ */ jsx(FeedbackMessage, {
2917
+ tone: "info",
2918
+ className: "alert alert-info",
2919
+ role: "status",
2920
+ children: "Checking packages..."
2490
2921
  });
2491
- case "payment-selection": return /* @__PURE__ */ jsx(HeadlessBookingPaymentSelectionStep, { booking });
2492
- case "custom-fields": return /* @__PURE__ */ jsx(DefaultDynamicFields, {
2922
+ case "load_error": return /* @__PURE__ */ jsx(FeedbackMessage, {
2923
+ tone: "error",
2924
+ className: "alert alert-error",
2925
+ role: "alert",
2926
+ children: "We couldn't load the packages for this booking. Please try again in a moment."
2927
+ });
2928
+ case "no_choices": return /* @__PURE__ */ jsx(FeedbackMessage, {
2929
+ tone: "info",
2930
+ className: "alert alert-info",
2931
+ role: "status",
2932
+ children: "You need a package to book this, and there isn't one you can buy online at the moment. Please get in touch and we'll help you book."
2933
+ });
2934
+ }
2935
+ }
2936
+ //#endregion
2937
+ //#region ../blocks/src/system/runtime/nodes/booking-form.mailing-list-choice.tsx
2938
+ function BookingMailingListChoice({ booking }) {
2939
+ const id = React.useId();
2940
+ if (!booking.mailingList) return null;
2941
+ return /* @__PURE__ */ jsxs("div", {
2942
+ className: "rb-space-y-2",
2943
+ children: [/* @__PURE__ */ jsx(CheckboxChoice, {
2944
+ id,
2945
+ name: "mailingListOptIn",
2946
+ checked: booking.mailingListOptIn,
2947
+ onChange: (event) => booking.actions.setMailingListOptIn(event.target.checked),
2948
+ label: `Email me news and updates from ${booking.mailingList.siteName}.`
2949
+ }), /* @__PURE__ */ jsx("p", {
2950
+ className: "rb-caption status-muted",
2951
+ children: "Optional. You can unsubscribe at any time."
2952
+ })]
2953
+ });
2954
+ }
2955
+ //#endregion
2956
+ //#region ../blocks/src/system/runtime/nodes/booking-form.details-step.tsx
2957
+ /**
2958
+ * The appointment form's "Your details" step: a recap of the chosen service
2959
+ * and time, the site form's fields, the service's during-booking questions,
2960
+ * then consent and the site's terms.
2961
+ */
2962
+ /**
2963
+ * The chosen service and time at the top of the details step, with a way back
2964
+ * to change them. "Change" goes to the first step that holds the choice.
2965
+ */
2966
+ function BookingDetailsRecap({ booking }) {
2967
+ const service = booking.services.selected;
2968
+ const slot = booking.availability.selectedSlot;
2969
+ if (!service || !slot) return null;
2970
+ const when = formatRecapTime(booking, slot);
2971
+ const practitioner = booking.resources.selected?.label ?? slot.resourceName ?? null;
2972
+ const changeStep = booking.steps.find((step) => step.id === "service-selection" || step.id === "datetime-selection");
2973
+ return /* @__PURE__ */ jsxs("div", {
2974
+ className: "rb-reg-summary rb-flex rb-items-start rb-justify-between rb-gap-4",
2975
+ children: [/* @__PURE__ */ jsxs("div", {
2976
+ className: "rb-flex-1",
2977
+ children: [/* @__PURE__ */ jsxs("p", {
2978
+ className: "ab-subtitle",
2979
+ children: [service.title, service.durationMinutes ? `, ${service.durationMinutes} minutes` : ""]
2980
+ }), when ? /* @__PURE__ */ jsxs("p", {
2981
+ className: "ab-text rb-on-surface--muted",
2982
+ children: [when, practitioner ? `, with ${practitioner}` : ""]
2983
+ }) : null]
2984
+ }), changeStep ? /* @__PURE__ */ jsx("button", {
2985
+ type: "button",
2986
+ className: "rb-bq-link",
2987
+ onClick: () => {
2988
+ booking.actions.goToStep(changeStep.id);
2989
+ },
2990
+ children: "Change"
2991
+ }) : null]
2992
+ });
2993
+ }
2994
+ function formatRecapTime(booking, slot) {
2995
+ const start = parseUtcIsoDateTimeString(slot.startAt);
2996
+ const end = parseUtcIsoDateTimeString(slot.endAt);
2997
+ return start.ok && end.ok && end.value >= start.value ? formatDateTimeRange({
2998
+ start: start.value,
2999
+ end: end.value
3000
+ }, booking.availability.dateContext, {
3001
+ date: "long",
3002
+ zone: booking.availability.zone
3003
+ }) : null;
3004
+ }
3005
+ function DefaultBookingDetailsStep({ booking }) {
3006
+ return /* @__PURE__ */ jsxs("div", {
3007
+ className: "rb-reg-stack",
3008
+ children: [/* @__PURE__ */ jsx(BookingDetailsRecap, { booking }), /* @__PURE__ */ jsx(DefaultDynamicFields, {
2493
3009
  fields: booking.fields.items,
2494
3010
  booking
3011
+ })]
3012
+ });
3013
+ }
3014
+ function DefaultDynamicFields({ booking, fields }) {
3015
+ const lastContactIndex = fields.reduce((last, field, index) => [
3016
+ "name",
3017
+ "email",
3018
+ "phone"
3019
+ ].includes(field.id) ? index : last, -1);
3020
+ const formFields = fields.filter((field) => field.field.type !== "booking_requirement_consent");
3021
+ const consentFields = fields.filter((field) => field.field.type === "booking_requirement_consent");
3022
+ return /* @__PURE__ */ jsxs("div", {
3023
+ className: "rb-space-y-6",
3024
+ children: [
3025
+ /* @__PURE__ */ jsx(SiteTermsChangedNotice, { message: booking.siteTerms.notice }),
3026
+ formFields.map((field, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsx(DefaultDynamicField, {
3027
+ booking,
3028
+ field
3029
+ }), index === lastContactIndex && booking.mailingList ? /* @__PURE__ */ jsx(BookingMailingListChoice, { booking }) : null] }, field.id)),
3030
+ /* @__PURE__ */ jsx(DefaultBookingQuestions, { booking }),
3031
+ consentFields.map((field) => /* @__PURE__ */ jsx(DefaultDynamicField, {
3032
+ booking,
3033
+ field
3034
+ }, field.id)),
3035
+ /* @__PURE__ */ jsx(SiteTermsAgreementField, {
3036
+ agreement: booking.siteTerms.view,
3037
+ onChange: booking.siteTerms.onChange,
3038
+ error: booking.siteTerms.error,
3039
+ disabled: booking.siteTerms.disabled,
3040
+ requiredMark: "none"
3041
+ })
3042
+ ]
3043
+ });
3044
+ }
3045
+ /** The selected service's during-booking questions: after the site form's fields, before consent. */
3046
+ function DefaultBookingQuestions({ booking }) {
3047
+ const questions = booking.questions;
3048
+ const email = booking.fields.values.email;
3049
+ return /* @__PURE__ */ jsx(BookingQuestionSections, {
3050
+ presentation: questions.presentation,
3051
+ values: questions.values,
3052
+ fieldErrors: questions.fieldErrors,
3053
+ onChange: questions.answer,
3054
+ answerMode: questions.answerMode,
3055
+ onAnswerModeChange: questions.chooseAnswerMode,
3056
+ signInEmail: typeof email === "string" && email.trim() ? email.trim() : void 0,
3057
+ signInReturnPath: questions.signInReturnPath,
3058
+ disabled: booking.status.tag === "submitting"
3059
+ });
3060
+ }
3061
+ /** Radios and multi-choice checkboxes answer one question with several controls, so they're a named group. */
3062
+ function isChoiceGroupField(field) {
3063
+ return field.type === "radio" || field.type === "checkbox" && (field.options?.length ?? 0) > 1;
3064
+ }
3065
+ function DefaultDynamicField({ booking, field }) {
3066
+ const error = field.error;
3067
+ const errorId = error ? field.errorId ?? `${field.inputId}-error` : `${field.inputId}-error`;
3068
+ const describedBy = [field.helpTextId, error ? errorId : null].filter(Boolean).join(" ") || void 0;
3069
+ return /* @__PURE__ */ jsxs(DynamicFieldFrame, {
3070
+ field,
3071
+ describedBy,
3072
+ children: [
3073
+ /* @__PURE__ */ jsx(DynamicFieldLabel, { field }),
3074
+ field.helpText ? /* @__PURE__ */ jsx("p", {
3075
+ id: field.helpTextId ?? void 0,
3076
+ className: "rb-caption status-muted",
3077
+ children: field.helpText
3078
+ }) : null,
3079
+ /* @__PURE__ */ jsx(DefaultFieldInput, {
3080
+ field,
3081
+ value: field.value ?? "",
3082
+ onChange: (nextValue) => booking.actions.updateField(field.id, nextValue),
3083
+ onBlur: () => booking.actions.markFieldTouched(field.id),
3084
+ error,
3085
+ errorId,
3086
+ describedBy
3087
+ }),
3088
+ error ? /* @__PURE__ */ jsx(FieldValidationMessage, {
3089
+ id: errorId,
3090
+ className: "rb-caption status-error",
3091
+ children: error
3092
+ }) : null
3093
+ ]
3094
+ });
3095
+ }
3096
+ /** A choice group is a fieldset whose legend is the question, as in the shared question fields. */
3097
+ function DynamicFieldFrame({ children, describedBy, field }) {
3098
+ if (!isChoiceGroupField(field.field)) return /* @__PURE__ */ jsx("div", {
3099
+ className: "rb-space-y-2",
3100
+ children
3101
+ });
3102
+ return /* @__PURE__ */ jsx("fieldset", {
3103
+ className: "rb-space-y-2 rb-border-0 rb-p-0 rb-m-0 rb-min-w-0",
3104
+ "aria-describedby": describedBy,
3105
+ ...field.field.type === "radio" ? {
3106
+ role: "radiogroup",
3107
+ ...field.required ? { "aria-required": true } : {}
3108
+ } : {},
3109
+ children
3110
+ });
3111
+ }
3112
+ /** Optional fields say so and required ones carry no mark, matching the question fields beside them. */
3113
+ function DynamicFieldLabel({ field }) {
3114
+ if (field.field.type === "booking_requirement_consent") return /* @__PURE__ */ jsx(BookingConsentAgreement, {
3115
+ agreement: field.field.agreement,
3116
+ title: field.label,
3117
+ titleId: field.labelId,
3118
+ requiredMark: "none"
3119
+ });
3120
+ const text = /* @__PURE__ */ jsxs(Fragment, { children: [field.label, field.required ? null : /* @__PURE__ */ jsx(OptionalMark, {})] });
3121
+ return isChoiceGroupField(field.field) ? /* @__PURE__ */ jsx("legend", {
3122
+ id: field.labelId,
3123
+ className: "form-label rb-p-0",
3124
+ children: text
3125
+ }) : /* @__PURE__ */ jsx("label", {
3126
+ id: field.labelId,
3127
+ htmlFor: field.inputId,
3128
+ className: "form-label",
3129
+ children: text
3130
+ });
3131
+ }
3132
+ function toFieldControl(props) {
3133
+ const validation = getFieldValidationControlProps({
3134
+ message: props.error,
3135
+ messageId: props.errorId,
3136
+ describedBy: props.describedBy
3137
+ });
3138
+ const { field, onBlur, value } = props;
3139
+ return {
3140
+ props,
3141
+ text: typeof value === "string" ? value : String(value ?? ""),
3142
+ validation,
3143
+ common: {
3144
+ id: field.inputId,
3145
+ name: field.id,
3146
+ onBlur,
3147
+ required: field.required,
3148
+ ...validation
3149
+ }
3150
+ };
3151
+ }
3152
+ function DefaultFieldInput(props) {
3153
+ const control = toFieldControl(props);
3154
+ const field = props.field.field;
3155
+ switch (field.type) {
3156
+ case "textarea": return /* @__PURE__ */ jsx(TextareaInput, { control });
3157
+ case "select": return field.multiple ? /* @__PURE__ */ jsx(MultiSelectInput, { control }) : /* @__PURE__ */ jsx(SelectInput, { control });
3158
+ case "radio": return /* @__PURE__ */ jsx(RadioInput, { control });
3159
+ case "checkbox": return field.options && field.options.length > 1 ? /* @__PURE__ */ jsx(CheckboxGroupInput, { control }) : /* @__PURE__ */ jsx(SingleCheckboxInput, {
3160
+ control,
3161
+ label: field.placeholder || props.field.label
3162
+ });
3163
+ case "booking_requirement_consent": return /* @__PURE__ */ jsx(SingleCheckboxInput, {
3164
+ control,
3165
+ label: field.checkboxLabel,
3166
+ presentation: "tile"
3167
+ });
3168
+ case "number":
3169
+ case "date":
3170
+ case "time": return /* @__PURE__ */ jsx(NumberOrDateInput, { control });
3171
+ case "text":
3172
+ case "email":
3173
+ case "tel":
3174
+ case "url": return /* @__PURE__ */ jsx(TextInput, { control });
3175
+ }
3176
+ }
3177
+ function fieldOptions(control) {
3178
+ const field = control.props.field.field;
3179
+ return "options" in field ? field.options ?? [] : [];
3180
+ }
3181
+ function TextareaInput({ control }) {
3182
+ const field = control.props.field.field;
3183
+ if (field.type !== "textarea") return null;
3184
+ return /* @__PURE__ */ jsx("textarea", {
3185
+ ...control.common,
3186
+ value: control.text,
3187
+ onChange: (event) => control.props.onChange(event.target.value),
3188
+ placeholder: field.placeholder,
3189
+ minLength: field.minLength,
3190
+ maxLength: field.maxLength,
3191
+ rows: 4,
3192
+ className: "form-textarea"
3193
+ });
3194
+ }
3195
+ function MultiSelectInput({ control }) {
3196
+ const { value, onChange } = control.props;
3197
+ return /* @__PURE__ */ jsx("select", {
3198
+ ...control.common,
3199
+ value: Array.isArray(value) ? value : [],
3200
+ onChange: (event) => onChange(Array.from(event.target.selectedOptions, (option) => option.value)),
3201
+ multiple: true,
3202
+ className: "form-select rb-h-32",
3203
+ children: fieldOptions(control).map((option) => /* @__PURE__ */ jsx("option", {
3204
+ value: option.value,
3205
+ children: option.label
3206
+ }, option.value))
3207
+ });
3208
+ }
3209
+ function SelectInput({ control }) {
3210
+ return /* @__PURE__ */ jsxs("select", {
3211
+ ...control.common,
3212
+ value: control.text,
3213
+ onChange: (event) => control.props.onChange(event.target.value),
3214
+ className: "form-select",
3215
+ children: [/* @__PURE__ */ jsx("option", {
3216
+ value: "",
3217
+ children: "Select an option..."
3218
+ }), fieldOptions(control).map((option) => /* @__PURE__ */ jsx("option", {
3219
+ value: option.value,
3220
+ children: option.label
3221
+ }, option.value))]
3222
+ });
3223
+ }
3224
+ function RadioInput({ control }) {
3225
+ const { field, value, onChange, onBlur } = control.props;
3226
+ return /* @__PURE__ */ jsx("div", {
3227
+ className: "rb-space-y-2",
3228
+ children: fieldOptions(control).map((option) => /* @__PURE__ */ jsxs("label", {
3229
+ className: "form-check",
3230
+ children: [/* @__PURE__ */ jsx("input", {
3231
+ type: "radio",
3232
+ name: field.id,
3233
+ value: option.value,
3234
+ checked: value === option.value,
3235
+ onChange: (event) => onChange(event.target.value),
3236
+ onBlur,
3237
+ required: field.required,
3238
+ ...control.validation,
3239
+ className: "form-radio"
3240
+ }), /* @__PURE__ */ jsx("span", {
3241
+ className: "form-check-label",
3242
+ children: option.label
3243
+ })]
3244
+ }, option.value))
3245
+ });
3246
+ }
3247
+ function CheckboxGroupInput({ control }) {
3248
+ const { field, value, onChange, onBlur } = control.props;
3249
+ const checkedValues = toStringArray(value);
3250
+ return /* @__PURE__ */ jsx("div", {
3251
+ className: "rb-space-y-2",
3252
+ children: fieldOptions(control).map((option) => /* @__PURE__ */ jsx(CheckboxChoice, {
3253
+ name: field.id,
3254
+ value: option.value,
3255
+ checked: checkedValues.includes(option.value),
3256
+ onChange: (event) => {
3257
+ onChange(event.target.checked ? [...checkedValues, option.value] : checkedValues.filter((item) => item !== option.value));
3258
+ },
3259
+ onBlur,
3260
+ ...control.validation,
3261
+ label: option.label
3262
+ }, option.value))
3263
+ });
3264
+ }
3265
+ function SingleCheckboxInput({ control, label, presentation }) {
3266
+ const { field, value, onChange, onBlur } = control.props;
3267
+ return /* @__PURE__ */ jsx(CheckboxChoice, {
3268
+ id: field.inputId,
3269
+ name: field.id,
3270
+ checked: Boolean(value),
3271
+ onChange: (event) => onChange(event.target.checked),
3272
+ onBlur,
3273
+ required: field.required,
3274
+ ...control.validation,
3275
+ label,
3276
+ ...presentation ? { presentation } : {}
3277
+ });
3278
+ }
3279
+ function boundAttribute(bound) {
3280
+ return bound ? String(bound) : void 0;
3281
+ }
3282
+ function NumberOrDateInput({ control }) {
3283
+ const field = control.props.field.field;
3284
+ if (field.type !== "number" && field.type !== "date" && field.type !== "time") return null;
3285
+ const bounds = field.type === "time" ? {} : field.type === "number" ? {
3286
+ min: field.min,
3287
+ max: field.max,
3288
+ placeholder: field.placeholder
3289
+ } : {
3290
+ min: boundAttribute(field.min),
3291
+ max: boundAttribute(field.max)
3292
+ };
3293
+ return /* @__PURE__ */ jsx("input", {
3294
+ ...control.common,
3295
+ type: field.type,
3296
+ value: control.text,
3297
+ onChange: (event) => control.props.onChange(event.target.value),
3298
+ ...bounds,
3299
+ className: "form-input"
3300
+ });
3301
+ }
3302
+ function TextInput({ control }) {
3303
+ const view = control.props.field;
3304
+ const field = view.field;
3305
+ if (field.type !== "text" && field.type !== "email" && field.type !== "tel" && field.type !== "url") return null;
3306
+ return /* @__PURE__ */ jsx("input", {
3307
+ ...control.common,
3308
+ type: view.type,
3309
+ value: control.text,
3310
+ onChange: (event) => control.props.onChange(event.target.value),
3311
+ placeholder: field.placeholder,
3312
+ minLength: field.minLength,
3313
+ maxLength: field.maxLength,
3314
+ pattern: field.pattern,
3315
+ className: "form-input"
3316
+ });
3317
+ }
3318
+ function toStringArray(value) {
3319
+ return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
3320
+ }
3321
+ //#endregion
3322
+ //#region ../blocks/src/system/runtime/nodes/booking-form.default-ui.tsx
3323
+ function formatBookingAmount(amount, currency) {
3324
+ return formatCurrencyAmount(amount, currency, { decimals: "auto" });
3325
+ }
3326
+ function HeadlessBookingDefaultForm({ booking, onSubmit }) {
3327
+ const currentStep = booking.currentStep;
3328
+ const errorSummaryId = React.useId();
3329
+ const currentStepIndex = currentStep?.visibleIndex ?? 0;
3330
+ if (!currentStep) return /* @__PURE__ */ jsx("div", {
3331
+ className: "rb-text-center rb-py-12",
3332
+ children: /* @__PURE__ */ jsx("p", {
3333
+ className: "status-muted",
3334
+ children: "No steps available"
3335
+ })
3336
+ });
3337
+ return /* @__PURE__ */ jsxs("div", {
3338
+ className: "multi-step-form",
3339
+ children: [
3340
+ booking.steps.length > 1 ? /* @__PURE__ */ jsx(StepIndicator, {
3341
+ currentStep: currentStepIndex + 1,
3342
+ totalSteps: booking.steps.length,
3343
+ stepLabels: booking.steps.map((step) => step.label),
3344
+ emitSharedClasses: true
3345
+ }) : null,
3346
+ /* @__PURE__ */ jsx(DefaultQuestionsRefusal, { booking }),
3347
+ /* @__PURE__ */ jsx("div", {
3348
+ className: "step-content",
3349
+ children: /* @__PURE__ */ jsx(DefaultBookingStepContent, {
3350
+ booking,
3351
+ errorSummaryId
3352
+ })
3353
+ }),
3354
+ /* @__PURE__ */ jsx(DefaultBookingErrorSummary, {
3355
+ errors: currentStep.errors,
3356
+ id: errorSummaryId
3357
+ }),
3358
+ /* @__PURE__ */ jsx(BookingFormSubmitActions, {
3359
+ booking,
3360
+ onSubmit
3361
+ }),
3362
+ /* @__PURE__ */ jsx(DefaultBookingDiscount, { booking }),
3363
+ /* @__PURE__ */ jsx(DefaultBookingFeedback, { booking })
3364
+ ]
3365
+ });
3366
+ }
3367
+ /**
3368
+ * A service whose questions can't be shown can't be booked. Say so before the
3369
+ * booker picks a time; the details step shows the same message in place of
3370
+ * the questions.
3371
+ */
3372
+ function DefaultQuestionsRefusal({ booking }) {
3373
+ const presentation = booking.questions.presentation;
3374
+ if (presentation.kind !== "unavailable" || booking.currentStep?.id === "custom-fields") return null;
3375
+ return /* @__PURE__ */ jsx(FeedbackMessage, {
3376
+ tone: "error",
3377
+ className: "alert alert-error",
3378
+ role: "alert",
3379
+ children: presentation.message
3380
+ });
3381
+ }
3382
+ function DefaultBookingStepContent({ booking, errorSummaryId }) {
3383
+ const stepId = booking.currentStep?.id;
3384
+ if (!stepId) return null;
3385
+ switch (stepId) {
3386
+ case "service-selection": return /* @__PURE__ */ jsx(DefaultServiceSelectionStep, { booking });
3387
+ case "datetime-selection": return /* @__PURE__ */ jsx(DefaultDateTimeSelectionStep, {
3388
+ booking,
3389
+ errorSummaryId
2495
3390
  });
3391
+ case "payment-selection": return /* @__PURE__ */ jsx(HeadlessBookingPaymentSelectionStep, { booking });
3392
+ case "custom-fields": return /* @__PURE__ */ jsx(DefaultBookingDetailsStep, { booking });
2496
3393
  default: return assertNever(stepId);
2497
3394
  }
2498
3395
  }
@@ -2506,14 +3403,10 @@ function DefaultServiceSelectionStep({ booking }) {
2506
3403
  return /* @__PURE__ */ jsxs("div", {
2507
3404
  className: "rb-reg-stack",
2508
3405
  children: [
2509
- /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("h2", {
3406
+ showServiceSelect ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("h2", {
2510
3407
  className: "ab-title",
2511
- children: "Select Service"
2512
- }), /* @__PURE__ */ jsx("p", {
2513
- className: "ab-text rb-on-surface--muted",
2514
- children: "Choose the service you'd like to book"
2515
- })] }),
2516
- showServiceSelect ? /* @__PURE__ */ jsx(DefaultServiceChoices, { booking }) : null,
3408
+ children: "Choose a service"
3409
+ }), /* @__PURE__ */ jsx(DefaultServiceChoices, { booking })] }) : null,
2517
3410
  booking.resources.state.tag === "loading" ? /* @__PURE__ */ jsxs("div", {
2518
3411
  className: "ab-center",
2519
3412
  children: [/* @__PURE__ */ jsx(SpinnerNode, {
@@ -2536,47 +3429,56 @@ function DefaultServiceSelectionStep({ booking }) {
2536
3429
  role: "alert",
2537
3430
  children: "No practitioners are available for this service right now."
2538
3431
  }) : null,
2539
- showResourceSelect && booking.resources.state.tag !== "loading" && (allowAnyResource || resources.length > 0) ? /* @__PURE__ */ jsxs("div", {
2540
- className: "rb-reg-stack rb-reg-stack--sm",
2541
- children: [
2542
- /* @__PURE__ */ jsxs("span", {
2543
- className: "ab-subtitle",
2544
- children: ["Practitioner", booking.resources.requiresSelection ? "" : " (Optional)"]
2545
- }),
2546
- /* @__PURE__ */ jsx("p", {
2547
- className: "ab-text rb-on-surface--muted",
2548
- children: allowAnyResource ? "Choose a specific practitioner or select \"Any Available\"" : "Choose the practitioner you'd like to book"
2549
- }),
2550
- /* @__PURE__ */ jsxs("div", {
2551
- className: "rb-reg-grid",
2552
- children: [allowAnyResource ? /* @__PURE__ */ jsxs("button", {
2553
- type: "button",
2554
- onClick: () => booking.actions.selectResource(null),
2555
- className: optionCardClassName(!selectedResourceId),
2556
- "aria-pressed": !selectedResourceId,
2557
- children: [/* @__PURE__ */ jsx("div", {
2558
- className: "rb-flex-1 ab-subtitle",
2559
- children: "Any Available"
2560
- }), !selectedResourceId ? /* @__PURE__ */ jsx(SelectedCheck, {}) : null]
2561
- }) : null, resources.map((resource) => {
2562
- const isSelected = selectedResourceId === resource.id;
2563
- return /* @__PURE__ */ jsxs("button", {
2564
- type: "button",
2565
- onClick: () => booking.actions.selectResource(resource.id),
2566
- className: optionCardClassName(isSelected),
2567
- "aria-pressed": isSelected,
2568
- children: [/* @__PURE__ */ jsx("div", {
2569
- className: "rb-flex-1 ab-subtitle",
2570
- children: resource.label
2571
- }), isSelected ? /* @__PURE__ */ jsx(SelectedCheck, {}) : null]
2572
- }, resource.id);
2573
- })]
2574
- })
2575
- ]
3432
+ showResourceSelect && booking.resources.state.tag !== "loading" && (allowAnyResource || resources.length > 0) ? /* @__PURE__ */ jsx(DefaultResourceChoices, {
3433
+ booking,
3434
+ resources,
3435
+ selectedResourceId,
3436
+ allowAnyResource
2576
3437
  }) : null
2577
3438
  ]
2578
3439
  });
2579
3440
  }
3441
+ function DefaultResourceChoices({ allowAnyResource, booking, resources, selectedResourceId }) {
3442
+ const headingId = React.useId();
3443
+ return /* @__PURE__ */ jsxs("div", {
3444
+ className: "rb-reg-stack rb-reg-stack--sm",
3445
+ role: "group",
3446
+ "aria-labelledby": headingId,
3447
+ children: [
3448
+ /* @__PURE__ */ jsxs("h3", {
3449
+ id: headingId,
3450
+ className: "ab-subtitle",
3451
+ children: ["Who would you like to see?", booking.resources.requiresSelection ? null : /* @__PURE__ */ jsx(OptionalMark, {})]
3452
+ }),
3453
+ /* @__PURE__ */ jsx(PackageOnlyResourceNote, { booking }),
3454
+ /* @__PURE__ */ jsxs("div", {
3455
+ className: "rb-reg-grid",
3456
+ children: [allowAnyResource ? /* @__PURE__ */ jsxs("button", {
3457
+ type: "button",
3458
+ onClick: () => booking.actions.selectResource(null),
3459
+ className: optionCardClassName(!selectedResourceId),
3460
+ "aria-pressed": !selectedResourceId,
3461
+ children: [/* @__PURE__ */ jsx("div", {
3462
+ className: "rb-flex-1 ab-subtitle",
3463
+ children: "Anyone available"
3464
+ }), !selectedResourceId ? /* @__PURE__ */ jsx(SelectedCheck, {}) : null]
3465
+ }) : null, resources.map((resource) => {
3466
+ const isSelected = selectedResourceId === resource.id;
3467
+ return /* @__PURE__ */ jsxs("button", {
3468
+ type: "button",
3469
+ onClick: () => booking.actions.selectResource(resource.id),
3470
+ className: optionCardClassName(isSelected),
3471
+ "aria-pressed": isSelected,
3472
+ children: [/* @__PURE__ */ jsx("div", {
3473
+ className: "rb-flex-1 ab-subtitle",
3474
+ children: resource.label
3475
+ }), isSelected ? /* @__PURE__ */ jsx(SelectedCheck, {}) : null]
3476
+ }, resource.id);
3477
+ })]
3478
+ })
3479
+ ]
3480
+ });
3481
+ }
2580
3482
  function BookingSelectedServiceSummary({ services }) {
2581
3483
  const service = services.items.length === 1 ? services.items[0] : void 0;
2582
3484
  if (!service) return null;
@@ -2654,24 +3556,45 @@ function DefaultDateTimeSelectionStep({ booking, errorSummaryId }) {
2654
3556
  ]
2655
3557
  });
2656
3558
  }
3559
+ /** Which ways to pay the step lists: held packages and per-session options, but no per-session payment for a packages-only service. */
3560
+ function planPaymentStepChoices(booking) {
3561
+ const viewModel = booking.payment.selection;
3562
+ const perSessionOffered = booking.services.selected?.onlinePaymentChoices?.perSession !== false;
3563
+ const perSessionOptions = perSessionOffered && viewModel ? viewModel.options : [];
3564
+ const choice = booking.payment.choice;
3565
+ const otherRows = [...heldPackageRows(booking), ...perSessionOptions.map((option) => ({
3566
+ id: option.kind,
3567
+ label: option.title,
3568
+ details: paymentChoiceDetails(option),
3569
+ price: paymentChoicePrice(option.amounts),
3570
+ selected: choice.kind === "per_session" ? choice.option === option.kind : choice.kind === "unselected" && viewModel?.mode === "single_option",
3571
+ onSelect: () => booking.actions.selectPaymentOption(option.kind)
3572
+ }))];
3573
+ return {
3574
+ perSessionOffered,
3575
+ perSessionOptions,
3576
+ otherRows,
3577
+ onlyOneWayToPay: viewModel?.mode === "single_option" && otherRows.length === perSessionOptions.length && !hasPurchasablePackages(booking.payment)
3578
+ };
3579
+ }
3580
+ function paymentStepUnavailableMessage(booking) {
3581
+ if (booking.payment.kind === "unsupported") return booking.payment.errorMessage;
3582
+ if (!booking.services.selected) return "Payment options are unavailable for this service right now.";
3583
+ return null;
3584
+ }
3585
+ function paymentStepTitle(booking) {
3586
+ return booking.payment.selection?.sectionTitle ?? "How would you like to pay?";
3587
+ }
2657
3588
  function HeadlessBookingPaymentSelectionStep({ booking }) {
2658
3589
  const service = booking.services.selected;
2659
- const viewModel = booking.payment.selection;
2660
- if (booking.payment.kind === "unsupported") return /* @__PURE__ */ jsx(FeedbackMessage, {
3590
+ const { perSessionOffered, perSessionOptions, otherRows, onlyOneWayToPay } = planPaymentStepChoices(booking);
3591
+ const unavailableMessage = paymentStepUnavailableMessage(booking);
3592
+ if (unavailableMessage !== null || !service) return /* @__PURE__ */ jsx(FeedbackMessage, {
2661
3593
  tone: "error",
2662
3594
  className: "alert alert-error",
2663
3595
  role: "alert",
2664
- children: booking.payment.errorMessage
3596
+ children: unavailableMessage
2665
3597
  });
2666
- if (!service || !viewModel) return /* @__PURE__ */ jsx(FeedbackMessage, {
2667
- tone: "error",
2668
- className: "alert alert-error",
2669
- role: "alert",
2670
- children: "Payment options are unavailable for this service right now."
2671
- });
2672
- const packageOptions = booking.payment.appointmentPackages.items;
2673
- const hasPackageOptions = packageOptions.length > 0;
2674
- const slidingScale = booking.payment.slidingScale;
2675
3598
  return /* @__PURE__ */ jsxs("div", {
2676
3599
  className: "rb-reg-stack",
2677
3600
  children: [
@@ -2679,54 +3602,16 @@ function HeadlessBookingPaymentSelectionStep({ booking }) {
2679
3602
  className: "rb-reg-summary",
2680
3603
  children: [/* @__PURE__ */ jsx("h3", {
2681
3604
  className: "ab-subtitle",
2682
- children: viewModel.sectionTitle
3605
+ children: paymentStepTitle(booking)
2683
3606
  }), /* @__PURE__ */ jsx("p", {
2684
3607
  className: "ab-text rb-on-surface--muted",
2685
3608
  children: service.title
2686
3609
  })]
2687
3610
  }),
2688
- booking.payment.appointmentPackages.state.tag === "loading" ? /* @__PURE__ */ jsx(FeedbackMessage, {
2689
- tone: "info",
2690
- className: "alert alert-info",
2691
- role: "status",
2692
- children: "Checking package credits..."
2693
- }) : null,
2694
- booking.payment.appointmentPackages.state.tag === "error" ? /* @__PURE__ */ jsxs(FeedbackMessage, {
2695
- tone: "info",
2696
- className: "alert alert-info",
2697
- role: "status",
2698
- children: [booking.payment.appointmentPackages.state.message, " You can continue with the normal payment option."]
2699
- }) : null,
2700
- slidingScale ? /* @__PURE__ */ jsxs("div", {
2701
- className: "rb-space-y-2",
2702
- children: [
2703
- /* @__PURE__ */ jsx("label", {
2704
- htmlFor: "appointment-sliding-amount",
2705
- className: "form-label",
2706
- children: "Choose your price"
2707
- }),
2708
- /* @__PURE__ */ jsxs("p", {
2709
- className: "rb-caption status-muted",
2710
- children: [
2711
- formatBookingAmount(slidingScale.minAmount, slidingScale.currency),
2712
- " to ",
2713
- formatBookingAmount(slidingScale.maxAmount, slidingScale.currency),
2714
- slidingScale.suggestedAmount !== null ? `, suggested ${formatBookingAmount(slidingScale.suggestedAmount, slidingScale.currency)}` : ""
2715
- ]
2716
- }),
2717
- /* @__PURE__ */ jsx("input", {
2718
- id: "appointment-sliding-amount",
2719
- type: "number",
2720
- className: "form-input",
2721
- min: slidingScale.minAmount / 100,
2722
- max: slidingScale.maxAmount / 100,
2723
- step: "0.01",
2724
- value: booking.payment.selectedSlidingAmountInput,
2725
- onChange: (event) => booking.actions.setSlidingAmountInput(event.target.value)
2726
- })
2727
- ]
2728
- }) : null,
2729
- viewModel.mode === "single_option" && !hasPackageOptions ? viewModel.options.map((option) => /* @__PURE__ */ jsx("div", {
3611
+ /* @__PURE__ */ jsx(HeldPackageStatus, { booking }),
3612
+ /* @__PURE__ */ jsx(PackagePaymentAvailabilityNotice, { payment: booking.payment }),
3613
+ perSessionOffered ? /* @__PURE__ */ jsx(SlidingScaleField, { booking }) : null,
3614
+ onlyOneWayToPay ? perSessionOptions.map((option) => /* @__PURE__ */ jsx("div", {
2730
3615
  className: "rb-reg-summary",
2731
3616
  children: /* @__PURE__ */ jsx(PaymentOptionContent, {
2732
3617
  id: option.kind,
@@ -2735,23 +3620,93 @@ function HeadlessBookingPaymentSelectionStep({ booking }) {
2735
3620
  summaryRows: option.summaryRows,
2736
3621
  helperText: option.helperText
2737
3622
  })
2738
- }, option.kind)) : /* @__PURE__ */ jsx(PaymentChoiceRows, {
3623
+ }, option.kind)) : otherRows.length > 0 ? /* @__PURE__ */ jsx(PaymentChoiceRows, {
2739
3624
  label: "Payment options",
2740
- rows: [...packageOptions.map((appointmentPackage) => ({
2741
- id: appointmentPackage.customerPassId,
2742
- label: appointmentPackage.passName,
2743
- details: ["Use 1 package credit", `Balance: ${appointmentPackage.creditsRemaining} of ${appointmentPackage.creditsTotal} credits remaining`],
2744
- price: "1 credit",
2745
- selected: booking.payment.selectedAppointmentPackageId === appointmentPackage.customerPassId,
2746
- onSelect: () => booking.actions.selectAppointmentPackage(appointmentPackage.customerPassId)
2747
- })), ...viewModel.options.map((option) => ({
2748
- id: option.kind,
2749
- label: option.title,
2750
- details: paymentChoiceDetails(option),
2751
- price: paymentChoicePrice(option.amounts),
2752
- selected: !booking.payment.selectedAppointmentPackageId && (booking.payment.selectedCollectionOptionKind === option.kind || viewModel.mode === "single_option"),
2753
- onSelect: () => booking.actions.selectPaymentOption(option.kind)
2754
- }))]
3625
+ rows: otherRows
3626
+ }) : null,
3627
+ /* @__PURE__ */ jsx(PurchasablePackageChoices, {
3628
+ booking,
3629
+ serviceTitle: service.title,
3630
+ hasOtherChoices: otherRows.length > 0
3631
+ })
3632
+ ]
3633
+ });
3634
+ }
3635
+ function PackageOnlyResourceNote({ booking }) {
3636
+ if (booking.services.selected?.onlinePaymentChoices?.anyAvailable !== false) return null;
3637
+ return /* @__PURE__ */ jsx("p", {
3638
+ className: "ab-text rb-on-surface--muted",
3639
+ children: "You book this with a package, and each package is with one practitioner. Choose who you'd like to see, and you'll see their packages when you pay."
3640
+ });
3641
+ }
3642
+ function HeldPackageStatus({ booking }) {
3643
+ const held = booking.payment.appointmentPackages;
3644
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3645
+ held.state.tag === "loading" ? /* @__PURE__ */ jsx(FeedbackMessage, {
3646
+ tone: "info",
3647
+ className: "alert alert-info",
3648
+ role: "status",
3649
+ children: "Checking package credits..."
3650
+ }) : null,
3651
+ held.state.tag === "error" ? /* @__PURE__ */ jsxs(FeedbackMessage, {
3652
+ tone: "info",
3653
+ className: "alert alert-info",
3654
+ role: "status",
3655
+ children: [held.state.message, " You can continue with the normal payment option."]
3656
+ }) : null,
3657
+ held.kind === "ready" ? held.heldWithTeamMembers.map((member) => /* @__PURE__ */ jsxs("div", {
3658
+ className: "rb-reg-summary rb-space-y-2",
3659
+ children: [/* @__PURE__ */ jsxs("p", {
3660
+ className: "ab-text",
3661
+ children: [
3662
+ "You have sessions with ",
3663
+ member.name,
3664
+ ". Book with ",
3665
+ member.name,
3666
+ " to use them."
3667
+ ]
3668
+ }), /* @__PURE__ */ jsx(ThemedButton, {
3669
+ type: "button",
3670
+ variant: "secondary",
3671
+ size: "sm",
3672
+ label: `Book with ${member.name}`,
3673
+ onClick: () => {
3674
+ booking.actions.selectResource(member.id);
3675
+ booking.actions.goToStep("datetime-selection");
3676
+ }
3677
+ })]
3678
+ }, member.id)) : null
3679
+ ] });
3680
+ }
3681
+ function SlidingScaleField({ booking }) {
3682
+ const slidingScale = booking.payment.slidingScale;
3683
+ if (!slidingScale) return null;
3684
+ return /* @__PURE__ */ jsxs("div", {
3685
+ className: "rb-space-y-2",
3686
+ children: [
3687
+ /* @__PURE__ */ jsx("label", {
3688
+ htmlFor: "appointment-sliding-amount",
3689
+ className: "form-label",
3690
+ children: "Choose your price"
3691
+ }),
3692
+ /* @__PURE__ */ jsxs("p", {
3693
+ className: "rb-caption status-muted",
3694
+ children: [
3695
+ formatBookingAmount(slidingScale.minAmount, slidingScale.currency),
3696
+ " to ",
3697
+ formatBookingAmount(slidingScale.maxAmount, slidingScale.currency),
3698
+ slidingScale.suggestedAmount !== null ? `, suggested ${formatBookingAmount(slidingScale.suggestedAmount, slidingScale.currency)}` : ""
3699
+ ]
3700
+ }),
3701
+ /* @__PURE__ */ jsx("input", {
3702
+ id: "appointment-sliding-amount",
3703
+ type: "number",
3704
+ className: "form-input",
3705
+ min: slidingScale.minAmount / 100,
3706
+ max: slidingScale.maxAmount / 100,
3707
+ step: "0.01",
3708
+ value: booking.payment.selectedSlidingAmountInput,
3709
+ onChange: (event) => booking.actions.setSlidingAmountInput(event.target.value)
2755
3710
  })
2756
3711
  ]
2757
3712
  });
@@ -2786,228 +3741,6 @@ function PaymentOptionContent({ description, helperText, id, summaryRows, title
2786
3741
  ]
2787
3742
  });
2788
3743
  }
2789
- function DefaultDynamicFields({ booking, fields }) {
2790
- const lastContactIndex = fields.reduce((last, field, index) => [
2791
- "name",
2792
- "email",
2793
- "phone"
2794
- ].includes(field.id) ? index : last, -1);
2795
- return /* @__PURE__ */ jsxs("div", {
2796
- className: "rb-space-y-6",
2797
- children: [
2798
- /* @__PURE__ */ jsx(SiteTermsChangedNotice, { message: booking.siteTerms.notice }),
2799
- fields.map((field, index) => /* @__PURE__ */ jsxs(React.Fragment, { children: [/* @__PURE__ */ jsx(DefaultDynamicField, {
2800
- booking,
2801
- field
2802
- }), index === lastContactIndex && booking.mailingList ? /* @__PURE__ */ jsx(BookingMailingListChoice, { booking }) : null] }, field.id)),
2803
- /* @__PURE__ */ jsx(SiteTermsAgreementField, {
2804
- agreement: booking.siteTerms.view,
2805
- onChange: booking.siteTerms.onChange,
2806
- error: booking.siteTerms.error,
2807
- disabled: booking.siteTerms.disabled
2808
- })
2809
- ]
2810
- });
2811
- }
2812
- function DefaultDynamicField({ booking, field }) {
2813
- const value = field.value ?? "";
2814
- const error = field.error;
2815
- const errorId = error ? field.errorId ?? `${field.inputId}-error` : null;
2816
- const describedBy = [field.helpTextId, errorId].filter(Boolean).join(" ") || void 0;
2817
- return /* @__PURE__ */ jsxs("div", {
2818
- className: "rb-space-y-2",
2819
- children: [
2820
- field.field.type === "booking_requirement_consent" ? /* @__PURE__ */ jsx(BookingConsentAgreement, {
2821
- agreement: field.field.agreement,
2822
- title: field.label,
2823
- titleId: field.labelId
2824
- }) : /* @__PURE__ */ jsxs("label", {
2825
- id: field.labelId,
2826
- htmlFor: field.inputId,
2827
- className: "form-label",
2828
- children: [field.label, field.required ? /* @__PURE__ */ jsx("span", {
2829
- className: "required-marker",
2830
- children: "*"
2831
- }) : null]
2832
- }),
2833
- field.helpText ? /* @__PURE__ */ jsx("p", {
2834
- id: field.helpTextId ?? void 0,
2835
- className: "rb-caption status-muted",
2836
- children: field.helpText
2837
- }) : null,
2838
- /* @__PURE__ */ jsx(DefaultFieldInput, {
2839
- field,
2840
- value,
2841
- onChange: (nextValue) => booking.actions.updateField(field.id, nextValue),
2842
- onBlur: () => booking.actions.markFieldTouched(field.id),
2843
- error,
2844
- errorId: errorId ?? `${field.inputId}-error`,
2845
- describedBy
2846
- }),
2847
- error ? /* @__PURE__ */ jsx(FieldValidationMessage, {
2848
- id: errorId ?? `${field.inputId}-error`,
2849
- className: "rb-caption status-error",
2850
- children: error
2851
- }) : null
2852
- ]
2853
- });
2854
- }
2855
- function DefaultFieldInput({ describedBy, error, errorId, field, onBlur, onChange, value }) {
2856
- const strValue = typeof value === "string" ? value : String(value ?? "");
2857
- const validationProps = getFieldValidationControlProps({
2858
- message: error,
2859
- messageId: errorId,
2860
- describedBy
2861
- });
2862
- const commonProps = {
2863
- id: field.inputId,
2864
- name: field.id,
2865
- onBlur,
2866
- required: field.required,
2867
- ...validationProps
2868
- };
2869
- switch (field.field.type) {
2870
- case "textarea": return /* @__PURE__ */ jsx("textarea", {
2871
- ...commonProps,
2872
- value: strValue,
2873
- onChange: (event) => onChange(event.target.value),
2874
- placeholder: field.field.placeholder,
2875
- minLength: field.field.minLength,
2876
- maxLength: field.field.maxLength,
2877
- rows: 4,
2878
- className: "form-textarea"
2879
- });
2880
- case "select":
2881
- if (field.field.multiple) return /* @__PURE__ */ jsx("select", {
2882
- ...commonProps,
2883
- value: Array.isArray(value) ? value : [],
2884
- onChange: (event) => {
2885
- onChange(Array.from(event.target.selectedOptions, (option) => option.value));
2886
- },
2887
- multiple: true,
2888
- className: "form-select rb-h-32",
2889
- children: field.field.options?.map((option) => /* @__PURE__ */ jsx("option", {
2890
- value: option.value,
2891
- children: option.label
2892
- }, option.value))
2893
- });
2894
- return /* @__PURE__ */ jsxs("select", {
2895
- ...commonProps,
2896
- value: strValue,
2897
- onChange: (event) => onChange(event.target.value),
2898
- className: "form-select",
2899
- children: [/* @__PURE__ */ jsx("option", {
2900
- value: "",
2901
- children: "Select an option..."
2902
- }), field.field.options?.map((option) => /* @__PURE__ */ jsx("option", {
2903
- value: option.value,
2904
- children: option.label
2905
- }, option.value))]
2906
- });
2907
- case "radio": return /* @__PURE__ */ jsx("div", {
2908
- className: "rb-space-y-2",
2909
- children: field.field.options?.map((option) => /* @__PURE__ */ jsxs("label", {
2910
- className: "form-check",
2911
- children: [/* @__PURE__ */ jsx("input", {
2912
- type: "radio",
2913
- name: field.id,
2914
- value: option.value,
2915
- checked: value === option.value,
2916
- onChange: (event) => onChange(event.target.value),
2917
- onBlur,
2918
- required: field.required,
2919
- ...validationProps,
2920
- className: "form-radio"
2921
- }), /* @__PURE__ */ jsx("span", {
2922
- className: "form-check-label",
2923
- children: option.label
2924
- })]
2925
- }, option.value))
2926
- });
2927
- case "checkbox":
2928
- if (field.field.options && field.field.options.length > 1) {
2929
- const checkedValues = toStringArray(value);
2930
- return /* @__PURE__ */ jsx("div", {
2931
- className: "rb-space-y-2",
2932
- children: field.field.options.map((option) => /* @__PURE__ */ jsx(CheckboxChoice, {
2933
- name: field.id,
2934
- value: option.value,
2935
- checked: checkedValues.includes(option.value),
2936
- onChange: (event) => {
2937
- onChange(event.target.checked ? [...checkedValues, option.value] : checkedValues.filter((item) => item !== option.value));
2938
- },
2939
- onBlur,
2940
- ...validationProps,
2941
- label: option.label
2942
- }, option.value))
2943
- });
2944
- }
2945
- return /* @__PURE__ */ jsx(CheckboxChoice, {
2946
- id: field.inputId,
2947
- name: field.id,
2948
- checked: Boolean(value),
2949
- onChange: (event) => onChange(event.target.checked),
2950
- onBlur,
2951
- required: field.required,
2952
- ...validationProps,
2953
- label: field.field.placeholder || field.label
2954
- });
2955
- case "booking_requirement_consent": return /* @__PURE__ */ jsx(CheckboxChoice, {
2956
- id: field.inputId,
2957
- name: field.id,
2958
- checked: Boolean(value),
2959
- onChange: (event) => onChange(event.target.checked),
2960
- onBlur,
2961
- required: field.required,
2962
- ...validationProps,
2963
- label: field.field.checkboxLabel,
2964
- presentation: "tile"
2965
- });
2966
- case "number": return /* @__PURE__ */ jsx("input", {
2967
- ...commonProps,
2968
- type: "number",
2969
- value: strValue,
2970
- onChange: (event) => onChange(event.target.value),
2971
- placeholder: field.field.placeholder,
2972
- min: field.field.min,
2973
- max: field.field.max,
2974
- className: "form-input"
2975
- });
2976
- case "date": return /* @__PURE__ */ jsx("input", {
2977
- ...commonProps,
2978
- type: "date",
2979
- value: strValue,
2980
- onChange: (event) => onChange(event.target.value),
2981
- min: field.field.min ? String(field.field.min) : void 0,
2982
- max: field.field.max ? String(field.field.max) : void 0,
2983
- className: "form-input"
2984
- });
2985
- case "time": return /* @__PURE__ */ jsx("input", {
2986
- ...commonProps,
2987
- type: "time",
2988
- value: strValue,
2989
- onChange: (event) => onChange(event.target.value),
2990
- className: "form-input"
2991
- });
2992
- case "text":
2993
- case "email":
2994
- case "tel":
2995
- case "url": return /* @__PURE__ */ jsx("input", {
2996
- ...commonProps,
2997
- type: field.type,
2998
- value: strValue,
2999
- onChange: (event) => onChange(event.target.value),
3000
- placeholder: field.field.placeholder,
3001
- minLength: field.field.minLength,
3002
- maxLength: field.field.maxLength,
3003
- pattern: field.field.pattern,
3004
- className: "form-input"
3005
- });
3006
- }
3007
- }
3008
- function toStringArray(value) {
3009
- return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
3010
- }
3011
3744
  function DefaultBookingDiscount({ booking }) {
3012
3745
  if (!(!booking.payment.selectedAppointmentPackageId && !booking.discount.loading && (booking.discount.manualCodeEntryAllowed || Boolean(booking.discount.autoAppliedDiscount)))) return null;
3013
3746
  return /* @__PURE__ */ jsxs("div", {
@@ -3056,14 +3789,16 @@ function DefaultBookingFeedback({ booking }) {
3056
3789
  })]
3057
3790
  });
3058
3791
  }
3792
+ /** Each field shows its own message, so the summary only says where to look. */
3793
+ const FIELD_ERRORS_SUMMARY = "Please check the details above.";
3059
3794
  function DefaultBookingErrorSummary({ errors, id }) {
3060
3795
  if (!hasBookingValidationErrors(errors)) return null;
3061
- return /* @__PURE__ */ jsxs(FeedbackMessage, {
3796
+ return /* @__PURE__ */ jsx(FeedbackMessage, {
3062
3797
  tone: "error",
3063
3798
  treatment: "field-note",
3064
3799
  id,
3065
3800
  role: "alert",
3066
- children: [errors.formError ? /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx("strong", { children: errors.formError }) }) : null, Object.entries(errors.fieldErrors).map(([key, message]) => /* @__PURE__ */ jsx("p", { children: message }, key))]
3801
+ children: /* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx("strong", { children: errors.formError ?? FIELD_ERRORS_SUMMARY }) })
3067
3802
  });
3068
3803
  }
3069
3804
  //#endregion
@@ -3247,9 +3982,8 @@ function appendRebookFlag(url, enabled) {
3247
3982
  }
3248
3983
  function createBookingFormSubmitHandler(input) {
3249
3984
  return async () => {
3250
- const { successUrl, cancelUrl } = buildCheckoutReturnUrls("booking", input.bookingAnchorId);
3985
+ const { successUrl, cancelUrl } = buildCheckoutReturnUrls("booking", input.bookingAnchorId, {}, input.pageNavigation);
3251
3986
  const options = {
3252
- redirect: "manual",
3253
3987
  successUrl: appendRebookFlag(successUrl, input.isPortalRebook),
3254
3988
  cancelUrl: appendRebookFlag(cancelUrl, input.isPortalRebook)
3255
3989
  };
@@ -3261,7 +3995,10 @@ function createBookingFormSubmitHandler(input) {
3261
3995
  customerEmail: result.outcome.customerEmail,
3262
3996
  mailingListNote: result.outcome.mailingListSignupNote ?? null
3263
3997
  });
3264
- window.location.href = result.outcome.checkoutUrl;
3998
+ const outcome = leavePage(result.outcome.checkoutUrl, input.pageNavigation, (url) => {
3999
+ window.location.href = url;
4000
+ });
4001
+ if (outcome.kind === "handOff") input.onHandOff(outcome);
3265
4002
  return;
3266
4003
  }
3267
4004
  input.setLocalMailingListNote(result.outcome.mailingListSignupNote ?? null);
@@ -3307,6 +4044,7 @@ const BookingFormClient = ({ siteId: siteIdProp, render }) => {
3307
4044
  const [localMailingListNote, setLocalMailingListNote] = useState(null);
3308
4045
  const [localCustomerEmail, setLocalCustomerEmail] = useState(null);
3309
4046
  const api = useBlockApi();
4047
+ const [handOff, setHandOff] = useState(null);
3310
4048
  const hasPortalAuth = api.config.auth.type === "bearer" || api.config.authOverrides?.portal?.type === "bearer";
3311
4049
  const formId = render.hydration.formId ?? form?.id ?? "booking-form";
3312
4050
  const booking = useHeadlessBookingFlow({
@@ -3348,10 +4086,15 @@ const BookingFormClient = ({ siteId: siteIdProp, render }) => {
3348
4086
  viewState.kind,
3349
4087
  viewState.kind === "error" ? viewState.message : null
3350
4088
  ]);
4089
+ const { endSignInReturn } = booking.questions;
3351
4090
  React.useEffect(() => {
3352
- if (viewState.kind === "success" && redirectState.kind === "success") scrollToBlock(bookingAnchorId);
4091
+ if (viewState.kind === "success" && redirectState.kind === "success") {
4092
+ scrollToBlock(bookingAnchorId);
4093
+ endSignInReturn();
4094
+ }
3353
4095
  }, [
3354
4096
  bookingAnchorId,
4097
+ endSignInReturn,
3355
4098
  redirectState.kind,
3356
4099
  viewState.kind
3357
4100
  ]);
@@ -3386,6 +4129,8 @@ const BookingFormClient = ({ siteId: siteIdProp, render }) => {
3386
4129
  })
3387
4130
  });
3388
4131
  const handleComplete = createBookingFormSubmitHandler({
4132
+ pageNavigation: render.hydration.pageNavigation,
4133
+ onHandOff: setHandOff,
3389
4134
  booking,
3390
4135
  bookingAnchorId,
3391
4136
  isPortalRebook,
@@ -3439,33 +4184,37 @@ const BookingFormClient = ({ siteId: siteIdProp, render }) => {
3439
4184
  onClick: verification.retry
3440
4185
  })]
3441
4186
  });
3442
- return /* @__PURE__ */ jsxs(BookingSurface, {
4187
+ return /* @__PURE__ */ jsx(BookingSurface, {
3443
4188
  id: bookingAnchorId,
3444
4189
  className: render.display.className,
3445
- children: [
3446
- render.hydration.noticeMessage ? /* @__PURE__ */ jsx(FeedbackMessage, {
3447
- tone: "info",
3448
- className: "alert alert-info rb-mb-4",
3449
- role: "status",
3450
- children: /* @__PURE__ */ jsx("p", {
3451
- className: "ab-text",
3452
- children: render.hydration.noticeMessage
3453
- })
3454
- }) : null,
3455
- viewState.kind === "error" ? /* @__PURE__ */ jsx(FeedbackMessage, {
3456
- tone: "error",
3457
- className: "alert alert-error rb-mb-4",
3458
- role: "alert",
3459
- children: /* @__PURE__ */ jsx("p", {
3460
- className: "ab-text",
3461
- children: viewState.message
4190
+ children: /* @__PURE__ */ jsxs(AppointmentNavigationContent, {
4191
+ handOff,
4192
+ onBack: () => setHandOff(null),
4193
+ children: [
4194
+ render.hydration.noticeMessage ? /* @__PURE__ */ jsx(FeedbackMessage, {
4195
+ tone: "info",
4196
+ className: "alert alert-info rb-mb-4",
4197
+ role: "status",
4198
+ children: /* @__PURE__ */ jsx("p", {
4199
+ className: "ab-text",
4200
+ children: render.hydration.noticeMessage
4201
+ })
4202
+ }) : null,
4203
+ viewState.kind === "error" ? /* @__PURE__ */ jsx(FeedbackMessage, {
4204
+ tone: "error",
4205
+ className: "alert alert-error rb-mb-4",
4206
+ role: "alert",
4207
+ children: /* @__PURE__ */ jsx("p", {
4208
+ className: "ab-text",
4209
+ children: viewState.message
4210
+ })
4211
+ }) : null,
4212
+ /* @__PURE__ */ jsx(HeadlessBookingDefaultForm, {
4213
+ booking,
4214
+ onSubmit: handleComplete
3462
4215
  })
3463
- }) : null,
3464
- /* @__PURE__ */ jsx(HeadlessBookingDefaultForm, {
3465
- booking,
3466
- onSubmit: handleComplete
3467
- })
3468
- ]
4216
+ ]
4217
+ })
3469
4218
  });
3470
4219
  };
3471
4220
  /**
@@ -3480,5 +4229,12 @@ const BookingFormNodeClient = (props) => /* @__PURE__ */ jsx(BookingFormClient,
3480
4229
  function buildBookingFormNodeClientProps(props) {
3481
4230
  return buildBookingFormInteractiveIslandProps(props);
3482
4231
  }
4232
+ function AppointmentNavigationContent(props) {
4233
+ return props.handOff ? /* @__PURE__ */ jsx(NavigationHandOffPanel, {
4234
+ handOff: props.handOff,
4235
+ purpose: "payment",
4236
+ onBack: props.onBack
4237
+ }) : props.children;
4238
+ }
3483
4239
  //#endregion
3484
4240
  export { useHeadlessBookingFlow as a, HeadlessBookingProvider as i, BookingFormNodeClient as n, createBookingBlockApiConfig as o, HeadlessBookingPaymentSelectionStep as r, getAppointmentBookingOverrideInput as s, BookingFormClient as t };