1import{f as C,e as I,r as s,j as r}from"./index-Ce-thbCy.js";import{t as w,x as p,R as M,y as v,z as S}from"./registrationCheckout-DsxF-1MN.js";import{L as W}from"./purify.es-Cstjuboy.js";import"./pricingPlans-geFsis9T.js";import"./check-DrgVKcCk.js";const Y=c=>{var o;const n=(o=c.get("checkout_status"))==null?void 0:o.toLowerCase();return["cancel","cancelled","canceled"].includes(n||"")||c.has("cancel")||c.has("cancelled")||c.has("canceled")?"cancelled":null};function H(){const c=C(),n=I(),o=s.useRef(!1),b=s.useRef(w()),[j,u]=s.useState(!0),[k,E]=s.useState(!1),[f,i]=s.useState(null),[N,a]=s.useState(null),e=b.current,m=new URLSearchParams(c.search),x=Y(m),l=m.get("session_id")||m.get("id")||(e==null?void 0:e.checkoutSessionId)||"",P=p(e),d=(e==null?void 0:e.plan)||null,g=(e==null?void 0:e.billingCycle)||"annual",h=(e==null?void 0:e.currency)||"usd";s.useEffect(()=>{if(o.current)return;o.current=!0,(async()=>{if(u(!0),a(null),x==="cancelled"){let t="Checkout was cancelled. Your registration has not been completed.";if(l)try{t=(await v.cancelSession(l,window.location.origin)).message||t}catch(y){t=y instanceof Error?y.message:t}S(),n("/registration-cancelled",{replace:!0,state:{plan:d,billingCycle:g,currency:h,email:(e==null?void 0:e.verifiedEmail)||(e==null?void 0:e.formData.email)||"",message:t}});return}if(!l){i("unconfirmed"),a("We could not find a checkout session to finish your registration."),u(!1);return}try{const t=await v.confirmRegistration(l,window.location.origin);if(t.success){S(),i("success"),a(t.message||"Your payment was confirmed and your registration is complete.");return}i("unconfirmed"),a(t.message||"Checkout session could not be confirmed. You can try again with a fresh checkout session.")}catch(t){i("unconfirmed"),a(t instanceof Error?t.message:"We could not finish your registration.")}finally{u(!1)}})()},[g,l,x,h,n,e,d]);const L=async()=>{const R=w();if(!p(R)){i("unconfirmed"),a("We could not recover your checkout details. Please return to pricing and start again.");return}E(!0),n("/register",{replace:!0,state:{retryCheckout:!0}})};return j||!f?r.jsx("div",{className:"min-h-screen bg-surface-white flex items-center justify-center p-6",children:r.jsxs("div",{className:"flex flex-col items-center gap-6 text-center",children:[r.jsx(W,{className:"w-10 h-10 animate-spin text-brand-blue"}),r.jsxs("div",{children:[r.jsx("h1",{className:"text-3xl font-display font-bold text-text-dark mb-3",children:"Finalising your registration"}),r.jsx("p",{className:"text-text-muted",children:"Please wait while we confirm your checkout session."})]})]})}):r.jsx(M,{outcome:f,message:N,isHtmlMessage:!0,plan:d,billingCycle:g,currency:h,email:(e==null?void 0:e.verifiedEmail)||(e==null?void 0:e.formData.email),canRetry:f!=="success"&&P,isRetrying:k,onRetry:L,onReturnToForm:()=>{n("/register",{replace:!0})}})}export{H as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.