@riverbankcms/sdk 0.179.0 → 0.181.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 (240) hide show
  1. package/README.md +2 -2
  2. package/dist/_dts/{BlocksIslandsHydrator-DKwgs95u.d.ts → BlocksIslandsHydrator-CVCasDPz.d.ts} +1 -1
  3. package/dist/_dts/{Page-lWenra5i.d.ts → Page-Dtj2Ui3S.d.ts} +7 -7
  4. package/dist/_dts/{SdkPreviewMode-BRxhRw4I.d.ts → SdkPreviewMode-D1f_60WW.d.ts} +3 -2
  5. package/dist/_dts/{client-qWn7xAwJ.d.ts → client-Chr9pNVW.d.ts} +288 -121
  6. package/dist/_dts/{content-types-DL6GIvTm.d.ts → content-types-kjccgopX.d.ts} +2 -2
  7. package/dist/_dts/{contracts-CzWyAiJj.d.ts → contracts-BodaiS00.d.ts} +3 -3
  8. package/dist/_dts/{generatePageMetadata-CBKd0cJ4.d.ts → generatePageMetadata-BS6kaJFp.d.ts} +2 -2
  9. package/dist/_dts/{index-DCiSHd-C.d.ts → index-Brl6_I2j.d.ts} +5 -4
  10. package/dist/_dts/{index-CaCum9mM.d.ts → index-CJkefwYh.d.ts} +2 -2
  11. package/dist/_dts/{index-7CDBZGb-.d.ts → index-D1WpKwQe.d.ts} +1 -1
  12. package/dist/_dts/{index-BU9uAkHB.d.ts → index-DG0OvBs0.d.ts} +8 -8
  13. package/dist/_dts/{index-BYnG_vF5.d.ts → index-Diqt0PvG.d.ts} +1 -1
  14. package/dist/_dts/{index-CZgJrhzT.d.ts → index-Dy50xUMK.d.ts} +2 -2
  15. package/dist/_dts/{loadContent-CPKbFQyq.d.ts → loadContent-BgxshKrA.d.ts} +7 -7
  16. package/dist/_dts/{request-BjKBCS7t.d.ts → request-CA0izds5.d.ts} +4561 -1390
  17. package/dist/_dts/{resolveBlockData-DupbMCup.d.ts → resolveBlockData-ChQmwEd3.d.ts} +5 -5
  18. package/dist/_dts/{resolvePageContent-BqNyCHi8.d.ts → resolvePageContent-BvGyvblj.d.ts} +1 -1
  19. package/dist/_dts/sdk/src/bookings/index.d.ts +2 -2
  20. package/dist/_dts/sdk/src/client/types.d.ts +2 -2
  21. package/dist/_dts/sdk/src/client.d.ts +7 -7
  22. package/dist/_dts/sdk/src/config/index.d.ts +6 -6
  23. package/dist/_dts/sdk/src/config/template-validation.d.ts +1 -1
  24. package/dist/_dts/sdk/src/config/validation.d.ts +1 -1
  25. package/dist/_dts/sdk/src/data/dataLoaderContext.d.ts +2 -2
  26. package/dist/_dts/sdk/src/data/resolveBlockData.d.ts +1 -1
  27. package/dist/_dts/sdk/src/data/types.d.ts +2 -2
  28. package/dist/_dts/sdk/src/gifting/client.d.ts +1 -2
  29. package/dist/_dts/sdk/src/index.d.ts +104 -8
  30. package/dist/_dts/sdk/src/manifest/index.d.ts +3 -3
  31. package/dist/_dts/sdk/src/metadata/index.d.ts +1 -1
  32. package/dist/_dts/sdk/src/navigation/index.d.ts +3 -3
  33. package/dist/_dts/sdk/src/next/index.d.ts +84 -53
  34. package/dist/_dts/sdk/src/next/middleware.d.ts +2 -2
  35. package/dist/_dts/sdk/src/page-converter/index.d.ts +3 -3
  36. package/dist/_dts/sdk/src/portal/client.d.ts +43 -56
  37. package/dist/_dts/sdk/src/portal/index.d.ts +3 -18
  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 -4
  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 +6 -6
  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/{serviceBookingOutline-YcsIjvn1.d.ts → serviceBookingOutline-BgFbJQhU.d.ts} +8 -7
  55. package/dist/_dts/{types-B7e6Lmo5.d.ts → types-CQrsP1x_.d.ts} +3 -3
  56. package/dist/_dts/{types-CT-KOxl_.d.ts → types-CgS3xLk8.d.ts} +7 -2
  57. package/dist/_dts/{types-BOxSq-Bq.d.ts → types-R65DKjPn.d.ts} +9 -8
  58. package/dist/_dts/{validation-Dz6qccue.d.ts → validation-6LTIbuBA.d.ts} +4 -4
  59. package/dist/client/{BlocksIslandsHydrator-1XifJg6V.mjs → BlocksIslandsHydrator-DqZPz6oW.mjs} +19 -19
  60. package/dist/client/{BookingMailingListNote-BsbEgagJ.mjs → BookingMailingListNote-uWfR2kaG.mjs} +177 -70
  61. package/dist/client/{BookingQuestionFields-C8IbeLHj.mjs → BookingQuestionFields-CyNIKw6k.mjs} +23 -82
  62. package/dist/client/CalendarAction-D_Glwvz2.mjs +105 -0
  63. package/dist/client/{CalendarNavigationChevron-Bbqij1XQ.mjs → CalendarNavigationChevron-BGCX3zwG.mjs} +6 -6
  64. package/dist/client/{CheckboxChoice-BZPLCgTU.mjs → CheckboxChoice-C8i4NraK.mjs} +1 -1
  65. package/dist/client/{DemoBookingPortalAccess-uA9H8LIL.mjs → DemoBookingPortalAccess-DFLPyuqe.mjs} +18 -10
  66. package/dist/client/{EventCalendar.client-yoSI77ov.mjs → EventCalendar.client-zDL4-t-B.mjs} +10 -10
  67. package/dist/client/{EventCombined.client-HeCNlliq.mjs → EventCombined.client-uciDKLID.mjs} +60 -10
  68. package/dist/client/{EventEmbeddedCheckoutStep-BDnicDM6.mjs → EventEmbeddedCheckoutStep-BGkbUhuw.mjs} +1 -1
  69. package/dist/client/{EventItem-Duhk1vnF.mjs → EventItem-CwzrjcRw.mjs} +8 -7
  70. package/dist/client/{EventListWeekNavigation-BiutEqPK.mjs → EventListWeekNavigation-ChvcnPma.mjs} +1 -1
  71. package/dist/client/{EventListing.client-B5ln77jG.mjs → EventListing.client-DA57Qoyx.mjs} +3 -3
  72. package/dist/client/{EventListing.view-hUDhNtMv.mjs → EventListing.view-DZ0qMFF4.mjs} +8 -211
  73. package/dist/client/{EventRegistrationPayment-DqtX1vB2.mjs → EventRegistrationPayment-DSqCJL8E.mjs} +1657 -403
  74. package/dist/client/{Page-ChJ2TGVk.mjs → Page-C7mygH_f.mjs} +536 -287
  75. package/dist/client/{ProtectedSubmitButton-De6AzhE6.mjs → ProtectedSubmitButton-BNnKuir8.mjs} +1 -1
  76. package/dist/client/{SiteTermsAgreementField-CDBU31xW.mjs → SiteTermsAgreementField-B4z-e4Wq.mjs} +27 -24
  77. package/dist/client/{StepIndicator-JQA-VuEH.mjs → StepIndicator-Dn_DY4oY.mjs} +1 -1
  78. package/dist/client/{StepIndicator-2Dl9zon2.mjs → StepIndicator-atfDU82W.mjs} +21 -13
  79. package/dist/client/{ThemedButton-CnSa7o-I.mjs → ThemedButton-PFOhXktM.mjs} +1 -33
  80. package/dist/client/{accessibleSurfaces-Wl8-_OVJ.mjs → accessibleSurfaces-n6kS6Hct.mjs} +77 -1
  81. package/dist/client/{accordion-B6SqU49k.mjs → accordion-CsW8U3ff.mjs} +1 -1
  82. package/dist/client/{booking-form.client-DrEOjQ3N.mjs → booking-form.client-cBWM392H.mjs} +442 -86
  83. package/dist/client/bookingCalendar--aWnqFDn.mjs +180 -0
  84. package/dist/client/{bookingForm-drZBwEZW.mjs → bookingForm-DgySpp6C.mjs} +4 -4
  85. package/dist/client/bookings.mjs +51 -15
  86. package/dist/client/{boxStyleClassNames-DEh45w16.mjs → boxStyleClassNames-BpGVdLFD.mjs} +2 -2
  87. package/dist/client/{carousel-C-YJliD-.mjs → carousel-DJoleFV3.mjs} +2 -2
  88. package/dist/client/{carousel.client-DMtGYTTM.mjs → carousel.client-BtLwHefX.mjs} +1 -1
  89. package/dist/client/{cart-acGFWK9R.mjs → cart-EO5o6uPH.mjs} +3 -3
  90. package/dist/client/{cart.client-BzlOGP2j.mjs → cart.client-D_gPw45z.mjs} +1 -1
  91. package/dist/client/{checkout-SEontwhy.mjs → checkout-NVfZW0kR.mjs} +3 -3
  92. package/dist/client/{checkout.client-C0Qvh-d4.mjs → checkout.client-DD3JuqOy.mjs} +1 -1
  93. package/dist/client/{checkoutUrls-yUKeq1N9.mjs → checkoutUrls-z2gXvlGw.mjs} +1 -1
  94. package/dist/client/client.mjs +306 -196
  95. package/dist/client/constants-CoOkvw__.mjs +100 -0
  96. package/dist/client/{context-DTrwaQtg.mjs → context-CRhn9qzS.mjs} +922 -388
  97. package/dist/client/{dateFormatting-Cg8E1r9l.mjs → dateFormatting-BnWB4L1s.mjs} +15 -25
  98. package/dist/client/{demoPortalMagicLink-D0kOJYOX.mjs → demoPortalMagicLink-CWDGSTBu.mjs} +2 -3
  99. package/dist/client/{enhanceHeaderSection-DyrpZ7ks.mjs → enhanceHeaderSection-tdP_-Z9o.mjs} +4 -5
  100. package/dist/client/{event-registration.client-RLZQWi2V.mjs → event-registration.client-D7YYKySQ.mjs} +2084 -1640
  101. package/dist/client/{eventCalendar-CphYnImh.mjs → eventCalendar-CsAfu5d0.mjs} +4 -4
  102. package/dist/client/{eventCombined-BvqjASB_.mjs → eventCombined-VXJB5CoS.mjs} +4 -4
  103. package/dist/client/{eventListing-BaNAoC_M.mjs → eventListing-B3KIZNfY.mjs} +4 -4
  104. package/dist/client/{eventRegistration-COMHoRl6.mjs → eventRegistration-BP-dEk1c.mjs} +4 -4
  105. package/dist/client/{form-DyH2juYT.mjs → form-DM8Zbxbv.mjs} +3 -3
  106. package/dist/client/{form.client-DBwzkB0M.mjs → form.client-e2z_Tlgk.mjs} +5 -5
  107. package/dist/client/{form.parts-CY4kX3mh.mjs → form.parts-Ctljy1a3.mjs} +3 -3
  108. package/dist/client/gifting/client.mjs +32 -29
  109. package/dist/client/{gifting-CIx4V378.mjs → gifting-DWIsqQru.mjs} +4 -4
  110. package/dist/client/{gifting.client-BEVPpzJM.mjs → gifting.client-QsSWF0uA.mjs} +5 -5
  111. package/dist/client/{gifting.parts-VnORjnZK.mjs → gifting.parts-CedLgwa_.mjs} +2 -2
  112. package/dist/client/{headerSection-DGcJfRS8.mjs → headerSection-DAkRkwb-.mjs} +2 -2
  113. package/dist/client/{mediaAssets-B99AP7ai.mjs → mediaAssets-COfQolI3.mjs} +1 -1
  114. package/dist/client/{mediaContext-Fusweriw.mjs → mediaContext-DzvnjYXm.mjs} +1 -1
  115. package/dist/client/{newsletter-form.client-BvEDkjiD.mjs → newsletter-form.client-WYja9-WN.mjs} +7 -7
  116. package/dist/client/{newsletter-form.interactive-DCO1lErD.mjs → newsletter-form.interactive-RuM86VAv.mjs} +37 -44
  117. package/dist/client/{newsletter-form.parts-BIy4IUT3.mjs → newsletter-form.parts-2petDnWv.mjs} +2 -2
  118. package/dist/client/{newsletterForm-CoTXDNFS.mjs → newsletterForm-BUbXdA_e.mjs} +3 -3
  119. package/dist/client/{lookSurfaces-IqT_SVnX.mjs → noop-Dl4mZ-rr.mjs} +257 -49
  120. package/dist/client/portal/client.mjs +11779 -6745
  121. package/dist/client/portalOrders-COGn4BKG.mjs +596 -0
  122. package/dist/client/portalRoutes-D72yvtDh.mjs +862 -0
  123. package/dist/client/{product-detail.client-YHQ2aKX1.mjs → product-detail.client-pOAryevt.mjs} +1 -1
  124. package/dist/client/{product-list.client-DxoZw1vF.mjs → product-list.client-CcUpUiud.mjs} +1 -1
  125. package/dist/client/{productDetail-DjuFvkey.mjs → productDetail-BZJCfqat.mjs} +3 -3
  126. package/dist/client/{productList-DE9GEFoZ.mjs → productList-CiRs3mNb.mjs} +3 -3
  127. package/dist/client/{propsDecoder-Cyag_HOs.mjs → propsDecoder--uHW4tFM.mjs} +2 -2
  128. package/dist/client/{registry.server-BPwV-0Pp.mjs → registry.server-CDNNd8wC.mjs} +318 -235
  129. package/dist/client/{renderableMediaAssetAdmission-BlfqYLJW.mjs → renderableMediaAssetAdmission-BsOWd9lf.mjs} +1 -1
  130. package/dist/client/rendering/client.mjs +26 -26
  131. package/dist/client/rendering/islands.mjs +1 -1
  132. package/dist/client/rendering.mjs +16 -8
  133. package/dist/client/{richText-coerce-NrRqDeOg.mjs → richText-coerce-CQGE_wHV.mjs} +2 -1
  134. package/dist/client/{routeIslandApiConfig-BWq5gKFK.mjs → routeIslandApiConfig-BtCg87-N.mjs} +1 -1
  135. package/dist/client/{runtimeResponse-D2j2-mOk.mjs → runtimeResponse-DL_ARBpa.mjs} +1 -1
  136. package/dist/client/{runtimeResponse-DtWSfWSZ.mjs → runtimeResponse-Ds9cmBUf.mjs} +1 -1
  137. package/dist/client/{shop-C3wM0Hr4.mjs → shop-Rx_gEMK8.mjs} +3 -3
  138. package/dist/client/{shop-commerce-34YvcpbX.mjs → shop-commerce-D8evQnMT.mjs} +53 -16
  139. package/dist/client/{shop-commerce-store-B7xHksOs.mjs → shop-commerce-store-C9PcsSTj.mjs} +22 -5
  140. package/dist/client/{shop-discount-apply.state-BiBnozfO.mjs → shop-discount-apply.state-D5CtGfJI.mjs} +2 -2
  141. package/dist/client/{shop.client-C0v88nLd.mjs → shop.client-D4lzQ9oY.mjs} +17 -39
  142. package/dist/client/{shopShared-Ct-BRNez.mjs → shopShared-BVbq7Nm-.mjs} +2 -2
  143. package/dist/client/spam-protection.mjs +1 -1
  144. package/dist/client/src-Al4ooTl_.mjs +164 -0
  145. package/dist/client/{src-CCtanNlD.mjs → src-ZSqRK3dD.mjs} +345 -92
  146. package/dist/client/{timetableModel-lhE29TNT.mjs → timetableModel-BQJrSK0K.mjs} +205 -80
  147. package/dist/client/{shop-add-feedback-DvC2kP1K.mjs → urlParams-C2QHo1Pa.mjs} +1 -42
  148. package/dist/client/{useAvailableSlots-BelJviOT.mjs → useAvailableSlots-Dm3lKJKR.mjs} +3 -24
  149. package/dist/client/{useDiscountCodeUi-rQRE1-Ho.mjs → useDiscountCodeUi-klgfGn7f.mjs} +1 -1
  150. package/dist/client/{useEventPagination-C4rS2Xxl.mjs → useEventPagination-Jnjt7_ly.mjs} +8 -8
  151. package/dist/client/{view-LJVHVqsy.mjs → view-CC_yQLSA.mjs} +4 -4
  152. package/dist/client/{wizardSteps-CNDsxeJH.mjs → wizardSteps-BliJOzEX.mjs} +2512 -675
  153. package/dist/preview-next/before-render.mjs +1 -0
  154. package/dist/preview-next/client/{LocationPickerEnvironment-BHAT81Wx.mjs → LocationPickerEnvironment-BW3dRFIv.mjs} +1 -1
  155. package/dist/preview-next/client/{MapLibreEditMap-B52hkdIZ.mjs → MapLibreEditMap-Db9BHyXh.mjs} +2 -2
  156. package/dist/preview-next/client/{PageSectionToolbar-C4TtBPN-.mjs → PageSectionToolbar-BhL0uADo.mjs} +4 -4
  157. package/dist/preview-next/client/{PreviewEditorSidebar-D6fkE59-.mjs → PreviewEditorSidebar-Ct8eIm0i.mjs} +8 -7
  158. package/dist/preview-next/client/{PreviewEditorUI-amcDlj0O.mjs → PreviewEditorUI-BS32G4V9.mjs} +5 -5
  159. package/dist/preview-next/client/{PreviewShell-DeQjx4zk.mjs → PreviewShell-RL0WfZXD.mjs} +7 -7
  160. package/dist/preview-next/client/{SdkPreviewModeRuntime-Cx0SXnoX.mjs → SdkPreviewModeRuntime-MK_gHeGy.mjs} +39 -7
  161. package/dist/preview-next/client/{lucide-react-McYZeSMb.mjs → lucide-react-00FF_oar.mjs} +13 -1
  162. package/dist/preview-next/client/{previewAssistantSlot-aqpU34WI.mjs → previewAssistantSlot-CQyS8pcq.mjs} +10318 -3719
  163. package/dist/preview-next/client/{previewChromeRoot-D3Gy_Rs0.mjs → previewChromeRoot-BSxp3Mfu.mjs} +1 -1
  164. package/dist/preview-next/client/runtime.mjs +3 -3
  165. package/dist/preview-next/client/{sdk-runtime-Dzx_RrN7.mjs → sdk-runtime-DKnTzy74.mjs} +2 -2
  166. package/dist/preview-next/client/{siteStyleAccess-LHedw83e.mjs → siteStyleAccess-BlmbvbLN.mjs} +37 -25
  167. package/dist/preview-next/client/{useAutosaveStatus-DpSd9aVk.mjs → useAutosaveStatus-D-7GwZOQ.mjs} +1 -1
  168. package/dist/preview-next/client/{useOpenBlockForSetup-BGZn5AT1.mjs → useOpenBlockForSetup-BNZtGM5g.mjs} +2 -2
  169. package/dist/preview-next/container-responsive.css +292 -170
  170. package/dist/preview-next/keepAlive.mjs +1 -1
  171. package/dist/preview-next/middleware.mjs +1 -1
  172. package/dist/preview-next/{route-contract-DnL-FgSV.mjs → route-contract-R3PcMmax.mjs} +114 -37
  173. package/dist/server/{Block.shared-BEbq6EwO.mjs → Block.shared-CniF9tSu.mjs} +5 -5
  174. package/dist/server/{ThemeScopeCore-DFEM1a85.mjs → ThemeScopeCore-BQWsnGT6.mjs} +133 -120
  175. package/dist/server/{accessibleSurfaces-CM3QANtw.mjs → accessibleSurfaces-WPzUAHp4.mjs} +33 -2
  176. package/dist/server/accordions-By_0Ykks.mjs +111 -0
  177. package/dist/server/{bindings-Bly0dRs7.mjs → bindings-DxojjtK3.mjs} +7 -7
  178. package/dist/server/{client-CGJ2ztYp.mjs → client-CDndhbYO.mjs} +1412 -1307
  179. package/dist/server/config-validation.mjs +1 -1
  180. package/dist/server/config.mjs +2 -2
  181. package/dist/server/constants-VyF5nEhL.mjs +1474 -0
  182. package/dist/server/{customCss-BZ8YSrQg.mjs → customCss-C9kgPHvr.mjs} +41 -5
  183. package/dist/server/data/resolveBlockData.mjs +1 -1
  184. package/dist/server/index.mjs +3 -3
  185. package/dist/server/{loadContent-BkK1w3QQ.mjs → loadContent-BKstMBmX.mjs} +7 -4
  186. package/dist/server/{loadPage-DTLe0FEs.mjs → loadPage-IgNnZaqr.mjs} +3 -3
  187. package/dist/server/{lookMediaFrame-CaH018pK.mjs → lookMediaFrame-TFjgNG61.mjs} +74 -18
  188. package/dist/server/manifest.mjs +36 -25
  189. package/dist/server/{mapLocation-BM5WX7FY.mjs → mapLocation-MDDSubTp.mjs} +1 -1
  190. package/dist/server/media-BRmYrnzb.mjs +31 -0
  191. package/dist/server/{media-luf7RF22.mjs → media-gvfIw3z8.mjs} +2 -31
  192. package/dist/server/{navigation-BcNfYYuu.mjs → navigation-quBYlSKD.mjs} +2 -2
  193. package/dist/server/navigation.mjs +1 -1
  194. package/dist/server/next.mjs +170 -104
  195. package/dist/server/{overrideResolution-Uy9Zp2Ks.mjs → overrideResolution-CCaAPpIa.mjs} +1 -1
  196. package/dist/server/page-converter.mjs +3 -3
  197. package/dist/server/{pageRenderPlan-JzxBnqfV.mjs → pageRenderPlan-B7iULvKe.mjs} +15 -12
  198. package/dist/server/{pageRuntimeSupport-DyNSd2Yj.mjs → pageRuntimeSupport-BytMroxn.mjs} +9 -5
  199. package/dist/server/{pageShared-DU4ETFPS.mjs → pageShared-Dcs_XTIO.mjs} +836 -624
  200. package/dist/server/{parseThemeForPersistence-DOsfofCy.mjs → parseThemeForPersistence-Bihl4W5K.mjs} +3 -2
  201. package/dist/server/{portal-B4JVkdjc.mjs → portal-CMW_b9mG.mjs} +62 -46
  202. package/dist/server/portal.mjs +3 -3
  203. package/dist/server/portalQuestions-oUyohgL9.mjs +225 -0
  204. package/dist/server/{prebuild-8jNtDXmS.mjs → prebuild-agaH-vZV.mjs} +1 -1
  205. package/dist/server/prebuild.mjs +1 -1
  206. package/dist/server/{prefetchBlockData-xeMG42aw.mjs → prefetchBlockData-DwpRjqw4.mjs} +5 -3
  207. package/dist/server/{registry-DH1VrsCl.mjs → registry-DM9dHfDC.mjs} +582 -526
  208. package/dist/server/rendering/components/pageShared.mjs +1 -1
  209. package/dist/server/rendering/helpers/loadPage.mjs +1 -1
  210. package/dist/server/rendering/helpers/pageRuntimeSupport.mjs +1 -1
  211. package/dist/server/rendering/server.mjs +4 -4
  212. package/dist/server/rendering.mjs +10 -9
  213. package/dist/server/{resolveBlockData-BN8tweTx.mjs → resolveBlockData-CinHGf8l.mjs} +39 -31
  214. package/dist/server/{resolveButtonColourStates--6yJp9Tq.mjs → resolveButtonColourStates-B0O1IM16.mjs} +2 -1028
  215. package/dist/server/{resolvePageContent-DnM16_f9.mjs → resolvePageContent-BWKUZUIn.mjs} +1 -1
  216. package/dist/server/{responseMedia-F-ElH2Rd.mjs → responseMedia-IfH65QAH.mjs} +57 -2
  217. package/dist/server/routing.mjs +1 -1
  218. package/dist/server/{schema-BpsqaSSU.mjs → schema-CwfxQjc4.mjs} +10 -113
  219. package/dist/server/server.mjs +3 -3
  220. package/dist/server/{servicePageContent-B-FezJmH.mjs → servicePageContent-BBBhOtdE.mjs} +31 -26
  221. package/dist/server/theme-bridge.mjs +3 -2
  222. package/dist/server/theme.mjs +2 -2
  223. package/dist/server/{three-pass-converter-39SXCCnh.mjs → three-pass-converter-DPaUPTfl.mjs} +34 -16
  224. package/dist/server/titleSourceSchema-NhK6azFS.mjs +2018 -0
  225. package/dist/server/typeGuards-CTW_9AXq.mjs +413 -0
  226. package/dist/server/types-BKaBZFjD.mjs +1085 -0
  227. package/dist/server/{validation-3jOzYdPL.mjs → validation-DG5jX3jH.mjs} +70 -17
  228. package/dist/server/{version-8t0o6_jd.mjs → version-CipbxPHL.mjs} +1 -1
  229. package/dist/server/video-Cdr3wh-q.mjs +272 -0
  230. package/dist/styles/index.css +3446 -3796
  231. package/package.json +2 -1
  232. package/dist/_dts/index-DVSipdrT.d.ts +0 -101
  233. package/dist/client/TabBarFragment-DlKQRhP4.mjs +0 -56
  234. package/dist/client/checkoutRoute-DKlZRNZD.mjs +0 -22
  235. package/dist/client/constants-4o4_hl34.mjs +0 -6
  236. package/dist/client/creditProducts-BQ1t1erI.mjs +0 -266
  237. package/dist/client/formatDate-CTEN7gxW.mjs +0 -26
  238. package/dist/server/constants-Cj7hfbrA.mjs +0 -41
  239. package/dist/server/richTextSchema-QLaQrbII.mjs +0 -212
  240. package/dist/server/titleSourceSchema-Cu-3PRvv.mjs +0 -122
