1import{r as m,d as Q,u as X,j as e,N as J}from"./vendor-react-DfYGAhtm.js";import{t as L,m as p,g as K}from"./index-DsBgCU7r.js";import{D as Z}from"./DatePickerField-CClDGS0S.js";import{s as ee}from"./savings-hero-texture-CV-9LBUG.js";import{r as te,e as u,d as v,h as x,v as ne,c as ie,f as oe,i as re}from"./SavingsCardShell-BXwb2Evc.js";import{a as l,F as C,T as a,v as ae,H as se}from"./vendor-ui-DA_r9yXk.js";import{b4 as le}from"./vendor-icons-1odZwi-b.js";import{d as ue,f as H,a as pe}from"./savingsProjection-Bn8kpypl.js";import{S as ce,a as V}from"./SavingsStepperField-ZKJSAunC.js";import{a as de,S as me}from"./SavingsCoverageModal-D0pExffH.js";import{S as k}from"./routes-BR5I3bEX.js";import"./vendor-forms-BP-7CbAP.js";import{g as xe}from"./errors-BYKXB8DF.js";import{a as ge}from"./savingsPolicyApi-D4i5qSCX.js";import{u as fe}from"./savingsProjectionApi-BsGvj6st.js";import{g as G}from"./dateOfBirth-BQh2Bcet.js";import{b as he}from"./savingsBudget-ALoZ0Gim.js";import{b as be,c as Se,d as ye,e as je,f as ve,h as Ce,a as Ae,i as Fe,j as Pe,t as we}from"./savingsFlow-Crd0jwFD.js";import{u as De}from"./useSavingsBudgetInput-C4H5nWfy.js";import"./LinkPaymentMethodOption-CuZHpNDU.js";import"./vendor-state-BsBVN-fX.js";import"./DropdownPopover-KjBTPKBF.js";import"./checkoutSessionStore-BRM5sYZN.js";import"./Modal-DS-VW05m.js";const He=450,Re=t=>1-Math.pow(1-t,3),Ye=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,Be=(t,r=He)=>{const[n,c]=m.useState(t),d=m.useRef(t),i=m.useRef(null);return m.useEffect(()=>{const o=d.current;if(o===t||!Number.isFinite(t))return;const g=()=>{d.current=t,c(t)};if(Ye())return i.current=requestAnimationFrame(g),()=>{i.current!==null&&cancelAnimationFrame(i.current)};const b=performance.now(),y=A=>{const f=Math.min(1,(A-b)/r),F=o+(t-o)*Re(f);d.current=f===1?t:F,c(d.current),f<1&&(i.current=requestAnimationFrame(y))};return i.current=requestAnimationFrame(y),()=>{i.current!==null&&cancelAnimationFrame(i.current)}},[r,t]),n},Ie=()=>{const t=Q(),{state:r}=X(),n=De(),{createSavingsPolicy:c,isLoading:d}=ge(),i=r,o=i?.plan??null,g=i?.goal??null,[b,y]=m.useState(g?.dateOfBirth??""),[A,f]=m.useState(!1),[F,O]=m.useState(()=>i?.rider?.premiumAmount??null),s=be(o,n?.frequency),[h,z]=m.useState(()=>Se({minContribution:s.minContribution,goalAmount:g?.contributionAmount})),[R,Y]=m.useState(()=>ye({minContribution:s.minContribution,requested:g?.contributionAmount})),[j,B]=m.useState(()=>je({minDurationYears:s.minDurationYears,goalDuration:g?.durationYears,budgetDuration:n?.duration,planTermYears:o?.termYears})),[I]=m.useState(()=>({amount:h,duration:j})),{projection:P,isLoading:T}=fe(o&&n?{frequency:n.frequency,amount:I.amount,duration:I.duration,planId:o.id}:null),{coverOption:E,selectedCover:w}=o?ve(o,F):{coverOption:null,selectedCover:null},{payout:N}=o?ue(o,{amount:h,frequency:n?.frequency??"MONTHLY",years:j}):{payout:0},W=Be(N);if(!o||!n)return{status:"redirect"};const D=h<s.minContribution,q=Ce({planName:o.name,minContribution:s.minContribution,frequency:n.frequency,raisedFromAmount:R}),_=()=>{if(D){L.error(`${o.name} starts from ${H(s.minContribution)} ${te[n.frequency]}.`);return}if(!b.trim()){L.error("Please enter your date of birth to continue.");return}const S={contributionAmount:h,frequency:n.frequency,durationYears:j,dateOfBirth:b};c(Pe({plan:o,goal:S,coverPremium:w?.initialFee}),{onSuccess:M=>{t(`/${k.Details}`,{state:{plan:o,goal:S,policy:M.data,rider:we(w)}})},onError:M=>{L.error(xe(M)??"We could not start your savings application. Please try again.")}})};return{status:"ready",plan:o,budget:n,dateOfBirth:b,setDateOfBirth:y,isCoverageOpen:A,openCoverage:()=>f(!0),closeCoverage:()=>f(!1),contributionAmount:h,setContributionAmount:S=>{Y(null),z(S)},onContributionClamp:S=>{S<s.minContribution&&Y(S)},durationYears:j,setDurationYears:B,minContribution:s.minContribution,minDurationYears:s.minDurationYears,minAgeYears:s.minAgeYears,maxAgeYears:s.maxAgeYears,dobMinDate:G(s.maxAgeYears),dobMaxDate:G(s.minAgeYears),isBelowMinContribution:D,contributionHint:q,isContributionWarning:R!=null,durationHint:Fe(o),coverOption:E,selectedCover:w,setRiderPremium:O,projectedPayoutLabel:N>0?pe(W):T?"â¦":"â",estimatedReturnLabel:Ae(o,P?.rate??null),contributionLabel:H(h),isSubmitting:d,continueToDetail
1s:_,goToPlans:()=>t({pathname:`/${k.Plans}`,search:he(n)})}},$=({label:t,value:r,align:n})=>e.jsxs(C,{direction:"column",align:n,children:[e.jsx(a,{fontFamily:u,fontSize:"11px",fontWeight:"semibold",lineHeight:"16.5px",letterSpacing:"1.1px",textTransform:"uppercase",color:"rgba(255, 255, 255, 0.7)",whiteSpace:"nowrap",children:t}),e.jsx(a,{pt:"4px",fontFamily:v,fontWeight:"700",fontSize:{base:"26px",md:"32px"},lineHeight:"48px",color:"white",whiteSpace:"nowrap",children:r})]}),U=({label:t,value:r,align:n})=>e.jsxs(C,{direction:"column",align:n,children:[e.jsx(a,{fontFamily:u,fontSize:"11px",lineHeight:"16.5px",color:"rgba(255, 255, 255, 0.7)",children:t}),e.jsx(a,{pt:"4px",fontFamily:u,fontSize:"14px",fontWeight:"medium",lineHeight:"21px",color:"white",children:r})]}),Ne=({projectedPayout:t,estimatedReturn:r,contribution:n,underwriter:c})=>e.jsxs(l,{position:"relative",overflow:"hidden",w:"100%",borderRadius:"24px",boxShadow:"0px 1px 3px 0px rgba(0, 0, 0, 0.1), 0px 1px 2px -1px rgba(0, 0, 0, 0.1)",backgroundImage:`url(${ee})`,backgroundSize:"cover",backgroundPosition:"center",children:[e.jsx(l,{position:"absolute",inset:0,bg:"rgba(31, 54, 95, 0.53)",pointerEvents:"none"}),e.jsxs(l,{position:"relative",p:"24px",children:[e.jsxs(C,{align:"flex-start",justify:"space-between",gap:"16px",children:[e.jsx($,{label:"Projected payout",value:t,align:"flex-start"}),e.jsx($,{label:"Est. return",value:r,align:"flex-end"})]}),e.jsxs(C,{align:"flex-end",justify:"space-between",gap:"16px",mt:"32px",pt:"17px",children:[e.jsx(U,{label:"Your contribution",value:n,align:"flex-start"}),e.jsx(U,{label:"Powered by",value:c,align:"flex-end"})]})]})]}),Oe=({title:t,coverPremiums:r,premiumAmount:n,onPremiumChange:c})=>{const d=r.find(i=>i.initialFee===n)??r[0];return e.jsxs(l,{position:"relative",bg:x.riderPanelBg,border:"1px solid",borderColor:x.riderPanelBorder,borderRadius:"24px",p:"25px",children:[e.jsx(ae,{as:le,position:"absolute",top:"24px",right:"25px",boxSize:"32px",opacity:.8,color:p.navy[300]}),e.jsx(a,{fontFamily:u,fontSize:"11px",fontWeight:"semibold",lineHeight:"16.5px",textTransform:"uppercase",color:p.text.tertiary,children:"Protect your savings"}),e.jsx(a,{pt:"4px",fontFamily:v,fontWeight:"700",fontSize:"22px",lineHeight:"33px",color:x.orangeMain,children:t}),e.jsx(a,{pt:"16px",pr:"32px",maxW:"514px",fontFamily:u,fontSize:"13px",lineHeight:"21.125px",color:p.text.tertiary,children:"In the unfortunate event of the policyholder's passing, the beneficiary will receive the total amount saved, along with the guaranteed life cover benefit."}),e.jsxs(l,{mt:"24px",bg:x.riderInnerBg,border:"1px solid",borderColor:x.riderInnerBorder,borderRadius:"16px",p:"21px",children:[e.jsx(a,{fontFamily:u,fontSize:"14px",fontWeight:"semibold",lineHeight:"21px",color:p.text.tertiary,children:"Choose Cover Amount"}),e.jsx(l,{pt:"12px",children:e.jsx(ce,{variant:"solid",options:r.map(i=>({value:String(i.initialFee),label:H(i.initialFee)})),value:String(d?.initialFee??n),onChange:i=>c(Number(i))})}),e.jsxs(C,{align:"center",justify:"space-between",gap:"16px",mt:"16px",pt:"13px",borderTop:"1px solid",borderColor:x.riderInnerBorder,children:[e.jsx(a,{fontFamily:u,fontSize:"14px",lineHeight:"21px",color:p.text.tertiary,children:"Guaranteed Payout"}),e.jsx(a,{fontFamily:u,fontSize:"16px",fontWeight:"bold",lineHeight:"24px",color:p.text.tertiary,children:H(d?.benefitAmount??0)})]})]}),e.jsx(se,{gap:"8px",pt:"16px",wrap:"wrap",children:ne.map(i=>e.jsx(l,{bg:"white",border:"1px solid",borderColor:x.toggleBorder,borderRadius:"full",px:"13px",py:"7px",children:e.jsx(a,{fontFamily:u,fontSize:"12px",fontWeight:"medium",lineHeight:"18px",color:p.text.tertiary,children:i})},i))})]})},at=()=>{const t=Ie();if(t.status==="redirect")return e.jsx(J,{to:`/${k.Budget}`,replace:!0});const{plan:r,budget:n,dateOfBirth:c,setDateOfBirth:d,isCoverageOpen:i,openCoverage:o,closeCoverage:g,contributionAmount:b,setContributionAmount:y,onContributionClamp:A,durationYears:f,setDurationYears:F,minContribution:O,minDurationYears:s,minAgeYears:h,maxAgeYears:z,dobMinDate:R,dobMaxDate:Y,contributionHint:j,isContributionWarning:B,durationHint:I,coverOption:P,selectedCover:T,setRiderPremium:E,projectedPayoutLabel:w,estimatedReturnLabel:N,contributionLabel:W,isSubmitting:D,continueToDetail
1s:q,goToPlans:_}=t;return e.jsxs(ie,{onBack:_,children:[e.jsx(de,{open:i,onClose:g,plan:r,frequency:n.frequency}),e.jsxs(C,{align:"flex-start",justify:"space-between",gap:"16px",pb:"8px",children:[e.jsx(a,{as:"h1",fontFamily:v,fontWeight:"700",fontSize:{base:"24px",md:"28px"},lineHeight:"35px",color:p.text.tertiary,children:r.name}),e.jsx(me,{variant:"outline",onClick:o})]}),e.jsx(a,{pb:"24px",fontFamily:u,fontSize:"15px",lineHeight:"24.375px",color:p.text.tertiary,children:r.description}),e.jsx(Ne,{projectedPayout:w,estimatedReturn:N,contribution:W,underwriter:r.underwriter}),e.jsxs(l,{pt:"24px",children:[e.jsx(a,{as:"h2",fontFamily:v,fontWeight:"700",fontSize:"20px",lineHeight:"30px",color:p.text.tertiary,children:"How much do you want to save?"}),e.jsx(l,{pt:"16px",children:e.jsx(V,{value:b,onChange:y,min:O,step:oe,formatValue:H,isEditable:!0,onClamp:A,label:"contribution amount"})}),e.jsx(a,{pt:"8px",fontFamily:u,fontStyle:"italic",fontSize:"12px",lineHeight:"18px",color:B?p.orange[500]:x.muted,...B?{role:"alert"}:{},children:j})]}),e.jsxs(l,{pt:"24px",children:[e.jsx(a,{as:"h2",fontFamily:v,fontWeight:"700",fontSize:"20px",lineHeight:"30px",color:p.text.tertiary,children:"How long do you want to save?"}),e.jsx(l,{pt:"16px",children:e.jsx(V,{value:f,onChange:F,min:s,max:re,unit:"Year",label:"savings duration"})}),e.jsx(a,{pt:"8px",fontFamily:u,fontStyle:"italic",fontSize:"12px",lineHeight:"18px",color:x.muted,children:I})]}),e.jsxs(l,{pt:"24px",children:[e.jsx(a,{as:"h2",fontFamily:v,fontWeight:"700",fontSize:"20px",lineHeight:"30px",color:p.text.tertiary,children:"Eligibility check"}),e.jsx(l,{pt:"16px",children:e.jsx(Z,{value:c,onChange:d,placeholder:"Date of birth",iconPosition:"right",borderRadius:"48px",borderColor:x.inputBorder,minDate:R,maxDate:Y})}),e.jsxs(a,{pt:"8px",fontFamily:u,fontStyle:"italic",fontSize:"12px",lineHeight:"18px",color:x.muted,children:["* You should be between ",h," to ",z," years of age."]})]}),P&&e.jsx(l,{pt:"24px",children:e.jsx(Oe,{title:P.title,coverPremiums:P.coverPremiums,premiumAmount:T?.initialFee??0,onPremiumChange:E})}),e.jsx(l,{pt:"32px",children:e.jsx(K,{buttonType:"primary",type:"button",text:"Continue",size:"lg",h:"48px",fullWidth:!0,borderRadius:"full",fontFamily:u,fontSize:"14px",fontWeight:"medium",letterSpacing:"-0.9px",loading:D,disabled:!c.trim()||D,onClick:q})})]})};export{at 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.