1import{j as t,d as ge,u as he,p as me,r as p}from"./vendor-react-DfYGAhtm.js";import{S as xe}from"./StepPageLayout-DdZUweau.js";import{m as l,g as ye,e as F,bg as Se,t as k,bh as be}from"./index-DsBgCU7r.js";import{a as y,H as fe}from"./HealthFormShell-BdiFYoa2.js";import{C as Ce,I as ve}from"./IndividualPlanTierCard-CLUUibjp.js";import"./LinkPaymentMethodOption-CuZHpNDU.js";import{M as je,b as Te,a as Ie,I as Pe,c as Le}from"./individualHealthConstants-DtbURbNc.js";import{S as C}from"./SelectField-B8rkxDSz.js";import{a as S,T as g,F as K,S as we,V as Q,i as Ee}from"./vendor-ui-DA_r9yXk.js";import{f as H,u as Fe,e as He}from"./vendor-state-BsBVN-fX.js";import{g as $}from"./errors-BYKXB8DF.js";import{u as De,a as Oe}from"./healthPolicyApi-Dd-t-T9K.js";import{H as _e}from"./routes-Dr23NpA-.js";import"./vendor-icons-1odZwi-b.js";import"./vendor-forms-BP-7CbAP.js";import"./underwriterLogoDisplay-B0FBG3Nn.js";import"./UnderwriterPlanLogo-CdMcnE2i.js";import"./currency-tq8RhIEU.js";import"./DropdownPopover-KjBTPKBF.js";const b={fontSize:"15px",lineHeight:"22.5px",fontWeight:"medium",letterSpacing:"-0.2px",color:l.text.primary,mb:"7px"},v={h:"52px",px:"21px",bg:"white",borderColor:y.inputBorder,boxShadow:"none",outline:"none",fontSize:"14px",fontWeight:"medium",lineHeight:"21px",_hover:{borderColor:y.inputBorder,bg:"white"},_focusWithin:{borderColor:l.orange[500],boxShadow:"none",outline:"none"}},Ne=({stateId:e,lgaId:a,townId:n,stateOptions:s,lgaOptions:o,townOptions:u,isLoadingStates:D,isLoadingLgas:r,isLoadingTowns:c,onStateChange:O,onLgaChange:_,onTownChange:N})=>t.jsxs(t.Fragment,{children:[t.jsxs(S,{children:[t.jsx(g,{...b,children:"State"}),t.jsx(C,{options:s,value:e,onChange:O,placeholder:D?"Loading statesâ¦":"Select state",borderRadius:"44px",isDisabled:D,searchable:!0,valueColor:l.text.label,iconColor:y.inputIcon,triggerProps:v})]}),t.jsxs(S,{children:[t.jsx(g,{...b,children:"Local government"}),t.jsx(C,{options:o,value:a,onChange:_,placeholder:e?r?"Loading LGAsâ¦":"Select local government":"Select a state first",borderRadius:"44px",isDisabled:!e||r,searchable:!0,valueColor:l.text.label,iconColor:y.inputIcon,triggerProps:v})]}),t.jsxs(S,{children:[t.jsx(g,{...b,children:"Town"}),t.jsx(C,{options:u,value:n,onChange:N,placeholder:e?c?"Loading townsâ¦":"Select town":"Select a state first",borderRadius:"44px",isDisabled:!e||c,searchable:!0,valueColor:l.text.label,iconColor:y.inputIcon,triggerProps:v})]})]}),Ae=({maritalStatus:e,onMaritalStatusChange:a,noOfDependants:n,onNoOfDependantsChange:s,isDependantCountEditable:o,dependantCountOptions:u})=>t.jsxs(t.Fragment,{children:[t.jsxs(S,{children:[t.jsx(g,{...b,children:"Marital Status"}),t.jsx(C,{options:je,value:e,onChange:a,placeholder:"Select marital status",borderRadius:"44px",valueColor:l.text.label,iconColor:y.inputIcon,triggerProps:v})]}),t.jsxs(S,{opacity:o?1:.5,children:[t.jsx(g,{...b,children:"Number of dependants"}),t.jsx(C,{options:u,value:n,onChange:s,placeholder:"Select number of dependants",borderRadius:"44px",isDisabled:!o,valueColor:l.text.label,iconColor:y.inputIcon,triggerProps:v})]})]}),Re=({planTypes:e,selectedPlanTypeId:a,isLoading:n,onSelect:s})=>t.jsxs(S,{children:[t.jsx(g,{...b,children:"Who is this cover for?"}),n?t.jsx(K,{justify:"center",py:8,children:t.jsx(we,{color:l.orange[500]})}):t.jsx(Q,{gap:"12px",align:"stretch",children:e.map(o=>t.jsx(Ce,{title:o.displayName,subtitle:o.description.trim(),selected:a===o.id,onSelect:()=>s(o)},o.id))})]}),Me=({planTypeSection:e,personalDetailsSection:a,locationFieldsSection:n,canSubmit:s,isSubmitting:o,onContinue:u})=>t.jsxs(t.Fragment,{children:[t.jsxs(Q,{gap:"24px",align:"stretch",pt:"32px",children:[t.jsx(Re,{...e}),t.jsx(Ae,{...a}),t.jsx(Ne,{...n})]}),t.jsx(K,{justify:{base:"stretch",md:"flex-end"},mt:{base:8,md:"42px"},children:t.jsx(ye,{type:"button",buttonType:"primary",text:"Continue",size:"lg",w:{base:"100%",md:"217px"},h:{base:"56px",md:"65px"},fontSize:{base:"16px",md:"18px"},letterSpacing:"-1.2px",border:"0.677px solid rgba(255, 255, 255, 0.14)",boxShadow:"inset 0px 5.392px 13.661px rgba(255, 255, 255, 0.42), 0px 7.19px 7.19px rgba(0, 0, 0, 0.06)",disabled:!s||o,loading:o,onClick:u})})]}),We=()=>t.jsxs(t.Fragment,{children:[t.jsxs(Ee,{fontSize:{base:"26px",md:"32px"},fontWeight:"semibold",lineHeight:"1.1",letterSpacing:"-0.5px",children:[t.jsxs(g,{as:"span",color:l.text.primary,children:["Tell us about"," "]}),t.jsx(g,{as:"span",color:l.orange[500],children:"yourself"})]}),t.jsx(g,{fontSize:"14px",lineHeight:"22px",color:l.text.primary,mt:"4px",children:"Tell us a bit about you, this is a required step"})]}),Ue=async()=>{const{data:e}=await F.get("/api/v1/health-policy/states");if(!e.success)throw new Error(e.message||"Failed to load states");return e.data},qe=async e=>{const{data:a}=await F.get(`/api/v1/health-policy/lgas/${e}`);if(!a.success)throw new Error(a.message||"Failed to load local governments");return a.data},Ge=async e=>{const{data:a}=await F.get(`/api/v1/health-policy/towns/${e}`);if(!a.success)throw new Error(a.message||"Failed to load towns");return a.data},ze=()=>{const{data:e,isPending:a,isError:n,error:s}=H({queryKey:["health","states"],queryFn:Ue,staleTime:18e5});return{states:e??[],isLoading:a,isError:n,error:s}},Be=e=>{const{data:a,isPending:n,isError:s,error:o}=H({queryKey:["health","state",e,"lgas"],queryFn:()=>qe(e),enabled:!!e,staleTime:18e5});return{lgas:a??[],isLoading:!!e&&n,isError:s,error:o}},Ve=e=>{const{data:a,isPending:n,isError:s,error:o}=H({queryKey:["health","state",e,"towns"],queryFn:()=>Ge(e),enabled:!!e,staleTime:18e5});return{towns:a??[],isLoading:!!e&&n,isError:s,error:o}},ke=async e=>{const{data:a}=await F.get(`/api/v1/health-policy/categories/${e}/plan-types`);
1if(!a.success)throw new Error(a.message||"Failed to load health plan types");return a.data},$e=e=>{const{data:a,isPending:n,isError:s,error:o}=H({queryKey:["health","category",e,"plan-types"],queryFn:()=>ke(e),enabled:!!e,staleTime:3e5});return{planTypes:a??[],isLoading:!!e&&n,isError:s,error:o}},U=e=>{const a=e.trim().toLowerCase();return a.includes("couple")?"couple":a.includes("family")?"family":"myself"},E=e=>e?Ie[U(e.displayName)]:0,Ke=e=>E(e)>0,Qe=e=>Te(E(e)),Ye=e=>e.trim().toUpperCase().replace(/\s+/g,"_"),W=e=>e.map(a=>({value:a.id,label:a.displayName})),Xe=()=>{const e=ge(),a=he(),[n]=me(),s=Fe(),o=He(i=>i.individualHealth),u=a.state?.categoryId,r=n.get("categoryId")??void 0??u??o.categoryId??void 0,{planTypes:c,isLoading:O}=$e(r),{states:_,isLoading:N}=ze(),[j,Y]=p.useState(""),[T,X]=p.useState(""),[f,q]=p.useState(""),[h,J]=p.useState(""),[I,G]=p.useState(""),[P,z]=p.useState(""),{lgas:Z,isLoading:ee}=Be(h||void 0),{towns:te,isLoading:ae}=Ve(h||void 0),{createIndividualHealthPolicy:oe,isLoading:se}=De(),{updateIndividualHealthPolicyLocation:ne,isLoading:re}=Oe(),m=p.useMemo(()=>j&&c.some(d=>d.id===j)?j:(c.find(d=>U(d.displayName)==="myself")??c[0])?.id??"",[j,c]),x=p.useMemo(()=>c.find(i=>i.id===m)??null,[c,m]),L=Ke(x),ie=p.useMemo(()=>Qe(x),[x]),A=E(x),B=A===1,le=L&&!B,R=B?String(A):L&&f&&Number(f)<=A?f:"";p.useEffect(()=>{r&&s(Se(r))},[r,s]);const ce=i=>{J(i),G(""),z("")},de=i=>{Y(i.id);const d=E(i);d>1&&f&&Number(f)>d&&q("")},V=!!r&&!!m&&!!x&&!!T&&!!h&&!!I&&!!P&&(!L||!!R),pe=se||re,ue=()=>{if(!V||!r||!x)return;const i=L?Number(R):0;oe({usageType:"PERSONAL",planTypeId:m,package:Ye(x.displayName),noOfDependants:i,maritalStatus:T.toUpperCase(),categoryId:r},{onSuccess:d=>{const w=d.data.id;ne({policyId:w,payload:{lgaId:I,stateId:h,townId:P}},{onSuccess:()=>{s(be({coverageFor:U(x.displayName),maritalStatus:T,categoryId:r,planTypeId:m,noOfDependants:i,stateId:h,lgaId:I,townId:P,policyId:w}));const M=new URLSearchParams({policyId:w,stateCode:h,planTypeId:m,categoryId:r});e({pathname:`/${_e.IndividualSelectPlan}`,search:`?${M.toString()}`},{state:{policyId:w,stateCode:h,planTypeId:m,categoryId:r}})},onError:M=>{k.error($(M)??"Could not save your location details. Please try again.")}})},onError:d=>{k.error($(d)??"Could not create your health application. Please try again.")}})};return{categoryId:r,planTypeSection:{planTypes:c,selectedPlanTypeId:m,isLoading:O,onSelect:de},personalDetailsSection:{maritalStatus:T,onMaritalStatusChange:X,noOfDependants:R,onNoOfDependantsChange:q,isDependantCountEditable:le,dependantCountOptions:ie},locationFieldsSection:{stateId:h,lgaId:I,townId:P,stateOptions:W(_),lgaOptions:W(Z),townOptions:W(te),isLoadingStates:N,isLoadingLgas:ee,isLoadingTowns:ae,onStateChange:ce,onLgaChange:G,onTownChange:z},canSubmit:V,isSubmitting:pe,onContinue:ue}},yt=()=>{const{planTypeSection:e,personalDetailsSection:a,locationFieldsSection:n,canSubmit:s,isSubmitting:o,onContinue:u}=Xe();return t.jsx(xe,{items:[],contentMaxW:"888px",mobileContentOnly:!0,children:t.jsxs(fe,{px:{base:4,md:10,lg:"48px"},py:{base:6,md:12,lg:"74px"},children:[t.jsx(ve,{steps:Le,activeStep:Pe.WhoIsCovered,mb:{base:8,md:"78px"}}),t.jsxs(S,{maxW:"480px",mx:"auto",fontFamily:y.bodyFont,children:[t.jsx(We,{}),t.jsx(Me,{planTypeSection:e,personalDetailsSection:a,locationFieldsSection:n,canSubmit:s,isSubmitting:o,onContinue:u})]})]})})};export{yt 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.