@@ -1,18 +1,19 @@
1
1
  "use client";
2
- import { f as err, p as ok } from "./renderableMediaAssetAdmission-BlfqYLJW.mjs";
3
- import { $ as beginWaitlistInvitation, $t as severalRunsChoiceMessage, An as getSlidingScaleForEvent, Ar as resolveEventRegistrationScopedEvents, At as decideSelectionPayment, Bo as eventRegistrationErrorEndsCommand, C as resolveGuestNextStepCheck, Cn as getVisibleTicketTypes, Ct as runsKeepingAnswers, Dn as getCurrentTicketSelection, E as resolveRegistrationTicketContinuation, Er as closedDateCopy, Et as paymentReturnRestoration, Fn as shouldLoadRegistrationOptions, Ft as registrationSelectionMode, G as withOfferedEvent, Gt as selectionItemPrice, H as registrationBrowserDraft, Hn as hasValidPricingOptionSelection, Ho as parseEventRegistrationErrorReason, Hr as groupPublicEventsByRun, In as withRegistrationAvailability, J as resolveDiscountContext, Jo as resolveWholeSeriesBookingPhase, K as buildRegistrationSelectionRequest, L as calculateEventRegistrationPreviewTotal, M as resolveEventRegistrationSubmitPlan, Mn as getTicketSelectionRemainingPlaces, Mt as incompleteRunChoiceMessage, Nn as parseCurrencyInputToCents, Nt as planSelectionPrice, O as visitorHoldsOwnPlace, Oi as toBookingQuestionsPaymentSnapshot, On as getEligibilityFlowFlags, Pn as resolveHeldTicketPlaces, Pt as primarySelectionItem, Q as toRegistrationRequestSubject, Qt as severalItemsOf, Rn as getSingleSelectedPricingOptionId, S as planRegistrationDetailsContinuation, St as runFieldErrors, Ti as needsBookingQuestionsRefresh, Tn as transformRegistrationOptionsResponse, Tr as closedRunCopy, Tt as withoutKeptAnswers, U as registrationBrowserDraftSchema, Un as normalizeTicketSelectionLines, Vo as eventRegistrationErrors, W as restorableBrowserDraftCode, Wt as selectionIncludes, X as resolveRegistrationTarget, Xt as selectionTicketInputs, Y as resolveEventRequiresPayment, Z as resolveRouteRequiresPayment, Zo as resolveBookingSignupOffer, _t as buildSelectionRequirementsSubmission, a as registrationPresentation, an as combinationWorking, at as toWaitlistClaimResolveFailure, bn as getImplicitSingleTicketType, bt as deriveRunRequirements, cn as selectionPreviewKey, ct as getRegistrationStartAt, d as decideEventChoice, da as PAGE_NAVIGATION, dt as toWholeSeriesRegistrationEvents, en as summariseSelectionPayment, et as createRegistrationDraftData, f as getDeclinedPass, fi as formatCentsAsCurrencyInput, ft as EVENT_SIGN_IN_FORM_ID, g as decideEventRegistrationPayment, gt as toEventSignInDraft, h as buildEventRegistrationPaymentOptionsViewModel, ha as requestSignIn, ht as eventSignInRestoration, i as registrationPaymentRoute, in as combinationOffersOf, it as isSameWaitlistClaim, jn as getSlidingScaleSelectionMessage, jt as effectiveSelection, kn as getRegistrationOccurrenceId, kr as resolveEventRegistrationChoices, kt as canToggleSelectionItem, ln as selectionPreviewLines, lt as toRegistrationEvents, m as registrationFlowReducer, mt as eventSignInEnds, nn as combinationHintCopy, nt as registrationQuestionsMessage, o as registrationRoute, on as selectionCombinationHint, p as isRegistrationLocked, pa as leavePage, pn as findSelectedTicketType, pt as eventSignInDraftStore, q as findPreSelectedEvent, qo as orderedLiveRunSessions, rr as appliedDiscountHint, rt as validateFormData, tn as toggleSelectionItem, tt as invitationSubmission, u as createInitialRegistrationFlowState, un as serverPricedTotalCents, ur as formatCommercePrice, us as publicEventPricingCurrency, vt as checkRunRequirements, w as resolveRegistrationAdmission, wi as deriveBookingQuestions, wr as closedDatesCopy, wt as toRunRequirementsSnapshots, x as planRegistrationDetailsCheck, xn as getPortalSubjectEmail, xt as nextRunToRead, y as getTicketSelectionPurpose, yt as decideSelectionRequirementsLayout, zo as decideSelectionAttendance } from "./wizardSteps-CNDsxeJH.mjs";
4
- import { mn as resolveBookingBusinessTimeZone, t as assertNever, tn as inferSiteDateLocale } from "./src-CCtanNlD.mjs";
5
- import { o as checkBookingQuestionsAnswered } from "./creditProducts-BQ1t1erI.mjs";
6
- import { a as eventSiteTermsSurface, i as useSiteTermsAgreement, r as siteTermsFailureKind } from "./SiteTermsAgreementField-CDBU31xW.mjs";
2
+ import { m as ok, p as err } from "./renderableMediaAssetAdmission-BsOWd9lf.mjs";
3
+ import { An as formatCurrencyAmount, St as roomChoicesSchema, dn as inferSiteDateLocale, t as assertNever, wn as resolveBookingBusinessTimeZone, xt as reviewedRoomsSchema } from "./src-ZSqRK3dD.mjs";
4
+ import { $a as PAGE_NAVIGATION, $n as serverPricedTotalCents, $t as toWholeSeriesRegistrationEvents, A as ownCoverPaysEveryDate, Ar as normalizeTicketSelectionLines, As as eventRegistrationErrors, At as resolveEventRequiresPayment, Bt as defaultTicketOptions, C as currentSelectionFundingLookup, Cn as primarySelectionItem, Cr as withRegistrationAvailability, Ct as beginWaitlistInvitation, D as fundingOptionPick, Ds as decideSelectionAttendance, Dt as buildRegistrationSelectionRequest, E as fundingOptionKey, Et as withOfferedEvent, F as selectionFundingRequest, Ft as validateFormData, G as planRegistrationDetailsContinuation, Gn as combinationHintCopy, Gs as resolveWholeSeriesBookingPhase, Gt as selectRoomOffer, H as getTicketSelectionPurpose, Hn as severalRunsChoiceMessage, Ht as presentRoomChooser, I as buildEventRegistrationPaymentOptionsViewModel, J as resolveRegistrationAdmission, Jn as combinationWorking, Kt as isSameWaitlistClaim, L as buildSelectionCollectionOptions, Lt as bookingLines, M as selectionFundingBasis, Ms as parseEventRegistrationErrorReason, Mt as resolveRouteRequiresPayment, N as selectionFundingFetchWanted, Nn as selectionIncludes, Ns as EVENT_CHECKOUT_HOLD_DURATION_MS, Nt as toRegistrationRequestSubject, O as initialSelectionFundingLookup, P as selectionFundingReducer, Pn as selectionItemPrice, Ps as planCheckoutPaymentFlow, Pt as registrationQuestionsMessage, Q as visitorHoldsOwnPlace, Qn as selectionPreviewLines, R as decideEventRegistrationPayment, Rs as getStripeMinimumChargeRequirement, Rt as dayOptionsOf, S as chosenFundingOption, Sn as planSelectionPrice, Sr as shouldLoadRegistrationOptions, St as entryStart, T as fundingMoneyDates, Tr as getSingleSelectedPricingOptionId, Tt as invitationBooking, Un as summariseSelectionPayment, Ut as roomChoiceMessage, Vn as severalItemsOf, Vt as isRoomChoiceRefusal, W as planRegistrationDetailsCheck, Wn as toggleSelectionItem, Wr as appliedDiscountHint, Ws as orderedLiveRunSessions, Wt as roomSubmission, X as resolveRegistrationTicketContinuation, Xn as selectionCombinationHint, Xt as getRegistrationStartAt, Yn as paymentCaption, Ys as resolveBookingSignupOffer, Zr as formatCommercePrice, Zt as toRegistrationEvents, _ as pickCollections, _i as resolveEventRegistrationScopedEvents, _r as getSlidingScaleForEvent, _t as bookingOccurrenceContext, a as registrationPresentation, an as buildSelectionRequirementsSubmission, b as selectionPaysNothing, bn as effectiveSelection, br as parseCurrencyInputToCents, bt as entryPageEvent, cn as deriveRunRequirements, cr as getPortalSubjectEmail, ct as calculateEventRegistrationPreviewTotal, d as decideEventChoice, da as needsBookingQuestionsRefresh, di as closedDatesCopy, dn as runsKeepingAnswers, dt as paymentChoiceDetails, en as EVENT_SIGN_IN_FORM_ID, er as findSelectedTicketType, f as isRegistrationLocked, fi as closedRunCopy, fn as toRunRequirementsSnapshots, fr as transformRegistrationOptionsResponse, ft as paymentChoicePrice, g as paymentOptionFor, ga as formatPrice, gi as resolveEventRegistrationChoices, gr as getRegistrationOccurrenceId, gt as restorableBrowserDraftCode, h as moneyCollections, hn as ATTENDANCE_CHOICE_MESSAGE, hr as getCurrentTicketSelection, ht as registrationBrowserDraftSchema, i as registrationPaymentRoute, in as toEventSignInDraft, j as selectionDatesQuote, js as eventRegistrationRefusalMessage, jt as resolveRegistrationTarget, k as lookupChosenOption, ki as groupPublicEventsByRun, kr as hasValidPricingOptionSelection, ks as eventRegistrationErrorEndsCommand, kt as resolveDiscountContext, lc as publicEventPricingCurrency, ln as nextRunToRead, m as collectionsOf, ma as toBookingQuestionsPaymentSnapshot, mn as paymentReturnRestoration, mt as registrationBrowserDraft, nn as eventSignInEnds, nt as resolveEventRegistrationSubmitPlan, o as registrationRoute, on as checkRunRequirements, p as registrationFlowReducer, pi as closedDateCopy, pn as withoutKeptAnswers, q as resolveGuestNextStepCheck, qn as combinationOffersOf, qt as toWaitlistClaimResolveFailure, rn as eventSignInRestoration, ro as requestSignIn, sn as decideSelectionRequirementsLayout, sr as getImplicitSingleTicketType, tn as eventSignInDraftStore, to as leavePage, tr as formatBookingWhen, u as createInitialRegistrationFlowState, ua as deriveBookingQuestions, un as runFieldErrors, ur as getVisibleTicketTypes, v as runsSelectionPaymentRequest, vn as attendanceChoicePending, vr as getSlidingScaleSelectionMessage, vt as decideRegistrationEntry, w as fundingChoice, wn as quoteReductions, wt as invitationSubmission, x as cardStepServesDates, xn as incompleteRunChoiceMessage, xr as resolveHeldTicketPlaces, xt as entrySelectionMode, y as selectionItemLabels, yn as canToggleSelectionItem, yr as getTicketSelectionRemainingPlaces, yt as entryChoosesEvent, zn as selectionTicketInputs, zt as decideRoomStay } from "./wizardSteps-BliJOzEX.mjs";
5
+ import { i as portalPath } from "./portalRoutes-D72yvtDh.mjs";
6
+ import { c as checkBookingQuestionsAnswered } from "./bookingCalendar--aWnqFDn.mjs";
7
+ import { i as useSiteTermsAgreement, r as siteTermsFailureKind } from "./SiteTermsAgreementField-B4z-e4Wq.mjs";
7
8
  import { t as generateUuidV4 } from "./uuid-BETKW8rS.mjs";
8
- import { i as BlockApiError, n as useBlockApi } from "./context-DTrwaQtg.mjs";
9
+ import { s as indefiniteArticle } from "./BookingQuestionFields-CyNIKw6k.mjs";
10
+ import { i as BlockApiError, n as useBlockApi } from "./context-CRhn9qzS.mjs";
11
+ import { n as EVENT_REGISTRATION_CHECKOUT_ATTEMPT_PARAM, r as paidInFullNote, t as EVENT_REGISTRATION_ANCHOR_ID } from "./constants-CoOkvw__.mjs";
9
12
  import { t as resolveDedicatedBookingHref } from "./bookingRoute-D6DlxYx6.mjs";
10
- import { n as EVENT_REGISTRATION_CHECKOUT_ATTEMPT_PARAM, t as EVENT_REGISTRATION_ANCHOR_ID } from "./constants-4o4_hl34.mjs";
11
- import { r as DISCOUNT_APPLY_MESSAGES } from "./DemoBookingPortalAccess-uA9H8LIL.mjs";
12
- import { i as useBookingNowIso, r as parseBookingSubmissionFailure } from "./BookingQuestionFields-C8IbeLHj.mjs";
13
- import { t as useDiscountCodeUi } from "./useDiscountCodeUi-rQRE1-Ho.mjs";
14
- import { a as usePolling, c as useBookingQuestionsRefresh, o as portalSessionIdentity, s as useSignInReturn } from "./BookingMailingListNote-BsbEgagJ.mjs";
15
- import { s as storeDemoBookingPass, t as CUSTOMER_PORTAL_PATH } from "./demoPortalMagicLink-D0kOJYOX.mjs";
13
+ import { i as discountEmailProblem } from "./DemoBookingPortalAccess-DFLPyuqe.mjs";
14
+ import { c as parseBookingSubmissionFailure, d as useSignInReturn, f as useBookingQuestionsRefresh, l as useBookingNowIso, s as usePolling, u as portalSessionIdentity } from "./BookingMailingListNote-uWfR2kaG.mjs";
15
+ import { t as useDiscountCodeUi } from "./useDiscountCodeUi-klgfGn7f.mjs";
16
+ import { s as storeDemoBookingPass } from "./demoPortalMagicLink-CWDGSTBu.mjs";
16
17
  import { Suspense, lazy, useCallback, useEffect, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
17
18
  import { jsx } from "react/jsx-runtime";
18
19
  import { z } from "zod";
@@ -270,30 +271,24 @@ function registrationDiscountView(input) {
270
271
  };
271
272
  }
272
273
  /** A draft code must remain editable while its price is unresolved and payment choices are disabled. */
