1import{j as t,p as J,r as d,d as U}from"./vendor-react-DfYGAhtm.js";import{m as l,g as b,aO as Z,c as ee,ar as te,I as re,l as oe,B as se,aP as ae}from"./index-DsBgCU7r.js";import{g as ie}from"./errors-BYKXB8DF.js";import{c as ne,d as le,g as ce,f as pe,ay as ue,av as de}from"./vendor-icons-1odZwi-b.js";import{F as S,T as m,B as D,a as f,V as k,H as T,i as me,h as I,o as ge,S as xe}from"./vendor-ui-DA_r9yXk.js";import"./fnolAccidentDetailsSchema-J33INL6o.js";import"./vendor-forms-BP-7CbAP.js";import{u as he}from"./useAnalytics-HP01GbIH.js";import"./healthCategoryUi-C2_keODf.js";import{g as be}from"./getPolicyClaimEntryPath-DKxxrScc.js";import"./missedContributionRetry-D0dCo6_S.js";import{a as W}from"./policiesApi-DYBxVdNQ.js";import{F as z,c as V,d as fe,e as O,f as ye,p as je,h as Pe,i as Le}from"./constants-DZgaJSjb.js";import{b as Se}from"./greeting-COgqVEJw.js";import"./normalizeBrand-Cr5Qmi7I.js";import"./PolicyContributionFilters-CIXgAXYH.js";import{o as Ce}from"./other-icon-DC1bN4dP.js";import{T as Te}from"./Tag-CjDhIpKV.js";import{a as we}from"./currency-tq8RhIEU.js";import{b as Ee,a as Ae,g as ve}from"./policyProductType-BD61ZnUx.js";import"./LinkPaymentMethodOption-CuZHpNDU.js";import"./router-CbysvjTw.js";import"./router-Bz1-kiAm.js";import"./vendor-state-BsBVN-fX.js";import"./savings-BJUwUGln.js";import"./routes-BR5I3bEX.js";import"./annuity-retirement-C1dZ1QHM.js";import"./health-ped-DAki1cTK.js";import"./professional-indemnity-Cx_HID73.js";import"./property-building-content-BPs_xKUv.js";import"./property-business-assets-DHEXMjWx.js";import"./property-home-content-BS-RQEdB.js";import"./savings-specialized-hA4moY7S.js";import"./savings-targeted-goals-BG697KhM.js";import"./routes-CNOe4p0Z.js";import"./ocrConfig-B-KSx9JM.js";import"./checkoutSessionStore-BRM5sYZN.js";import"./gadgetPostPaymentFlowConfig-ChCU4qBA.js";import"./routes-Dr23NpA-.js";import"./routes-BTwm__Y5.js";import"./routes-rIK6zvx1.js";import"./routes-D6u-5hjo.js";import"./routes-alBnq1HL.js";import"./routes-SlierU_8.js";import"./useApiQuery-mQnoCtpJ.js";import"./api-BEJchXjA.js";import"./DropdownPopover-KjBTPKBF.js";import"./SelectField-B8rkxDSz.js";import"./contributionPeriods-BVOAzSfZ.js";import"./transit-insurance-DHaUSpuL.js";import"./fire-BtgY-J44.js";import"./phone-ouFZPfGU.js";import"./nigerianPhone-B1rv0Wc5.js";import"./routes-BuiSREd6.js";import"./ProductAuthGate-BV--HzK8.js";import"./routes-Bvg9FlGf.js";const ke=({page:e,pageSize:r,totalItems:o,onPageChange:s})=>{const a=Math.max(1,Math.ceil(o/r)),i=Math.min(Math.max(1,e),a),c=o===0?0:(i-1)*r+1,n=Math.min(i*r,o);return o===0?null:t.jsxs(S,{align:"center",justify:"space-between",gap:3,flexWrap:"wrap",mt:6,pt:4,borderTop:"1px solid",borderColor:l.gray[200],children:[t.jsxs(m,{fontSize:"sm",color:l.text.info,children:["Showing ",c,"â",n," of ",o]}),t.jsxs(S,{align:"center",gap:2,children:[t.jsx(D,{type:"button",variant:"outline",size:"sm",borderRadius:"full",px:3,disabled:i<=1,onClick:()=>s(i-1),"aria-label":"Previous page",children:t.jsx(ne,{size:18})}),t.jsxs(m,{fontSize:"sm",fontWeight:"medium",color:l.text.label,children:["Page ",i," of ",a]}),t.jsx(D,{type:"button",variant:"outline",size:"sm",borderRadius:"full",px:3,disabled:i>=a,onClick:()=>s(i+1),"aria-label":"Next page",children:t.jsx(le,{size:18})})]})]})},Ie=(e,r)=>{const o=Number.parseInt(e??"",10);return!Number.isFinite(o)||o<1?r:o},ze=(e,r=1)=>e<=r?null:String(e),Fe=(e,r,o)=>{o==null||o===""?e.delete(r):e.set(r,o)},Re=(e,r)=>{const[s,a]=J(),i=d.useMemo(()=>{const n={};for(const p of Object.keys(e)){const u=e[p];n[p]=u.parse(s.get(u.paramKey))}return n},[s,e]),c=d.useCallback(n=>{a(p=>{const u=new URLSearchParams(p);for(const x of Object.keys(n)){const h=n[x];if(h===void 0)continue;const y=e[x];Fe(u,y.paramKey,y.serialize(h))}return u},{replace:!0})},[e,a,!0]);return[i,c]},Ne=({variant:e,activeFilter:r="ALL",tabScope:o="on-page",errorMessage:s})=>{switch(e){case"no-policies":return{title:"You don't have any policies yet",description:"When you buy a policy, it will show up here. Browse plans from the home page to get covered in minutes."};case"tab-empty":return o==="global-zero"&&r!=="ALL"?{title:`No ${z[r]} policies yet`,description:"You have policies in other categories. View all policies or pick another filter."}:r==="ALL"?{title:"No policies on this page",description:"Try the first page or refresh. If something looks wrong, use Try again or chat with Myka from the header."}:{title:`No ${z[r]} policies on this page`,description:"This page has no policies in that category. Open the All tab or move to another page."};case"search-empty":return{title:"No policies match your search",description:"Try a different keyword, or clear the search to see your full list."};case"load-error":return{title:"We couldn't load your policies",description:s?.trim()||"Check your connection and try again. If it keeps happening, chat with Myka from the header."}}},_e=e=>{const r=o=>t.jsx(f,{w:12,h:12,borderRadius:"full",bg:l.orange[50],display:"flex",alignItems:"center",justifyContent:"center",border:`1.5px solid ${l.orange[200]}`,color:l.orange[500],children:o});return r(e==="load-error"?t.jsx(ce,{size:22,"aria-hidden":!0}):e==="search-empty"?t.jsx(pe,{size:22,"aria-hidden":!0}):t.jsx(ue,{size:22,"aria-hidden":!0}))},C=({variant:e,activeFilter:r="ALL",tabScope:o="on-page",errorMessage:s,onBrowsePlans:a,onViewAllPolicies:i,onClearSearch:c,onRetry:n,onGoToFirstPage:p})=>{const{title:u,description:x}=Ne({variant:e,activeFilter:r,tabScope:o,errorMessage:s});return t.jsx(f,{borderRadius:"xl",border:`1px solid ${l.gray[200]}`,bg:l.white.DEFAULT,style:{boxShadow:"0px 1px 3px 0px rgba(0,0,0,0.06), 0px 1px 2px -1px rgba(0,0,0,0.04)"},children:t.jsx(f,{p:{base:10,md:16},children:t.jsxs(k,{gap:4,align:"center",py:8,children:[_e(e),t.jsxs(k,{gap:2,align:"center",children:[t.jsx(m,{fontSize:"lg",fontWeight:"bold",color:l.text.label,textAlign:"center",children:u}),t.jsx(m,{fontSize:"sm",color:l.text.info,textAlign:"center",maxW:"400px",lineHeight:"1.6",children:x})]}),(n!=null||a!=null||i!=null||c!=null||p!=null)&&t.jsxs(T,{gap:3,flexWrap:"wrap",justify:"center",pt:1,children:[n!=null?t.jsx(b,{type:"button",buttonType:"secondary",text:"Try again",size:"md",onClick:n}):null,a!=null?t.jsx(b,{type:"button",buttonType:"primary",text:"Browse plans",size:"md",onClick:a}):null,i!=null?t.jsx(b,{type:"button",buttonType:"outline",text:"View all policies",size:"md",onClick:i}):null,c!=null?t.jsx(b,{type:"button",buttonType:"outline",text:"Clear search",size:"md",onClick:c}):null,p!=null?t.jsx(b,{type:"button",buttonType:"outline",text:"First page",size:"md",onClick:p}):null]})]})})})},Me=["ALL","ACTIVE","PENDING","EXPIRED"],De=({activeFilter:e,counts:r,onFilterChange:o})=>{const s=d.useMemo(()=>Me.map(a=>({value:a,label:`${z[a]} (${r[a]})`})),[r]);return t.jsx(f,{w:"full",overflowX:"auto",overflowY:"hidden",mx:{base:-4,md:0},px:{base:4,md:0},css:{WebkitOverflowScrolling:"touch",scrollbarWidth:"none",msOverflowStyle:"none","&::-webkit-scrollbar":{display:"none"}}
1,children:t.jsx(Z,{items:s,value:e,onChange:o})})},We=()=>{const{user:e}=ee(),r=U(),{firstName:o}=te(e?.kyc)??null,s=Se({firstName:o??null});return t.jsxs(S,{justify:"space-between",align:{base:"stretch",md:"center"},direction:{base:"column",md:"row"},gap:{base:4,md:4},children:[t.jsxs(f,{flex:{md:1},minW:0,children:[t.jsx(m,{textStyle:"text-lg-regular",fontWeight:"semibold",color:l.text.tertiary,children:s}),t.jsx(me,{fontSize:{base:"xl",md:"2xl",lg:"3xl"},fontWeight:"bold",color:l.text.label,lineHeight:"1.2",mt:1,children:"My Policies"})]}),t.jsxs(I,{direction:{base:"column",sm:"row"},gap:3,w:{base:"full",md:"auto"},align:{base:"stretch",sm:"center"},flexShrink:0,children:[t.jsx(b,{buttonType:"whatsapp",text:"Chat with Myka",size:"md",w:{base:"full",sm:"auto"},onClick:re}),t.jsx(b,{buttonType:"primary",text:"Claims",size:"md",w:{base:"full",sm:"auto"},onClick:()=>r("/claims")})]})]})},Ue=e=>{const r=e.details;if(r==null||typeof r!="object")return null;const o=r.localEndDate;return typeof o=="string"&&o.trim()?o.trim():null},Ve=e=>{const r=Ee(e.productType),o=e.endDate?.trim()||Ue(e);return{label:r?"Payout Date":"Expiration Date",display:oe(o,{preset:"gb-short",fallback:"N/A"})}},Oe="#F0F5FA",Be=new Set(["LIFE","GROUP_LIFE","SAVINGS","ANNUITY"]),He=({policy:e,onViewDetails:r,onFileClaim:o})=>{const s=V(e.status),a=fe(e.status),i=O(e.productType),c=Ae(e.productType),n=c.icon??Ce,p=e.details??{},u=typeof p.coverType=="string"?p.coverType:void 0,x=ve(e.productType),h=e.underwriterProductName?.trim(),y=(()=>{if(x==="MOTOR"){if(h)return h;if(u!=null)return ye(u)}return Be.has(x)&&h?h:e.usageType?.trim()||"N/A"})(),L=Ve(e),E=e.policyNumber?.trim()||e.ourReference?.trim()||"N/A",A=e.status.toUpperCase()==="ACTIVE",w=je(e.premium),P=w!=null?we(w,e.currency??"NGN"):"N/A";return t.jsxs(f,{borderRadius:"xl",border:"1px solid",borderColor:"#E2E8F0",bg:Oe,px:{base:4,md:5},py:5,style:{boxShadow:"0px 1px 3px 0px rgba(15, 23, 42, 0.06), 0px 1px 2px -1px rgba(15, 23, 42, 0.04)"},children:[t.jsxs(S,{justify:"space-between",align:"flex-start",gap:3,wrap:"wrap",mb:3,children:[t.jsxs(T,{gap:3,align:"flex-start",minW:0,children:[t.jsx(f,{w:12,h:12,borderRadius:"lg",background:c.gradient,borderWidth:1,borderColor:c.borderColor,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,children:t.jsx(ge,{src:n,alt:"",boxSize:7,objectFit:"contain"})}),t.jsxs(k,{align:"flex-start",gap:0,minW:0,children:[t.jsx(m,{fontSize:"lg",fontWeight:"semibold",color:l.text.label,lineHeight:"short",children:i}),t.jsx(m,{fontSize:"md",color:l.text.info,children:y})]})]}),t.jsx(T,{gap:2,flexShrink:0,children:t.jsx(Te,{variant:"outline",borderRadius:"full",px:2.5,py:1.5,size:"lg",fontSize:"sm",fontWeight:"semibold",customColors:{bg:a.bg,color:a.color,borderColor:a.color},children:s})})]}),t.jsx(m,{fontSize:"sm",fontWeight:"bold",color:l.text.label,mb:2,children:E}),t.jsxs(S,{justify:"space-between",align:{base:"flex-start",md:"center"},gap:4,direction:{base:"column",md:"row"},children:[t.jsxs(T,{gap:6,flexWrap:"wrap",color:l.text.info,children:[t.jsxs(T,{gap:1.5,children:[t.jsx(de,{size:16,color:l.orange[500]}),t.jsx(m,{fontSize:"md",children:`${L.label}: ${L.display}`})]}),t.jsx(m,{fontSize:"md",fontWeight:"medium",children:P})]}),t.jsxs(T,{gap:2,flexShrink:0,wrap:"wrap",children:[t.jsx(b,{type:"button",buttonType:"outline",text:"File a Claim",size:"sm",disabled:!A,_hover:{bg:l.gray[50],boxShadow:"0 2px 8px rgba(0,0,0,0.06)"},style:{border:`1px solid ${l.gray[200]}`,boxShadow:"0 2px 8px rgba(0,0,0,0.06)"},onClick:()=>o(e)}),t.jsx(b,{type:"button",buttonType:"primary",text:"View Details",size:"sm",onClick:()=>r(e.id)})]})]})]})},Ge="tab",Ye="page",$e={all:"ALL",active:"ACTIVE",pending:"PENDING",expired:"EXPIRED"},Qe={ALL:null,ACTIVE:"active",PENDING:"pending",EXPIRED:"expired"},Ke=e=>{if(e==null||e==="")return"ALL";const r=e.toLowerCase();return $e[r]??"ALL"},Xe=e=>Qe[e],qe=e=>Ie(e,1),Je={activeFilter:{paramKey:Ge,parse:Ke,serialize:Xe},page:{paramKey:Ye,parse:qe,serialize:e=>ze(e,1)}},Ze=()=>{const[e,r]=Re(Je),o=d.useCallback(a=>{r({activeFilter:a,page:1})},[r]),s=d.useCallback(a=>{r({page:a})},[r]);return{activeFilter:e.activeFilter,page:e.page,setActiveFilter:o,setPage:s}},B=e=>e.toLowerCase().replace(/&/g," and ").replace(/[_/-]+/g," ").replace(/[^a-z0-9\s]/g," ").replace(/\s+/g," ").trim(),et=e=>B([e.ourReference,e.productType,O(e.productType),e.policyNumber??"",e.status,V(e.status),e.underwriterProductName??"",e.quoteReference??"",e.usageType??"",e.vehicle?.plateNumber??"",e.vehicle?.make??"",e.vehicle?.model??""].join(" ")),tt=(e,r)=>{const o=B(r);return o?e.filter(s=>et(s).includes(o)):e},rt=(e,r)=>r==="ALL"?e:e.filter(o=>Pe(o.status)===r),ot={ALL:0,ACTIVE:0,PENDING:0,EXPIRED:0},st=e=>e?.pagination==null||e.counts==null||e.pagination.total==null?ot:Le({total:e.pagination.total,counts:e.counts}),nr=()=>{const e=U(),[r,o]=d.useState(""),{activeFilter:s,page:a,setActiveFilter:i,setPage:c}=Ze(),{data:n,isLoading:p,isError:u,error:x,refetch:h}=W({page:a}),y=n?.data?.pagination,L=y?.total??0,E=y?.limit??20,j=d.useMemo(()=>st(n?.data),[n]),A=r.trim()!=="",w=s!=="ALL"||A,P=w&&L>E,{data:F,isLoading:H}=W({page:1,limit:P?L:void 0,enabled:P}),v=d.useMemo(()=>P?F?.data?.items??[]:n?.data?.items??[],[n,F,P]),{track:R}=he(),N=d.useRef(!1);d.useEffect(()=>{!n||N.current||(N.current=!0,R(se.POLICY_LIST_VIEWED,{active_count:j.ACTIVE,expired_count:j.EXPIRED,cancelled_count:0}))},[n,j,R]);const G=j.ALL>0?j.ALL:y?.total??v.length,_=d.useMemo(()=>rt(v,s),[v,s]),M=d.useMemo(()=>tt(_,r),[_,r]),Y=L>0,$=!w,Q=g=>{e(`/policies/${g}`)},K=()=>{e("/home")},X=g=>{e(be(g),{state:{policy:g}})},q=g=>{};return t.jsxs(I,{gap:6,align:"stretch",px:{base:4,md:6,lg:8},py:6,children:[t.jsx(We,{}
1),t.jsxs(f,{id:"policies-policy-list",children:[t.jsxs(S,{justify:"space-between",align:{base:"flex-start",md:"center"},direction:{base:"column",md:"row"},gap:3,mb:4,children:[t.jsxs(f,{minW:0,w:{base:"full",md:"auto"},flex:{md:1},children:[t.jsx(m,{fontSize:"lg",fontWeight:"bold",color:l.text.label,mb:2,children:p?"Loadingâ¦":`${G} Total Policies`}),t.jsx(De,{activeFilter:s,counts:j,onFilterChange:i})]}),t.jsx(ae,{placeholder:"Search",value:r,onChange:g=>o(g.target.value),width:{base:"full",md:"280px"},flexShrink:0})]}),p||P&&H?t.jsx(S,{justify:"center",align:"center",minH:"200px",children:t.jsx(xe,{size:"lg",color:l.orange[500]})}):u?t.jsx(C,{variant:"load-error",errorMessage:ie(x)??"",onRetry:()=>{h()}}):Y?M.length===0?A?t.jsx(C,{variant:"search-empty",onClearSearch:()=>{o("")}}):s!=="ALL"&&j[s]===0?t.jsx(C,{variant:"tab-empty",tabScope:"global-zero",activeFilter:s,onViewAllPolicies:()=>{i("ALL")}}):P?t.jsx(C,{variant:"tab-empty",tabScope:"global-zero",activeFilter:s,onViewAllPolicies:()=>{i("ALL")}}):t.jsx(C,{variant:"tab-empty",tabScope:"on-page",activeFilter:s,onViewAllPolicies:()=>{i("ALL")},...a>1?{onGoToFirstPage:()=>c(1)}:{}}):t.jsxs(t.Fragment,{children:[t.jsx(I,{gap:4,children:M.map(g=>t.jsx(He,{policy:g,onViewDetails:Q,onFileClaim:X,onRenew:q},g.id))}),$&&t.jsx(ke,{page:a,pageSize:E,totalItems:L,onPageChange:c})]}):t.jsx(C,{variant:"no-policies",onBrowsePlans:K})]})]})};export{nr 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.