273
- function registrationDiscountEntryVisible(view, method) {
274
- return (view.manualCodeEntryAllowed || view.editingCode) && (view.several || method === "stripe" || method === "pass_bundle" || method === "membership_bundle");
274
+ function registrationDiscountEntryVisible(view) {
275
+ return view.manualCodeEntryAllowed || view.editingCode;
276
+ }
277
+ function registrationDiscountAccess(method, funding) {
278
+ if (method === "membership") return "notOffered";
279
+ if (funding.tag !== "loaded") return "card";
280
+ return chosenFundingOption(funding.funding, funding.pick).kind === "money" ? "card" : "notOffered";
275
281
  }
276
282
  //#endregion
277
283
  //#region ../blocks/src/system/runtime/nodes/event-registration/registrationDiscountCode.state.ts
278
284
  const NO_REDUCTION = {
279
285
  bookingTotalCents: null,
280
- automaticDiscount: null,
281
- passTotalCents: null,
282
- membershipFirstPaymentCents: null
286
+ automaticDiscount: null
283
287
  };
284
288
  function decideSingleBookingPrices(input) {
285
289
  const { context, quote } = input;
286
290
  if (input.several || !context) return NO_REDUCTION;
287
- if (context.type === "event" || context.type === "whole_series") return eventPrices(input, quote);
288
- if (!quote) return NO_REDUCTION;
289
- if (context.type === "pass") return {
290
- ...NO_REDUCTION,
291
- passTotalCents: reducedTotal(quote)
292
- };
293
- return context.type === "membership" ? {
294
- ...NO_REDUCTION,
295
- membershipFirstPaymentCents: reducedTotal(quote)
296
- } : NO_REDUCTION;
291
+ return context.type === "event" || context.type === "whole_series" ? eventPrices(input, quote) : NO_REDUCTION;
297
292
  }
298
293
  function eventPrices(input, quote) {
299
294
  if (!quote) return input.typedCode.trim() || input.lookupFailed ? NO_REDUCTION : {
@@ -313,9 +308,6 @@ function eventPrices(input, quote) {
313
308
  automaticDiscount: automaticFromQuote(quote.preview, input.advertisedAutomatic)
314
309
  };
315
310
  }
316
- function reducedTotal(quote) {
317
- return quote.preview.type === "applied" ? quote.preview.totalAfterDiscountCents : null;
318
- }
319
311
  /** The discount the server chose for this customer, which may not be the one advertised to everyone. */
320
312
  function automaticFromQuote(preview, advertised) {
321
313
  const shared = {
@@ -336,21 +328,11 @@ function automaticFromQuote(preview, advertised) {
336
328
  };
337
329
  }
338
330
  /** What an applied code does to this purchase, said beside the code. */
339
- function appliedCodeHint(selection, discount) {
340
- if (!discount) return "";
341
- if (selection.method !== "membership_bundle") return appliedDiscountHint({
331
+ function appliedCodeHint(discount) {
332
+ return discount ? appliedDiscountHint({
342
333
  ...discount,
343
334
  membership: null
344
- }) ?? "";
345
- const { productPrice, productInterval } = selection;
346
- if (!productPrice || productInterval !== "month" && productInterval !== "year") return "";
347
- return appliedDiscountHint({
348
- ...discount,
349
- membership: {
350
- priceCents: productPrice,
351
- billingInterval: productInterval
352
- }
353
- }) ?? "";
335
+ }) ?? "" : "";
354
336
  }
355
337
  /** Holds Pay for a code awaiting Apply, and says whether that's the only thing holding it. */
356
338
  function holdPaymentForCode(state, awaitingApply) {
@@ -370,25 +352,29 @@ function resolveRegistrationRecoveryAction(step, action) {
370
352
  if (step === "verifying-payment" || step === "verifying-timeout" || step === "payment") return "none";
371
353
  return action;
372
354
  }
355
+ /**
356
+ * After the details check refuses the booker (an earlier unpaid booking of theirs stands, or it couldn't be
357
+ * found safely), Try again returns to their details so continuing runs the check again. Not 'retry', which
358
+ * goes straight to payment and is for a refused submission. Not 'places', which on a full event swaps the
359
+ * message for the waitlist offer.
360
+ */
361
+ const DETAILS_CHECK_REFUSAL_RECOVERY = "details";
373
362
  function shouldRefreshAfterRegistrationError(step, action, enabled) {
374
363
  return enabled || step === "error" && action === "places";
375
364
  }
365
+ /** A fresh booking where this page's bookings start; the reset owns the start item's own defaults. */
376
366
  function resetRegistrationAfterExpiry(input) {
377
367
  input.dispatchFlow({
378
368
  type: "reset",
379
- hasPreSelectedContext: input.hasPreSelectedContext
369
+ start: input.start
380
370
  });
381
- input.setSelectedTicketLines([]);
382
- input.setSelectedSlidingAmountInput("");
383
- const mode = input.preSelectedEvent?.deliveryMode;
384
- input.setSelectedAttendanceMode(mode === "online" || mode === "in_person" ? mode : null);
385
371
  input.setErrorMessage("");
386
372
  }
387
373
  /** Retry the retained submission in place; explicit payment uncertainty stays status-only. */
388
374
  function recoverRegistrationError(action, handlers, navigation) {
389
375
  switch (action) {
390
376
  case "none": return { kind: "navigated" };
391
- case "portal": return leavePage(CUSTOMER_PORTAL_PATH, navigation);
377
+ case "portal": return leavePage(portalPath({ page: "bookings" }), navigation);
392
378
  case "event": return leavePage(window.location.pathname, navigation);
393
379
  case "retry":
394
380
  handlers.clearError();
@@ -467,7 +453,7 @@ function receiveHandOff(outcome, receive) {
467
453
  }
468
454
  //#endregion
469
455
  //#region ../blocks/src/system/runtime/nodes/event-registration/sessionStorage.ts
470
- const STORAGE_PREFIX = "riverbank:event-registration:";
456
+ const STORAGE_PREFIX$1 = "riverbank:event-registration:";
471
457
  const STALE_THRESHOLD_MS = 1440 * 60 * 1e3;
472
458
  const browserDraftEntry = z.object({
473
459
  version: z.literal(1),
@@ -489,7 +475,7 @@ function getRegistrationBrowserDraft(scope) {
489
475
  try {
490
476
  const stored = sessionStorage.getItem(`riverbank:event-draft:${scope}`);
491
477
  const entry = browserDraftEntry.safeParse(stored ? JSON.parse(stored) : null);
492
- if (entry.success && Date.now() - entry.data.timestamp <= STALE_THRESHOLD_MS) return entry.data.draft;
478
+ if (entry.success && Date.now() - entry.data.timestamp <= 108e5) return entry.data.draft;
493
479
  clearRegistrationBrowserDraft(scope);
494
480
  } catch {}
495
481
  return null;
@@ -510,32 +496,10 @@ const paymentSelection = z.discriminatedUnion("method", [
510
496
  "flexible_balance"
511
497
  ])
512
498
  }),
513
- z.object({
514
- method: z.literal("pass"),
515
- passId: z.string(),
516
- productName: z.string().optional()
517
- }),
518
499
  z.object({
519
500
  method: z.literal("membership"),
520
501
  membershipId: z.string(),
521
502
  productName: z.string().optional()
522
- }),
523
- z.object({
524
- method: z.literal("pass_bundle"),
525
- bundlePassId: z.string(),
526
- productName: z.string().optional(),
527
- productDescription: z.string().optional(),
528
- productPrice: z.number().optional(),
529
- productCurrency: z.string().optional()
530
- }),
531
- z.object({
532
- method: z.literal("membership_bundle"),
533
- bundleMembershipId: z.string(),
534
- productName: z.string().optional(),
535
- productDescription: z.string().optional(),
536
- productPrice: z.number().optional(),
537
- productCurrency: z.string().optional(),
538
- productInterval: z.string().optional()
539
503
  })
540
504
  ]);
541
505
  const reference = z.discriminatedUnion("scope", [z.object({
@@ -574,7 +538,15 @@ const currentSchema = z.object({
574
538
  runChoices: z.record(z.string(), z.object({
575
539
  pricingOptionId: z.string().nullable(),
576
540
  slidingAmountInput: z.string()
577
- })).optional()
541
+ })).optional(),
542
+ rooms: z.object({
543
+ choices: roomChoicesSchema,
544
+ reviewed: reviewedRoomsSchema.default([]),
545
+ dayLines: z.array(z.object({
546
+ pricingOptionId: z.string().nullable(),
547
+ quantity: z.number().int().positive()
548
+ }))
549
+ }).optional()
578
550
  });
579
551
  /** Saved before booking several existed: one reference and one event. */
580
552
  const version6Schema = z.object({
@@ -589,7 +561,7 @@ const version6Schema = z.object({
589
561
  }));
590
562
  const schema = z.union([currentSchema, version6Schema]);
591
563
  function key(siteId, submissionId) {
592
- return `${STORAGE_PREFIX}${siteId}:${submissionId}`;
564
+ return `${STORAGE_PREFIX$1}${siteId}:${submissionId}`;
593
565
  }
594
566
  function savePendingRegistration(siteId, submissionId, data) {
595
567
  try {
@@ -623,7 +595,7 @@ function clearPendingRegistration(siteId, submissionId) {
623
595
  }
624
596
  function cleanupStaleRegistrations() {
625
597
  try {
626
- Array.from({ length: sessionStorage.length }, (_, index) => sessionStorage.key(index)).filter((item) => item !== null && item.startsWith(STORAGE_PREFIX)).forEach((item) => {
598
+ Array.from({ length: sessionStorage.length }, (_, index) => sessionStorage.key(index)).filter((item) => item !== null && item.startsWith(STORAGE_PREFIX$1)).forEach((item) => {
627
599
  try {
628
600
  const parsed = z.safeParse(schema, JSON.parse(sessionStorage.getItem(item) ?? "null"));
629
601
  if (!parsed.success || Date.now() - parsed.data.timestamp > STALE_THRESHOLD_MS) sessionStorage.removeItem(item);
@@ -651,7 +623,7 @@ function hasRegistrationReturn(flow) {
651
623
  const params = new URLSearchParams(window.location.search);
652
624
  return flow.invitation.kind !== "none" || params.has("registration") || params.has("rb_booking_sign_in");
653
625
  }
654
- /** Only the allowlisted contact, ticket and code draft survives a reload in this tab. */
626
+ /** Only the allowlisted draft (`registrationBrowserDraftSchema`) survives a reload in this tab. */
655
627
  function useRegistrationBrowserDraft(input) {
656
628
  const [ready, setReady] = useState(false);
657
629
  const restored = useRef(false);
@@ -663,7 +635,8 @@ function useRegistrationBrowserDraft(input) {
663
635
  input.dispatch({
664
636
  type: "browser-draft-restored",
665
637
  draft: saved,
666
- events: input.events
638
+ events: input.events,
639
+ identity: input.identity
667
640
  });
668
641
  const code = restorableBrowserDraftCode(saved, input.events);
669
642
  if (code.trim()) input.onDiscountCodeRestored(code);
@@ -682,7 +655,7 @@ function useSaveRegistrationBrowserDraft(input) {
682
655
  return;
683
656
  }
684
657
  if (hasRegistrationReturn(input.flow)) return;
685
- const draft = registrationBrowserDraft(input.flow, input.discountCode);
658
+ const draft = registrationBrowserDraft(input.flow, input.discountCode, input.identity);
686
659
  if (draft) saveRegistrationBrowserDraft(input.scope, draft);
687
660
  }, [input, ready]);
688
661
  }
@@ -1076,7 +1049,7 @@ function useRunQuestionsRefresh(input) {
1076
1049
  }
1077
1050
  //#endregion
1078
1051
  //#region ../blocks/src/system/runtime/nodes/event-registration/useTicketSelectionInitialization.ts
1079
- /** Pick the single default once; removing or refreshing a line never picks it again. */
1052
+ /** Pick the single default once; removing or refreshing a line never picks it again. An event with rooms passes no options: its guests choose. */
1080
1053
  function useTicketSelectionInitialization(input) {
1081
1054
  const initializedSelection = useRef(null);
1082
1055
  useEffect(() => {
@@ -1128,7 +1101,8 @@ function eligibilityLookupReducer(state, action) {
1128
1101
  tag: "failed",
1129
1102
  eligibility: null,
1130
1103
  settledRequestKey: action.requestKey,
1131
- error: action.message
1104
+ error: action.message,
1105
+ closed: action.closed
1132
1106
  };
1133
1107
  default: return assertNever(action);
1134
1108
  }
@@ -1148,6 +1122,10 @@ function existingRegistrationLookupReducer(state, action) {
1148
1122
  tag: "resolved",
1149
1123
  registrations: action.registrations
1150
1124
  };
1125
+ case "failed": return {
1126
+ tag: "failed",
1127
+ registrations: []
1128
+ };
1151
1129
  default: return assertNever(action);
1152
1130
  }
1153
1131
  }
@@ -1177,27 +1155,28 @@ function usePortalAuthWithDeps(deps) {
1177
1155
  useEffect(() => {
1178
1156
  let cancelled = false;
1179
1157
  async function checkPortalAuth() {
1180
- if ((api.config.authOverrides?.portal ?? api.config.auth).type !== "bearer") {
1158
+ const visitor = api.portalVisitor;
1159
+ if (!visitor) {
1181
1160
  setAuthState("unauthenticated");
1182
1161
  setProfile(null);
1183
1162
  return;
1184
1163
  }
1185
1164
  setAuthState("checking");
1186
1165
  setProfile(null);
1187
- try {
1188
- const me = await api.getPortalProfile();
1189
- if (cancelled) return;
1190
- setProfile({
1191
- email: me.profile.email,
1192
- name: me.profile.name,
1193
- phone: me.profile.phone || ""
1194
- });
1195
- setAuthState("authenticated");
1196
- } catch {
1197
- if (cancelled) return;
1166
+ const result = await visitor.profile();
1167
+ if (cancelled) return;
1168
+ if (!result.ok) {
1198
1169
  setAuthState("unauthenticated");
1199
1170
  setProfile(null);
1171
+ return;
1200
1172
  }
1173
+ const { profile: me } = result.value;
1174
+ setProfile({
1175
+ email: me.email,
1176
+ name: me.name,
1177
+ phone: me.phone || ""
1178
+ });
1179
+ setAuthState("authenticated");
1201
1180
  }
1202
1181
  checkPortalAuth();
1203
1182
  return () => {
@@ -1259,15 +1238,25 @@ async function loadEligibility(input) {
1259
1238
  eligibility: transformRegistrationOptionsResponse(result),
1260
1239
  requestKey: input.requestKey
1261
1240
  });
1262
- } catch {
1241
+ } catch (error) {
1263
1242
  if (!input.isCurrent()) return;
1264
- input.dispatch({
1243
+ input.dispatch(isBookingsClosedRefusal(error) ? {
1265
1244
  type: "failed",
1266
1245
  requestKey: input.requestKey,
1267
- message: "We couldn’t load the booking options for this event. Please refresh this page and try again. If this keeps happening, contact the organiser for help."
1246
+ closed: true,
1247
+ message: "Bookings for this event have closed."
1248
+ } : {
1249
+ type: "failed",
1250
+ requestKey: input.requestKey,
1251
+ closed: false,
1252
+ message: "We couldn’t load the booking options for this event. Try again, or contact the organiser if this keeps happening."
1268
1253
  });
1269
1254
  }
1270
1255
  }
1256
+ /** The options route tags a refusal from an event that has stopped taking bookings. */
1257
+ function isBookingsClosedRefusal(error) {
1258
+ return error instanceof BlockApiError && error.tag === "REGISTRATION_OPTIONS_CLOSED";
1259
+ }
1271
1260
  function useEligibilityWithDeps(params, deps) {
1272
1261
  const api = deps.useBlockApi();
1273
1262
  const request = eligibilityRequest(params);
@@ -1314,6 +1303,7 @@ function useEligibilityWithDeps(params, deps) {
1314
1303
  requestKey,
1315
1304
  isLoading: effectiveState.tag === "loading",
1316
1305
  error: effectiveState.error,
1306
+ bookingsClosed: effectiveState.tag === "failed" && effectiveState.closed,
1317
1307
  creditState: registrationOptionsCreditState(effectiveState, params.subjectEmail)
1318
1308
  };
1319
1309
  }
@@ -1334,13 +1324,10 @@ function registrationOptionsCreditState(state, subjectEmail) {
1334
1324
  credit: state.eligibility.credit ?? null
1335
1325
  };
1336
1326
  }
1337
- function useExistingEventRegistration({ isAuthenticated, occurrenceId }) {
1338
- return useExistingEventRegistrationWithDeps({
1339
- isAuthenticated,
1340
- occurrenceId
1341
- }, eventRegistrationHooksDeps);
1327
+ function useExistingEventRegistration(params) {
1328
+ return useExistingEventRegistrationWithDeps(params, eventRegistrationHooksDeps);
1342
1329
  }
1343
- function useExistingEventRegistrationWithDeps({ isAuthenticated, occurrenceId }, deps) {
1330
+ function useExistingEventRegistrationWithDeps({ isAuthenticated, occurrenceId, completedBookings }, deps) {
1344
1331
  const api = deps.useBlockApi();
1345
1332
  const [state, dispatch] = useReducer(existingRegistrationLookupReducer, initialExistingRegistrationLookupState);
1346
1333
  const requestIdRef = useRef(0);
@@ -1352,23 +1339,20 @@ function useExistingEventRegistrationWithDeps({ isAuthenticated, occurrenceId },
1352
1339
  dispatch({ type: "reset" });
1353
1340
  return;
1354
1341
  }
1342
+ const visitor = api.portalVisitor;
1355
1343
  const requestId = requestIdRef.current + 1;
1356
1344
  requestIdRef.current = requestId;
1357
- dispatch({ type: "loading-started" });
1358
- try {
1359
- const { registrations: events } = await api.getPortalEvents({ occurrenceId });
1360
- if (cancelled || requestIdRef.current !== requestId) return;
1361
- dispatch({
1362
- type: "resolved",
1363
- registrations: events.filter((event) => event.occurrenceId === occurrenceId && event.status !== "cancelled" && event.transferState !== "transferred_out")
1364
- });
1365
- } catch {
1366
- if (cancelled || requestIdRef.current !== requestId) return;
1367
- dispatch({
1368
- type: "resolved",
1369
- registrations: []
1370
- });
1345
+ if (!visitor) {
1346
+ dispatch({ type: "reset" });
1347
+ return;
1371
1348
  }
1349
+ dispatch({ type: "loading-started" });
1350
+ const result = await visitor.occurrenceBookings(occurrenceId);
1351
+ if (cancelled || requestIdRef.current !== requestId) return;
1352
+ dispatch(result.ok ? {
1353
+ type: "resolved",
1354
+ registrations: result.value
1355
+ } : { type: "failed" });
1372
1356
  }
1373
1357
  fetchExistingRegistration();
1374
1358
  return () => {
@@ -1377,7 +1361,8 @@ function useExistingEventRegistrationWithDeps({ isAuthenticated, occurrenceId },
1377
1361
  }, [
1378
1362
  api,
1379
1363
  isAuthenticated,
1380
- occurrenceId
1364
+ occurrenceId,
1365
+ completedBookings
1381
1366
  ]);
1382
1367
  return {
1383
1368
  state,
@@ -1510,6 +1495,69 @@ function useEventRegistrationStripeReturn(options) {
1510
1495
  }, [options]);
1511
1496
  }
1512
1497
  //#endregion
1498
+ //#region ../blocks/src/system/runtime/nodes/event-registration/pendingCheckouts.ts
1499
+ const STORAGE_PREFIX = "riverbank:event-pending-checkouts:";
1500
+ const storedSchema = z.object({
1501
+ version: z.literal(1),
1502
+ checkouts: z.array(z.object({
1503
+ id: z.string().min(1),
1504
+ expiresAt: z.number().finite()
1505
+ }))
1506
+ });
1507
+ /** Pure: the checkouts still held at `now`, newest first, cut to what a request may name. */
1508
+ function currentPendingCheckouts(checkouts, now) {
1509
+ return checkouts.filter((checkout) => checkout.expiresAt > now).slice(0, 3);
1510
+ }
1511
+ /** Pure: the list with this checkout newest, holding its places for the hold window from `now`. */
1512
+ function withPendingCheckout(checkouts, commandId, now) {
1513
+ return currentPendingCheckouts([{
1514
+ id: commandId,
1515
+ expiresAt: now + EVENT_CHECKOUT_HOLD_DURATION_MS
1516
+ }, ...checkouts.filter((checkout) => checkout.id !== commandId)], now);
1517
+ }
1518
+ /**
1519
+ * The store over one browser storage. `storage` is read on every use and may throw, as may anything
1520
+ * it returns; every access is wrapped, so a failure reads as an empty list and a write is dropped.
1521
+ */
1522
+ function createPendingCheckoutStore(storage, clock = Date.now) {
1523
+ const key = (siteId) => `${STORAGE_PREFIX}${siteId}`;
1524
+ const read = (siteId) => {
1525
+ try {
1526
+ const stored = storage().getItem(key(siteId));
1527
+ const parsed = storedSchema.safeParse(stored ? JSON.parse(stored) : null);
1528
+ return parsed.success ? parsed.data.checkouts : [];
1529
+ } catch {
1530
+ return [];
1531
+ }
1532
+ };
1533
+ const write = (siteId, checkouts) => {
1534
+ try {
1535
+ if (checkouts.length === 0) storage().removeItem(key(siteId));
1536
+ else storage().setItem(key(siteId), JSON.stringify({
1537
+ version: 1,
1538
+ checkouts
1539
+ }));
1540
+ } catch {}
1541
+ };
1542
+ return {
1543
+ remember: (siteId, commandId) => {
1544
+ if (siteId) write(siteId, withPendingCheckout(read(siteId), commandId, clock()));
1545
+ },
1546
+ forget: (siteId, commandId) => {
1547
+ if (siteId) write(siteId, currentPendingCheckouts(read(siteId).filter((checkout) => checkout.id !== commandId), clock()));
1548
+ },
1549
+ ids: (siteId) => {
1550
+ if (!siteId) return [];
1551
+ const stored = read(siteId);
1552
+ const current = currentPendingCheckouts(stored, clock());
1553
+ if (current.length !== stored.length) write(siteId, current);
1554
+ return current.map((checkout) => checkout.id);
1555
+ }
1556
+ };
1557
+ }
1558
+ /** This browser's list, shared by every tab on the site's origin. */
1559
+ const browserPendingCheckouts = createPendingCheckoutStore(() => window.localStorage);
1560
+ //#endregion
1513
1561
  //#region ../blocks/src/system/runtime/nodes/event-registration/paymentLocation.ts
1514
1562
  function eventPaymentReturnUrl(submissionId) {
1515
1563
  const url = new URL(window.location.href);
@@ -1519,24 +1567,43 @@ function eventPaymentReturnUrl(submissionId) {
1519
1567
  url.hash = EVENT_REGISTRATION_ANCHOR_ID;
1520
1568
  return url.toString();
1521
1569
  }
1522
- function rememberEventPayment(submissionId, sessionId) {
1570
+ /**
1571
+ * A checkout has reached payment. The tab's address carries it, so a reload or a return from the
1572
+ * bank finds it, and the browser's list carries it too, so a booking made in another tab can name it.
1573
+ */
1574
+ function rememberEventPayment(siteId, submissionId, sessionId) {
1523
1575
  const url = new URL(eventPaymentReturnUrl(submissionId));
1524
1576
  url.searchParams.set("session_id", sessionId);
1525
1577
  window.history.replaceState(window.history.state, "", url);
1578
+ browserPendingCheckouts.remember(siteId, submissionId);
1526
1579
  }
1527
- function clearEventPayment(siteId) {
1580
+ /**
1581
+ * The tab has left that payment. `place` says what became of the booking: `finished` when it was paid,
1582
+ * abandoned or its places released, so the browser's list drops it; `held` when its places still
1583
+ * stand and the visitor is booking again, so another tab can still take it over.
1584
+ */
1585
+ function clearEventPayment(siteId, place) {
1528
1586
  const url = new URL(window.location.href);
1529
1587
  const submissionId = url.searchParams.get(EVENT_REGISTRATION_CHECKOUT_ATTEMPT_PARAM);
1530
1588
  if (siteId && submissionId) clearPendingRegistration(siteId, submissionId);
1589
+ if (submissionId && place === "finished") browserPendingCheckouts.forget(siteId, submissionId);
1531
1590
  url.searchParams.delete("registration");
1532
1591
  url.searchParams.delete(EVENT_REGISTRATION_CHECKOUT_ATTEMPT_PARAM);
1533
1592
  url.searchParams.delete("session_id");
1534
1593
  window.history.replaceState(window.history.state, "", url);
1535
1594
  }
1536
1595
  //#endregion
1596
+ //#region ../blocks/src/system/runtime/api/serverRefusal.ts
1597
+ /**
1598
+ * The server answered and refused the request (a 4xx), so nothing was written
1599
+ * and its message is meant for the person. A 5xx, no answer at all, or a 2xx
1600
+ * whose body couldn't be read leaves the outcome unknown.
1601
+ */
1602
+ function isServerRefusal(error) {
1603
+ return error instanceof BlockApiError && error.status >= 400 && error.status < 500;
1604
+ }
1605
+ //#endregion
1537
1606
  //#region ../blocks/src/system/runtime/nodes/event-registration/registrationErrorPresentation.ts
1538
- /** The tag the server gives a refused booking request, with a message meant for the booker. */
1539
- const REFUSED_INPUT_TAG = "REGISTRATION_INVALID_INPUT";
1540
1607
  /**
1541
1608
  * Public-site admission refusals: the site isn't open for online bookings.
1542
1609
  * The booker's details were fine, so these never ask them to check them.
@@ -1550,15 +1617,14 @@ function parseEventRegistrationFailure(error) {
1550
1617
  ...parseBookingSubmissionFailure(error, "Something went wrong. Please try again."),
1551
1618
  reason: !(error instanceof BlockApiError) ? null : siteUnavailable(error) ? "siteNotTakingBookings" : parseEventRegistrationErrorReason(error.tag),
1552
1619
  siteTermsFailure: siteTermsFailureKind(error),
1553
- isClientError: error instanceof BlockApiError && error.status < 500 && error.code !== "invalid_booking_response",
1554
- discountRefused: error instanceof BlockApiError && error.fieldErrors.some((field) => field.field === "discountCode"),
1555
- refusedInput: error instanceof BlockApiError && error.tag === REFUSED_INPUT_TAG && error.message.trim().length > 0
1620
+ isClientError: isServerRefusal(error),
1621
+ discountRefused: error instanceof BlockApiError && error.fieldErrors.some((field) => field.field === "discountCode")
1556
1622
  };
1557
1623
  }
1558
1624
  /**
1559
- * What the booker reads when a booking is refused. Booking several items
1560
- * (issue 1725) shows the server's own refusal ("Book one run at a time for
1561
- * this course.") rather than the general one, since it says what to change.
1625
+ * What the booker reads when a booking is refused. A known reason says its own message, or the
1626
+ * server's words where `eventRegistrationRefusalMessage` prefers them. A reason the form doesn't
1627
+ * know, as a form built before that reason was added won't, reads as a general refusal.
1562
1628
  */
1563
1629
  function registrationErrorPresentation(failure, bookings = "one") {
1564
1630
  if (failure.discountRefused) return {
@@ -1570,17 +1636,14 @@ function registrationErrorPresentation(failure, bookings = "one") {
1570
1636
  action: "details"
1571
1637
  };
1572
1638
  const reason = failure.reason;
1573
- if (reason) {
1574
- const { message, action } = eventRegistrationErrors[reason];
1575
- return {
1576
- message,
1577
- action
1578
- };
1579
- }
1639
+ if (reason) return {
1640
+ message: eventRegistrationRefusalMessage(reason, failure.message, bookings),
1641
+ action: eventRegistrationErrors[reason].action
1642
+ };
1580
1643
  if (failure.isClientError) {
1581
1644
  const { message, action } = eventRegistrationErrors.invalidCommitInput;
1582
1645
  return {
1583
- message: bookings === "several" && failure.refusedInput ? failure.message : message,
1646
+ message,
1584
1647
  action
1585
1648
  };
1586
1649
  }
@@ -1590,13 +1653,85 @@ function registrationErrorPresentation(failure, bookings = "one") {
1590
1653
  };
1591
1654
  }
1592
1655
  //#endregion
1656
+ //#region ../blocks/src/system/runtime/nodes/event-registration/eventRegistrationFunding.ts
1657
+ /**
1658
+ * How a whole run is paid on the wire. Dates send the server's funding option
1659
+ * instead (issue 1767), so a run is the only booking that names a method.
1660
+ */
1661
+ function toEventRunPayment(choice) {
1662
+ switch (choice.method) {
1663
+ case "free":
1664
+ case "stripe": return { paymentMethod: choice.method };
1665
+ case "membership": return {
1666
+ paymentMethod: "membership",
1667
+ customerMembershipId: choice.membershipId
1668
+ };
1669
+ default: return assertNever(choice.method);
1670
+ }
1671
+ }
1672
+ //#endregion
1593
1673
  //#region ../blocks/src/system/runtime/nodes/event-registration/useEventRegistrationSubmit.ts
1594
1674
  function wantsMailingListSignup(options) {
1595
1675
  return options.mailingListSignup !== null && options.formData.mailingListOptIn === true;
1596
1676
  }
1677
+ /**
1678
+ * The earlier bookings from this browser that a submission may take over from. The server replaces an
1679
+ * unpaid booking only for the browser that can name it, and accepts any one of these that matches.
1680
+ * This is the one place the list is built, from three sources:
1681
+ *
1682
+ * - the booking whose payment the visitor came back from in this tab (`heldPlace`);
1683
+ * - the command a changed form left behind, and whatever that command named;
1684
+ * - the checkouts this browser took to payment in any tab (`browserCheckouts`, newest first), which
1685
+ * is how a new tab names a booking whose own tab was closed.
1686
+ *
1687
+ * It's a list because the form can't tell which of them holds the place. A refused command reserved
1688
+ * nothing, so the booking it was to replace still stands; a command whose response was lost may have
1689
+ * reserved. Every id is derived here, so nothing has to be remembered or forgotten as attempts fail.
1690
+ *
1691
+ * The order decides what survives the cut to what the server accepts. The held place leads, since the
1692
+ * server has said it stands. The command just left behind comes next, as the only one that may hold a
1693
+ * place nobody was told about. Then the browser's checkouts, which did reach payment, and last the
1694
+ * older guesses. An identical retry sends what it sent before.
1695
+ */
1696
+ function replacedCommandIds(previous, intentChanged, heldPlace, browserCheckouts) {
1697
+ const held = heldPlace ? [heldPlace.submissionId] : [];
1698
+ const earlier = previous === null ? browserCheckouts : intentChanged ? [
1699
+ previous.id,
1700
+ ...browserCheckouts,
1701
+ ...previous.replaces
1702
+ ] : [...previous.replaces, ...browserCheckouts];
1703
+ return [.../* @__PURE__ */ new Set([...held, ...earlier])].slice(0, 3);
1704
+ }
1705
+ /**
1706
+ * The earlier bookings this browser can name before it submits, the command it last sent among them, as
1707
+ * a changed submission would name them. The guest details check sends these, so the answer it gets
1708
+ * (go on to pay, or an earlier booking stands) is the one submitting would give.
1709
+ */
1710
+ function earlierBookingsToName(previous, heldPlace, browserCheckouts) {
1711
+ return replacedCommandIds(previous, true, heldPlace, browserCheckouts);
1712
+ }
1713
+ /** The command this submission runs under: the same one for an identical retry, a new one once the details change. */
1714
+ function nextCommand(previous, submitted, earlier, createId) {
1715
+ const intentChanged = previous !== null && previous.intentKey !== submitted.intentKey;
1716
+ const id = intentChanged ? createId() : submitted.id;
1717
+ return {
1718
+ id,
1719
+ intentKey: submitted.intentKey,
1720
+ replaces: replacedCommandIds(previous, intentChanged, earlier.heldPlace, earlier.browserCheckouts).filter((named) => named !== id)
1721
+ };
1722
+ }
1723
+ /** The request under its command, naming the earlier bookings it may take over from when there are any. */
1724
+ function commandRequest(request, command) {
1725
+ return {
1726
+ ...request,
1727
+ registrationCommandId: command.id,
1728
+ ...command.replaces.length > 0 ? { replacesRegistrationCommandIds: command.replaces } : {}
1729
+ };
1730
+ }
1597
1731
  const eventRegistrationSubmitDeps = {
1598
1732
  savePendingRegistration,
1599
- createClientCommandId: generateUuidV4
1733
+ createClientCommandId: generateUuidV4,
1734
+ pendingCheckouts: browserPendingCheckouts
1600
1735
  };
1601
1736
  function useEventRegistrationSubmit(options) {
1602
1737
  return useEventRegistrationSubmitWithDeps(options, eventRegistrationSubmitDeps);
@@ -1647,31 +1782,31 @@ function useEventRegistrationSubmitWithDeps(options, deps) {
1647
1782
  */
1648
1783
  const { commandRef } = options;
1649
1784
  const inFlightRef = useRef(null);
1650
- const submit = async (method, passId, membershipId, selection) => {
1785
+ const submit = async (method, membershipId, selection) => {
1651
1786
  const start = resolveSubmissionStart(options);
1652
1787
  if (start.kind === "blocked") return start.result;
1653
1788
  const { invitation, target } = start;
1654
1789
  options.setStep("submitting");
1655
1790
  const registrationCommandId = commandRef.current?.id ?? deps.createClientCommandId();
1656
1791
  try {
1657
- const initialPrepared = prepareSubmitContext(options, registrationCommandId, target, method, passId, membershipId, selection);
1658
- const intentKey = registrationRequestIntentKey(buildRegistrationRequest(options, initialPrepared, invitation, method, passId, membershipId));
1659
- const prepared = commandRef.current !== null && commandRef.current.intentKey !== intentKey ? {
1660
- ...initialPrepared,
1661
- registrationCommandId: deps.createClientCommandId()
1662
- } : initialPrepared;
1663
- const request = buildRegistrationRequest(options, prepared, invitation, method, passId, membershipId);
1664
- commandRef.current = {
1665
- id: prepared.registrationCommandId,
1792
+ const initialPrepared = prepareSubmitContext(options, registrationCommandId, target, method, membershipId, selection);
1793
+ const intentKey = registrationRequestIntentKey(buildRegistrationRequest(options, initialPrepared, invitation, method, membershipId));
1794
+ const command = nextCommand(commandRef.current, {
1795
+ id: registrationCommandId,
1666
1796
  intentKey
1797
+ }, {
1798
+ heldPlace: options.heldPlace,
1799
+ browserCheckouts: deps.pendingCheckouts.ids(options.api.config.siteId)
1800
+ }, deps.createClientCommandId);
1801
+ const prepared = {
1802
+ ...initialPrepared,
1803
+ registrationCommandId: command.id
1667
1804
  };
1668
- return await completeRegistrationSubmission(options, deps, prepared, await options.api.registerForEvent({
1669
- ...request,
1670
- registrationCommandId: prepared.registrationCommandId
1671
- }));
1805
+ commandRef.current = command;
1806
+ return await completeRegistrationSubmission(options, deps, prepared, await options.api.registerForEvent(commandRequest(buildRegistrationRequest(options, prepared, invitation, method, membershipId), command)));
1672
1807
  } catch (error) {
1673
1808
  if (error instanceof BlockApiError && (eventRegistrationErrorEndsCommand(error.tag) || error.fieldErrors.some((field) => field.field === "discountCode"))) commandRef.current = null;
1674
- return reportFailedRegistration(options, error, method);
1809
+ return reportFailedRegistration(options, error);
1675
1810
  }
1676
1811
  };
1677
1812
  return (...args) => {
@@ -1699,6 +1834,7 @@ async function completeRegistrationSubmission(options, deps, prepared, result) {
1699
1834
  outcome: { kind: "payment_status" }
1700
1835
  };
1701
1836
  case "checkoutRequired":
1837
+ forgetReplacedBooking(options, deps);
1702
1838
  savePendingCheckout(options, deps, prepared, result.submissionId, result.mailingListSignupNote);
1703
1839
  const subject = result.reference.scope === "occurrence" ? {
1704
1840
  scope: "occurrence",
@@ -1726,15 +1862,21 @@ async function completeRegistrationSubmission(options, deps, prepared, result) {
1726
1862
  mailingListSignupNote: result.mailingListSignupNote
1727
1863
  });
1728
1864
  break;
1865
+ case "fundingChanged":
1866
+ options.commandRef.current = null;
1867
+ if (options.onFundingChanged) options.onFundingChanged(result.funding, result.message);
1868
+ else options.setErrorMessage(result.message);
1869
+ options.setStep("select-payment");
1870
+ return {
1871
+ ok: false,
1872
+ reason: "blocked",
1873
+ message: result.message
1874
+ };
1729
1875
  case "bookingComplete":
1730
- options.complete({
1731
- status: "confirmed",
1732
- outcome: result.outcome,
1733
- ...result.outcomes ? { outcomes: result.outcomes } : {},
1734
- message: result.summary.passCreditsRemaining !== void 0 ? result.summary.message : void 0,
1735
- mailingListSignupNote: result.mailingListSignupNote
1736
- });
1876
+ forgetReplacedBooking(options, deps);
1877
+ options.complete(confirmedRegistration(result));
1737
1878
  break;
1879
+ default: return assertNever(result);
1738
1880
  }
1739
1881
  options.commandRef.current = null;
1740
1882
  return {
@@ -1742,6 +1884,29 @@ async function completeRegistrationSubmission(options, deps, prepared, result) {
1742
1884
  outcome: { kind: "completed" }
1743
1885
  };
1744
1886
  }
1887
+ /**
1888
+ * The server took this booking, so the one the visitor came back from has been replaced and the
1889
+ * browser's list drops it. An id the list supplied from another tab stays until its hold runs out:
1890
+ * it may belong to a different event, and the response doesn't say which bookings were replaced.
1891
+ */
1892
+ function forgetReplacedBooking(options, deps) {
1893
+ if (options.heldPlace) deps.pendingCheckouts.forget(options.api.config.siteId, options.heldPlace.submissionId);
1894
+ }
1895
+ /**
1896
+ * A completed booking as the finished screen reads it. One booking says its pass balance in the
1897
+ * summary's message; several list it with how each date was paid, so the message would repeat it.
1898
+ */
1899
+ function confirmedRegistration(result) {
1900
+ const { passCreditsRemaining } = result.summary;
1901
+ return {
1902
+ status: "confirmed",
1903
+ submissionPayment: result.submissionPayment,
1904
+ outcome: result.outcome,
1905
+ mailingListSignupNote: result.mailingListSignupNote,
1906
+ ...result.outcomes ? { outcomes: result.outcomes } : { message: passCreditsRemaining !== void 0 ? result.summary.message : void 0 },
1907
+ ...passCreditsRemaining !== void 0 ? { passCreditsRemaining } : {}
1908
+ };
1909
+ }
1745
1910
  function toTicketSelectionRequests(lines) {
1746
1911
  return lines.map((line) => ({
1747
1912
  pricingOptionId: line.pricingOptionId,
@@ -1752,15 +1917,13 @@ function toTicketSelectionRequests(lines) {
1752
1917
  * Freeze everything this submission is about to send, including the command
1753
1918
  * identity the server keys the commit on.
1754
1919
  */
1755
- function prepareSubmitContext(options, registrationCommandId, target, method, passId, membershipId, selection) {
1920
+ function prepareSubmitContext(options, registrationCommandId, target, method, membershipId, selection) {
1756
1921
  const ticketSelections = normalizeTicketSelectionLines(options.ticketSelections);
1757
1922
  if (ticketSelections.length === 0) throw new Error("Choose at least one ticket to continue.");
1758
- const bundleProductId = method === "pass_bundle" || method === "membership_bundle" ? passId || membershipId : void 0;
1759
1923
  return {
1760
1924
  registrationCommandId,
1761
1925
  ticketSelections,
1762
- bundleProductId,
1763
- selectionSnapshot: resolveSelectionSnapshot(method, passId, membershipId, bundleProductId, selection),
1926
+ selectionSnapshot: resolveSelectionSnapshot(method, membershipId, selection),
1764
1927
  guestsPayload: options.requireGuestDetails && options.guests.length > 0 ? options.guests.map((guest) => ({
1765
1928
  name: guest.name.trim(),
1766
1929
  email: guest.email?.trim().toLowerCase() || void 0,
@@ -1775,24 +1938,12 @@ function prepareSubmitContext(options, registrationCommandId, target, method, pa
1775
1938
  })
1776
1939
  };
1777
1940
  }
1778
- function resolveSelectionSnapshot(method, passId, membershipId, bundleProductId, selection) {
1941
+ function resolveSelectionSnapshot(method, membershipId, selection) {
1779
1942
  if (selection?.method) return selection;
1780
- if (method === "pass" && passId) return {
1781
- method,
1782
- passId
1783
- };
1784
1943
  if (method === "membership" && membershipId) return {
1785
1944
  method,
1786
1945
  membershipId
1787
1946
  };
1788
- if (method === "pass_bundle" && bundleProductId) return {
1789
- method,
1790
- bundlePassId: bundleProductId
1791
- };
1792
- if (method === "membership_bundle" && bundleProductId) return {
1793
- method,
1794
- bundleMembershipId: bundleProductId
1795
- };
1796
1947
  if (method === "free") return { method };
1797
1948
  throw new Error("Choose an available payment option.");
1798
1949
  }
@@ -1809,7 +1960,12 @@ function savePendingCheckout(options, deps, prepared, checkoutAttemptId, mailing
1809
1960
  guests: options.guests,
1810
1961
  selectedSlidingAmount: options.selectedSlidingAmount,
1811
1962
  discountCode: options.discountCode,
1812
- mailingListSignupNote
1963
+ mailingListSignupNote,
1964
+ ...options.rooms ? { rooms: {
1965
+ choices: options.rooms.request.choices,
1966
+ reviewed: options.rooms.request.reviewed,
1967
+ dayLines: options.rooms.dayLines
1968
+ } } : {}
1813
1969
  });
1814
1970
  }
1815
1971
  function registrationRequestIntentKey(request) {
@@ -1822,15 +1978,14 @@ function registrationRequestIntentKey(request) {
1822
1978
  } : void 0
1823
1979
  });
1824
1980
  }
1825
- function buildRegistrationRequest(options, prepared, invitation, method, passId, membershipId) {
1826
- return {
1981
+ function buildRegistrationRequest(options, prepared, invitation, method, membershipId) {
1982
+ const common = {
1827
1983
  registrationCommandId: prepared.registrationCommandId,
1828
1984
  checkout: {
1829
1985
  returnUrl: eventPaymentReturnUrl(prepared.registrationCommandId),
1830
1986
  discountCode: options.discountCode.trim() || void 0,
1831
1987
  collectionOptionKind: prepared.selectionSnapshot.method === "stripe" ? prepared.selectionSnapshot.collectionOptionKind : void 0
1832
1988
  },
1833
- selection: prepared.selection,
1834
1989
  ticketSelections: toTicketSelectionRequests(prepared.ticketSelections),
1835
1990
  selectedSlidingAmount: options.selectedSlidingAmount ?? void 0,
1836
1991
  email: options.formData.email.trim().toLowerCase(),
@@ -1839,12 +1994,22 @@ function buildRegistrationRequest(options, prepared, invitation, method, passId,
1839
1994
  notes: options.formData.notes.trim() || void 0,
1840
1995
  ...singleBookingRequirements(options, prepared),
1841
1996
  mailingListOptIn: wantsMailingListSignup(options),
1842
- paymentMethod: method,
1843
- customerPassId: method === "pass" ? passId : void 0,
1844
- customerMembershipId: method === "membership" ? membershipId : void 0,
1845
- bundleProductId: prepared.bundleProductId,
1846
1997
  ...invitationRequestCredential(invitation.credential),
1847
- guests: prepared.guestsPayload
1998
+ guests: prepared.guestsPayload,
1999
+ ...options.rooms ? { rooms: options.rooms.request } : {}
2000
+ };
2001
+ const selection = prepared.selection;
2002
+ return selection.kind === "dates" ? {
2003
+ ...common,
2004
+ selection,
2005
+ funding: options.selectionFunding ?? { kind: "money" }
2006
+ } : {
2007
+ ...common,
2008
+ selection,
2009
+ ...toEventRunPayment({
2010
+ method,
2011
+ membershipId
2012
+ })
1848
2013
  };
1849
2014
  }
1850
2015
  /**
@@ -1865,19 +2030,30 @@ function invitationRequestCredential(credential) {
1865
2030
  }
1866
2031
  }
1867
2032
  /** Legal rejection returns to the intact draft, before any payment effect. */
1868
- function failedRegistrationStep(failure, method) {
2033
+ function failedRegistrationStep(failure, funding) {
2034
+ if (isRoomChoiceRefusal(failure.reason)) return "select-tickets";
1869
2035
  if (failure.discountRefused) return "select-payment";
1870
2036
  if (failure.reason === "paymentContextMismatch") return "select-payment";
1871
2037
  if (failure.reason === "invalidAnswers") return "enter-details";
1872
2038
  if (!failure.siteTermsFailure) return "error";
1873
- return method === "pass_bundle" || method === "membership_bundle" ? "select-payment" : "enter-details";
2039
+ return buysWithBooking(funding) ? "select-payment" : "enter-details";
2040
+ }
2041
+ function buysWithBooking(funding) {
2042
+ if (!funding || funding.kind === "money") return false;
2043
+ switch (funding.source.kind) {
2044
+ case "buyPass":
2045
+ case "buyMembership": return true;
2046
+ case "ownedPass":
2047
+ case "ownedMembership": return false;
2048
+ default: return assertNever(funding.source);
2049
+ }
1874
2050
  }
1875
2051
  function bookingCount(target) {
1876
2052
  const selection = target?.selection;
1877
2053
  return (selection?.kind === "runs" ? selection.eventSeriesIds.length : selection?.occurrenceIds.length ?? 1) > 1 ? "several" : "one";
1878
2054
  }
1879
2055
  /** Keep feedback, field errors and navigation together when a submission fails. */
1880
- function reportFailedRegistration(options, error, method) {
2056
+ function reportFailedRegistration(options, error) {
1881
2057
  const parsed = parseEventRegistrationFailure(error);
1882
2058
  const { message, action } = registrationErrorPresentation(parsed, bookingCount(options.registrationTarget));
1883
2059
  const failure = {
@@ -1889,7 +2065,8 @@ function reportFailedRegistration(options, error, method) {
1889
2065
  options.setErrorAction?.(action);
1890
2066
  options.setErrorMessage(message);
1891
2067
  options.setSubmissionFailure(failure);
1892
- options.setStep(failedRegistrationStep(parsed, method));
2068
+ if (isRoomChoiceRefusal(parsed.reason)) options.refreshOptions?.();
2069
+ options.setStep(failedRegistrationStep(parsed, options.selectionFunding));
1893
2070
  return {
1894
2071
  ok: false,
1895
2072
  reason: "submission-failed",
@@ -1918,10 +2095,21 @@ function quoteFeedback(state) {
1918
2095
  message: state.preview.type === "applied" ? `${state.preview.publicLabel} applied. You'll pay ${formatCommercePrice(state.preview.totalAfterDiscountCents, state.preview.currency)}.` : ""
1919
2096
  } : null;
1920
2097
  }
2098
+ /** The request for this input, or null while there's nothing to price yet. */
2099
+ function selectionQuoteRequest(input) {
2100
+ if (input.dates !== null) switch (input.dates.kind) {
2101
+ case "order": return { selection: input.dates.selection };
2102
+ case "waiting":
2103
+ case "nothingToPay": return null;
2104
+ default: return assertNever(input.dates);
2105
+ }
2106
+ const lines = input.several !== null ? selectionPreviewLines(input) : input.singleLines.length > 0 ? input.singleLines : null;
2107
+ return lines ? { lines } : null;
2108
+ }
1921
2109
  /** A quote belongs to the complete priced input and the customer, never just the draft code. */
1922
- function selectionQuoteKey(lines, email, scope) {
1923
- return lines ? JSON.stringify([
1924
- selectionPreviewKey(null, lines),
2110
+ function selectionQuoteKey(request, email, scope) {
2111
+ return request ? JSON.stringify([
2112
+ request,
1925
2113
  email.trim().toLowerCase(),
1926
2114
  ...scope ? [scope] : []
1927
2115
  ]) : null;
@@ -1937,16 +2125,20 @@ function editedSelectionCode(state, key, draftCode) {
1937
2125
  ...same && state.uncoded ? { uncoded: state.uncoded } : {}
1938
2126
  };
1939
2127
  }
2128
+ /**
2129
+ * What one quote answer means for the selection. A changed pass or membership isn't a price at all: the
2130
+ * options go back to the server's revised ones, as when submit refuses the split, and the new option is
2131
+ * priced from there. Its state stays unpriced, so nothing is charged on the old split meanwhile.
2132
+ */
2133
+ function decideSelectionQuoteAnswer(pending, result) {
2134
+ return {
2135
+ state: decideSelectionQuoteResponse(pending, result),
2136
+ fundingChanged: result.type === "fundingChanged" ? result : null
2137
+ };
2138
+ }
1940
2139
  function decideSelectionQuoteResponse(pending, result) {
1941
2140
  const typed = Boolean(pending.draftCode.trim());
1942
- if (result.type === "rejected") return typed && result.reason === "invalid_or_not_applicable" ? {
1943
- ...pending,
1944
- status: "refused",
1945
- message: result.message
1946
- } : {
1947
- ...pending,
1948
- status: "failed"
1949
- };
2141
+ if (result.type === "rejected" || result.type === "fundingChanged") return unpricedQuote(pending, typed, result);
1950
2142
  if (typed && result.type !== "applied") return {
1951
2143
  ...pending,
1952
2144
  status: "failed"
@@ -1960,6 +2152,17 @@ function decideSelectionQuoteResponse(pending, result) {
1960
2152
  decidedCode: typed && result.type === "applied" ? result.code : void 0
1961
2153
  };
1962
2154
  }
2155
+ /** No price: a typed code the server refused shows why; anything else, a changed pass included, is unresolved. */
2156
+ function unpricedQuote(pending, typed, result) {
2157
+ return typed && result.type === "rejected" && result.reason === "invalid_or_not_applicable" ? {
2158
+ ...pending,
2159
+ status: "refused",
2160
+ message: result.message
2161
+ } : {
2162
+ ...pending,
2163
+ status: "failed"
2164
+ };
2165
+ }
1963
2166
  /**
1964
2167
  * Whether to ask the server now, without the visitor pressing Apply: for the
1965
2168
  * automatic code, or for a code the visitor typed before (in one item's box,
@@ -1967,28 +2170,43 @@ function decideSelectionQuoteResponse(pending, result) {
1967
2170
  * as far as they know. A code typed here waits for Apply.
1968
2171
  */
1969
2172
  function explicitSelectionQuoteWanted(state, input, carried = false) {
1970
- if (input.several === null && input.combinedPending) return false;
1971
- return input.automaticWanted && state.status === "draft" && (carried || (input.several !== null || input.productAutomaticOffered) && !state.draftCode.trim());
2173
+ if (!serverPricesTotal(input) && input.combinedPending) return false;
2174
+ return input.automaticWanted && state.status === "draft" && (carried || uncodedQuoteWanted(input) && !state.draftCode.trim());
2175
+ }
2176
+ /**
2177
+ * Several items, and dates paid with a pass or membership, have no total until the server
2178
+ * prices their order; one booking paid by card has a price already.
2179
+ */
2180
+ function serverPricesTotal(input) {
2181
+ return input.several !== null || input.dates !== null;
1972
2182
  }
1973
- /** Nothing to price: no code or automatic discount can change a free selection. */
2183
+ function uncodedQuoteWanted(input) {
2184
+ return serverPricesTotal(input) || input.productAutomaticOffered;
2185
+ }
2186
+ /** Nothing to price: no code or automatic discount can change a free selection, or dates the visitor's own cover pays for. */
1974
2187
  function freeSelection(input) {
1975
- return input.several !== null && input.price.listTotalCents === 0;
2188
+ return serverPricesTotal(input) && (input.price.listTotalCents === 0 || input.dates?.kind === "nothingToPay");
1976
2189
  }
1977
2190
  function selectionPayable(input, state) {
1978
- if (input.several === null || freeSelection(input)) return input.price.totalCents;
2191
+ if (!serverPricesTotal(input)) return input.price.totalCents;
2192
+ if (freeSelection(input)) return input.dates?.kind === "nothingToPay" ? 0 : input.price.totalCents;
1979
2193
  if (input.payment.kind === "payment") return serverPricedTotalCents({
1980
- listTotalCents: input.price.listTotalCents,
2194
+ listTotalCents: paymentListCents(input, state),
1981
2195
  reductions: input.payment.checkout.priceReductions ?? []
1982
2196
  });
1983
2197
  return pricedPreview(state)?.totalAfterDiscountCents ?? null;
1984
2198
  }
2199
+ /** A dates order can hold a bought pass besides the dates, so its list price is the one the server priced. */
2200
+ function paymentListCents(input, state) {
2201
+ return (input.dates?.kind === "order" ? pricedPreview(state)?.subtotalCents ?? null : null) ?? input.price.listTotalCents;
2202
+ }
1985
2203
  /** The price to show and charge: the decided quote, or after a refused code, the price without it. */
1986
2204
  function pricedPreview(state) {
1987
2205
  if (state.status === "priced") return state.preview;
1988
2206
  return state.status === "refused" ? state.uncoded ?? null : null;
1989
2207
  }
1990
2208
  function selectionPriceSettled(input, state) {
1991
- return !(input.several === null && state.key !== null && Boolean(state.draftCode.trim()) && state.status !== "priced") && (pricedPreview(state) !== null || freeSelection(input) || singleBookingNeedsNoAnswer(input, state));
2209
+ return !(!serverPricesTotal(input) && state.key !== null && Boolean(state.draftCode.trim()) && state.status !== "priced") && (pricedPreview(state) !== null || freeSelection(input) || singleBookingNeedsNoAnswer(input, state));
1992
2210
  }
1993
2211
  /** The only projection that can expose a selection's payable total and submitted code. */
1994
2212
  function decidedSelectionPricing(input, state, apply) {
@@ -2021,11 +2239,11 @@ function decidedSelectionPricing(input, state, apply) {
2021
2239
  * price anyway, so a preview that failed never stops a booking. A typed code always waits.
2022
2240
  */
2023
2241
  function singleBookingNeedsNoAnswer(input, state) {
2024
- if (input.several !== null || input.combinedPending) return false;
2242
+ if (serverPricesTotal(input) || input.combinedPending) return false;
2025
2243
  if (state.key === null) return true;
2026
2244
  if (state.draftCode.trim()) return false;
2027
2245
  if (state.status === "failed") return true;
2028
- return state.status === "draft" && !((input.several !== null || input.productAutomaticOffered) && input.automaticWanted);
2246
+ return state.status === "draft" && !(uncodedQuoteWanted(input) && input.automaticWanted);
2029
2247
  }
2030
2248
  /** What the payment step is waiting for. Checking a typed code on one booking leaves its choices on screen, with Pay held. */
2031
2249
  function quoteWaiting(input, state, settled) {
@@ -2034,7 +2252,7 @@ function quoteWaiting(input, state, settled) {
2034
2252
  awaitingVisitor: false,
2035
2253
  codeHoldingOne: false
2036
2254
  };
2037
- const typedOnOne = input.several === null && Boolean(state.draftCode.trim());
2255
+ const typedOnOne = !serverPricesTotal(input) && Boolean(state.draftCode.trim());
2038
2256
  const deciding = serverDeciding(state);
2039
2257
  return {
2040
2258
  quoting: deciding && !typedOnOne,
@@ -2122,17 +2340,20 @@ function presentSelectionCombination(input) {
2122
2340
  /** The checkout and quote both consume the code decided by this response. */
2123
2341
  async function requestSelectionQuote(input) {
2124
2342
  try {
2125
- const code = input.pending.draftCode.trim();
2343
+ const code = "selection" in input.request && input.request.selection.funding.kind === "entitlement" ? "" : input.pending.draftCode.trim();
2126
2344
  const result = await input.api.applyDiscountCode({
2127
2345
  customerEmail: input.email.trim(),
2128
- lines: input.lines,
2346
+ ...input.request,
2129
2347
  ...code ? { discountCode: code } : {}
2130
2348
  });
2131
- return decideSelectionQuoteResponse(input.pending, result);
2349
+ return decideSelectionQuoteAnswer(input.pending, result);
2132
2350
  } catch {
2133
2351
  return {
2134
- ...input.pending,
2135
- status: "failed"
2352
+ state: {
2353
+ ...input.pending,
2354
+ status: "failed"
2355
+ },
2356
+ fundingChanged: null
2136
2357
  };
2137
2358
  }
2138
2359
  }
@@ -2143,21 +2364,24 @@ async function requestSelectionQuote(input) {
2143
2364
  * request remains unresolved and can be retried explicitly.
2144
2365
  */
2145
2366
  function useSelectionCombinationPricing(input) {
2146
- const lines = input.several !== null ? selectionPreviewLines(input) : input.singleLines.length > 0 ? input.singleLines : null;
2147
- const key = selectionQuoteKey(lines, input.email, input.registrationRequestKey);
2367
+ const request = selectionQuoteRequest(input);
2368
+ const seededFromOptions = input.several === null && input.dates === null;
2369
+ const key = selectionQuoteKey(request, input.email, seededFromOptions ? input.registrationRequestKey : void 0);
2148
2370
  const [state, setState] = useState(() => emptyQuoteDraft(key));
2149
2371
  const [carried, setCarried] = useState(false);
2150
- const registrationPreview = input.several === null ? input.registrationPreview : null;
2372
+ const latestPending = useRef(null);
2373
+ const latestKey = useRef(key);
2374
+ latestKey.current = key;
2375
+ const registrationPreview = seededFromOptions ? input.registrationPreview : null;
2151
2376
  const current = seedRegistrationQuote(currentSelectionQuote(state, key), registrationPreview);
2152
- const activeKey = useRef(key);
2153
- activeKey.current = key;
2154
2377
  const apply = async () => {
2155
- if (key === null || lines === null) return;
2156
- if (current.draftCode.trim() && !input.email.trim()) {
2378
+ if (key === null || request === null) return;
2379
+ const emailProblem = current.draftCode.trim() ? discountEmailProblem(input.email) : null;
2380
+ if (emailProblem) {
2157
2381
  setState({
2158
2382
  ...current,
2159
2383
  status: "refused",
2160
- message: DISCOUNT_APPLY_MESSAGES.emailRequired
2384
+ message: emailProblem
2161
2385
  });
2162
2386
  return;
2163
2387
  }
@@ -2167,13 +2391,17 @@ function useSelectionCombinationPricing(input) {
2167
2391
  };
2168
2392
  setCarried(false);
2169
2393
  setState(pending);
2170
- const next = await requestSelectionQuote({
2394
+ latestPending.current = pending;
2395
+ const answer = await requestSelectionQuote({
2171
2396
  api: input.api,
2172
2397
  email: input.email,
2173
- lines,
2398
+ request,
2174
2399
  pending
2175
2400
  });
2176
- setState((previous) => activeKey.current === key && previous === pending ? next : previous);
2401
+ setState((previous) => latestKey.current === pending.key && previous === pending ? answer.state : previous);
2402
+ if (latestPending.current !== pending || latestKey.current !== pending.key || answer.fundingChanged === null) return;
2403
+ setCarried(Boolean(pending.draftCode.trim()));
2404
+ input.onFundingChanged(answer.fundingChanged.funding, answer.fundingChanged.message);
2177
2405
  };
2178
2406
  useEffect(() => {
2179
2407
  if (explicitSelectionQuoteWanted(current, input, carried)) apply();
@@ -2197,6 +2425,7 @@ function useSelectionCombinationPricing(input) {
2197
2425
  };
2198
2426
  /** A new booking starts with no code and no earlier price. */
2199
2427
  const reset = () => {
2428
+ latestPending.current = null;
2200
2429
  setCarried(false);
2201
2430
  setState(emptyQuoteDraft(key));
2202
2431
  };
@@ -2224,10 +2453,608 @@ function useEventRegistrationRecoveryRequest() {
2224
2453
  return arrival;
2225
2454
  }
2226
2455
  //#endregion
2456
+ //#region ../blocks/src/system/runtime/nodes/event-registration/useSelectionFunding.ts
2457
+ const SELECTION_FUNDING_LOAD_FAILED = "We couldn’t load the ways to pay for these dates. Try again, or refresh the page.";
2458
+ const ONE_DATE_FUNDING_LOAD_FAILED = "We couldn’t load the ways to pay for this date. Try again, or refresh the page.";
2459
+ /**
2460
+ * The server's ways to pay for the dates, one or several, fetched when the
2461
+ * wizard wants them: one date on its payment step, several once their tickets
2462
+ * are chosen. The key carries the dates, places and who's signed in, so any
2463
+ * change asks again and the pick goes back to the server's default.
2464
+ */
2465
+ function useSelectionFunding(input) {
2466
+ const requestKey = input.request ? JSON.stringify([input.request, input.identity]) : null;
2467
+ const [state, dispatch] = useReducer(selectionFundingReducer, initialSelectionFundingLookup);
2468
+ const wanted = selectionFundingFetchWanted(state, requestKey, input.enabled);
2469
+ useEffect(() => {
2470
+ if (!wanted || requestKey === null || input.request === null) return;
2471
+ dispatch({
2472
+ type: "loading",
2473
+ requestKey
2474
+ });
2475
+ const severalDates = input.request.subject.occurrenceIds.length > 1;
2476
+ input.api.getSelectionFunding(input.request).then((response) => dispatch(severalDates && !response.payment ? {
2477
+ type: "failed",
2478
+ requestKey
2479
+ } : {
2480
+ type: "loaded",
2481
+ requestKey,
2482
+ funding: response.funding,
2483
+ payment: response.payment ?? null
2484
+ }), () => dispatch({
2485
+ type: "failed",
2486
+ requestKey
2487
+ }));
2488
+ }, [wanted, requestKey]);
2489
+ const lookup = input.enabled || state.tag !== "idle" ? currentSelectionFundingLookup(state, requestKey) : initialSelectionFundingLookup;
2490
+ const basis = selectionFundingBasis(lookup);
2491
+ return {
2492
+ lookup,
2493
+ choose: (pick) => dispatch({
2494
+ type: "picked",
2495
+ pick
2496
+ }),
2497
+ revise: (funding, message) => dispatch({
2498
+ type: "changed",
2499
+ funding,
2500
+ message,
2501
+ basis
2502
+ }),
2503
+ reset: () => dispatch({ type: "reset" })
2504
+ };
2505
+ }
2506
+ //#endregion
2507
+ //#region ../blocks/src/system/runtime/nodes/event-registration/useRunsSelectionPayment.state.ts
2508
+ /**
2509
+ * The runs read's lookup: which request is being asked, and the answer it got.
2510
+ * Dates get their answer with their funding (useSelectionFunding.state).
2511
+ */
2512
+ const RUNS_PAYMENT_LOAD_FAILED = "We couldn’t load the ways to pay for these runs. Refresh the page to try again.";
2513
+ const IDLE_SELECTION_PAYMENT = { tag: "idle" };
2514
+ /** An answer settles only the request it was sent for. */
2515
+ function selectionPaymentLookupReducer(state, action) {
2516
+ const settles = state.tag === "loading" && state.requestKey === action.requestKey;
2517
+ switch (action.type) {
2518
+ case "loading": return {
2519
+ tag: "loading",
2520
+ requestKey: action.requestKey
2521
+ };
2522
+ case "loaded": return settles ? {
2523
+ tag: "loaded",
2524
+ requestKey: action.requestKey,
2525
+ payment: action.payment
2526
+ } : state;
2527
+ case "failed": return settles ? {
2528
+ tag: "failed",
2529
+ requestKey: action.requestKey
2530
+ } : state;
2531
+ default: return assertNever(action);
2532
+ }
2533
+ }
2534
+ /** The lookup for this request: another request's answer, or none yet, is still loading. */
2535
+ function currentSelectionPaymentLookup(state, requestKey) {
2536
+ if (requestKey === null) return IDLE_SELECTION_PAYMENT;
2537
+ if (state.tag !== "idle" && state.requestKey === requestKey) return state;
2538
+ return {
2539
+ tag: "loading",
2540
+ requestKey
2541
+ };
2542
+ }
2543
+ /** Whether the hook should ask the server now. */
2544
+ function selectionPaymentFetchWanted(state, requestKey, enabled) {
2545
+ return enabled && requestKey !== null && (state.tag === "idle" || state.requestKey !== requestKey);
2546
+ }
2547
+ //#endregion
2548
+ //#region ../blocks/src/system/runtime/nodes/event-registration/useRunsSelectionPayment.ts
2549
+ /**
2550
+ * How several runs can be paid, from the server, asked once the runs and
2551
+ * their tickets are chosen. The key carries the runs, tickets, places and who's
2552
+ * signed in, so any change asks again. Dates get theirs with their funding.
2553
+ */
2554
+ function useRunsSelectionPayment(input) {
2555
+ const requestKey = input.request ? JSON.stringify([input.request, input.identity]) : null;
2556
+ const [state, dispatch] = useReducer(selectionPaymentLookupReducer, IDLE_SELECTION_PAYMENT);
2557
+ const wanted = selectionPaymentFetchWanted(state, requestKey, input.enabled);
2558
+ useEffect(() => {
2559
+ if (!wanted || requestKey === null || input.request === null) return;
2560
+ dispatch({
2561
+ type: "loading",
2562
+ requestKey
2563
+ });
2564
+ input.api.getRunsSelectionPayment(input.request).then((response) => dispatch({
2565
+ type: "loaded",
2566
+ requestKey,
2567
+ payment: response.payment
2568
+ }), () => dispatch({
2569
+ type: "failed",
2570
+ requestKey
2571
+ }));
2572
+ }, [wanted, requestKey]);
2573
+ return input.enabled || state.tag !== "idle" ? currentSelectionPaymentLookup(state, requestKey) : IDLE_SELECTION_PAYMENT;
2574
+ }
2575
+ //#endregion
2576
+ //#region ../blocks/src/system/runtime/nodes/event-registration/selectionFundingView.ts
2577
+ const SEVERAL_PLACES_ENTITLEMENT_NOTE = "Class passes and memberships can be used when you book one place on each date.";
2578
+ const ONE_DATE_SEVERAL_PLACES_ENTITLEMENT_NOTE = "Class passes and memberships can be used when you book one place.";
2579
+ /** The chosen option at the quote's price once it's in; every other option at the funding read's. */
2580
+ function orderPrice(option, chosen, input) {
2581
+ return chosen && input.chosenOrder !== null ? input.chosenOrder : {
2582
+ totalCents: option.money.totalCents,
2583
+ discountCents: 0
2584
+ };
2585
+ }
2586
+ /**
2587
+ * The server's price for the option's order, with account credit taken off the whole of it, as checkout takes it.
2588
+ * Paid directly, nothing is taken online: the whole order is owed to the business.
2589
+ */
2590
+ function decideCharge(option, order, input, collection) {
2591
+ const moneyDateCount = fundingMoneyDates(option).length;
2592
+ if (collection === "deferred_manual") {
2593
+ const remainder = moneyDateCount === 0 ? "none" : order.totalCents === 0 ? "free" : "direct";
2594
+ return {
2595
+ moneyDateCount,
2596
+ boughtCents: boughtPriceCents(option),
2597
+ creditCents: 0,
2598
+ cardCents: 0,
2599
+ directCents: order.totalCents,
2600
+ remainder
2601
+ };
2602
+ }
2603
+ const creditCents = planCheckoutPaymentFlow({
2604
+ amountDueCents: order.totalCents,
2605
+ discountCents: order.discountCents,
2606
+ availableCreditCents: input.availableCreditCents,
2607
+ creditCurrencyMatches: true,
2608
+ minimumStripeChargeCents: input.minimumCardChargeCents
2609
+ }).reserveCreditCents;
2610
+ const cardCents = order.totalCents - creditCents;
2611
+ const remainder = moneyDateCount === 0 ? "none" : order.totalCents === 0 ? "free" : cardCents === 0 ? "credit" : "card";
2612
+ return {
2613
+ moneyDateCount,
2614
+ boughtCents: boughtPriceCents(option),
2615
+ creditCents,
2616
+ cardCents,
2617
+ directCents: 0,
2618
+ remainder
2619
+ };
2620
+ }
2621
+ function boughtPriceCents(option) {
2622
+ if (option.kind === "money") return 0;
2623
+ switch (option.entitlement.kind) {
2624
+ case "buyPass":
2625
+ case "buyMembership": return option.entitlement.priceCents;
2626
+ case "ownedPass":
2627
+ case "ownedMembership": return 0;
2628
+ default: return assertNever(option.entitlement);
2629
+ }
2630
+ }
2631
+ function plural(count, singular, pluralForm = `${singular}s`) {
2632
+ return `${count} ${count === 1 ? singular : pluralForm}`;
2633
+ }
2634
+ const credits = (count) => plural(count, "credit");
2635
+ const datesCount = (count) => plural(count, "date");
2636
+ /** "Fri 13 Nov", "Fri 13 Nov and Fri 20 Nov", "A, B and C". */
2637
+ function joinDays(days) {
2638
+ const last = days[days.length - 1] ?? "";
2639
+ return days.length < 2 ? last : `${days.slice(0, -1).join(", ")} and ${last}`;
2640
+ }
2641
+ /** "the other 2", or "the other date" for one. */
2642
+ function theOther(count) {
2643
+ return count === 1 ? "the other date" : `the other ${count}`;
2644
+ }
2645
+ /** Card wording only when a card is really charged. */
2646
+ function payer(charge) {
2647
+ switch (charge.remainder) {
2648
+ case "card": return "Card pays for";
2649
+ case "direct": return "You pay the business directly for";
2650
+ case "none":
2651
+ case "credit":
2652
+ case "free": return "You pay for";
2653
+ default: return assertNever(charge.remainder);
2654
+ }
2655
+ }
2656
+ /** Why a date isn't covered, under the date. */
2657
+ const UNCOVERED_REASON_COPY = {
2658
+ ends_before: "After your pass ends",
2659
+ not_started: "Before your membership starts",
2660
+ membership_ended: "After your membership ends",
2661
+ already_used_on_date: "Already used for this date",
2662
+ no_credits_left: "No credits left for this date"
2663
+ };
2664
+ function partTitle(facts) {
2665
+ switch (facts.charge.remainder) {
2666
+ case "none":
2667
+ case "free": return facts.name;
2668
+ case "card": return `${facts.name} and card`;
2669
+ case "direct": return `${facts.name} and pay the rest directly`;
2670
+ case "credit": return `${facts.name} and account credit`;
2671
+ default: return assertNever(facts.charge.remainder);
2672
+ }
2673
+ }
2674
+ function ownedPassShortfall(facts) {
2675
+ switch (facts.shortfall) {
2676
+ case "credits": return facts.covered === 1 ? `Your last credit covers the first date. ${payer(facts.charge)} ${theOther(facts.moneyDates)}.` : `Your last ${facts.covered} credits cover the first ${facts.covered} dates. ${payer(facts.charge)} ${theOther(facts.moneyDates)}.`;
2677
+ case "ends": return `Your pass ends on ${facts.endsOn ?? ""}, so it covers ${datesCount(facts.covered)}. ${payer(facts.charge)} ${facts.moneyDays}.`;
2678
+ case "other": return `Your pass covers ${facts.coveredDays}. ${payer(facts.charge)} ${theOther(facts.moneyDates)}.`;
2679
+ default: return assertNever(facts.shortfall);
2680
+ }
2681
+ }
2682
+ function boughtPassShortfall(facts) {
2683
+ switch (facts.shortfall) {
2684
+ case "ends": return `It ends on ${facts.endsOn ?? ""}, so it covers ${datesCount(facts.covered)}. You pay for ${facts.moneyDays}.`;
2685
+ case "credits": return `${credits(facts.creditsBefore ?? facts.covered)}, so it covers the first ${datesCount(facts.covered)}. You pay for ${theOther(facts.moneyDates)}.`;
2686
+ case "other": return `It covers ${facts.coveredDays}. You pay for ${facts.moneyDays}.`;
2687
+ default: return assertNever(facts.shortfall);
2688
+ }
2689
+ }
2690
+ const membershipRenewal = (facts) => `${facts.boughtPrice ?? ""} a ${facts.interval ?? "month"}, renews ${facts.interval === "year" ? "yearly" : "monthly"}.`;
2691
+ /** The option's price when money is owed: today's card payment, or "£24.00 due" to the business. */
2692
+ function remainderPrice(facts) {
2693
+ switch (facts.charge.remainder) {
2694
+ case "card": return facts.toPay;
2695
+ case "direct": return `${facts.toPayDirectly} due`;
2696
+ case "none":
2697
+ case "credit":
2698
+ case "free": return null;
2699
+ default: return assertNever(facts.charge.remainder);
2700
+ }
2701
+ }
2702
+ const passCredits = (facts) => `${facts.covered} pass ${facts.covered === 1 ? "credit" : "credits"}`;
2703
+ /** Each kind's words. A new kind of pass or membership won't compile until it has its own. */
2704
+ const ENTITLEMENT_COPY = {
2705
+ ownedPass: {
2706
+ coveredValue: credits(1),
2707
+ countsCredits: true,
2708
+ title: partTitle,
2709
+ detail: (facts) => facts.moneyDates === 0 ? `${credits(facts.creditsBefore ?? 0)} left, ${facts.creditsLeftAfter ?? 0} after this booking` : ownedPassShortfall(facts),
2710
+ price: (facts) => remainderPrice(facts) ?? credits(facts.covered),
2711
+ button: (facts) => {
2712
+ switch (facts.charge.remainder) {
2713
+ case "none": return `Book using ${passCredits(facts)}`;
2714
+ case "card": return `Use ${passCredits(facts)} and pay ${facts.toPay}`;
2715
+ case "direct":
2716
+ case "credit":
2717
+ case "free": return `Use ${passCredits(facts)} and book`;
2718
+ default: return assertNever(facts.charge.remainder);
2719
+ }
2720
+ },
2721
+ boughtLine: () => null
2722
+ },
2723
+ ownedMembership: {
2724
+ coveredValue: "Included",
2725
+ countsCredits: false,
2726
+ title: partTitle,
2727
+ detail: (facts) => facts.moneyDates === 0 ? facts.dateCount === 1 ? "Your membership covers this date" : `Your membership covers all ${facts.dateCount} dates` : `Your membership covers ${facts.covered} of these dates. ${payer(facts.charge)} ${theOther(facts.moneyDates)}.`,
2728
+ price: (facts) => remainderPrice(facts) ?? "Included",
2729
+ button: (facts) => facts.charge.remainder === "card" ? `Pay ${facts.toPay}` : facts.dateCount === 1 ? "Book your place" : "Book your places",
2730
+ boughtLine: () => null
2731
+ },
2732
+ buyPass: {
2733
+ coveredValue: credits(1),
2734
+ countsCredits: false,
2735
+ title: (facts) => facts.moneyDates === 0 ? `Buy ${indefiniteArticle(facts.name)} ${facts.name}` : `Buy ${indefiniteArticle(facts.name)} ${facts.name} and pay for the rest`,
2736
+ detail: (facts) => facts.moneyDates === 0 ? `${credits(facts.creditsBefore ?? 0)}. ${facts.dateCount === 1 ? "This date uses" : "These dates use"} ${facts.covered}, leaving ${facts.creditsLeftAfter ?? 0}.` : boughtPassShortfall(facts),
2737
+ price: (facts) => facts.toPay,
2738
+ button: (facts) => facts.moneyDates === 0 || facts.charge.cardCents === 0 ? "Buy pass and book" : `Buy pass and pay ${facts.toPay}`,
2739
+ boughtLine: (facts) => ({ note: facts.creditsBefore === 1 ? "Uses its 1 class" : `Uses ${facts.covered} of its ${facts.creditsBefore ?? facts.covered} classes, ${facts.creditsLeftAfter ?? 0} left for later` })
2740
+ },
2741
+ buyMembership: {
2742
+ coveredValue: "Covered",
2743
+ countsCredits: false,
2744
+ title: (facts) => `Buy ${indefiniteArticle(facts.name)} ${facts.name}`,
2745
+ detail: (facts) => facts.dateCount === 1 ? `${membershipRenewal(facts)} It covers this date. You can cancel from your account.` : `${facts.boughtPrice ?? ""} a ${facts.interval ?? "month"}. It covers all ${datesCount(facts.covered)}.`,
2746
+ price: (facts) => facts.toPay,
2747
+ button: (facts) => facts.moneyDates === 0 || facts.charge.cardCents === 0 ? "Buy membership and book" : `Buy membership and pay ${facts.toPay}`,
2748
+ boughtLine: (facts) => ({ note: `${membershipRenewal(facts)} You can cancel from your account.` })
2749
+ }
2750
+ };
2751
+ function entitlementFacts(entitlement, currency) {
2752
+ switch (entitlement.kind) {
2753
+ case "ownedPass": return {
2754
+ creditsBefore: entitlement.credits.used + entitlement.credits.leftAfter,
2755
+ creditsLeftAfter: entitlement.credits.leftAfter,
2756
+ ends: entitlement.expiresAt,
2757
+ boughtPrice: null,
2758
+ interval: null
2759
+ };
2760
+ case "ownedMembership": return {
2761
+ creditsBefore: null,
2762
+ creditsLeftAfter: null,
2763
+ ends: entitlement.endsAt,
2764
+ boughtPrice: null,
2765
+ interval: null
2766
+ };
2767
+ case "buyPass": return {
2768
+ creditsBefore: entitlement.credits.total,
2769
+ creditsLeftAfter: entitlement.credits.leftAfter,
2770
+ ends: entitlement.expiresAt,
2771
+ boughtPrice: formatPrice(entitlement.priceCents, currency),
2772
+ interval: null
2773
+ };
2774
+ case "buyMembership": return {
2775
+ creditsBefore: null,
2776
+ creditsLeftAfter: null,
2777
+ ends: null,
2778
+ boughtPrice: formatPrice(entitlement.priceCents, currency),
2779
+ interval: entitlement.interval
2780
+ };
2781
+ default: return assertNever(entitlement);
2782
+ }
2783
+ }
2784
+ /**
2785
+ * Credits ran out when every skipped date ran out and the covered ones are
2786
+ * the earliest; the pass ended when every skipped date is after its end.
2787
+ * Anything else names the dates it covers.
2788
+ */
2789
+ function decideShortfall(option, dates, ends) {
2790
+ const reasons = option.uncovered.map((date) => date.reason);
2791
+ const firstCovered = dates.slice(0, option.covered.length).every((date) => option.covered.includes(date.occurrenceId));
2792
+ if (reasons.every((reason) => reason === "no_credits_left") && firstCovered) return "credits";
2793
+ if (ends !== null && reasons.every((reason) => reason === "ends_before")) return "ends";
2794
+ return "other";
2795
+ }
2796
+ function daysOf(ids, dates) {
2797
+ return joinDays(dates.filter((date) => ids.includes(date.occurrenceId)).map((date) => date.day));
2798
+ }
2799
+ function optionFacts(option, charge, input) {
2800
+ const facts = entitlementFacts(option.entitlement, input.currency);
2801
+ return {
2802
+ name: option.entitlement.name,
2803
+ dateCount: input.dates.length,
2804
+ covered: option.covered.length,
2805
+ moneyDates: charge.moneyDateCount,
2806
+ creditsBefore: facts.creditsBefore,
2807
+ creditsLeftAfter: facts.creditsLeftAfter,
2808
+ endsOn: facts.ends === null ? null : input.formatDay(facts.ends),
2809
+ boughtPrice: facts.boughtPrice,
2810
+ interval: facts.interval,
2811
+ shortfall: decideShortfall(option, input.dates, facts.ends),
2812
+ coveredDays: daysOf(option.covered, input.dates),
2813
+ moneyDays: daysOf(fundingMoneyDates(option), input.dates),
2814
+ toPay: formatPrice(charge.cardCents, input.currency),
2815
+ toPayDirectly: formatPrice(charge.directCents, input.currency),
2816
+ charge
2817
+ };
2818
+ }
2819
+ function optionRows(option, chosenKey, input) {
2820
+ const key = fundingOptionKey(option);
2821
+ const selected = key === chosenKey;
2822
+ const pick = fundingOptionPick(option);
2823
+ switch (option.kind) {
2824
+ case "money": {
2825
+ const price = formatPrice(orderPrice(option, selected, input).totalCents, input.currency);
2826
+ return input.moneyRows.map((row) => ({
2827
+ key: input.moneyRows.length === 1 ? key : `${key}:${row.key}`,
2828
+ pick,
2829
+ card: row.card,
2830
+ label: row.label,
2831
+ details: row.details,
2832
+ price: row.price ?? price,
2833
+ selected: selected && row.current
2834
+ }));
2835
+ }
2836
+ case "entitlement": {
2837
+ const copy = ENTITLEMENT_COPY[option.entitlement.kind];
2838
+ const ways = input.collectionsOf(pick);
2839
+ const chosenWay = collectionShown(ways, input.chosenCollection);
2840
+ return (ways.length > 1 ? ways : [chosenWay]).map((way) => {
2841
+ const facts = optionFacts(option, decideCharge(option, orderPrice(option, selected, input), input, way), input);
2842
+ return {
2843
+ key: ways.length > 1 ? `${key}:${way ?? ""}` : key,
2844
+ pick,
2845
+ card: ways.length > 1 ? way : null,
2846
+ selected: selected && way === chosenWay,
2847
+ label: copy.title(facts),
2848
+ details: [copy.detail(facts)],
2849
+ price: copy.price(facts)
2850
+ };
2851
+ });
2852
+ }
2853
+ default: return assertNever(option);
2854
+ }
2855
+ }
2856
+ function dateLines(option, copy, charge, input) {
2857
+ const money = (cents) => formatCurrencyAmount(cents, input.currency);
2858
+ return input.dates.map((date) => {
2859
+ if (option.covered.includes(date.occurrenceId)) return {
2860
+ key: date.occurrenceId,
2861
+ label: date.label,
2862
+ note: null,
2863
+ value: copy.coveredValue
2864
+ };
2865
+ const uncovered = option.uncovered.find((entry) => entry.occurrenceId === date.occurrenceId);
2866
+ const value = charge.remainder === "free" ? "Free" : date.priceCents === null ? "" : money(date.priceCents);
2867
+ return {
2868
+ key: date.occurrenceId,
2869
+ label: date.label,
2870
+ note: uncovered ? UNCOVERED_REASON_COPY[uncovered.reason] : null,
2871
+ value
2872
+ };
2873
+ });
2874
+ }
2875
+ /** The way an option's money is collected: the visitor's choice when the option offers it, otherwise its first. */
2876
+ function collectionShown(ways, chosen) {
2877
+ return chosen !== null && ways.includes(chosen) ? chosen : ways[0] ?? null;
2878
+ }
2879
+ function fundedSummary(option, collection, input) {
2880
+ const charge = decideCharge(option, orderPrice(option, true, input), input, collection);
2881
+ const facts = optionFacts(option, charge, input);
2882
+ const copy = ENTITLEMENT_COPY[option.entitlement.kind];
2883
+ const money = (cents) => formatCurrencyAmount(cents, input.currency);
2884
+ const bought = copy.boughtLine(facts);
2885
+ const lines = [...dateLines(option, copy, charge, input), ...bought ? [{
2886
+ key: "bought",
2887
+ label: `${facts.name} (buying now)`,
2888
+ note: bought.note,
2889
+ value: money(charge.boughtCents)
2890
+ }] : []];
2891
+ const owesMoney = charge.moneyDateCount > 0 || charge.boughtCents > 0;
2892
+ const totals = [
2893
+ ...copy.countsCredits && facts.covered > 0 && owesMoney ? [{
2894
+ key: "credits",
2895
+ label: "From your pass",
2896
+ value: credits(facts.covered),
2897
+ total: false
2898
+ }] : [],
2899
+ ...owesMoney ? input.reductions.map((row) => ({
2900
+ key: row.key,
2901
+ label: row.label,
2902
+ value: `−${money(row.amountCents)}`,
2903
+ total: false
2904
+ })) : [],
2905
+ ...charge.creditCents > 0 ? [{
2906
+ key: "account-credit",
2907
+ label: "Account credit",
2908
+ value: `−${money(charge.creditCents)}`,
2909
+ total: false
2910
+ }] : [],
2911
+ ...owesMoney ? [toPayTotal(charge, money)] : copy.countsCredits ? [{
2912
+ key: "credits",
2913
+ label: "From your pass",
2914
+ value: credits(facts.covered),
2915
+ total: true
2916
+ }] : []
2917
+ ];
2918
+ return {
2919
+ summary: {
2920
+ caption: paymentCaption("dates", input.dates.length, input.places),
2921
+ lines,
2922
+ totals
2923
+ },
2924
+ facts,
2925
+ copy
2926
+ };
2927
+ }
2928
+ /** What's left to pay: today by card, or to the business directly. */
2929
+ function toPayTotal(charge, money) {
2930
+ return charge.remainder === "direct" ? {
2931
+ key: "to-pay",
2932
+ label: "To pay directly",
2933
+ value: money(charge.directCents),
2934
+ total: true
2935
+ } : {
2936
+ key: "to-pay",
2937
+ label: "To pay",
2938
+ value: money(charge.cardCents),
2939
+ total: true
2940
+ };
2941
+ }
2942
+ /**
2943
+ * Whether the breakdown says something the chosen option's row and button don't:
2944
+ * a code, a combination price or account credit coming off. One date shows it
2945
+ * only then.
2946
+ */
2947
+ function summaryExplainsMoreThanTheOption(summary) {
2948
+ return summary.totals.some((row) => row.key !== "credits" && row.key !== "to-pay");
2949
+ }
2950
+ function entitlementNote(funding, dateCount) {
2951
+ switch (funding.entitlementNote) {
2952
+ case "none": return null;
2953
+ case "severalPlaces": return dateCount === 1 ? ONE_DATE_SEVERAL_PLACES_ENTITLEMENT_NOTE : SEVERAL_PLACES_ENTITLEMENT_NOTE;
2954
+ default: return assertNever(funding.entitlementNote);
2955
+ }
2956
+ }
2957
+ function termsSurfaceOf(option) {
2958
+ if (option.kind === "money") return "primary";
2959
+ switch (option.entitlement.kind) {
2960
+ case "buyPass":
2961
+ case "buyMembership": return "commerce";
2962
+ case "ownedPass":
2963
+ case "ownedMembership": return "primary";
2964
+ default: return assertNever(option.entitlement);
2965
+ }
2966
+ }
2967
+ function presentSelectionFunding(input) {
2968
+ const option = chosenFundingOption(input.funding, input.pick);
2969
+ const chosenKey = fundingOptionKey(option);
2970
+ const common = {
2971
+ option,
2972
+ rows: (ownCoverPaysEveryDate(option) ? input.funding.options.filter((candidate) => candidate.kind === "money" || ownCoverPaysEveryDate(candidate)) : input.funding.options).flatMap((candidate) => optionRows(candidate, chosenKey, input)),
2973
+ termsSurface: termsSurfaceOf(option),
2974
+ note: entitlementNote(input.funding, input.dates.length)
2975
+ };
2976
+ switch (option.kind) {
2977
+ case "money": return {
2978
+ ...common,
2979
+ summary: null,
2980
+ buttonText: null,
2981
+ cardCents: null,
2982
+ collection: null,
2983
+ takesPayment: orderPrice(option, true, input).totalCents > 0
2984
+ };
2985
+ case "entitlement": {
2986
+ const collection = collectionShown(input.collectionsOf(fundingOptionPick(option)), input.chosenCollection);
2987
+ const { summary, facts, copy } = fundedSummary(option, collection, input);
2988
+ return {
2989
+ ...common,
2990
+ summary,
2991
+ buttonText: copy.button(facts),
2992
+ cardCents: facts.charge.cardCents,
2993
+ collection,
2994
+ takesPayment: facts.charge.cardCents > 0
2995
+ };
2996
+ }
2997
+ default: return assertNever(option);
2998
+ }
2999
+ }
3000
+ /** The chosen dates as the summary lists them, each at its own price for every place. */
3001
+ function fundingDatesOf(selection, itemPrice) {
3002
+ return selection.flatMap((event) => event.registrationSubject.kind === "occurrence" ? [{
3003
+ occurrenceId: event.registrationSubject.occurrenceId,
3004
+ label: formatBookingWhen(event, "short"),
3005
+ day: formatBookingWhen(event, "day"),
3006
+ priceCents: itemPrice(event)?.subtotalCents ?? null
3007
+ }] : []);
3008
+ }
3009
+ /** "31 Jan", where the event is. */
3010
+ function fundingDayFormatter(event) {
3011
+ return (iso) => formatBookingWhen({
3012
+ startsAt: iso,
3013
+ timeZone: event?.timeZone ?? null,
3014
+ siteTimeZone: event?.siteTimeZone ?? null,
3015
+ deliveryMode: event?.deliveryMode ?? null
3016
+ }, "dayMonth");
3017
+ }
3018
+ /**
3019
+ * The payment step's status and button for several dates. The money option
3020
+ * keeps the card step's own; a pass or membership option waits for the
3021
+ * server to price its order.
3022
+ */
3023
+ function fundingPaymentStepState(base, lookup, view, priced) {
3024
+ switch (lookup.tag) {
3025
+ case "idle": return base;
3026
+ case "loading": return {
3027
+ ...base,
3028
+ status: base.status === "ready" ? "loading" : base.status,
3029
+ canContinue: false
3030
+ };
3031
+ case "failed": return {
3032
+ ...base,
3033
+ status: base.status === "ready" ? "error" : base.status,
3034
+ canContinue: false
3035
+ };
3036
+ case "loaded":
3037
+ if (lookup.reload !== null) return {
3038
+ ...base,
3039
+ status: base.status === "ready" ? "loading" : base.status,
3040
+ canContinue: false
3041
+ };
3042
+ if (!view || view.buttonText === null) return base;
3043
+ return {
3044
+ ...base,
3045
+ canContinue: base.status === "ready" && priced,
3046
+ buttonText: view.buttonText
3047
+ };
3048
+ default: return assertNever(lookup);
3049
+ }
3050
+ }
3051
+ //#endregion
2227
3052
  //#region ../blocks/src/system/runtime/nodes/event-registration/useGuestDetailsCheck.ts
2228
3053
  /** When a guest completes details on a full event with a waitlist, asks the
2229
3054
  * server whether their email has an unfinished booking to pay for instead.
2230
- * The answer is navigation only; submission still owns the booking. */
3055
+ * Only one this browser can name is offered for payment (#1832), so the check
3056
+ * sends the same names a submission would. The answer is navigation only;
3057
+ * submission still owns the booking. */
2231
3058
  function useGuestDetailsCheck(input) {
2232
3059
  const [checkingNextStep, setCheckingNextStep] = useState(false);
2233
3060
  const checkDetailsNextStep = () => checkGuestNextStep(input, guestNextStepRequest(input), setCheckingNextStep);
@@ -2260,7 +3087,9 @@ async function checkGuestNextStep(input, request, setCheckingNextStep) {
2260
3087
  }
2261
3088
  function guestNextStepRequest(input) {
2262
3089
  const buyer = parseParticipantEmail(input.formData.email);
2263
- return input.registrationTarget ? {
3090
+ if (!input.registrationTarget) return null;
3091
+ const earlier = input.earlierBookings();
3092
+ return {
2264
3093
  subject: toRegistrationRequestSubject(input.registrationTarget.subject, input.selectedAttendanceMode),
2265
3094
  selections: input.ticketSelections,
2266
3095
  selectedSlidingAmount: input.selectedSlidingAmount ?? void 0,
@@ -2269,8 +3098,9 @@ function guestNextStepRequest(input) {
2269
3098
  kind: "email",
2270
3099
  email: buyer.value
2271
3100
  } : { kind: "unknown" },
2272
- purchaseTarget: "eventTickets"
2273
- } : null;
3101
+ purchaseTarget: "eventTickets",
3102
+ ...earlier.length > 0 ? { replacesRegistrationCommandIds: earlier } : {}
3103
+ };
2274
3104
  }
2275
3105
  //#endregion
2276
3106
  //#region ../blocks/src/system/runtime/nodes/event-registration/paymentResponse.ts
@@ -2300,6 +3130,7 @@ function planCheckoutOutcome({ outcome, subject }, intent) {
2300
3130
  switch (outcome.kind) {
2301
3131
  case "resolved": return {
2302
3132
  kind: "confirmed",
3133
+ submissionPayment: outcome.submissionPayment,
2303
3134
  outcome: outcome.outcome,
2304
3135
  ...outcome.outcomes ? { outcomes: outcome.outcomes } : {}
2305
3136
  };
@@ -2440,7 +3271,7 @@ function usePaymentTransitions(options, runtime) {
2440
3271
  const { setState, note, generation, operation } = runtime;
2441
3272
  const openPayment = useCallback((checkout, subject, mailingListSignupNote) => {
2442
3273
  if (mailingListSignupNote) note.current = mailingListSignupNote;
2443
- rememberEventPayment(subject.submissionId, checkout.sessionId);
3274
+ rememberEventPayment(options.api.config.siteId, subject.submissionId, checkout.sessionId);
2444
3275
  setState({
2445
3276
  kind: "payment",
2446
3277
  checkout,
@@ -2448,6 +3279,7 @@ function usePaymentTransitions(options, runtime) {
2448
3279
  });
2449
3280
  options.setStep("payment");
2450
3281
  }, [
3282
+ options.api.config.siteId,
2451
3283
  options.setStep,
2452
3284
  setState,
2453
3285
  note
@@ -2468,7 +3300,7 @@ function usePaymentTransitions(options, runtime) {
2468
3300
  setState
2469
3301
  ]);
2470
3302
  const restartFrom = useCallback((step, heldPlaceRetry) => {
2471
- clearEventPayment(options.api.config.siteId);
3303
+ clearEventPayment(options.api.config.siteId, heldPlaceRetry ? "held" : "finished");
2472
3304
  runtime.setHeldTicketSelection(snapshotHeldTicketSelection(heldPlaceRetry, options.ticketSelection));
2473
3305
  setState({
2474
3306
  kind: "idle",
@@ -2485,11 +3317,12 @@ function usePaymentTransitions(options, runtime) {
2485
3317
  case "confirmed":
2486
3318
  options.complete({
2487
3319
  status: "confirmed",
3320
+ submissionPayment: transition.submissionPayment,
2488
3321
  outcome: transition.outcome,
2489
3322
  ...transition.outcomes ? { outcomes: transition.outcomes } : {},
2490
3323
  mailingListSignupNote: note.current
2491
3324
  });
2492
- clearEventPayment(options.api.config.siteId);
3325
+ clearEventPayment(options.api.config.siteId, "finished");
2493
3326
  setState({
2494
3327
  kind: "idle",
2495
3328
  heldPlaceRetry: null
@@ -2737,7 +3570,9 @@ function usePaymentStatusRecovery(options) {
2737
3570
  if (recovery?.kind === "retryAvailable") transitions.resetBooking(heldPlaceRetry(recovery));
2738
3571
  },
2739
3572
  /** True while this tab books again on a place the server said is still its own. */
2740
- retryingHeldPlace: state.kind === "idle" && state.heldPlaceRetry !== null
3573
+ retryingHeldPlace: state.kind === "idle" && state.heldPlaceRetry !== null,
3574
+ /** That booking, which the next submission names so the server lets it take the place over. */
3575
+ heldPlace: state.kind === "idle" ? state.heldPlaceRetry : null
2741
3576
  };
2742
3577
  }
2743
3578
  function heldPlaceRetry(recovery) {
@@ -2772,22 +3607,16 @@ const eventRegistrationWizardDeps = {
2772
3607
  */
2773
3608
  function presentWizardStep(facts) {
2774
3609
  return registrationPresentation(facts.flow, registrationRoute({
2775
- chooseEvent: !facts.hasPreSelectedContext,
3610
+ chooseEvent: entryChoosesEvent(facts.entry),
2776
3611
  payment: registrationPaymentRoute(facts)
2777
3612
  }));
2778
3613
  }
2779
- /** The amount field starts at the suggested price on a sliding-scale event. */
2780
- function initialSlidingAmountInput(event) {
2781
- const suggested = getSlidingScaleForEvent(event)?.suggestedAmount;
2782
- return suggested === null || suggested === void 0 ? "" : formatCentsAsCurrencyInput(suggested);
2783
- }
2784
3614
  function useEventRegistrationWizard(options) {
2785
3615
  return useEventRegistrationWizardWithDeps(options, eventRegistrationWizardDeps);
2786
3616
  }
2787
3617
  const CHOOSER_CLOCK = { kind: "relative" };
2788
3618
  /** The wizard owns the step, so it owns whether the clock has stopped this visitor starting a booking. */
2789
- function useFreshBookingClosure(deps, options, events, step, visitorHoldsPlace) {
2790
- const recoveryRequest = useEventRegistrationRecoveryRequest();
3619
+ function useFreshBookingClosure(deps, options, events, step, visitorHoldsPlace, recoveryRequest) {
2791
3620
  const nextBoundary = useMemo(() => nextFreshBookingBoundary(events, options.occurrenceContext, options.subject), [
2792
3621
  events,
2793
3622
  options.occurrenceContext,
@@ -2810,6 +3639,10 @@ function useFreshBookingClosure(deps, options, events, step, visitorHoldsPlace)
2810
3639
  function holdsPlace(claim, payment) {
2811
3640
  return claim.kind !== "none" || payment.retryingHeldPlace;
2812
3641
  }
3642
+ /** A hybrid event's places and prices depend on how they'll attend, so nothing is quoted until they've said. */
3643
+ function attendanceAllowsQuote(attendance, selected, wanted) {
3644
+ return wanted && !attendanceChoicePending(attendance, selected);
3645
+ }
2813
3646
  /** A date that has closed has nothing to quote for a new booking. */
2814
3647
  function bookingClosureAllowsQuote(closure, wanted) {
2815
3648
  return closure.kind !== "closedEarly" && closure.kind !== "started" && wanted;
@@ -2915,15 +3748,28 @@ function useEventRegistrationWizardWithDeps(options, deps) {
2915
3748
  const api = useBlockApi();
2916
3749
  const arrivalCredential = deps.useWaitlistClaimCredential();
2917
3750
  const nowIso = deps.useBookingNowIso(options.now);
2918
- const { events, registrationEvents, recoveryEvents, scopedEvents, claimEventSource } = useRegistrationEventSource(options, deps.useBookingNowIso(options.now, CHOOSER_CLOCK));
2919
- const preSelectedEvent = useMemo(() => findPreSelectedEvent({
2920
- scopedEvents,
2921
- occurrenceContext: options.occurrenceContext
2922
- }), [scopedEvents, options.occurrenceContext]);
2923
- const hasPreSelectedContext = !!(options.occurrenceContext || preSelectedEvent);
2924
- const [flowState, dispatchFlow] = useReducer(registrationFlowReducer, hasPreSelectedContext, (context) => ({
2925
- ...createInitialRegistrationFlowState(context),
2926
- draft: createRegistrationDraftData(preSelectedEvent ?? null),
3751
+ const choiceNowIso = deps.useBookingNowIso(options.now, CHOOSER_CLOCK);
3752
+ const { events, registrationEvents, recoveryEvents, scopedEvents: pageChoices, claimEventSource } = useRegistrationEventSource(options, choiceNowIso);
3753
+ const arrivedFor = useEventRegistrationRecoveryRequest();
3754
+ const [arrivalFinished, setArrivalFinished] = useState(false);
3755
+ const arrival = arrivalFinished ? "none" : arrivedFor;
3756
+ const entryFor = useCallback((request) => decideRegistrationEntry({
3757
+ events: pageChoices,
3758
+ occurrenceContext: options.occurrenceContext,
3759
+ offer: options.datePageOffer,
3760
+ arrival: request,
3761
+ now: new Date(choiceNowIso)
3762
+ }), [
3763
+ pageChoices,
3764
+ options.occurrenceContext,
3765
+ options.datePageOffer,
3766
+ choiceNowIso
3767
+ ]);
3768
+ const entry = useMemo(() => entryFor(arrival), [entryFor, arrival]);
3769
+ const scopedEvents = entry.choices;
3770
+ const preSelectedEvent = entryPageEvent(entry);
3771
+ const [flowState, dispatchFlow] = useReducer(registrationFlowReducer, entryStart(entry), (start) => ({
3772
+ ...createInitialRegistrationFlowState(start),
2927
3773
  invitation: beginWaitlistInvitation(arrivalCredential)
2928
3774
  }));
2929
3775
  const [restoredCode, restoreDiscountCode] = useState(null);
@@ -2933,25 +3779,16 @@ function useEventRegistrationWizardWithDeps(options, deps) {
2933
3779
  flow: flowState,
2934
3780
  dispatch: dispatchFlow,
2935
3781
  events: scopedEvents,
3782
+ identity: portalSessionIdentity(api.config),
2936
3783
  eventsReady: options.eventSource.kind === "ready",
2937
3784
  onDiscountCodeRestored: restoreDiscountCode
2938
3785
  });
2939
3786
  const step = flowState.step;
2940
3787
  const paymentIntent = flowState.paymentSelection;
2941
- const { selection, runChoices, formData: draftFormData, guests, selectedAttendanceMode, selectedTicketLines, selectedSlidingAmountInput: draftSlidingAmountInput } = flowState.draft;
3788
+ const { selection, runChoices, formData: draftFormData, guests, selectedAttendanceMode, selectedTicketLines, roomChoices, selectedSlidingAmountInput: draftSlidingAmountInput } = flowState.draft;
2942
3789
  const selectedEvent = primarySelectionItem(selection);
2943
- const selectionMode = registrationSelectionMode({
2944
- events: scopedEvents,
2945
- hasPreSelectedContext
2946
- });
3790
+ const selectionMode = entrySelectionMode(entry);
2947
3791
  const several = severalItemsOf(selection);
2948
- const setSelection = useCallback((value) => dispatchFlow({
2949
- type: "draft-edited",
2950
- edit: {
2951
- field: "selection",
2952
- value
2953
- }
2954
- }), []);
2955
3792
  const setRunChoices = useCallback((value) => dispatchFlow({
2956
3793
  type: "draft-edited",
2957
3794
  edit: {
@@ -2987,6 +3824,13 @@ function useEventRegistrationWizardWithDeps(options, deps) {
2987
3824
  value
2988
3825
  }
2989
3826
  }), []);
3827
+ const setRoomChoices = useCallback((value) => dispatchFlow({
3828
+ type: "draft-edited",
3829
+ edit: {
3830
+ field: "roomChoices",
3831
+ value
3832
+ }
3833
+ }), []);
2990
3834
  const setSelectedSlidingAmountInput = useCallback((value) => dispatchFlow({
2991
3835
  type: "draft-edited",
2992
3836
  edit: {
@@ -3045,10 +3889,11 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3045
3889
  }));
3046
3890
  }, [portalAuthState, portalProfile]);
3047
3891
  const handleLogout = () => logoutPortal(options.anchorId);
3892
+ const bookingContext = bookingOccurrenceContext(options.occurrenceContext, preSelectedEvent, selection);
3048
3893
  const registrationTarget = useMemo(() => resolveRegistrationTarget({
3049
- occurrenceContext: options.occurrenceContext,
3894
+ occurrenceContext: bookingContext,
3050
3895
  selection
3051
- }), [options.occurrenceContext, selection]);
3896
+ }), [bookingContext, selection]);
3052
3897
  const registrationOccurrenceId = getRegistrationOccurrenceId(registrationTarget);
3053
3898
  const registrationNavigation = useRegistrationNavigation({
3054
3899
  pageNavigation: options.pageNavigation,
@@ -3058,7 +3903,8 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3058
3903
  });
3059
3904
  const { showMagicLinkModal, changeSignInVisibility: setShowMagicLinkModal, interceptPaymentSelection } = registrationNavigation;
3060
3905
  const currentEvent = selectedEvent ?? preSelectedEvent;
3061
- const attendance = useMemo(() => decideSelectionAttendance(effectiveSelection(selection, preSelectedEvent ?? null)), [selection, preSelectedEvent]);
3906
+ const activeSelection = useMemo(() => effectiveSelection(selection, preSelectedEvent ?? null), [selection, preSelectedEvent]);
3907
+ const attendance = useMemo(() => decideSelectionAttendance(activeSelection), [activeSelection]);
3062
3908
  const commandRef = useRef(null);
3063
3909
  const setStep = useCallback((nextStep) => {
3064
3910
  dispatchFlow({
@@ -3066,10 +3912,13 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3066
3912
  step: nextStep
3067
3913
  });
3068
3914
  }, []);
3915
+ const roomOffer = selectRoomOffer(activeSelection, flowState.roomFacts);
3916
+ const roomStay = useMemo(() => decideRoomStay(roomOffer, roomChoices), [roomOffer, roomChoices]);
3917
+ const bookedTicketLines = useMemo(() => bookingLines(selectedTicketLines, roomStay), [selectedTicketLines, roomStay]);
3069
3918
  const ticketInputs = useMemo(() => selectionTicketInputs({
3070
3919
  several,
3071
3920
  primary: currentEvent,
3072
- lines: selectedTicketLines,
3921
+ lines: bookedTicketLines,
3073
3922
  slidingAmountInput: draftSlidingAmountInput,
3074
3923
  placeCount: flowState.placeCount,
3075
3924
  runChoices,
@@ -3077,7 +3926,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3077
3926
  }), [
3078
3927
  several,
3079
3928
  currentEvent,
3080
- selectedTicketLines,
3929
+ bookedTicketLines,
3081
3930
  draftSlidingAmountInput,
3082
3931
  flowState.placeCount,
3083
3932
  runChoices,
@@ -3085,10 +3934,15 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3085
3934
  ]);
3086
3935
  const usesTicketTypeSelections = ticketInputs.usesTicketLines;
3087
3936
  const selectedSlidingAmountInput = ticketInputs.slidingAmountInput;
3088
- const normalizedSelectedTicketLines = useMemo(() => normalizeTicketSelectionLines(selectedTicketLines), [selectedTicketLines]);
3937
+ const normalizedSelectedTicketLines = useMemo(() => normalizeTicketSelectionLines(bookedTicketLines), [bookedTicketLines]);
3938
+ const roomlessTicketLines = useMemo(() => normalizeTicketSelectionLines(selectedTicketLines), [selectedTicketLines]);
3089
3939
  const primaryLines = useMemo(() => normalizeTicketSelectionLines(ticketInputs.lines), [ticketInputs.lines]);
3090
3940
  const ticketsCount = ticketInputs.ticketsCount;
3091
- const ticketSelections = useMemo(() => waitlistClaim.kind === "ready" ? [...waitlistClaim.restoration.ticketSelections] : primaryLines, [waitlistClaim, primaryLines]);
3941
+ const { ticketSelections, quoteSelections, maxTicketsNum } = useMemo(() => invitationBooking(waitlistClaim, primaryLines, options.maxTicketsNum), [
3942
+ waitlistClaim,
3943
+ primaryLines,
3944
+ options.maxTicketsNum
3945
+ ]);
3092
3946
  const currentTicketSelection = getCurrentTicketSelection(currentEvent, selectedAttendanceMode, ticketSelections);
3093
3947
  const paymentController = usePaymentStatusRecovery({
3094
3948
  api,
@@ -3103,7 +3957,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3103
3957
  detailsInPage: () => Object.keys(validateFormData(formData)).length === 0
3104
3958
  });
3105
3959
  const { recovery: paymentStatusRecovery, showRecovery: setPaymentStatusRecovery, check: handleCheckPaymentStatus, continuePayment: handleContinueExistingPayment, returnToPayment: handleReturnToPayment, returnToBooking: handleReturnToBooking } = paymentController;
3106
- const bookingClosure = useFreshBookingClosure(deps, options, events, step, holdsPlace(waitlistClaim, paymentController));
3960
+ const bookingClosure = useFreshBookingClosure(deps, options, events, step, holdsPlace(waitlistClaim, paymentController), arrival);
3107
3961
  const eligibilityResult = deps.useEligibility({
3108
3962
  refreshKey: optionsRefreshKey,
3109
3963
  buyerEmail: formData.email,
@@ -3114,17 +3968,18 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3114
3968
  api.config.siteId,
3115
3969
  portalIdentity
3116
3970
  ]),
3117
- enabled: bookingClosureAllowsQuote(bookingClosure, shouldRefreshAfterRegistrationError(step, errorAction, shouldLoadRegistrationOptions(portalAuthState, step))),
3971
+ enabled: bookingClosureAllowsQuote(bookingClosure, attendanceAllowsQuote(attendance, selectedAttendanceMode, shouldRefreshAfterRegistrationError(step, errorAction, shouldLoadRegistrationOptions(portalAuthState, step)))),
3118
3972
  subject: registrationTarget?.subject ?? null,
3119
3973
  attendanceMode: selectedAttendanceMode,
3120
- ticketSelections,
3974
+ ticketSelections: quoteSelections,
3121
3975
  selectedSlidingAmount: parseCurrencyInputToCents(selectedSlidingAmountInput),
3122
3976
  subjectEmail: getPortalSubjectEmail(portalProfile),
3123
3977
  waitlistClaim: waitlistClaimCredential(waitlistClaim)
3124
3978
  });
3125
3979
  const existingRegistrationResult = deps.useExistingEventRegistration({
3126
3980
  isAuthenticated: portalAuthState === "authenticated",
3127
- occurrenceId: registrationOccurrenceId
3981
+ occurrenceId: registrationOccurrenceId,
3982
+ completedBookings: flowState.completedOutcomes.length
3128
3983
  });
3129
3984
  const existingRegistrations = useMemo(() => existingRegistrationResult.registrations.filter((registration) => registration.occurrenceId === registrationOccurrenceId), [existingRegistrationResult.registrations, registrationOccurrenceId]);
3130
3985
  const registrationOptionsState = eligibilityResult.state;
@@ -3214,15 +4069,18 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3214
4069
  maxTickets: options.maxTicketsNum,
3215
4070
  attendanceMode: selectedAttendanceMode
3216
4071
  };
3217
- const { slidingScaleSelectionMessage, selectionChoiceMessage } = resolveSelectionChoiceMessages({
4072
+ const choiceMessages = resolveSelectionChoiceMessages({
3218
4073
  several,
3219
4074
  attendance,
3220
4075
  selection,
3221
4076
  runChoices,
3222
4077
  facts: runChoiceFacts,
3223
4078
  slidingScale: selectedEventSlidingScale,
3224
- selectedAmount: selectedSlidingAmount
4079
+ selectedAmount: selectedSlidingAmount,
4080
+ roomMessage: roomChoiceMessage(roomStay, roomlessTicketLines)
3225
4081
  });
4082
+ const { slidingScaleSelectionMessage } = choiceMessages;
4083
+ const selectionChoiceMessage = choiceMessages.selectionChoiceMessage;
3226
4084
  const ticketTypeSelectionRequired = useMemo(() => {
3227
4085
  const event = currentEvent;
3228
4086
  if (!event || !usesTicketTypeSelections) return false;
@@ -3233,15 +4091,54 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3233
4091
  selectedAttendanceMode,
3234
4092
  usesTicketTypeSelections
3235
4093
  ]);
4094
+ const { selectionFunding, datesQuote } = useWizardSelectionFunding({
4095
+ api,
4096
+ target: registrationTarget,
4097
+ event: currentEvent,
4098
+ several,
4099
+ attendanceMode: selectedAttendanceMode,
4100
+ ticketSelections,
4101
+ selectedSlidingAmount,
4102
+ identity: getPortalSubjectEmail(portalProfile),
4103
+ step,
4104
+ portalAuthState
4105
+ });
4106
+ const runsPayment = useRunsSelectionPayment({
4107
+ api,
4108
+ identity: getPortalSubjectEmail(portalProfile),
4109
+ ...runsPaymentAsk({
4110
+ several,
4111
+ step,
4112
+ portalAuthState,
4113
+ selectionChoiceMessage,
4114
+ request: {
4115
+ selection,
4116
+ runChoices,
4117
+ places: ticketsCount,
4118
+ attendanceMode: selectedAttendanceMode
4119
+ }
4120
+ })
4121
+ });
4122
+ const severalAnswer = severalItemsPaymentAnswer(several, selectionFunding.lookup, runsPayment);
4123
+ const selectionPayment = answeredPayment(severalAnswer);
4124
+ useEffect(() => {
4125
+ dispatchFlow({
4126
+ type: "selection-payment-updated",
4127
+ payment: selectionPayment
4128
+ });
4129
+ }, [selectionPayment]);
3236
4130
  const admission = resolveRegistrationAdmission({
3237
4131
  eligibility,
3238
4132
  eligibilityError,
4133
+ bookingsClosed: eligibilityResult.bookingsClosed,
3239
4134
  eligibilityLoading,
3240
4135
  holdsOwnPlace: visitorHoldsOwnPlace({
3241
4136
  hasWaitlistClaim: waitlistClaim.kind === "ready",
3242
4137
  retryingHeldPlace: paymentController.retryingHeldPlace
3243
4138
  }),
3244
- isAuthenticated: portalAuthState === "authenticated"
4139
+ isAuthenticated: portalAuthState === "authenticated",
4140
+ businessName: options.siteName,
4141
+ selectionPayment
3245
4142
  });
3246
4143
  const ticketSelectionPurpose = getTicketSelectionPurpose({
3247
4144
  admission,
@@ -3259,7 +4156,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3259
4156
  purpose: ticketSelectionPurpose,
3260
4157
  lines: normalizedSelectedTicketLines,
3261
4158
  visibleOptions: visibleTicketTypes,
3262
- maxTickets: options.maxTicketsNum,
4159
+ maxTickets: maxTicketsNum,
3263
4160
  overallRemainingPlaces,
3264
4161
  heldPlacesBySelection
3265
4162
  });
@@ -3269,8 +4166,8 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3269
4166
  locked: selectionLocked,
3270
4167
  restoring: !browserDraftReady,
3271
4168
  usesTicketTypes: usesTicketTypeSelections,
3272
- lines: normalizedSelectedTicketLines,
3273
- visibleOptions: visibleTicketTypes,
4169
+ lines: roomlessTicketLines,
4170
+ visibleOptions: defaultTicketOptions(roomOffer, visibleTicketTypes),
3274
4171
  purpose: ticketSelectionPurpose,
3275
4172
  setLines: setSelectedTicketLines
3276
4173
  });
@@ -3299,13 +4196,8 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3299
4196
  const handleGuestShakeEnd = () => {
3300
4197
  setGuestSectionShake(false);
3301
4198
  };
3302
- const selectionPayment = decideSelectionPayment({
3303
- selection,
3304
- runChoices,
3305
- eligibility
3306
- });
3307
4199
  const eventRequiresPayment = useMemo(() => {
3308
- if (selectionPayment.kind === "several") return selectionPayment.due === "card";
4200
+ if (several !== null) return !selectionPaysNothing(selectionPayment);
3309
4201
  if (selectedEventSlidingScale) return (selectedSlidingAmount ?? 0) > 0;
3310
4202
  return resolveEventRequiresPayment({
3311
4203
  eligibility,
@@ -3318,6 +4210,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3318
4210
  currentEvent,
3319
4211
  selectedEventSlidingScale,
3320
4212
  selectedSlidingAmount,
4213
+ several,
3321
4214
  selectionPayment
3322
4215
  ]);
3323
4216
  const { ticketContinuation, handleTicketsComplete } = useRegistrationAdmission({
@@ -3337,11 +4230,12 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3337
4230
  registrationTarget,
3338
4231
  selectedAttendanceMode,
3339
4232
  ticketSelections,
3340
- selectedSlidingAmount
4233
+ selectedSlidingAmount,
4234
+ earlierBookings: () => earlierBookingsToName(commandRef.current, paymentController.heldPlace, browserPendingCheckouts.ids(api.config.siteId))
3341
4235
  });
3342
- const blockDetailsCompletion = (blocker) => {
4236
+ const blockDetailsCompletion = (blocker, action = "places") => {
3343
4237
  if (blocker.kind === "unavailable") {
3344
- setErrorAction("places");
4238
+ setErrorAction(action);
3345
4239
  setErrorMessage(blocker.message);
3346
4240
  setStep("error");
3347
4241
  }
@@ -3396,7 +4290,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3396
4290
  kind: "unavailable",
3397
4291
  reason: "closed",
3398
4292
  message: continuation.message
3399
- });
4293
+ }, DETAILS_CHECK_REFUSAL_RECOVERY);
3400
4294
  case "payment-step":
3401
4295
  setStep("select-payment");
3402
4296
  return {
@@ -3404,8 +4298,8 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3404
4298
  outcome: "payment-step"
3405
4299
  };
3406
4300
  case "submit": {
3407
- const { method, passId, membershipId, selection } = continuation.args;
3408
- const result = await handleSubmit(method, passId, membershipId, selection);
4301
+ const { method, membershipId, selection } = continuation.args;
4302
+ const result = await handleSubmit(method, membershipId, selection);
3409
4303
  return result.ok ? {
3410
4304
  ok: true,
3411
4305
  outcome: "submitted"
@@ -3417,9 +4311,25 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3417
4311
  }
3418
4312
  }
3419
4313
  };
4314
+ /** The payment step's button, for the block and the headless flow alike. */
3420
4315
  const handlePaymentSelect = async () => {
3421
- const surface = eventSiteTermsSurface(paymentSelection.method);
3422
- if (surface === "commerce" && !siteTerms.requireAgreement(surface)) return;
4316
+ const surface = paymentTermsSurface;
4317
+ if (surface === "commerce" && !siteTerms.requireAgreement(surface)) return {
4318
+ ok: false,
4319
+ reason: "blocked",
4320
+ message: "Agree to the terms of sale to continue."
4321
+ };
4322
+ if (fundingView?.option.kind === "entitlement") {
4323
+ if (fundingView.collection === null && fundingView.takesPayment) return {
4324
+ ok: false,
4325
+ reason: "blocked",
4326
+ message: "Choose an available payment option."
4327
+ };
4328
+ return handleSubmit("stripe", void 0, {
4329
+ method: "stripe",
4330
+ collectionOptionKind: fundingView.collection ?? "upfront"
4331
+ });
4332
+ }
3423
4333
  const submitPlan = resolveEventRegistrationSubmitPlan({
3424
4334
  paymentSelection,
3425
4335
  eventRequiresPayment,
@@ -3428,15 +4338,13 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3428
4338
  if (!submitPlan.ok) {
3429
4339
  setErrorMessage(submitPlan.message);
3430
4340
  setStep("error");
3431
- return;
4341
+ return {
4342
+ ok: false,
4343
+ reason: "blocked",
4344
+ message: submitPlan.message
4345
+ };
3432
4346
  }
3433
- await handleSubmit(submitPlan.args.method, submitPlan.args.passId, submitPlan.args.membershipId, submitPlan.args.selection);
3434
- };
3435
- const handleUseCardInsteadOfPass = () => {
3436
- dispatchFlow({ type: "use-card-instead-of-pass" });
3437
- };
3438
- const handleUsePassInstead = () => {
3439
- dispatchFlow({ type: "use-pass" });
4347
+ return handleSubmit(submitPlan.args.method, submitPlan.args.membershipId, submitPlan.args.selection);
3440
4348
  };
3441
4349
  const handleBookForSomeoneElse = () => {
3442
4350
  if (portalAuthState === "authenticated") {
@@ -3475,6 +4383,11 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3475
4383
  runChoices,
3476
4384
  primaryTicketUnits: ticketSelectionSummaryLines
3477
4385
  });
4386
+ const pricedAsOrder = pricesAsOrder(several, datesQuote);
4387
+ const reviseFunding = (revised, message) => {
4388
+ setErrorMessage("");
4389
+ selectionFunding.revise(revised, message);
4390
+ };
3478
4391
  const combinationPricing = useSelectionCombinationPricing({
3479
4392
  api,
3480
4393
  selection,
@@ -3482,6 +4395,8 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3482
4395
  places: ticketsCount,
3483
4396
  price: selectionPrice,
3484
4397
  itemPrice,
4398
+ dates: datesQuote,
4399
+ onFundingChanged: reviseFunding,
3485
4400
  email: formData.email,
3486
4401
  payment: paymentController.state,
3487
4402
  automaticWanted: step === "select-payment",
@@ -3499,12 +4414,20 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3499
4414
  productAutomaticOffered: discountUi.autoAppliedDiscount !== null && discountContext?.type === "pass"
3500
4415
  });
3501
4416
  const discountView = registrationDiscountView({
3502
- several: several !== null,
4417
+ several: pricedAsOrder,
3503
4418
  single: discountUi,
3504
4419
  selection: combinationPricing,
3505
4420
  context: discountContext
3506
4421
  });
3507
4422
  const { code: discountCode, editCode: setDiscountCode } = discountView;
4423
+ const discountAccess = registrationDiscountAccess(paymentIntent.method, selectionFunding.lookup);
4424
+ useEffect(() => {
4425
+ if (discountAccess !== "card" && discountCode) setDiscountCode("");
4426
+ }, [
4427
+ discountAccess,
4428
+ discountCode,
4429
+ setDiscountCode
4430
+ ]);
3508
4431
  useEffect(() => {
3509
4432
  if (restoredCode === null || paymentReturn) return;
3510
4433
  restoreDiscountCode(null);
@@ -3515,10 +4438,11 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3515
4438
  scope: browserScope,
3516
4439
  ready: browserDraftReady,
3517
4440
  flow: flowState,
3518
- discountCode
4441
+ discountCode,
4442
+ identity: portalSessionIdentity(api.config)
3519
4443
  });
3520
4444
  const singlePrices = decideSingleBookingPrices({
3521
- several: !(several === null),
4445
+ several: pricedAsOrder,
3522
4446
  context: discountContext,
3523
4447
  quote: combinationPricing.quote,
3524
4448
  typedCode: discountCode,
@@ -3527,31 +4451,61 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3527
4451
  });
3528
4452
  const codeAwaitingApply = combinationPricing.codeHoldingOne;
3529
4453
  const ticketSelectionSubtotalCents = singlePrices.bookingTotalCents ?? combinationPricing.payableCents;
3530
- const directPaymentOptions = resolveWizardDirectPaymentOptions({
4454
+ const directPaymentInput = {
3531
4455
  eligibility,
3532
4456
  currentEvent,
3533
- occurrenceContext: options.occurrenceContext,
3534
- ticketSelectionSubtotalCents,
4457
+ occurrenceContext: bookingContext,
4458
+ ticketSelectionSubtotalCents: oneBookingCardSubtotal({
4459
+ datesQuote,
4460
+ primarySubtotalCents,
4461
+ ticketSelectionSubtotalCents
4462
+ }),
3535
4463
  automaticDiscount: singlePrices.automaticDiscount,
3536
- nowIso,
3537
- selectionPayment
4464
+ nowIso
4465
+ };
4466
+ const itemLabel = useMemo(() => selectionItemLabels(selection), [selection]);
4467
+ const { directPaymentOptions, moneyCardOptions, paymentInFullNote, paysNothing, paymentOptionsLoading, paymentOptionsError } = decideWizardPaymentOptions({
4468
+ several,
4469
+ severalAnswer,
4470
+ directPaymentInput,
4471
+ chosenFunding: chosenFundingPick(selectionFunding.lookup),
4472
+ orderTotalCents: ticketSelectionSubtotalCents,
4473
+ itemLabel,
4474
+ choiceNowIso,
4475
+ eligibility,
4476
+ eligibilityError,
4477
+ loading: anyLoading(eligibilityLoading, checkingNextStep, combinationPricing.quoting)
3538
4478
  });
3539
4479
  const { paymentDecision, paymentSelection, paymentStepState: quotedPaymentStepState } = resolveWizardPaymentView({
3540
4480
  directPaymentOptions,
3541
4481
  paymentIntent,
3542
4482
  eligibility,
3543
4483
  admission,
3544
- selectionPayment,
3545
- eligibilityLoading,
3546
- quoting: combinationPricing.quoting,
3547
- checkingNextStep,
3548
- eligibilityError,
4484
+ paysNothing,
4485
+ offersEntitlements: several === null,
4486
+ loading: paymentOptionsLoading,
4487
+ error: paymentOptionsError,
3549
4488
  isAuthenticated: flowState.isAuthenticated,
3550
4489
  portalCreditState,
3551
4490
  discountCode: codeAwaitingApply ? discountCode : "",
3552
4491
  step
3553
4492
  });
3554
- const { state: paymentStepState, heldForCode: paymentHeldForCode } = holdPaymentForCode(quotedPaymentStepState, codeAwaitingApply);
4493
+ const { state: cardPaymentStepState, heldForCode: paymentHeldForCode } = holdPaymentForCode(quotedPaymentStepState, codeAwaitingApply);
4494
+ const funding = decideWizardSelectionFunding({
4495
+ lookup: selectionFunding.lookup,
4496
+ selection,
4497
+ itemPrice,
4498
+ places: ticketsCount,
4499
+ eligibility,
4500
+ event: currentEvent,
4501
+ moneyCardOptions,
4502
+ several,
4503
+ paymentDecision,
4504
+ pricing: combinationPricing,
4505
+ creditState: portalCreditState,
4506
+ cardStepState: cardPaymentStepState
4507
+ });
4508
+ const { view: fundingView, paymentStepState, termsSurface: paymentTermsSurface } = funding;
3555
4509
  const siteTerms = useSiteTermsAgreement({
3556
4510
  terms: options.siteTerms,
3557
4511
  context: {
@@ -3560,8 +4514,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3560
4514
  admission
3561
4515
  }
3562
4516
  });
3563
- const selectionMethod = paymentSelection.method;
3564
- const shouldShowDiscountToggle = registrationDiscountEntryVisible(discountView, selectionMethod);
4517
+ const shouldShowDiscountToggle = registrationDiscountEntryVisible(discountView);
3565
4518
  const requirementsLayout = useMemo(() => decideSelectionRequirementsLayout(selection), [selection]);
3566
4519
  const questions = useEventRegistrationQuestions({
3567
4520
  api,
@@ -3590,6 +4543,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3590
4543
  const handleSubmit = deps.useEventRegistrationSubmit({
3591
4544
  openPayment: paymentController.openPayment,
3592
4545
  commandRef,
4546
+ heldPlace: paymentController.heldPlace,
3593
4547
  setSubmissionFailure: (failure) => {
3594
4548
  if (failure.answersNeeded) requirements.keepRefused();
3595
4549
  dispatchFlow({
@@ -3602,6 +4556,8 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3602
4556
  registrationTarget,
3603
4557
  selectedAttendanceMode,
3604
4558
  ticketSelections,
4559
+ rooms: roomSubmission(roomOffer, roomChoices, roomlessTicketLines, flowState.draft.reviewedRooms),
4560
+ refreshOptions: () => setOptionsRefreshKey((value) => value + 1),
3605
4561
  selectedSlidingAmount,
3606
4562
  runChoices,
3607
4563
  formData,
@@ -3616,6 +4572,8 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3616
4572
  combinationPricing.refuse(message);
3617
4573
  },
3618
4574
  quoteReady: combinationPricing.ready,
4575
+ selectionFunding: funding.choice,
4576
+ onFundingChanged: reviseFunding,
3619
4577
  invitation: invitationSubmission(waitlistClaim),
3620
4578
  setStep,
3621
4579
  complete,
@@ -3646,6 +4604,16 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3646
4604
  event
3647
4605
  });
3648
4606
  };
4607
+ /**
4608
+ * Several dates: back to the dates with the same ones ticked. The way to pay
4609
+ * and the code's price are dropped; coming back plans them again.
4610
+ */
4611
+ const handleChangeDates = () => {
4612
+ if (selectionLocked) return;
4613
+ selectionFunding.reset();
4614
+ combinationPricing.carryCode(discountCode);
4615
+ setStep("select-event");
4616
+ };
3649
4617
  /** Booking several: Continue moves on with whatever is ticked. */
3650
4618
  const handleSelectionContinue = () => {
3651
4619
  if (selection.length > 0) dispatchFlow({
@@ -3676,20 +4644,15 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3676
4644
  */
3677
4645
  const handleBookAnother = () => {
3678
4646
  clearWaitlistClaimLocation();
4647
+ setArrivalFinished(true);
3679
4648
  resetRegistrationAfterExpiry({
3680
- hasPreSelectedContext,
3681
- preSelectedEvent,
4649
+ start: entryStart(entryFor("none")),
3682
4650
  dispatchFlow,
3683
- setSelectedTicketLines,
3684
- setSelectedSlidingAmountInput,
3685
- setSelectedAttendanceMode,
3686
4651
  setErrorMessage
3687
4652
  });
3688
- setSelectedSlidingAmountInput(initialSlidingAmountInput(preSelectedEvent ?? null));
3689
- setSelection(preSelectedEvent ? [preSelectedEvent] : []);
3690
- setGuests([]);
3691
4653
  setGuestErrors({});
3692
4654
  combinationPricing.reset();
4655
+ selectionFunding.reset();
3693
4656
  commandRef.current = null;
3694
4657
  setOptionsRefreshKey((value) => value + 1);
3695
4658
  };
@@ -3701,12 +4664,8 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3701
4664
  reset: () => {
3702
4665
  clearWaitlistClaimLocation();
3703
4666
  resetRegistrationAfterExpiry({
3704
- hasPreSelectedContext,
3705
- preSelectedEvent,
4667
+ start: entryStart(entry),
3706
4668
  dispatchFlow,
3707
- setSelectedTicketLines,
3708
- setSelectedSlidingAmountInput,
3709
- setSelectedAttendanceMode,
3710
4669
  setErrorMessage
3711
4670
  });
3712
4671
  }
@@ -3721,7 +4680,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3721
4680
  const presentation = presentWizardStep({
3722
4681
  step,
3723
4682
  flow: flowState,
3724
- hasPreSelectedContext,
4683
+ entry,
3725
4684
  admission,
3726
4685
  eventRequiresPayment: resolveRouteRequiresPayment({
3727
4686
  event: currentEvent,
@@ -3740,33 +4699,53 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3740
4699
  navigate: setStep,
3741
4700
  payment: paymentController
3742
4701
  });
3743
- const { hasEligibility, hasMembershipEligibility, isMembershipFastTrack } = getEligibilityFlowFlags({
3744
- eligibility,
3745
- portalAuthState,
3746
- ticketsCount,
3747
- paymentMethod: paymentSelection.method
3748
- });
3749
4702
  const displayEvent = withRegistrationAvailability(currentEvent, eligibilityLoading ? null : eligibility, selectedAttendanceMode);
3750
4703
  return {
3751
4704
  ...registrationNavigation.presentation,
4705
+ /** The rooms step, on an event with rooms; null otherwise. */
4706
+ roomChooser: roomChooserStep({
4707
+ step,
4708
+ offer: roomOffer,
4709
+ choices: roomChoices,
4710
+ stay: roomStay,
4711
+ dayLines: roomlessTicketLines,
4712
+ options: visibleTicketTypes,
4713
+ maxTickets: options.maxTicketsNum,
4714
+ refusal: submissionErrorMessage,
4715
+ event: currentEvent,
4716
+ setRoomChoices: (choices) => {
4717
+ setErrorMessage("");
4718
+ setRoomChoices(choices);
4719
+ },
4720
+ setDayLines: (lines) => {
4721
+ setErrorMessage("");
4722
+ setSelectedTicketLines(normalizeTicketSelectionLines(lines));
4723
+ }
4724
+ }),
4725
+ /** What can be listed as a ticket: an event's room prices can only be chosen through its rooms. */
4726
+ listableTicketTypes: dayOptionsOf(visibleTicketTypes, roomOffer),
3752
4727
  api,
3753
4728
  nowIso,
3754
4729
  /** Whether the clock has stopped this visitor starting a booking on this page. */
3755
4730
  bookingClosure,
3756
4731
  directPaymentOptions,
3757
4732
  paymentDecision,
4733
+ /** Why one booking's card payment is the whole price although its terms offer a deposit; null otherwise. */
4734
+ paymentInFullNote,
3758
4735
  anchorId: options.anchorId,
3759
- occurrenceContext: options.occurrenceContext,
4736
+ /** The page's occurrence while the booking is for the page's date, otherwise null. */
4737
+ occurrenceContext: bookingContext,
3760
4738
  registrationTarget,
3761
4739
  subject: options.subject,
3762
4740
  events,
3763
- maxTicketsNum: waitlistClaim.kind === "ready" ? waitlistClaim.restoration.ticketsCount : options.maxTicketsNum,
4741
+ maxTicketsNum,
3764
4742
  /** The new-booking choices, plus the run or date an invitation holds a place on. */
3765
4743
  scopedEvents: withOfferedEvent(scopedEvents, waitlistClaim),
3766
4744
  /** Everything on this page a booking could be for, whether or not it's still a choice. */
3767
4745
  recoveryEvents,
3768
4746
  preSelectedEvent: preSelectedDisplayEvent(preSelectedEvent, currentEvent, displayEvent),
3769
- hasPreSelectedContext,
4747
+ /** Where booking starts on this page, and what it chooses from. */
4748
+ entry,
3770
4749
  presentation,
3771
4750
  flow: flowState,
3772
4751
  setStep: (next) => {
@@ -3775,7 +4754,10 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3775
4754
  },
3776
4755
  admission,
3777
4756
  ticketContinuation,
3778
- handleTicketsComplete,
4757
+ handleTicketsComplete: () => {
4758
+ setErrorMessage("");
4759
+ return handleTicketsComplete();
4760
+ },
3779
4761
  selectedEvent: selectedEvent ? displayEvent : null,
3780
4762
  /** Every chosen item, in date order; the first is `selectedEvent`. */
3781
4763
  selection,
@@ -3784,8 +4766,6 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3784
4766
  severalItems: several,
3785
4767
  /** One way of attending for every chosen item. */
3786
4768
  attendance,
3787
- /** How the whole selection is paid. */
3788
- selectionPayment,
3789
4769
  /** What each run's ticket choice is checked against when booking several runs. */
3790
4770
  runChoiceFacts,
3791
4771
  selectionPrice,
@@ -3800,8 +4780,26 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3800
4780
  itemPrice
3801
4781
  }),
3802
4782
  /** The code field shares the booking's server quote. */
3803
- combinationCodeField: registrationCodeField(combinationPricing.codeField, combinationPricing.quote, paymentIntent),
4783
+ combinationCodeField: registrationCodeField(combinationPricing.codeField, combinationPricing.quote),
3804
4784
  combinationAwaitingVisitor: combinationPricing.awaitingVisitor,
4785
+ /**
4786
+ * The dates' ways to pay from the server and the visitor's pick; null for anything else, and
4787
+ * for one date the card alone pays for, which keeps the card step.
4788
+ */
4789
+ selectionFunding: selectionFundingStepModel({
4790
+ funding: selectionFunding,
4791
+ view: fundingView,
4792
+ locked: selectionLocked,
4793
+ dateCount: fundingDateCount(registrationTarget),
4794
+ chooseCard: (card) => {
4795
+ if (!selectionLocked) handlePaymentSelectionChange({
4796
+ method: "stripe",
4797
+ collectionOptionKind: card
4798
+ });
4799
+ }
4800
+ }),
4801
+ handleChangeDates,
4802
+ paymentTermsSurface,
3805
4803
  /** The payment step's list of what several items cost; null for one item. */
3806
4804
  selectionPaymentSummary: summariseSelectionPayment({
3807
4805
  ready: combinationPricing.ready,
@@ -3829,7 +4827,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3829
4827
  ticketSelections,
3830
4828
  selectedTicketLines: normalizedSelectedTicketLines,
3831
4829
  setSelectedTicketLines: (lines) => {
3832
- if (selectionLocked || waitlistClaim.kind === "ready") return;
4830
+ if (selectionLocked) return;
3833
4831
  setSelectedTicketLines(normalizeTicketSelectionLines(lines));
3834
4832
  },
3835
4833
  selectedSlidingAmountInput,
@@ -3884,27 +4882,25 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3884
4882
  paymentStepState,
3885
4883
  /** Pay is off only because a typed code hasn't been applied yet, which the customer needs telling. */
3886
4884
  paymentHeldForCode: paymentHeldForCode && combinationPricing.awaitingVisitor,
3887
- /** What the pass costs once an applied code is taken off; null when no code applies. */
3888
- passPriceAfterCodeCents: singlePrices.passTotalCents,
3889
- /** A membership's first payment after its discount; it renews at the regular price. */
3890
- membershipFirstPaymentCents: singlePrices.membershipFirstPaymentCents,
3891
4885
  handlePaymentSelectionChange: (value) => {
3892
4886
  if (!selectionLocked) handlePaymentSelectionChange(value);
3893
4887
  },
3894
4888
  paymentSelection,
3895
- declinedPass: getDeclinedPass(flowState),
3896
- isMembershipFastTrack,
3897
4889
  waitlistClaim,
3898
4890
  eligibility,
3899
4891
  registrationOptionsState,
3900
4892
  eligibilityLoading: anyLoading(eligibilityLoading, checkingNextStep, combinationPricing.quoting),
3901
4893
  eligibilityError,
4894
+ /** The payment step's own wait: the booking options, and several runs' ways to pay. */
4895
+ paymentOptionsLoading,
4896
+ /** Why the payment step can't show ways to pay, when the booking options or several runs' ways to pay didn't load. */
4897
+ paymentOptionsError,
4898
+ /** Asks for the booking options again, after they failed to load. */
4899
+ reloadOptions: () => setOptionsRefreshKey((value) => value + 1),
3902
4900
  existingRegistrations,
3903
4901
  existingRegistrationLoading: existingRegistrationResult.isLoading || portalAuthState === "authenticated" && eligibilityLoading,
3904
4902
  existingRegistrationState: existingRegistrationResult.state,
3905
4903
  registrationState,
3906
- hasEligibility,
3907
- hasMembershipEligibility,
3908
4904
  requireGuestDetails,
3909
4905
  discountCode,
3910
4906
  setDiscountCode: (value) => {
@@ -3918,6 +4914,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3918
4914
  discountsAvailableLoading: discountView.discountsAvailableLoading,
3919
4915
  discountContext,
3920
4916
  shouldShowDiscountToggle,
4917
+ discountAccess,
3921
4918
  verification,
3922
4919
  paymentController,
3923
4920
  paymentStatusRecovery,
@@ -3928,8 +4925,6 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3928
4925
  checkingNextStep,
3929
4926
  handleDetailsComplete,
3930
4927
  handlePaymentSelect,
3931
- handleUseCardInsteadOfPass,
3932
- handleUsePassInstead,
3933
4928
  handleBookForSomeoneElse,
3934
4929
  handleBookAnother,
3935
4930
  handleSubmit: (...args) => selectionLocked ? Promise.resolve({
@@ -3947,6 +4942,25 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3947
4942
  ...registrationCompletionState(flowState)
3948
4943
  };
3949
4944
  }
4945
+ /** The rooms step, while the guest is on it. */
4946
+ function roomChooserStep(input) {
4947
+ const { offer, options } = input;
4948
+ if (!offer || input.step !== "select-tickets") return null;
4949
+ const dayOptions = dayOptionsOf(options, offer);
4950
+ const dayIds = new Set(dayOptions.map((option) => option.pricingOptionId));
4951
+ return {
4952
+ view: presentRoomChooser({
4953
+ ...input,
4954
+ offer,
4955
+ timeZone: resolveBookingBusinessTimeZone(input.event?.siteTimeZone)
4956
+ }),
4957
+ choices: input.choices,
4958
+ /** The places without a room. */
4959
+ dayOptions,
4960
+ setRoomChoices: input.setRoomChoices,
4961
+ setDayLines: (lines) => input.setDayLines(lines.filter((line) => line.pricingOptionId !== null && dayIds.has(line.pricingOptionId)))
4962
+ };
4963
+ }
3950
4964
  /**
3951
4965
  * What still needs choosing. Several runs need one way of attending and a
3952
4966
  * usable ticket or amount for each run before the tickets step goes on; one
@@ -3955,7 +4969,7 @@ function useEventRegistrationWizardWithDeps(options, deps) {
3955
4969
  function resolveSelectionChoiceMessages(input) {
3956
4970
  if (input.several !== "runs") return {
3957
4971
  slidingScaleSelectionMessage: getSlidingScaleSelectionMessage(input),
3958
- selectionChoiceMessage: null
4972
+ selectionChoiceMessage: attendanceChoicePending(input.attendance, input.facts.attendanceMode) ? ATTENDANCE_CHOICE_MESSAGE : input.roomMessage
3959
4973
  };
3960
4974
  return {
3961
4975
  slidingScaleSelectionMessage: incompleteRunChoiceMessage(input),
@@ -3995,34 +5009,27 @@ function registrationCompletionState(state) {
3995
5009
  function preSelectedDisplayEvent(preSelected, current, display) {
3996
5010
  return preSelected?.selectionId === current?.selectionId ? display : preSelected;
3997
5011
  }
3998
- /** What a single booking's typed code is checked against. Several items have their own quote. */
5012
+ /** What a single booking's typed code is checked against. Several items, and dates bought with a pass, have their own quote. */
3999
5013
  function singleBookingDiscountLines(input) {
4000
5014
  const { discountContext, eligibility } = input;
4001
5015
  if (!discountContext || !eligibility) return [];
4002
- const product = bundleProductPrice(discountContext, eligibility);
4003
5016
  return [{
4004
5017
  context: discountContext,
4005
- subtotalCents: product ? product.price : input.primarySubtotalCents ?? 0,
4006
- currency: product ? product.currency : eligibility.currency,
4007
- ...singleBookingTicketDetails(discountContext.type, input)
5018
+ subtotalCents: input.primarySubtotalCents ?? 0,
5019
+ currency: eligibility.currency,
5020
+ ...singleBookingTicketDetails(discountContext, input)
4008
5021
  }];
4009
5022
  }
4010
- /** What the pass or membership being bought costs, from the server's options, so a caller only has to name it. */
4011
- function bundleProductPrice(context, eligibility) {
4012
- if (context.type === "pass") return eligibility.availablePasses.find((pass) => pass.id === context.passId) ?? null;
4013
- if (context.type === "membership") return eligibility.availableMemberships.find((membership) => membership.id === context.membershipId) ?? null;
4014
- return null;
4015
- }
4016
- function singleBookingTicketDetails(contextType, input) {
5023
+ function singleBookingTicketDetails(context, input) {
4017
5024
  const ticketUnits = input.ticketLines.map((line) => ({
4018
5025
  unitPriceCents: line.unitPriceCents,
4019
5026
  quantity: line.quantity
4020
5027
  }));
4021
- if (contextType === "whole_series") return {
5028
+ if (context.type === "whole_series") return {
4022
5029
  quantity: input.ticketsCount,
4023
5030
  ticketUnits
4024
5031
  };
4025
- if (contextType !== "event") return {};
5032
+ if (context.type !== "event") return {};
4026
5033
  const subject = input.currentEvent?.registrationSubject;
4027
5034
  return {
4028
5035
  occurrenceId: subject?.kind === "occurrence" ? subject.occurrenceId : void 0,
@@ -4030,45 +5037,138 @@ function singleBookingTicketDetails(contextType, input) {
4030
5037
  };
4031
5038
  }
4032
5039
  /** The quote's field, saying beside an applied code what it does to this purchase. */
4033
- function registrationCodeField(field, quote, paymentIntent) {
5040
+ function registrationCodeField(field, quote) {
4034
5041
  if (!field) return null;
4035
5042
  const applied = quote?.source === "typed" && quote.preview.type === "applied" ? quote.preview : null;
4036
5043
  return {
4037
5044
  ...field,
4038
- hint: appliedCodeHint(paymentIntent, applied)
5045
+ hint: appliedCodeHint(applied)
4039
5046
  };
4040
5047
  }
4041
5048
  /**
4042
- * The card options on the payment step. One item offers what its own options
4043
- * allow. Several items offer one way, paying the whole total up front, when
4044
- * anything is due (issue 1725); the first item's options don't decide it.
5049
+ * One booking's card options: what its own options allow, repriced with its
5050
+ * automatic discount. Several items take theirs from the server's answer.
5051
+ */
5052
+ function oneBookingCardOptions(input) {
5053
+ const { eligibility } = input;
5054
+ if (!eligibility || !eligibility.requiresPayment || !eligibility.price) return [];
5055
+ return buildDirectPaymentOptions(input, eligibility, {
5056
+ subtotalCents: input.ticketSelectionSubtotalCents ?? eligibility.price,
5057
+ approvedPaymentOptions: eligibility.paymentOptions,
5058
+ paymentTerms: eligibility.paymentTerms
5059
+ }, previewTotalWithAutomaticDiscount(input));
5060
+ }
5061
+ /** The steps where several items need the server's answer: their tickets are chosen from here on. */
5062
+ const SEVERAL_ANSWER_STEPS = /* @__PURE__ */ new Set([
5063
+ "select-tickets",
5064
+ "enter-details",
5065
+ "select-payment"
5066
+ ]);
5067
+ /**
5068
+ * The payment step's options. One booking keeps its own card options and
5069
+ * paid-in-full note; several items offer the ways the server's answer collects
5070
+ * the chosen option's money.
4045
5071
  */
4046
- function resolveWizardDirectPaymentOptions(input) {
4047
- const { eligibility, selectionPayment } = input;
4048
- if (!eligibility) return [];
4049
- switch (selectionPayment.kind) {
4050
- case "one-item":
4051
- if (!eligibility.requiresPayment || !eligibility.price) return [];
4052
- return buildDirectPaymentOptions(input, eligibility, {
4053
- subtotalCents: input.ticketSelectionSubtotalCents ?? eligibility.price,
4054
- approvedPaymentOptions: eligibility.paymentOptions,
4055
- paymentTerms: eligibility.paymentTerms
4056
- }, previewTotalWithAutomaticDiscount(input));
4057
- case "several": {
4058
- const subtotalCents = input.ticketSelectionSubtotalCents;
4059
- if (selectionPayment.due === "nothing" || subtotalCents === null) return [];
4060
- return buildDirectPaymentOptions(input, eligibility, {
4061
- subtotalCents,
4062
- approvedPaymentOptions: [{
4063
- kind: "payInFull",
4064
- amountCents: subtotalCents,
4065
- currency: eligibility.currency
4066
- }],
4067
- paymentTerms: { allowedOptions: [{ kind: "upfront" }] }
4068
- }, (decided) => decided);
5072
+ function decideWizardPaymentOptions(input) {
5073
+ return input.several === null ? oneBookingPaymentOptions(input) : severalItemsPaymentOptions(input);
5074
+ }
5075
+ function oneBookingPaymentOptions(input) {
5076
+ const directPaymentOptions = oneBookingCardOptions(input.directPaymentInput);
5077
+ return {
5078
+ directPaymentOptions,
5079
+ moneyCardOptions: directPaymentOptions,
5080
+ paymentInFullNote: decidePaidInFullNote(input.directPaymentInput, directPaymentOptions, input.choiceNowIso),
5081
+ paysNothing: input.eligibility?.isFree ?? false,
5082
+ paymentOptionsLoading: input.loading,
5083
+ paymentOptionsError: input.eligibilityError
5084
+ };
5085
+ }
5086
+ /** The chosen option's ways to pay, and the money option's own for its rows beside a pass or membership. */
5087
+ function severalItemsPaymentOptions(input) {
5088
+ const payment = answeredPayment(input.severalAnswer);
5089
+ const optionsFor = (collections, orderTotalCents) => buildSelectionCollectionOptions({
5090
+ collections,
5091
+ orderTotalCents,
5092
+ itemLabel: input.itemLabel
5093
+ });
5094
+ const runsStatus = input.several === "runs" ? input.severalAnswer.tag : "loaded";
5095
+ return {
5096
+ directPaymentOptions: optionsFor(pickCollections(payment, input.chosenFunding), input.orderTotalCents),
5097
+ moneyCardOptions: optionsFor(moneyCollections(payment), input.chosenFunding.kind === "money" ? input.orderTotalCents : null),
5098
+ paymentInFullNote: null,
5099
+ paysNothing: selectionPaysNothing(payment),
5100
+ paymentOptionsLoading: input.loading || runsStatus === "waiting",
5101
+ paymentOptionsError: input.eligibilityError ?? runsLoadError(runsStatus)
5102
+ };
5103
+ }
5104
+ function runsLoadError(status) {
5105
+ return status === "failed" ? RUNS_PAYMENT_LOAD_FAILED : null;
5106
+ }
5107
+ function answeredPayment(answer) {
5108
+ return answer.tag === "loaded" ? answer.payment : null;
5109
+ }
5110
+ /** Several runs ask how they can be paid once each run's ticket is chosen. */
5111
+ function runsPaymentAsk(input) {
5112
+ return {
5113
+ request: input.selectionChoiceMessage === null ? runsSelectionPaymentRequest(input.request) : null,
5114
+ enabled: input.several === "runs" && SEVERAL_ANSWER_STEPS.has(input.step) && input.portalAuthState !== "checking"
5115
+ };
5116
+ }
5117
+ /** Several items, and one date paid by a pass or membership, are priced as an order. */
5118
+ function pricesAsOrder(several, datesQuote) {
5119
+ return several !== null || datesQuote !== null;
5120
+ }
5121
+ /** One date's card options keep the date's own price while a pass or membership prices the order. */
5122
+ function oneBookingCardSubtotal(input) {
5123
+ return input.datesQuote !== null ? input.primarySubtotalCents : input.ticketSelectionSubtotalCents;
5124
+ }
5125
+ /** Dates have their answer with their funding; runs ask for theirs on their own. */
5126
+ function severalItemsPaymentAnswer(several, dates, runs) {
5127
+ switch (several) {
5128
+ case null: return { tag: "none" };
5129
+ case "dates": switch (dates.tag) {
5130
+ case "idle":
5131
+ case "loading": return { tag: "waiting" };
5132
+ case "failed": return { tag: "failed" };
5133
+ case "loaded": return dates.payment ? {
5134
+ tag: "loaded",
5135
+ payment: dates.payment
5136
+ } : { tag: "failed" };
5137
+ }
5138
+ case "runs": switch (runs.tag) {
5139
+ case "idle":
5140
+ case "loading": return { tag: "waiting" };
5141
+ case "failed": return { tag: "failed" };
5142
+ case "loaded": return {
5143
+ tag: "loaded",
5144
+ payment: runs.payment
5145
+ };
4069
5146
  }
4070
5147
  }
4071
5148
  }
5149
+ /** The funding option the visitor has picked; money until a pass or membership is offered and picked. */
5150
+ function chosenFundingPick(lookup) {
5151
+ const option = lookupChosenOption(lookup);
5152
+ return option ? fundingOptionPick(option) : { kind: "money" };
5153
+ }
5154
+ /**
5155
+ * The payment step's sentence when one booking's card options, as shown
5156
+ * (repriced, discounts included), have no deposit although its terms offer one.
5157
+ */
5158
+ function decidePaidInFullNote(input, cardOptions, liveNowIso) {
5159
+ const { eligibility } = input;
5160
+ if (!eligibility) return null;
5161
+ return paidInFullNote({
5162
+ paymentTerms: eligibility.paymentTerms,
5163
+ offeredKinds: cardOptions.map((option) => option.kind),
5164
+ dates: {
5165
+ bookingStartAt: getRegistrationStartAt(input.currentEvent, input.occurrenceContext) ?? null,
5166
+ instalmentCollectionDeadlineAt: eligibility.instalmentCollectionDeadlineAt,
5167
+ timeZone: resolveBookingBusinessTimeZone(input.currentEvent?.siteTimeZone),
5168
+ nowIso: liveNowIso
5169
+ }
5170
+ });
5171
+ }
4072
5172
  /** One item: its price less the automatic discount; a typed code is already out of the price. */
4073
5173
  function previewTotalWithAutomaticDiscount(input) {
4074
5174
  return (subtotalCents) => calculateEventRegistrationPreviewTotal({
@@ -4110,11 +5210,12 @@ function resolveWizardPaymentView(input) {
4110
5210
  const paymentDecision = decideEventRegistrationPayment({
4111
5211
  directPaymentOptions: input.directPaymentOptions,
4112
5212
  selection: input.paymentIntent,
4113
- selectionPayment: input.selectionPayment,
5213
+ paysNothing: input.paysNothing,
5214
+ offersEntitlements: input.offersEntitlements,
4114
5215
  eligibility: input.eligibility,
4115
5216
  admission: input.admission,
4116
- loading: anyLoading(input.eligibilityLoading, input.checkingNextStep, input.quoting),
4117
- error: input.eligibilityError,
5217
+ loading: input.loading,
5218
+ error: input.error,
4118
5219
  isAuthenticated: input.isAuthenticated,
4119
5220
  creditState: input.portalCreditState,
4120
5221
  manualDiscountPending: Boolean(input.discountCode.trim())
@@ -4125,9 +5226,162 @@ function resolveWizardPaymentView(input) {
4125
5226
  paymentSelection: resolveRegistrationPhaseSelection(input.step, input.paymentIntent, paymentDecision.selection)
4126
5227
  };
4127
5228
  }
5229
+ /**
5230
+ * Several dates' ways to pay, and what they decide for the payment step: its
5231
+ * button, the terms the visitor agrees to and the choice submit sends.
5232
+ */
5233
+ function decideWizardSelectionFunding(input) {
5234
+ const view = presentWizardSelectionFunding(input);
5235
+ const option = lookupChosenOption(input.lookup);
5236
+ return {
5237
+ view,
5238
+ paymentStepState: fundingPaymentStepState(input.cardStepState, input.lookup, view, input.pricing.ready),
5239
+ termsSurface: view?.termsSurface ?? "primary",
5240
+ choice: option ? fundingChoice(option) : null
5241
+ };
5242
+ }
5243
+ /**
5244
+ * The payment step's view of the dates' ways to pay, once the server has
5245
+ * sent them. The money rows keep the card options' own words.
5246
+ */
5247
+ function presentWizardSelectionFunding(input) {
5248
+ const currency = input.eligibility?.currency;
5249
+ if (input.lookup.tag !== "loaded" || !currency) return null;
5250
+ const dates = fundingDatesOf(input.selection, input.itemPrice);
5251
+ const payment = input.lookup.payment;
5252
+ return presentSelectionFunding({
5253
+ funding: input.lookup.funding,
5254
+ pick: input.lookup.pick,
5255
+ dates,
5256
+ places: input.places,
5257
+ currency,
5258
+ moneyRows: moneyRows(input),
5259
+ collectionsOf: (pick) => payment ? collectionsOf(paymentOptionFor(payment, pick)).map((collection) => collection.kind) : ["upfront"],
5260
+ chosenCollection: chosenCardKind(input.paymentDecision),
5261
+ chosenOrder: input.pricing.ready ? quotedOrder(input.pricing.quote) : null,
5262
+ reductions: quoteReductions(input.pricing.quote),
5263
+ availableCreditCents: availableCreditCents(input.creditState, currency),
5264
+ minimumCardChargeCents: getStripeMinimumChargeRequirement(currency)?.minimumAmountCents ?? null,
5265
+ formatDay: fundingDayFormatter(input.event)
5266
+ });
5267
+ }
5268
+ /** The way to pay the visitor has chosen on the payment step, if it's one on offer. */
5269
+ function chosenCardKind(decision) {
5270
+ const state = decision.directPaymentSelectionState;
5271
+ return state.kind === "valid" ? state.selection.collectionOptionKind : null;
5272
+ }
5273
+ /**
5274
+ * How the money option is offered: each of its ways to pay (a deposit for one date,
5275
+ * say, or paying directly for several), so choosing money still chooses how. Paying
5276
+ * several dates in full shows the order's price, codes and combination prices included.
5277
+ */
5278
+ function moneyRows(input) {
5279
+ const { moneyCardOptions: cards, paymentDecision, lookup } = input;
5280
+ const money = lookup.tag === "loaded" && lookup.pick.kind === "money";
5281
+ const chosen = chosenCardKind(paymentDecision);
5282
+ if (cards.length === 0) {
5283
+ if (input.several !== null && !(lookup.tag === "loaded" && selectionPaysNothing(lookup.payment))) return [];
5284
+ return [{
5285
+ key: "card",
5286
+ label: moneyRowLabel(false, paymentDecision.preview, void 0),
5287
+ details: [],
5288
+ price: null,
5289
+ card: null,
5290
+ current: true
5291
+ }];
5292
+ }
5293
+ return cards.map((card) => ({
5294
+ key: card.kind,
5295
+ label: moneyRowLabel(money && chosen === card.kind, paymentDecision.preview, card.label),
5296
+ details: paymentChoiceDetails(card),
5297
+ price: input.several !== null && card.kind === "upfront" ? null : paymentChoicePrice(card.amounts),
5298
+ card: cards.length > 1 ? card.kind : null,
5299
+ current: cards.length === 1 || chosen === card.kind
5300
+ }));
5301
+ }
5302
+ /** A chosen money row says site credit when the credit preview spends it, as the card step does. */
5303
+ function moneyRowLabel(chosen, preview, label) {
5304
+ if (!chosen || preview.kind !== "applied") return label ?? "Pay by card";
5305
+ return preview.outcome === "credit_only" ? "Pay with site credit" : "Use site credit + card";
5306
+ }
5307
+ /**
5308
+ * The payment step's model for the dates; null while nothing is asked, and for one date
5309
+ * the card alone pays for, which keeps the card step it always had. Picks wait while a
5310
+ * payment is under way.
5311
+ */
5312
+ function selectionFundingStepModel(input) {
5313
+ const { funding, view, locked } = input;
5314
+ const lookup = funding.lookup;
5315
+ if (lookup.tag === "idle" || cardStepServesDates(lookup, input.dateCount)) return null;
5316
+ return {
5317
+ status: lookup.tag,
5318
+ view,
5319
+ dateCount: input.dateCount,
5320
+ notice: lookup.tag === "loaded" ? lookup.notice : null,
5321
+ choose: (row) => {
5322
+ if (locked) return;
5323
+ funding.choose(row.pick);
5324
+ if (row.card !== null) input.chooseCard(row.card);
5325
+ },
5326
+ retry: funding.reset
5327
+ };
5328
+ }
5329
+ /** The server's price for the chosen option's order, from its quote. */
5330
+ function quotedOrder(quote) {
5331
+ if (!quote) return null;
5332
+ const { subtotalCents, totalAfterDiscountCents } = quote.preview;
5333
+ return {
5334
+ totalCents: totalAfterDiscountCents,
5335
+ discountCents: subtotalCents - totalAfterDiscountCents
5336
+ };
5337
+ }
5338
+ /**
5339
+ * Asks for the dates' ways to pay, and what the quote then prices: the chosen
5340
+ * option's whole order. One date asks on its payment step; several dates as
5341
+ * soon as their tickets are chosen, since their answer decides whether there's
5342
+ * anything to pay and whether the site can take it.
5343
+ */
5344
+ function useWizardSelectionFunding(input) {
5345
+ const { target, attendanceMode, ticketSelections, selectedSlidingAmount } = input;
5346
+ const eventSeriesId = input.event?.seriesId ?? null;
5347
+ const request = useMemo(() => selectionFundingRequest({
5348
+ target,
5349
+ eventSeriesId,
5350
+ attendanceMode,
5351
+ ticketSelections,
5352
+ selectedSlidingAmount
5353
+ }), [
5354
+ target,
5355
+ eventSeriesId,
5356
+ attendanceMode,
5357
+ ticketSelections,
5358
+ selectedSlidingAmount
5359
+ ]);
5360
+ const wanted = input.step === "select-payment" || input.several === "dates" && SEVERAL_ANSWER_STEPS.has(input.step);
5361
+ const selectionFunding = useSelectionFunding({
5362
+ api: input.api,
5363
+ request,
5364
+ identity: input.identity,
5365
+ enabled: wanted && input.portalAuthState !== "checking"
5366
+ });
5367
+ return {
5368
+ selectionFunding,
5369
+ datesQuote: useMemo(() => selectionDatesQuote(selectionFunding.lookup, request), [selectionFunding.lookup, request])
5370
+ };
5371
+ }
5372
+ /** How many dates the funding step's copy speaks of; 0 for anything that isn't dates. */
5373
+ function fundingDateCount(target) {
5374
+ return target?.selection.kind === "dates" ? target.selection.occurrenceIds.length : 0;
5375
+ }
5376
+ /** Account credit the visitor can spend on this booking's currency. */
5377
+ function availableCreditCents(state, currency) {
5378
+ if (state.kind !== "loaded") return 0;
5379
+ const summary = state.credit?.summary;
5380
+ return summary && summary.currency.toUpperCase() === currency.toUpperCase() ? Math.max(0, summary.availableCents) : 0;
5381
+ }
4128
5382
  //#endregion
4129
5383
  //#region ../blocks/src/system/runtime/nodes/event-registration/EventRegistrationPayment.tsx
4130
- const Payment = lazy(() => import("./EventEmbeddedCheckoutStep-BDnicDM6.mjs"));
5384
+ const Payment = lazy(() => import("./EventEmbeddedCheckoutStep-BGkbUhuw.mjs"));
4131
5385
  /** The one Stripe mount, shared by the standard wizard and headless arrangements. */
4132
5386
  function EventPaymentMount({ state, onComplete, onRetry, onBack, buttonVariant }) {
4133
5387
  if (state.kind === "abandoning") return /* @__PURE__ */ jsx("p", {
@@ -4160,4 +5414,4 @@ function EventRegistrationPayment({ flow }) {
4160
5414
  });
4161
5415
  }
4162
5416
  //#endregion
4163
- export { planEventRegistrationSurface as a, useEventRegistrationRecoveryRequest as i, EventRegistrationPayment as n, registrationAdmissionSurface as o, useEventRegistrationWizard as r, resolveEventRegistrationClientSurface as s, EventPaymentMount as t };
5417
+ export { ONE_DATE_FUNDING_LOAD_FAILED as a, planEventRegistrationSurface as c, summaryExplainsMoreThanTheOption as i, registrationAdmissionSurface as l, EventRegistrationPayment as n, SELECTION_FUNDING_LOAD_FAILED as o, useEventRegistrationWizard as r, useEventRegistrationRecoveryRequest as s, EventPaymentMount as t, resolveEventRegistrationClientSurface as u };