@eka-care/abha 0.0.18 → 0.0.19

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.
@@ -133,4 +133,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
133
133
  pds2-transition-colors pds2-duration-200
134
134
  `,tabIndex:-1,ref:a,children:m.jsx("p",{className:`${n?"pds2-text-text-brand Body2Semibold":"pds2-text-text-01 Body2Medium"}`,children:e})})}const fy=()=>{const e=T(N=>N.screen),t=T(N=>N.selectedAbhaAddress),n=T(N=>N.setBottomsheetErrorInfo),r=T(N=>N.clearAbhaAuthStore),a=T(N=>N.goBackLoginScreen),[i,s]=p.useState(q.IDLE),[o,l]=p.useState({firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""}),[u,c]=p.useState({firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""}),[d,f]=p.useState(null),{mutateAsync:w}=Om(),[x,v]=p.useState(!1),_=T(N=>N.ekaProfileInfo),h=T(N=>N.setEkaProfileInfo),g=T(N=>N.setScreen),y=e[e.length-1],E=T(N=>N.aadhaarVerificationSkipStateStatus),R=Ci.getQueryData(["abdmProfilePhrResponse"]),C=T(N=>N.abhaAuthFlowMethod);p.useState({firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""});const k=T(N=>N.isDocAppRequest),A=T(N=>N.clientId),B=T(N=>N.isEkaAppLogin),$=T(N=>N.isNewLoginOrCreateFlow),F=T(N=>N.txnId),H=Vn(),[I,D]=p.useState(null),M=T(N=>N.abhaAuthFlowMethod),O=({name:N,data:z={}})=>{var U,j;const S={...{login_platform:A,is_eka_app_login:B?"true":"false",is_new_login_or_create_flow:$?"true":"false",txn_id:F||"missing txnId",oid:H!=null&&H["X-User-ID"]?"true":"false",access_token:H!=null&&H.auth?"true":"false",flow:M??""},...z};Qe({eventName:N,eventData:S}),(j=(U=window.curio)==null?void 0:U.pushToMixpanel)==null||j.call(U,N,S)};p.useEffect(()=>{O({name:"page_view",data:{page_view:"create_profile_screen"}})},[A]),p.useEffect(()=>{var N;if((N=window.EkaAbha)!=null&&N.changeStatusBarColor)return window.EkaAbha.changeStatusBarColor("#F2F4F7"),()=>{var z,W;(z=window.EkaAbha)!=null&&z.changeStatusBarColor&&((W=window==null?void 0:window.EkaAbha)==null||W.changeStatusBarColor("#FFFFFF"))}},[]),p.useEffect(()=>{if(R){const{first_name:N,last_name:z,gender:W,pincode:S,day_of_birth:U,month_of_birth:j,year_of_birth:K}=R,ee=U===0?1:U,re=`${K}-${String(j===0?1:j).padStart(2,"0")}-${String(ee).padStart(2,"0")}`;O({name:"profile_data_set_from_phr_cache",data:{source:"phr_cache",date_of_birth:re,firstname:N??"missing",lastname:z??"missing",gender:W??"missing",pincode:S??"missing",dob_day:U??"missing",dob_month:j??"missing",dob_year:K??"missing",flow:M??""}}),l({firstname:N,lastname:z,gender:W,pincode:S,date_of_birth:re});return}if(_){let N="1983",z="01",W="01";if(_.date_of_birth){const U=_.date_of_birth.split("-");N=U[0],z=U[1]==="00"||!U[1]?"01":U[1],W=U[2]==="00"||!U[2]?"01":U[2]}const S=`${N}-${String(z).padStart(2,"0")}-${String(W).padStart(2,"0")}`;l({firstname:_.firstname,lastname:_.lastname,gender:_.gender,pincode:_.pincode,date_of_birth:S,oid:_.oid}),O({name:"profile_data_set_from_eka_profile",data:{source:"eka_profile",date_of_birth:(_==null?void 0:_.date_of_birth)??"missing",firstname:(_==null?void 0:_.firstname)??"missing",lastname:(_==null?void 0:_.lastname)??"missing",gender:(_==null?void 0:_.gender)??"missing",pincode:(_==null?void 0:_.pincode)??"missing",oid:(_==null?void 0:_.oid)??"missing"}})}},[R,_]);const P=p.useMemo(()=>!!(o.firstname&&!u.firstname&&o.date_of_birth&&!u.date_of_birth&&o.pincode&&!u.pincode&&o.gender&&!u.gender),[o,u]),b=async()=>{var z,W,S,U;const N={firstname:"",lastname:"",date_of_birth:"",pincode:"",gender:""};if(c(N),o.firstname.trim()||(N.firstname="Enter Name"),o.lastname.trim()||(N.lastname="This field is required"),o.date_of_birth||(N.date_of_birth="Enter DOB"),o.gender||(N.gender="Select Gender"),o.pincode||(N.pincode="Enter Valid Pincode"),!!P){if(O({name:"create_profile_screen_clicks",data:{type:"create_profile"}}),s(q.LOADING),y===ve.CREATE_EKA_PROFILE){if(O({name:"navigate_to_create_abha_address_screen",data:{type:"next",pincode_entered:(o==null?void 0:o.pincode)??"unknown",eka_profile_info_pincode:(_==null?void 0:_.pincode)??"unknown",flow_type:C||"unknown_method"}}),C===X.MOBILE){const j=await Qb({pincode:Number(o.pincode)});if(j!=null&&j.error){D(j!=null&&j.error?"Invalid Pincode":null),s(q.REJECTED),O({name:"pincode_api_failed",data:{type:"error",error:j==null?void 0:j.error}});return}if(O({name:"pincode_api_success",data:{type:"verify",pincode_received:!!j.pincode,txn_id:F}}),j!=null&&j.pincode){f(null),h(o),O({name:"eka_profile_info_set",data:{firstname:o==null?void 0:o.firstname,lastname:o==null?void 0:o.lastname,gender:o==null?void 0:o.gender,pincode:o==null?void 0:o.pincode,date_of_birth:o==null?void 0:o.date_of_birth}}),g(ve.CREATE_ABHA_ADDRESS);return}O({name:"no_action_on_pincode",data:{type:"verify",pincode_entered:!!j.pincode,txn_id:F}});return}else if(C===X.AADHAR_NUMBER){h(o),O({name:"eka_profile_info_set",data:{firstname:o==null?void 0:o.firstname,lastname:o==null?void 0:o.lastname,gender:o==null?void 0:o.gender,pincode:o==null?void 0:o.pincode,date_of_birth:o==null?void 0:o.date_of_birth}}),g(ve.CREATE_ABHA_ADDRESS);return}}if(y===ve.CREATE_PHR_EKA_PROFILE){if(!t){O({name:"abha_create_eka_profile_abha_address_missing",data:{platform:A}});return}const[j,K,ee]=o.date_of_birth?(z=o==null?void 0:o.date_of_birth)==null?void 0:z.split("-"):["","",""],fe={abha_address:t,day_of_birth:parseInt(ee),first_name:o.firstname,gender:o.gender,last_name:o.lastname||"",month_of_birth:parseInt(K),pincode:o.pincode,year_of_birth:parseInt(j)};O({name:"profile_eka_process_started",data:{platform:A,date_of_birth:(o==null?void 0:o.date_of_birth)||null,dob_day:ee||null,dob_month:K||null,dob_year:j||null}});const{error:re,eka:ue,action:he}=await Iy({...fe});if(he){O({name:"profile_eka_process_failed",data:{platform:A,error_message:((W=he==null?void 0:he.cta)==null?void 0:W.title)||"unknown_error",error_message_exists:!!((S=he==null?void 0:he.cta)!=null&&S.title)}}),n(he);return}if(re||!ue||!ue.oid){O({name:"profile_process_failed",data:{platform:A,error_message:re||"Unknown error",eka_oid:(ue==null?void 0:ue.oid)||"missing",eka_exists:!!ue,date_of_birth:(o==null?void 0:o.date_of_birth)||"missing",dob_day:ee||"missing",dob_month:K||"missing",dob_year:j||"missing",parsed_date_valid:!!(parseInt(ee)&&parseInt(K)&&parseInt(j)),firstname:(o==null?void 0:o.firstname)||"missing",gender:(o==null?void 0:o.gender)||"missing",pincode:(o==null?void 0:o.pincode)||"missing"}}),s(q.REJECTED),f(re||"Something went wrong. Please try again.");return}O({name:"profile_eka_process_success",data:{platform:A,eka:ue}}),O({name:"profile_switch_process_started",data:{platform:A,error_message:re,eka:ue}});const oe=await w({oid:ue.oid});if(oe.error){O({name:"profile_switch_process_failed",data:{platform:A,error_message:oe.error||"Something went wrong, please try again",error_message_exists:!!oe.error}}),s(q.REJECTED),f(((U=oe.error)==null?void 0:U.message)||"Something went wrong, please try again");return}O({name:"profile_switch_process_success",data:{platform:A,eka:ue}}),s(q.RESOLVED);return}}},L=()=>{a();const N=T.getState().isEkaAppLogin;r(),T.setState({isEkaAppLogin:N})};return m.jsxs("div",{className:"pds2-w-full pds2-flex pds2-flex-col pds2-bg-bg-01",style:{height:"80vh"},children:[m.jsx(Ta,{title:"",prefixIcon:m.jsx("button",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple",onClick:()=>v(!0),children:m.jsx(Gr,{className:""})}),className:"pds2-bg-bg-01"}),m.jsxs("div",{className:"pds2-flex pds2-flex-col pds2-flex-1 pds2-p-8",children:[m.jsx("div",{className:"pds2-flex pds2-items-center pds2-justify-between",children:m.jsx("div",{className:"pds2-space-y-2 pds2-text-text-01",children:k?m.jsx("div",{className:"Heading4Semibold",children:"Create ABHA Profile"}):m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"Heading4Semibold",children:"Create your"}),m.jsx("div",{className:"Heading2Semibold",children:"Eka Profile"})]})})}),m.jsx(jD,{profileData:o,setProfileData:l,error:u,setError:c,pincodeApiError:I})]}),d&&m.jsx("div",{className:"pds2-p-16 pds2-text-text-error pds2-text-center",children:d}),m.jsxs("div",{className:"pds2-sticky pds2-bottom-0 pds2-bg-bg-white pds2-w-full",children:[t&&E===Mt.ABHA_END?m.jsxs("div",{className:"pds2-flex pds2-items-center pds2-justify-between pds2-w-full pds2-px-16 pds2-py-6 pds2-bg-border-brand-02",children:[m.jsxs("div",{className:"",children:[m.jsx("span",{className:"pds2-text-text-03 Body2Regular",children:"Creating for: "}),m.jsx("span",{className:"pds2-text-text-01 Body2Semibold",children:t})]}),m.jsx("button",{onClick:a,className:"Body2Semibold pds2-text-text-brand pds2-rounded-full ripple pds2-px-8 pds2-py-2",children:"Change"})]}):null,m.jsx("div",{className:"pds2-p-16 pds2-w-full",children:m.jsx(dn,{className:"pds2-w-full",title:"Create Profile",state:i===q.LOADING?"disabled":"enabled",onClick:b,isLoading:i===q.LOADING})})]}),m.jsx(Xr,{onSubmitClick:L}),m.jsx(ml,{open:x,setOpen:v})]})},FD=[{id:"M",name:"Male"},{id:"F",name:"Female"},{id:"O",name:"Other"}],jD=({profileData:e,setProfileData:t,error:n,setError:r,pincodeApiError:a})=>{const i=({event:c,name:d})=>{const f=c.target.value;let w="";switch(d){case"firstname":f.trim()?w="":w="This field is required";break;case"lastname":!f||f.length<0?w="This field is required":w="";break;case"pincode":!f||isNaN(Number(f))||f.length!=6?w="Pincode must consist of exactly 6 digits":w="";break;case"date_of_birth":!f||f>new Date().toISOString().split("T")[0]?w="Date of Birth is invalid":w="";break}r({...n,[d]:w}),t({...e,[d]:f})},s=c=>{t({...e,gender:c}),r({...n,gender:""})},o=(c,d)=>d!=null&&d.pincode||!((c.firstname??"").trim()!==""&&(c.gender??"").trim()!==""&&(c.date_of_birth??"").trim()!=="")?!1:!c.pincode||(c.pincode+"").length!==6,l=T(c=>c.ekaProfileInfo),u=T(c=>c.abhaAuthFlowMethod);return m.jsxs("form",{className:"pds2-flex pds2-flex-col pds2-space-y-32",children:[m.jsxs("label",{className:"pds2-space-y-8",children:[m.jsxs("div",{className:"Body3Medium pds2-text-text-04",children:["Your name",m.jsx("sup",{className:"pds2-text-text-error Body3Semibold",children:"*"})]}),m.jsxs("div",{className:"pds2-flex pds2-gap-8",children:[m.jsxs("div",{className:"pds2-flex pds2-flex-col",children:[m.jsx(Hr,{isMandatory:!0,textColor:"pds2-text-text-01",padding:"pds2-px-16 pds2-py-12",borderRadius:"pds2-rounded-12",borderStyle:"focus-within:pds2-ring-2 focus-within:pds2-ring-border-brand-01 focus-within:pds2-ring-offset-2",placeholder:"Firstname",value:e.firstname,onChange:c=>i({event:c,name:"firstname"}),autoCapitalize:"on",disabled:!!(l!=null&&l.firstname)&&u===X.AADHAR_NUMBER,error:n.firstname}),n.firstname&&m.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-4",children:n.firstname})]}),m.jsx("div",{children:m.jsx(Hr,{textColor:"pds2-text-text-01",padding:"pds2-px-16 pds2-py-12",borderRadius:"pds2-rounded-12",borderStyle:"focus-within:pds2-ring-2 focus-within:pds2-ring-border-brand-01 focus-within:pds2-ring-offset-2",placeholder:"Lastname",value:e.lastname,onChange:c=>i({event:c,name:"lastname"}),autoCapitalize:"on",disabled:!!(l!=null&&l.lastname)&&u===X.AADHAR_NUMBER})})]})]}),m.jsxs("div",{className:"pds2-space-y-8",children:[m.jsxs("div",{className:"pds2-space-y-4",children:[m.jsxs("div",{className:"Body3Medium pds2-text-text-04",children:["Gender",m.jsx("sup",{className:"pds2-text-text-error Body3Semibold",children:"*"})]}),m.jsx("div",{className:"pds2-flex pds2-gap-16",children:FD.map((c,d)=>m.jsx("div",{className:`${n.gender?"pds2-border-2 pds2-rounded-12 pds2-border-text-error placeholder:pds2-text-text-error":"focus-within:pds2-ring-2 focus-within:pds2-ring-border-brand-01 focus-within:pds2-ring-offset-2 placeholder:pds2-text-text-04"}`,children:m.jsx(ID,{isSelected:c.id===e.gender,title:c.name,onSelect:()=>s(c.id)})},d))}),n.gender&&m.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-2",children:n.gender})]}),m.jsxs("div",{className:"pds2-flex pds2-flex-col",children:[m.jsx(Hr,{label:"Date of Birth",isMandatory:!0,textColor:"pds2-text-text-01",padding:"pds2-px-16 pds2-py-12",borderRadius:"pds2-rounded-12",borderStyle:"focus-within:pds2-ring-2 focus-within:pds2-ring-border-brand-01 focus-within:pds2-ring-offset-2",value:e.date_of_birth,disabled:!!(l!=null&&l.date_of_birth)&&u===X.AADHAR_NUMBER,onChange:c=>i({event:c,name:"date_of_birth"}),type:"date",maxDate:new Date().toISOString().split("T")[0],error:n.date_of_birth}),n.date_of_birth&&m.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-2",children:n.date_of_birth})]})]}),m.jsxs("div",{className:"pds2-flex pds2-flex-col pds2-space-y-4",children:[m.jsx(Hr,{label:"Pincode",isMandatory:!0,textColor:"pds2-text-text-01",padding:"pds2-px-16 pds2-py-12",borderRadius:"pds2-rounded-12",borderStyle:o(e,l)||a?"pds2-border-1 pds2-border-text-error":"",value:e.pincode,placeholder:"Enter Pincode",disabled:!!(l!=null&&l.pincode)&&u===X.AADHAR_NUMBER,onChange:c=>{c.target.value.length>6||i({event:c,name:"pincode"})},type:"number",error:o(e,l)?n.pincode:"",textStyle:o(e,l)||a?"placeholder:pds2-text-text-error":"placeholder:pds2-text-text-04"}),a||n.pincode&&m.jsx("div",{className:"Body3Medium pds2-text-text-error pds2-mt-4",children:n.pincode})]})]})},HD=()=>TC({queryKey:["profilesPhrUserResponse"],queryFn:async()=>{const e=await Db();var t;return Array.isArray(e)?t=e==null?void 0:e.filter(r=>!r["health-ids"]||r["health-ids"].length===0):t=[],{profiles:t}}}),$D=()=>{const e=T(v=>v.setScreen);T(v=>v.screen),T(v=>v.goBackLoginScreen),T(v=>v.clearAbhaAuthStore);const[t,n]=p.useState(!1);p.useState("");const r=T(v=>v.clientId),a=T(v=>v.aadhaarVerificationSkipStateStatus),i=T(v=>v.isEkaAppLogin),s=T(v=>v.isNewLoginOrCreateFlow),o=T(v=>v.txnId),l=Vn(),u=T(v=>v.abhaAuthFlowMethod),c=({name:v,data:_={}})=>{var y,E;const g={...{login_platform:r,is_eka_app_login:i?"true":"false",is_new_login_or_create_flow:s?"true":"false",txn_id:o||"missing txnId",oid:l!=null&&l["X-User-ID"]?"true":"false",access_token:l!=null&&l.auth?"true":"false",flow:u??""},..._};Qe({eventName:v,eventData:g}),(E=(y=window.curio)==null?void 0:y.pushToMixpanel)==null||E.call(y,v,g)};p.useEffect(()=>{if(r==="doctor"){c({name:"page_view",data:{platform:r,page_view:"get-all-profiles-screen"}}),c({name:"redirect_to_create_eka_profile_screen",data:{type:"next"}}),e(ve.CREATE_EKA_PROFILE);return}},[r]);let d=!1;i?d=!1:i||(r==="doctor"?d=!1:d=!0);const{data:f,error:w,isLoading:x}=d?HD():{data:null,error:null,isLoading:!1};return p.useEffect(()=>{if(r==="doctor")return;(async()=>{!x&&f&&(n(!0),await new Promise(_=>setTimeout(_,2e3)),n(!1),!f.profiles||f.profiles.length<1?a===Mt.ABHA_END?(c({name:"redirect_to_create_phr_eka_profile_screen",data:{type:"next",skip_state:a}}),e(ve.CREATE_PHR_EKA_PROFILE)):(c({name:"redirect_to_create_eka_profile_screen",data:{type:"next",skip_state:a}}),e(ve.CREATE_EKA_PROFILE)):(c({name:"redirect_to_select_eka_profile_screen",data:{type:"next",skip_state:a}}),e(ve.SELECT_EKA_PROFILE)))})()},[x,f]),t?m.jsx(em,{loading:!0,loadingText:"In progress...",successText:""}):null},VD=()=>{const e=T(i=>i.setAbhaAuthFlowMethod),t=T(i=>i.clientId),n=T(i=>i.clearAbhaAuthStore);p.useEffect(()=>{var i;if(Qe({eventName:"page_view",eventData:{page_view:"abha_login_screen",platform:t}}),e(X.MOBILE),(i=window.EkaAbha)!=null&&i.changeStatusBarColor)return window.EkaAbha.changeStatusBarColor("#F2F4F7"),()=>{var s,o;(s=window.EkaAbha)!=null&&s.changeStatusBarColor&&((o=window==null?void 0:window.EkaAbha)==null||o.changeStatusBarColor("#FFFFFF"))}},[]);const r=()=>{var s;(s=window.EkaAbha)==null||s.onAbhaClose();const i=T.getState().isNewLoginOrCreateFlow;n(),T.setState({isNewLoginOrCreateFlow:i}),jt()},a=["eka-web","phr"];return m.jsxs("div",{className:"pds2-bg-bg-white",children:[!a.includes(t)&&m.jsx(Ta,{prefixIcon:m.jsx("button",{onClick:r,children:m.jsx(Gr,{})}),title:"",className:"pds2-bg-bg-01"}),m.jsx(UD,{}),m.jsx(BD,{})]})},BD=()=>{const e=T(r=>r.setAbhaAuthFlowMethod),t=T(r=>r.abhaAuthFlowMethod),n=[{method:X.ABHA_NUMBER,title:"ABHA Number",icon:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA Number Icon",className:"pds2-h-24 pds2-w-24",loading:"lazy"})},{method:X.PHR_ADDRESS,title:"ABHA Address",icon:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA Address Icon",className:"pds2-h-24 pds2-w-24",loading:"lazy"})},{method:X.AADHAR_NUMBER,title:"Aadhaar Number",icon:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm5mcdm3h00070tfs9fjkepff.webp",alt:"Aadhaar Number Icon",className:"pds2-h-24 pds2-w-24",loading:"lazy"})},{method:X.MOBILE,title:"Mobile Number",icon:m.jsx(Sc,{className:"pds2-w-20 pds2-h-20 pds2-text-icon-success-02"})}];return m.jsxs("div",{className:"pds2-p-16 pds2-space-y-16",children:[m.jsx(Hc,{title:"Other login options for ABHA"}),m.jsx("div",{className:"pds2-space-y-16",children:n.filter(r=>r.method!==t).map(r=>m.jsx(gi,{prefixIcon:r.icon,title:r.title,suffixIcon:m.jsx(Pr,{className:"pds2-ml-auto pds2-h-16 pds2-w-16 pds2-text-text-04 -pds2-rotate-90","aria-hidden":"true"}),onClick:()=>e(r.method)},r.method))})]})},UD=()=>{const e=T(I=>I.setScreen),t=T(I=>I.abhaAuthFlowMethod||X.MOBILE),n=T(I=>I.setRegistrationType),r=T(I=>I.setAadhaarInitResponse),[a,i]=p.useState(""),[s,o]=p.useState(""),[l,u]=p.useState(q.IDLE),c=T(I=>I.setLoginIdentifierValue),d=T(I=>I.setSelectedAbhaAddress),[f,w]=p.useState(!1),x=T(I=>I.initAbhaAppMobileNumber),v=T(I=>I.setBottomsheetErrorInfo),[_,h]=Ie.useState(null),[g,y]=p.useState(""),E=T(I=>I.clientId),R=T(I=>I.isEkaAppLogin);p.useEffect(()=>{if(x&&t===X.MOBILE){i(x),w(x.length===10),o(null);return}i(""),o(null),w(!1)},[t]);const C=I=>{s&&o(null);const D=I.target.value;switch(t){case X.PHR_ADDRESS:if(D.length>20)return;break;case X.MOBILE:if(D&&!/^[0-9]+$/.test(D)||D.length>10)return;break;case X.ABHA_NUMBER:if(!/^[\d-]*$/.test(D)||D.length>17)return;break;case X.AADHAR_NUMBER:if(D&&!/^[0-9]+$/.test(D)||D.length>12)return;break}if(t===X.ABHA_NUMBER){const M=I.target.value.replace(/-/g,"");let O="";M.length>0&&(O+=M.slice(0,2)),M.length>2&&(O+=`-${M.slice(2,6)}`),M.length>6&&(O+=`-${M.slice(6,10)}`),M.length>10&&(O+=`-${M.slice(10,14)}`),i(O)}else i(D.trim())},k=({inputVal:I})=>{s&&o(null),I.length===12&&i(I)},A=p.useCallback(()=>{const I=t===X.MOBILE&&!!x;if(t===X.AADHAR_NUMBER)return m.jsx(jc,{numberOfInputs:3,length:4,placeholder:"XXXX",onSubmit:k});const D={value:a,onChange:C,...t===X.MOBILE&&{type:"tel",placeholder:"Mobile Number",disabled:I,PrefixComponent:m.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-x-8 pds2-border-r pds2-border-border-brand-02 pds2-pr-24",children:[m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4mlct2900000tg98p8u967s.webp",alt:"India Flag",className:"pds2-w-24 pds2-h-24"}),m.jsx("span",{className:"pds2-text-text-black",children:"+91"})]})},...t===X.ABHA_NUMBER&&{placeholder:"00-0000-0000-0000",padding:"pds2-p-18",textStyle:"Body2Regular pds2-text-center pds2-text-lg",borderStyle:"focus-within:pds2-border-border-brand-01",type:"tel"},...t===X.PHR_ADDRESS&&{placeholder:"Enter ABHA Address"}};return m.jsx(Hr,{...D})},[t,a,s]),B=(I=_)=>{I&&(T.setState({isLoggedInFromRedirect:!0}),y(a),T.setState({initAbhaAppMobileNumber:a}),T.setState({abhaAuthFlowMethod:X.MOBILE}),e(ve.CREATE_ABHA_WITH_AADHAAR),v(null))},$=async()=>{u(q.LOADING);let I="";if(!R){const{txn_id:L,error:N}=await eh({method:tl.ABHA});if(!L||N){o((N==null?void 0:N.message)||"Something went wrong. Please try again."),u(q.REJECTED);return}I=L,console.log("triggering logout api in login with abha screen"),await nh()}n(Ln.LOGIN);const D=t===X.PHR_ADDRESS?`${a}${No()}`:a;console.log("loginIdentifier",D);const{txn_id:M,error:O,action:P,hint:b}=await rh({method:t,identifier:D});if(console.log("after postAbdmLoginInit",P),console.log("after postAbdmLoginInit",P),P){h(P),v(P);return}if(O){o(O||"Something went wrong. Please try again."),u(q.REJECTED);return}if(!M){o("Something went wrong. Please try again."),u(q.REJECTED);return}t===X.PHR_ADDRESS&&d(D),r({authTxnId:I,txnId:M,aadhaarOtpSentToHint:b||null}),c(D),u(q.RESOLVED),Qe({eventName:"abha_login_submitted",eventData:{type:"next",platform:E}}),e(ve.VERIFY_OTP_LOGIN_WITH_ABHA)},F=Ie.useMemo(()=>{switch(t){case X.PHR_ADDRESS:return a.length>=4&&a.length<=20;case X.MOBILE:return a.length===10;case X.ABHA_NUMBER:return a.length===17;case X.AADHAR_NUMBER:return a.length===12}},[t,a]),H=Ie.useMemo(()=>{switch(t){case X.ABHA_NUMBER:return"Enter your ABHA Number";case X.PHR_ADDRESS:return"Enter your ABHA Address";case X.MOBILE:return"Enter your Mobile Number";case X.AADHAR_NUMBER:return"Enter your Aadhaar Number";default:return"Enter your ABHA Number"}},[t]);return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"pds2-p-16 pds2-bg-bg-01 pds2-space-y-16 pds2-text-center",children:[m.jsx("div",{className:"pds2-flex pds2-justify-center pds2-items-center pds2-gap-16",children:m.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-16",children:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"abha",className:"pds2-w-64 pds2-h-64"})})}),m.jsx("div",{className:"Heading3Semibold pds2-text-text-black",children:"Log in With ABHA"}),m.jsx("div",{className:"pds2-text-text-black pds2-mt-2",children:H}),m.jsx("div",{className:"pds2-space-y-12",children:m.jsxs("div",{className:"pds2-relative",children:[A(),t===X.PHR_ADDRESS&&m.jsx("div",{className:"pds2-absolute pds2-right-16 pds2-top-16 Body1Regular pds2-text-text-03",children:No()})]})}),s&&m.jsx("div",{className:"pds2-text-text-error Body3Regular",children:s}),m.jsx(dn,{title:"Next",IconComponent:()=>m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!F||!f||l===q.LOADING?"disabled":"enabled",isLoading:l===q.LOADING,onClick:$,className:"pds2-w-full"}),m.jsxs("div",{className:"pds2-flex pds2-flex-row pds2-justify-center pds2-items-center pds2-bg-bg-white pds2-w-fit pds2-px-12 pds2-bg-opacity-60 pds2-rounded-12 pds2-mx-auto",children:[m.jsx("div",{className:"pds2-text-text-04 Body3Regular",children:"Don’t have ABHA?"}),m.jsx(gi,{className:"pds2-text-text-brand Body3Semibold pds2-pl-4 pds2-pr-0 pds2-py-4 ripple pds2-border-none pds2-bg-transparent",width:"pds2-w-fit",title:"Register Now",onClick:()=>{e(ve.CREATE_ABHA_WITH_AADHAAR)}})]})]}),m.jsx(Xr,{onSubmitClick:B})]})},zD=()=>{const e=T(t=>t.setSelectedAbhaAddress);return ol({mutationFn:({txn_id:t,phr_address:n})=>zb({txn_id:t,phr_address:n}),onSuccess(t){t.profile&&(Ci.setQueryData(["abdmProfilePhrResponse"],t.profile),e(t.profile.abha_address))}})},WD=()=>{const[e,t]=p.useState(null),n=T(S=>S.setScreen),r=T(S=>S.goBackLoginScreen),a=T(S=>S.txnId),i=T(S=>S.authTxnId),s=T(S=>S.abhaAddressList),o=T(S=>S.setBottomsheetErrorInfo),l=T(S=>S.clearAbhaAuthStore),u=T(S=>S.setSelectedAbhaAddress),c=T(S=>S.abhaAuthFlowMethod),d=T(S=>S.loginIdentifierValue),[f,w]=p.useState(""),[x,v]=p.useState(!1),_=T(S=>S.setEkaProfileInfo),h=T(S=>S.setAadhaarVerificationSkipStateStatus),[g,y]=p.useState(q.IDLE),E=["M","F","O","U"],{mutateAsync:R}=tm(),{mutateAsync:C}=zD();T(S=>S.ekaProfileInfo),T(S=>S.registrationType);const k=T(S=>S.clientId),A=T(S=>S.isEkaAppLogin),B=T(S=>S.setRegistrationType),$=T(S=>S.abhaAuthFlowMethod),F=T(S=>S.identityValue),H=T(S=>S.setMobileInitResponse),[I,D]=p.useState({aadhaar:q.IDLE,mobile:q.IDLE}),M=T(S=>S.setAadhaarInitResponse),O=T(S=>S.setSelectedAbhaFlow),P=T(S=>S.isNewLoginOrCreateFlow),b=Vn(),L=({name:S,data:U={}})=>{var ee,fe;const K={...{login_platform:k,is_eka_app_login:A?"true":"false",is_new_login_or_create_flow:P?"true":"false",txn_id:a||"missing txnId",oid:b!=null&&b["X-User-ID"]?"true":"false",access_token:b!=null&&b.auth?"true":"false",flow:$??""},...U};Qe({eventName:S,eventData:K}),(fe=(ee=window.curio)==null?void 0:ee.pushToMixpanel)==null||fe.call(ee,S,K)},N=async()=>{var U,j;L({name:"abha_login_select_abha_init_started",data:{method:$,platform:k}});const S=(K,ee)=>{D(fe=>({...fe,[K]:ee}))};if(B(Ln.CREATE),$===X.MOBILE){const{txn_id:K,hint:ee,error:fe,action:re}=await ih({mobile_number:F});if(K&&ee){L({name:"abha_login_select_abha_mobile_init_success",data:{method:$,platform:k,txn_id:K}}),H({authTxnId:i,txnId:K,mobileOtpSentToHint:ee}),O("mobile"),S("mobile",q.RESOLVED),B(Ln.CREATE),n(ve.ABHA_PHONE_NUMBER_VERIFICATION);return}L({name:"abha_login_select_abha_init_failed",data:{method:$,platform:k,reason:fe||"unknown",reason_exists:!!fe}}),S("mobile",q.REJECTED),re?o(re):w(fe||"Something went wrong")}else if($===X.AADHAR_NUMBER){const{txn_id:K,hint:ee,error:fe,action:re}=await ah({aadhaar_number:F});if(K&&ee){L({name:"abha_login_select_abha_aadhaar_init_success",data:{method:$,platform:k,txn_id:K}}),M({authTxnId:i,txnId:K,aadhaarOtpSentToHint:ee}),S("aadhaar",q.RESOLVED),O("aadhaar"),B(Ln.CREATE),n(ve.ABHA_OTP_AND_MOBILE);return}L({name:"abha_login_select_abha_init_failed",data:{method:$,platform:k,reason:fe||"unknown",reason_exists:!!fe}}),S("aadhaar",q.REJECTED),re?(L({name:"abha_login_select_abha_error_action",data:{method:$,platform:k,action:((U=re==null?void 0:re.cta)==null?void 0:U.title)||"unknown",action_exists:!!((j=re==null?void 0:re.cta)!=null&&j.title)}}),o(re)):w(fe||"Something went wrong");return}},z=async()=>{var re,ue,he,oe;if(!e)return;if(u(e.abha_address),console.log(g,"from abha"),!a){L({name:"abha_login_select_abha_txnId_not_found",data:{platform:k,reason:"txnId missing",reason_exists:!0}});return}y(q.LOADING),L({name:"abha_login_select_abha_verify_start",data:{platform:k,txn_id:a}});const{error:S,eka:U,profile:j,action:K,skip_state:ee}=await C({txn_id:a,phr_address:e.abha_address});if(K){L({name:"abha_login_select_abha_error_action",data:{platform:k,txn_id:a,action:((re=K==null?void 0:K.cta)==null?void 0:re.title)||"unknown",action_exists:!!((ue=K==null?void 0:K.cta)!=null&&ue.title)}}),o(K);return}if(S||!U){L({name:"abha_login_select_abha_abdm_error",data:{platform:k,txn_id:a,error_message:S||"eka object missing",error_exists:!!S}}),y(q.REJECTED),w(S);return}if(!ee){w("skip State is missing");return}if(L({name:"abha_login_select_abha_verify_success",data:{platform:k,txn_id:a,skip_state:ee}}),h(ee),j&&(L({name:"abha_login_select_abha_profile_received",data:{platform:k}}),_({date_of_birth:`${j.year_of_birth}-${String(j.month_of_birth).padStart(2,"0")}-${String(j.day_of_birth).padStart(2,"0")}`,firstname:j.first_name,lastname:j.last_name,pincode:j.pincode,gender:j.gender,name:j.first_name+" "+j.last_name,mobile:j.mobile,oid:U==null?void 0:U.oid,middlename:j.middle_name,abha_address:j.abha_address,abha_number:j.abha_number}),u(j.abha_address)),A){if(!U.oid){L({name:"abha_login_select_abha_oid_null",data:{platform:k,oid:(U==null?void 0:U.oid)??"null_or_undefined"}}),y(q.REJECTED);return}const le=E.includes(j==null?void 0:j.gender)?j==null?void 0:j.gender:void 0,ge={oid:(U==null?void 0:U.oid)||"",fln:(j==null?void 0:j.first_name)+" "+(j==null?void 0:j.last_name),dob:`${j==null?void 0:j.year_of_birth}-${String(j==null?void 0:j.month_of_birth).padStart(2,"0")}-${String(j==null?void 0:j.day_of_birth).padStart(2,"0")}`,gen:le,mobile:j==null?void 0:j.mobile,at:"",fn:(j==null?void 0:j.first_name)||"",mn:(j==null?void 0:j.middle_name)||"",ln:(j==null?void 0:j.last_name)||"","health-ids":j!=null&&j.abha_address?[j.abha_address]:void 0,abha_number:(j==null?void 0:j.abha_number)||""},ne=mi(ge);if(y(q.RESOLVED),L({name:"abha_login_select_abha_inside_app_success",data:{platform:k,oid:U.oid}}),window.EkaAbha&&window.EkaAbha.onAbhaSuccess){(he=window.EkaAbha)==null||he.onAbhaSuccess(JSON.stringify({response:ne}));return}bn({response:ne}),jt();return}if(!U.min_token||!i){L({name:"abha_login_select_abha_min_token_missing",data:{platform:k,oid:(U==null?void 0:U.oid)??"missing_oid",min_token:(U==null?void 0:U.min_token)??"missing_min_token",auth_txnId:i??"missing_authTxnId"}}),y(q.REJECTED),w(S||"Something went wrong. Please try again.");return}const fe=await R({txn_id:i,token:U.min_token,...U.oid?{oid:U.oid}:null});if(!fe.data){L({name:"abha_login_select_abha_auth_verify_failed",data:{platform:k,oid:(U==null?void 0:U.oid)??"missing_oid",min_token:(U==null?void 0:U.min_token)??"missing_min_token",auth_txnId:i??"missing_authTxnId"}}),y(q.REJECTED),w(((oe=fe.error)==null?void 0:oe.message)||"Something went wrong, please try again");return}y(q.RESOLVED),L({name:"abha_login_select_abha_auth_verify_success",data:{platform:k,oid:U.oid,min_token:U==null?void 0:U.min_token,auth_txnId:i}})},W=()=>{const S=T.getState().initAbhaAppMobileNumber,U=T.getState().isEkaAppLogin;r(),l(),T.setState({initAbhaAppMobileNumber:S}),T.setState({isEkaAppLogin:U})};return m.jsxs("div",{className:"pds2-w-full pds2-flex pds2-flex-col pds2-h-screen pds2-bg-bg-01",children:[m.jsx(Ta,{title:"Select ABHA to continue",prefixIcon:m.jsx("button",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple",onClick:()=>v(!0),children:m.jsx(Gr,{})}),className:"pds2-border-b pds2-border-bg-seperator-dark pds2-bg-bg-white"}),m.jsxs("div",{className:"pds2-flex-1 pds2-overflow-y-auto pds2-flex pds2-flex-col pds2-p-16 pds2-space-y-16",children:[m.jsxs("div",{className:"pds2-text-text-03 Body1Regular pds2-text-center",children:["We found ",s==null?void 0:s.length," ABHA addresses ",m.jsx("br",{})," select one you want to log in with"]}),m.jsx(YD,{list:s,selectedAbha:e,setSelectedAbha:t}),((s==null?void 0:s.length)??0)<6&&(c===X.MOBILE||c===X.AADHAR_NUMBER)&&m.jsxs(m.Fragment,{children:[m.jsx(Hc,{title:"or"}),m.jsx(gi,{title:"Create new ABHA Address",prefixIcon:m.jsx(iw,{}),className:"pds2-justify-center pds2-text-text-brand pds2-border-bg-fab-bg-brand-04 Body1Semibold",onClick:N})]})]}),m.jsxs("div",{className:"pds2-bg-bg-white pds2-shadow-lg pds2-w-full pds2-sticky pds2-bottom-0 pds2-border-t pds2-border-border-brand-02 pds2-p-16 z-10",children:[f&&m.jsx("div",{className:"pds2-text-text-error pds2-text-center pds2-mb-4",children:f}),c===X.ABHA_NUMBER&&m.jsxs("div",{className:"pds2-text-center pds2-bg-bg-warning-03 pds2-py-2 pds2-mb-4",children:[m.jsx("span",{className:"pds2-text-text-03 Body2Regular",children:"Your ABHA No:"}),m.jsx("span",{className:"pds2-text-text-01 Body2Semibold",children:d})]}),m.jsx(dn,{title:"Continue",state:e===null||g===q.LOADING?"disabled":"enabled",isLoading:g===q.LOADING,className:"pds2-w-full",onClick:z})]}),m.jsx(Xr,{onSubmitClick:W}),m.jsx(ml,{open:x,setOpen:v})]})},YD=({list:e,selectedAbha:t,setSelectedAbha:n})=>m.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-16 pds2-border pds2-border-border-brand-02 pds2-w-full pds2-relative",children:e==null?void 0:e.map((r,a)=>m.jsxs(Ie.Fragment,{children:[m.jsxs("label",{className:"pds2-p-16 pds2-flex pds2-space-x-8",children:[m.jsx("input",{className:"pds2-self-start pds2-mt-4 pds2-w-14 pds2-h-14 pds2-p-2 checked:pds2-accent-text-brand",type:"radio",value:r.abha_address,checked:(t==null?void 0:t.abha_address)===r.abha_address,onChange:()=>{n(r)}}),m.jsxs("div",{className:"pds2-flex pds2-flex-col pds2-space-y-4 pds2-flex-1",children:[m.jsx("div",{className:"TitlesSubheadline pds2-text-text-primary pds2-flex pds2-flex-row pds2-items-center pds2-justify-between",children:m.jsx("div",{children:r==null?void 0:r.abha_address})}),m.jsx("div",{className:"pds2-text-text-03 Body3Regular pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-4",children:(r==null?void 0:r.name)&&m.jsx("div",{className:"Body3Regular pds2-text-text-03",children:r.name})})]})]}),a!==e.length-1&&m.jsx("div",{className:"pds2-px-16",children:m.jsx("div",{className:"pds2-bg-border-03 pds2-h-1 pds2-w-full"})})]},r.abha_address))}),GD=()=>{var I;const e=T(D=>D.setScreen),t=T(D=>D.setEkaProfileInfo),n=T(D=>D.registrationType),r=T(D=>D.goBackLoginScreen),[a,i]=p.useState(null),s=T(D=>D.setBottomsheetErrorInfo),o=T(D=>D.clearAbhaAuthStore),[l,u]=p.useState(q.IDLE),[c,d]=p.useState(!1),[f,w]=p.useState(null),x=T(D=>D.selectedAbhaAddress),v=T(D=>D.aadhaarVerificationSkipStateStatus),{mutateAsync:_}=Om(),h=Ci.getQueryData(["profilesPhrUserResponse"]),g=T(D=>D.clientId),y=T(D=>D.isEkaAppLogin),E=T(D=>D.isNewLoginOrCreateFlow),R=T(D=>D.txnId),C=Vn(),k=T(D=>D.abhaAuthFlowMethod),A=({name:D,data:M={}})=>{var b,L;const P={...{login_platform:g,is_eka_app_login:y?"true":"false",is_new_login_or_create_flow:E?"true":"false",txn_id:R||"missing txnId",oid:C!=null&&C["X-User-ID"]?"true":"false",access_token:C!=null&&C.auth?"true":"false",flow:k??""},...M};Qe({eventName:D,eventData:P}),(L=(b=window.curio)==null?void 0:b.pushToMixpanel)==null||L.call(b,D,P)};p.useEffect(()=>{A({name:"choose_eka_profile_screen",data:{platform:g,type:"select"}})},[g]);const B=()=>{if(A({name:"create_family_profile_clicks",data:{platform:g,type:"create",skip_state:v}}),v===Mt.ABHA_END){A({name:"navigate_to_create_phr_profile_screen",data:{platform:g}}),e(ve.CREATE_PHR_EKA_PROFILE);return}A({name:"navigate_to_create_eka_profile_screen",data:{platform:g}}),e(ve.CREATE_EKA_PROFILE)},$=async({profile:D})=>{A({name:"select_profile_clicks",data:{platform:g,oid:D.oid}}),i(D.oid)},F=async()=>{var b,L,N,z;if(A({name:"continue_click_on_choose_eka_profile",data:{platform:g,selectedProfileOid:a,registrationType:n,skip_state:v}}),a&&v===Mt.ABHA_CREATE){const W=h==null?void 0:h.profiles.find(S=>S.oid===a);if(!W){A({name:"continue_click_profile_not_found",data:{platform:g,oid:a||"unknown_oid",oid_exists:!!a}});return}A({name:"navigate_to_create_eka_profile_screen_from_abha_create",data:{platform:g,oid:W.oid}}),t({oid:W.oid,date_of_birth:W.dob,firstname:W.fn,lastname:W.ln,pincode:"",gender:W.gen,mobile:W.mobile,name:W.fln,middlename:W.mn,abha_address:(b=W==null?void 0:W["health-ids"])==null?void 0:b[0],abha_number:W.abha_number}),e(ve.CREATE_EKA_PROFILE);return}if(!x||!a){A({name:"continue_click_missing_profile_or_abha",data:{platform:g,oid:a||"missing_oid",oid_exists:!!a}});return}A({name:"linking_abha_to_profile_start",data:{platform:g,oid:a||"missing_oid",oid_exists:!!a}}),u(q.LOADING);const{error:D,action:M,eka:O}=await Fy({abha_address:x,oid:a});if(M){A({name:"linking_abha_to_profile_error_action",data:{platform:g,oid:a||"missing_oid",oid_exists:!!a}}),s(M);return}if(D||!O||!O.oid){A({name:"linking_abha_to_profile_failed",data:{platform:g,oid:a||"missing_oid",oid_exists:!!a,error:D||"No EKA/OID",error_exists:!!D}}),u(q.REJECTED),w(D||"Something went wrong. Please try again.");return}const P=await _({oid:O.oid});if(P.error){A({name:"profile_switch_failed_after_link",data:{platform:g,oid:(O==null?void 0:O.oid)||"missing_oid",oid_exists:!!(O!=null&&O.oid),error:((L=P.error)==null?void 0:L.message)||"unknown_error",error_exists:!!((N=P.error)!=null&&N.message)}}),u(q.REJECTED),w(((z=P.error)==null?void 0:z.message)||"Something went wrong, please try again");return}A({name:"linking_abha_to_profile_success",data:{platform:g,oid:O.oid}}),u(q.RESOLVED)},H=()=>{r();const D=T.getState().isEkaAppLogin;o(),T.setState({isEkaAppLogin:D})};return m.jsxs("div",{className:"pds2-w-full pds2-h-screen pds2-flex pds2-flex-col pds2-bg-bg-01",children:[m.jsx(Ta,{title:"Select Eka Profile",prefixIcon:m.jsx("button",{className:"pds2-w-24 pds2-h-24 pds2-rounded-full pds2-flex pds2-items-center pds2-justify-center ripple",onClick:()=>d(!0),children:m.jsx(Gr,{})}),className:"pds2-border-b pds2-border-bg-seperator-dark pds2-bg-bg-white"}),m.jsxs("div",{className:"pds2-flex-1 pds2-flex pds2-flex-col pds2-relative",children:[m.jsxs("div",{className:"pds2-flex-1 pds2-overflow-y-auto pds2-px-16 pds2-pt-24 pds2-pb-32",children:[m.jsxs("div",{className:"pds2-space-y-16 pds2-flex pds2-flex-col pds2-items-center pds2-text-center",children:[m.jsx("img",{src:"https://cdn.eka.care/vagus/cm6agrs5000090tfwfz984x5b.webp",alt:"Link ABHA",className:"pds2-w-163"}),m.jsxs("div",{className:"pds2-space-y-4",children:[m.jsx("div",{className:"pds2-text-text-01 Heading3Semibold",children:"Choose an Eka Profile"}),m.jsx("span",{className:"Body1Regular pds2-text-text-03",children:"Select the person for whom you want to create an ABHA address."})]})]}),m.jsxs("div",{className:"pds2-w-full pds2-flex pds2-flex-col pds2-justify-center pds2-space-y-12 pds2-mt-24",children:[m.jsx("div",{className:"pds2-text-text-03 Body2Medium pds2-text-center",children:"Select Eka Profile"}),m.jsx("div",{className:"pds2-space-y-8",children:(I=h==null?void 0:h.profiles)==null?void 0:I.map(D=>{const M=a===D.oid;return m.jsxs("label",{className:`pds2-flex pds2-items-center pds2-gap-x-8 pds2-cursor-pointer pds2-p-16 pds2-rounded-16 pds2-bg-bg-white pds2-border
135
135
  pds2-border-border-03 hover:pds2-bg-bg-hover-01
136
- pds2-transition-colors`,children:[m.jsx("input",{type:"radio",name:"ekaProfile",value:D.oid,checked:M,onChange:()=>$({profile:D}),className:"pds2-self-start pds2-mt-4 pds2-w-14 pds2-h-14"}),m.jsxs("div",{className:"pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-8 pds2-flex-1",children:[m.jsx("div",{className:"TitlesSubheadline pds2-text-text-primary",children:D.fln}),m.jsx("span",{className:"pds2-ml-auto pds2-text-text-brand pds2-text-14 pds2-font-600",children:"Link"})]})]},D.oid)})}),m.jsx(Hc,{title:"or"}),m.jsx(gi,{title:"Create new Family Member",prefixIcon:m.jsx(iw,{}),className:"pds2-justify-center pds2-text-text-brand pds2-border-bg-fab-bg-brand-04 Body1Semibold",onClick:B})]})]}),m.jsxs("div",{className:"pds2-sticky pds2-bottom-0 pds2-left-0 pds2-right-0 pds2-bg-bg-white pds2-shadow-lg pds2-p-16",children:[f&&m.jsx("div",{className:"pds2-text-text-error pds2-text-center pds2-mb-8",children:f}),m.jsx(dn,{title:"Continue",state:a===null||l===q.LOADING?"disabled":"enabled",isLoading:l===q.LOADING,className:"pds2-w-full",onClick:F})]})]}),m.jsx(Xr,{onSubmitClick:H}),m.jsx(ml,{open:c,setOpen:d})]})},KD=()=>{const e=T(r=>r.clientId);p.useEffect(()=>{var r;if((r=window.EkaAbha)!=null&&r.changeStatusBarColor)return window.EkaAbha.changeStatusBarColor("#F2F4F7"),()=>{var a,i;(a=window.EkaAbha)!=null&&a.changeStatusBarColor&&((i=window==null?void 0:window.EkaAbha)==null||i.changeStatusBarColor("#FFFFFF"))}},[]);const t=()=>{var r;(r=window.EkaAbha)==null||r.onAbhaClose(),jt()},n=["eka-web","phr"];return m.jsxs("div",{className:"pds2-bg-bg-01 pds2-pt-36",children:[!n.includes(e)&&m.jsx(Ta,{prefixIcon:m.jsx("button",{onClick:t,children:m.jsx(Gr,{})}),title:"",className:"pds2-bg-bg-01"}),m.jsx(qD,{})]})},qD=()=>{const e=T(J=>J.abhaAuthFlowMethod||X.MOBILE),t=T(J=>J.setAbhaAuthFlowMethod),[n,r]=p.useState(""),[a,i]=p.useState(q.IDLE),s=T(J=>J.isEkaAppLogin),[o,l]=p.useState(""),u=T(J=>J.setSelectedAbhaAddress),c=T(J=>J.setLoginIdentifierValue),d=T(J=>J.setScreen),[f,w]=p.useState({aadhaar:q.IDLE,mobile:q.IDLE}),x=T(J=>J.setRegistrationType),v=T(J=>J.setAadhaarInitResponse),_=T(J=>J.setMobileInitResponse),h=T(J=>J.initAbhaAppMobileNumber),[g,y]=p.useState(""),[E,R]=p.useState(!1),[C,k]=p.useState(!1),[A,B]=p.useState(""),[$,F]=p.useState(""),[H,I]=p.useState(""),D=T(J=>J.isNewLoginOrCreateFlow),M=T(J=>J.setIsNewLoginOrCreateFlow),O=T(J=>J.clientId),P=p.useRef(!1),b=T(J=>J.isInitApiTriggered),L=T(J=>J.setIsInitApiTriggered),N=T(J=>J.setIdentityValue);T(J=>J.identityValue);const z=Vn(),W=T(J=>J.setSelectedAbhaFlow),S=T(J=>J.isDocAppRequest),U=T(J=>J.txnId);p.useEffect(()=>{j({name:"abha_login_or_create_screen",data:{flow:e.toString()}})}),p.useEffect(()=>{if(h&&e===X.MOBILE){r(h),R(h.length===10),l(null);return}r(""),l(null),R(!1)},[e]),p.useEffect(()=>{b||P.current||g&&g.length===10&&(L(!0),P.current=!0,oe("auto_submit_mobile"))},[g]),p.useEffect(()=>{b||P.current||A&&A.length===12&&(L(!0),P.current=!0,oe("auto_submit_aadhaar"))},[A]);const j=({name:J,data:Y={}})=>{var Se,qe;const Ce={...{login_platform:O,is_eka_app_login:s?"true":"false",is_new_login_or_create_flow:D?"true":"false",oid:z!=null&&z["X-User-ID"]?"true":"false",access_token:z!=null&&z.auth?"true":"false",txn_id:U||"missing txnId",flow:e??""},...Y};Qe({eventName:J,eventData:Ce}),(qe=(Se=window.curio)==null?void 0:Se.pushToMixpanel)==null||qe.call(Se,J,Ce)},K=Ie.useMemo(()=>{switch(e){case X.MOBILE:return"Enter your Mobile Number";case X.AADHAR_NUMBER:return"Enter your Aadhaar Number";default:return""}},[e]),ee=J=>{const Y=J.target.value;switch(e){case X.PHR_ADDRESS:if(Y.length>20)return;I(Y),r(Y);break;case X.MOBILE:if(Y&&!/^[0-9]+$/.test(Y)||Y.length>10)return;y(Y),R(!0),r(Y);break;case X.ABHA_NUMBER:if(!/^[\d-]*$/.test(Y)||Y.length>17)return;const Z=J.target.value.replace(/-/g,"");let Ce="";return Z.length>0&&(Ce+=Z.slice(0,2)),Z.length>2&&(Ce+=`-${Z.slice(2,6)}`),Z.length>6&&(Ce+=`-${Z.slice(6,10)}`),Z.length>10&&(Ce+=`-${Z.slice(10,14)}`),F(Ce),r(Ce.trim());case X.AADHAR_NUMBER:if(Y&&!/^[0-9]+$/.test(Y)||Y.length>12)return;B(Y),k(!0),r(Y);break}r(Y.trim())},fe=e===X.MOBILE&&!!h,re=Ie.useMemo(()=>{switch(e){case X.PHR_ADDRESS:return n.length>=4&&n.length<=20;case X.MOBILE:return n.length===10;case X.ABHA_NUMBER:return n.length===17;case X.AADHAR_NUMBER:return n.length===12}},[e,n]),ue=(J,Y)=>{w(Z=>({...Z,[J]:Y}))},he=({inputVal:J})=>{J.length===12&&(r(J),B(J),k(!0))};p.useEffect(()=>{console.log("selectedMethod changed:==================>",e)},[e]);const oe=async J=>{var Ce,Se,qe;M(!0),j({name:"abha_login_next_click",data:{flow_step_type:J}}),i(q.LOADING),x(Ln.LOGIN);let Y="";if(!s){const ke=await nh();j({name:ke?"abha_logout_success":"abha_logout_failure",data:{platform:O}});const{txn_id:Pe,error:$e}=await eh({method:tl.ABHA});if(!Pe||$e){j({name:"abha_auth_init_failure",data:{flow_step_type:"init",authTxnId:Y,error_message:$e||"missing_txnId_or_unknown_error",error_message_exists:!!$e,txn_id_exists:!!Pe}}),l(($e==null?void 0:$e.message)||"Something went wrong. Please try again."),i(q.REJECTED);return}Y=Pe,j({name:"abha_auth_init_success.",data:{flow_step_type:"init",auth_txnId:Y}})}const Z=e===X.PHR_ADDRESS?`${n}${No()}`:n;if(e===X.MOBILE||e===X.ABHA_NUMBER||e===X.PHR_ADDRESS){const{txn_id:ke,error:Pe,action:$e,hint:Ge}=await rh({method:e,identifier:Z});if(N(Z),j({name:"abha_login_init_triggered",data:{flow_step_type:"init",authTxnId:Y,ndhmTxnId:ke,method:e}}),e===X.PHR_ADDRESS&&u(Z),Pe||!ke){if(((Ce=$e==null?void 0:$e.cta)==null?void 0:Ce.pid)==="abha_mobile_enroll"){ue("mobile",q.LOADING),x(Ln.CREATE);const{txn_id:_t,hint:mt,error:Tt,action:Et}=await ih({mobile_number:n});if(N(n),W("mobile"),_t&&mt){_({authTxnId:Y,txnId:_t,mobileOtpSentToHint:mt}),j({name:"abha_mobile_registration_init_success",data:{flow_step_type:"init",authTxnId:Y,ndhmTxnId:ke,error_message:Tt,error_action:$e}}),ue("mobile",q.RESOLVED),i(q.RESOLVED),x(Ln.CREATE),d(ve.ABHA_PHONE_NUMBER_VERIFICATION);return}if(ue("mobile",q.REJECTED),j({name:"abha_mobile_registration_init_failure",data:{flow_step_type:"init",authTxnId:Y,error_message:Tt||"unknown_error",error_message_exists:!!Tt,error_action_exists:!!Et}}),Et){if((Se=Et==null?void 0:Et.cta)!=null&&Se.pid)return d(ve.LOGIN_OR_CREATE_ABHA)}else l(Tt||"Something went wrong");l(Tt||"Something went wrong. Please try again."),i(q.REJECTED);return}j({name:"abha_login_init_failure",data:{flow_step_type:"init",authTxnId:Y,error_message:Pe||"unknown_error",error_message_exists:!!Pe,error_action_exists:!!$e}}),l(Pe||"Something went wrong. Please try again."),i(q.REJECTED);return}j({name:"abha_login_init_success",data:{flow_step_type:"init",authTxnId:Y,ndhmTxnId:ke,hint:Ge}}),v({authTxnId:Y,txnId:ke,aadhaarOtpSentToHint:Ge||null}),c(Z),i(q.RESOLVED),d(ve.VERIFY_OTP_LOGIN_WITH_ABHA);return}if(e===X.AADHAR_NUMBER){ue("aadhaar",q.LOADING),j({name:"aadhaar_registration_init_start",data:{flow_step_type:"init",authTxnId:Y,aadhaarNumber:n}});const{txn_id:ke,hint:Pe,error:$e,action:Ge}=await ah({aadhaar_number:n});if(N(n),W("aadhaar"),ke&&Pe){v({authTxnId:Y,txnId:ke,aadhaarOtpSentToHint:Pe}),j({name:"aadhaar_registration_init_success",data:{flow_step_type:"verify",ndhmTxnId:ke,authTxnId:Y}}),ue("aadhaar",q.RESOLVED),x(Ln.CREATE),i(q.RESOLVED),d(ve.ABHA_OTP_AND_MOBILE);return}if(j({name:"abha_registration_init_failure",data:{error_message:$e||"unknown_error",error_message_exists:!!$e,auth_txn_id:Y,error_action:Ge,error_action_exists:!!Ge}}),ue("aadhaar",q.REJECTED),i(q.REJECTED),Ge||$e){(qe=Ge==null?void 0:Ge.cta)!=null&&qe.pid?d(ve.LOGIN_OR_CREATE_ABHA):l($e||"Something went wrong");return}}},[le,ge]=p.useState(!1),[ne,ye]=p.useState(!1),[He,be]=p.useState(!1);return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"pds2-p-16 pds2-bg-bg-01 pds2-space-y-16 pds2-text-center",children:[m.jsx("div",{className:"pds2-flex pds2-justify-center pds2-items-center pds2-gap-16",children:m.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-16",children:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"abha",className:"pds2-w-64 pds2-h-64"})})}),m.jsx("div",{className:"Heading3Semibold pds2-text-text-black",children:O==="phr"?"Login or Create your ABHA":S?"Add Patient via ABHA":"Create your ABHA"}),m.jsx("div",{className:"pds2-text-text-03",style:{marginTop:"4px"},children:e===X.MOBILE?"Enter your Mobile Number":e===X.AADHAR_NUMBER?"Enter your Aadhaar Number":e===X.ABHA_NUMBER?"Enter your ABHA Number":e===X.PHR_ADDRESS?"Enter your ABHA Address":K}),(e===X.MOBILE||e===X.AADHAR_NUMBER)&&m.jsxs("div",{className:"pds2-flex pds2-mt-4 pds2-bg-bg-02 pds2-rounded-lg pds2-overflow-hidden pds2-p-1",children:[m.jsxs("button",{onClick:()=>t(X.MOBILE),className:`pds2-flex-1 pds2-py-3 pds2-flex pds2-items-center pds2-justify-center pds2-gap-8 pds2-relative ${e===X.MOBILE?"pds2-bg-bg-white":"pds2-bg-bg-seperator-dark"}`,style:{clipPath:"polygon(8px 0%, calc(100% - 8px) 0%, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0% calc(100% - 8px), 0% 8px)"},children:[m.jsx(Sc,{className:"pds2-w-14 pds2-h-14 pds2-text-icon-success-02"}),m.jsx("span",{className:`pds2-text-base ${e===X.MOBILE?"pds2-font-bold pds2-text-fg-default":"pds2-font-normal pds2-text-fg-subtle"}`,style:e===X.MOBILE?{fontWeight:700}:{fontWeight:400},children:"Mobile"})]}),m.jsxs("button",{onClick:()=>t(X.AADHAR_NUMBER),className:`pds2-flex-1 pds2-py-3 pds2-flex pds2-items-center pds2-justify-center pds2-gap-8 pds2-relative pds2-ml-1 ${e===X.AADHAR_NUMBER?"pds2-bg-bg-white":"pds2-bg-bg-seperator-dark"}`,style:{clipPath:"polygon(8px 0%, calc(100% - 8px) 0%, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0% calc(100% - 8px), 0% 8px)"},children:[m.jsx("img",{src:"https://cdn.eka.care/vagus/cm5mcdm3h00070tfs9fjkepff.webp",alt:"Aadhaar",className:"pds2-w-24 pds2-h-24"}),m.jsx("span",{className:`pds2-text-base ${e===X.AADHAR_NUMBER?"pds2-font-bold pds2-text-fg-default":"pds2-font-normal pds2-text-fg-subtle"}`,style:e===X.AADHAR_NUMBER?{fontWeight:700}:{fontWeight:400},children:"Aadhaar"})]})]}),(e===X.MOBILE||e===X.AADHAR_NUMBER)&&m.jsx("div",{className:"pds2-mt-16 pds2-w-full pds2-max-w-md pds2-mx-auto pds2-px-4 pds2-relative",children:e===X.AADHAR_NUMBER?m.jsx(jc,{numberOfInputs:3,length:4,placeholder:"XXXX",onSubmit:he,setIsValid:k}):m.jsx(Hr,{value:n,onChange:ee,type:"tel",placeholder:"Mobile Number",disabled:fe,inputMode:"numeric",autoFocus:!0,maxLength:10,PrefixComponent:m.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-x-8 pds2-border-r pds2-border-border-brand-02 pds2-pr-24",children:[m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4mlct2900000tg98p8u967s.webp",alt:"India Flag",className:"pds2-w-24 pds2-h-24"}),m.jsx("span",{className:"pds2-text-text-black pds2-text-sm",children:"+91"})]})})}),o&&m.jsx("div",{className:"pds2-text-text-error Body3Regular",children:o}),(e===X.MOBILE||e===X.AADHAR_NUMBER)&&m.jsx(dn,{title:"Next",IconComponent:()=>m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!re||a===q.LOADING?"disabled":"enabled",isLoading:a===q.LOADING,onClick:()=>oe("aadhaar_or_mobile_on_click"),className:"pds2-w-full"})]}),m.jsx("div",{className:"pds2-mt-24 pds2-mx-16 pds2-mb-48 pds2-pb-36",children:m.jsxs("div",{className:"pds2-bg-bg-white pds2-rounded-16 pds2-border pds2-border-border-03 pds2-overflow-hidden",children:[m.jsxs("button",{onClick:()=>ge(!le),className:"pds2-w-full pds2-flex pds2-items-center pds2-justify-between pds2-p-16 pds2-bg-bg-white hover:pds2-bg-bg-02 pds2-transition-colors",children:[m.jsx("span",{className:"pds2-text-text-03",children:"Other login options for ABHA"}),m.jsx(Pr,{className:`pds2-w-16 pds2-h-16 pds2-text-text-03 pds2-transition-transform ${le?"pds2-rotate-180":""}`})]}),le&&m.jsxs("div",{children:[m.jsxs("button",{onClick:()=>{ge(!1),t(X.ABHA_NUMBER),ye(!0)},className:"pds2-w-full pds2-flex pds2-items-center pds2-justify-between pds2-p-12 hover:pds2-bg-bg-02 pds2-transition-colors",children:[m.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-12",children:[m.jsx("div",{className:"pds2-w-40 pds2-h-40 pds2-rounded-full pds2-bg-bg-02 pds2-flex pds2-items-center pds2-justify-center",children:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA",className:"pds2-w-24 pds2-h-24"})}),m.jsx("span",{className:"Body1Regular pds2-text-text-black",children:"Login with ABHA Number"})]}),m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-text-text-03"})]}),m.jsxs("button",{onClick:()=>{ge(!1),t(X.PHR_ADDRESS),be(!0)},className:"pds2-w-full pds2-flex pds2-items-center pds2-justify-between pds2-p-12 hover:pds2-bg-bg-02 pds2-transition-colors",children:[m.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-12",children:[m.jsx("div",{className:"pds2-w-40 pds2-h-40 pds2-rounded-full pds2-bg-bg-02 pds2-flex pds2-items-center pds2-justify-center",children:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA",className:"pds2-w-24 pds2-h-24"})}),m.jsx("span",{className:"Body1Regular pds2-text-text-black",children:"Login with ABHA Address"})]}),m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-text-text-03"})]})]})]})}),m.jsx(py,{isOpen:ne,setIsOpen:ye,children:m.jsxs("div",{className:"pds2-p-24 pds2-text-center pds2-h-full pds2-flex pds2-flex-col",children:[m.jsx("div",{className:"pds2-flex pds2-justify-end pds2-mb-16",children:m.jsx("button",{onClick:()=>{ye(!1),t(X.MOBILE)},className:"pds2-w-24 pds2-h-24 pds2-flex pds2-items-center pds2-justify-center pds2-text-text-03 hover:pds2-text-text-black",children:"✕"})}),m.jsxs("div",{className:"pds2-flex-1 pds2-flex pds2-flex-col pds2-justify-start",children:[m.jsx("div",{className:"pds2-flex pds2-justify-center pds2-mb-16",children:m.jsx("div",{className:"pds2-w-64 pds2-h-64 pds2-rounded-full pds2-bg-bg-01 pds2-flex pds2-items-center pds2-justify-center",children:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA Logo",className:"pds2-w-48 pds2-h-48"})})}),m.jsx("h2",{className:"Heading3Semibold pds2-text-text-black",children:"Login with ABHA Number"}),m.jsx("p",{className:"Body2Regular pds2-text-text-03 pds2-mb-24",children:"Enter your 14 digit ABHA Number"}),m.jsx("div",{className:"pds2-mb-24",children:m.jsx(Hr,{value:n,onChange:ee,placeholder:"00-0000-0000-0000",padding:"pds2-p-18",textStyle:"Body2Regular pds2-text-center pds2-text-lg",borderStyle:"focus-within:pds2-border-border-brand-01",type:"tel",inputMode:"numeric",autoFocus:!0})}),o&&m.jsx("div",{className:"pds2-text-text-error Body3Regular",children:o}),m.jsx(dn,{title:"Next",IconComponent:()=>m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!n||a===q.LOADING?"disabled":"enabled",onClick:()=>oe("after_enter_abha_number_on_click_by_user"),className:"pds2-w-full",isLoading:a===q.LOADING})]})]})}),m.jsx(py,{isOpen:He,setIsOpen:be,children:m.jsxs("div",{className:"pds2-p-24 pds2-text-center pds2-h-full pds2-flex pds2-flex-col",children:[m.jsx("div",{className:"pds2-flex pds2-justify-end pds2-mb-16",children:m.jsx("button",{onClick:()=>{be(!1),t(X.MOBILE)},className:"pds2-w-24 pds2-h-24 pds2-flex pds2-items-center pds2-justify-center pds2-text-text-03 hover:pds2-text-text-black",children:"✕"})}),m.jsxs("div",{className:"pds2-flex-1 pds2-flex pds2-flex-col pds2-justify-start",children:[m.jsx("div",{className:"pds2-flex pds2-justify-center pds2-mb-16",children:m.jsx("div",{className:"pds2-w-64 pds2-h-64 pds2-rounded-full pds2-bg-bg-01 pds2-flex pds2-items-center pds2-justify-center",children:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA Logo",className:"pds2-w-48 pds2-h-48"})})}),m.jsx("h2",{className:"Heading3Semibold pds2-text-text-black",children:"Login with ABHA Address"}),m.jsx("p",{className:"Body2Regular pds2-text-text-03 pds2-mb-24",children:"Enter your ABHA Address below"}),m.jsxs("div",{className:"pds2-mb-24 pds2-relative",children:[m.jsx(Hr,{value:n,onChange:ee,placeholder:"Enter ABHA Address",inputMode:"text",autoFocus:!0}),m.jsx("div",{className:"pds2-absolute pds2-right-16 pds2-top-16 Body1Regular pds2-text-text-03",children:No()==="PROD"?"@abdm":"@sbx"})]}),o&&m.jsx("div",{className:"pds2-text-text-error Body3Regular",children:o}),m.jsx(dn,{title:"Next",IconComponent:()=>m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!n||a===q.LOADING?"disabled":"enabled",onClick:()=>oe("after_enter_abha_address_on_click_by_user"),className:"pds2-w-full",isLoading:a===q.LOADING})]})]})})]})},py=({isOpen:e,setIsOpen:t,children:n,overlayClassName:r="pds2-bg-text-black pds2-bg-opacity-50"})=>e?m.jsxs("div",{className:"pds2-absolute pds2-inset-0 pds2-z-50 pds2-flex pds2-items-end",children:[m.jsx("div",{className:`pds2-absolute pds2-inset-0 ${r}`,style:{backgroundColor:"rgba(0, 0, 0, 0.5)"},onClick:()=>t(!1)}),m.jsx("div",{className:"pds2-relative pds2-bg-bg-white pds2-rounded-t-24 pds2-w-full",style:{height:"75%",maxHeight:"600px",overflowY:"auto"},children:n})]}):null,QD=()=>{const e=T(n=>n.screen);switch(e[e.length-1]){case ve.LOGIN_WITH_ABHA:return m.jsx(VD,{});case ve.VERIFY_OTP_LOGIN_WITH_ABHA:return m.jsx(xD,{});case ve.CREATE_ABHA_WITH_AADHAAR:return m.jsx(CD,{});case ve.ABHA_OTP_AND_MOBILE:return m.jsx(OD,{});case ve.ABHA_PHONE_NUMBER_VERIFICATION:return m.jsx(PD,{});case ve.AADHAAR_VERIFICATION_STATUS:return m.jsx(jC,{});case ve.ABHA_MOBILE_LINKING_STATUS:return m.jsx(bD,{});case ve.SELECT_ABHA_FROM_LIST:return m.jsx(WD,{});case ve.SELECT_EKA_PROFILE:return m.jsx(GD,{});case ve.CREATE_ABHA_ADDRESS:return m.jsx(LD,{});case ve.CREATE_EKA_PROFILE:return m.jsx(fy,{});case ve.CREATE_PHR_EKA_PROFILE:return m.jsx(fy,{});case ve.GET_ALL_PROFILES:return m.jsx($D,{});case ve.LOGIN_OR_CREATE_ABHA:return m.jsx(KD,{});default:return m.jsx(m.Fragment,{})}},Ci=new hC;function XD(){return p.useEffect(()=>()=>{jt()},[]),m.jsx(wC,{client:Ci,children:m.jsx("div",{className:"pds2-h-full pds2-w-full pds2-bg-darwin-neutral-0",style:{position:"relative",height:"100vh",overflowY:"auto"},children:m.jsx(QD,{})})})}let to=null,jt,bn;function JD(e){var A;console.log("clear the abha auth store for every sdk invocation",e),T.getState().clearAbhaAuthStore();const{clientId:t,containerId:n,urlParams:r,method:a,data:i,appVersion:s,onSuccess:o,onError:l,onAbhaClose:u}=e,{mobile:c,accessToken:d,oid:f,env:w}=i||{},x={};d&&(x.auth=d),f&&(x["X-User-ID"]=f),console.log("set headers in headers"),console.log("invoked initAbhaApp",x);const v=x!==null&&("auth"in x||"X-User-ID"in x);T.getState().setIsEkaAppLogin(v),t==="doc-web"&&T.getState().setIsEkaAppLogin(!0),console.log("clientId ",t),console.log("isEkaAppLogin",T.getState().isEkaAppLogin),t==="androiddoc"||t==="doctor-app-ios"||t==="doctor-ipad-ios"||t==="doc-web"?T.getState().setClientId("doctor"):t==="androidp"||t==="patient-app-ios"?T.getState().setClientId("phr"):t==="www-eka"?T.getState().setClientId("eka-web"):(console.log("here"),T.getState().setClientId("phr"));let _=!1;Qe({eventName:"init_abha_app",eventData:{platform:t,method:a||"",mobile:c||"",accessToken:d||"",oid:f||"",appVersion:s||"",isEkaAppLogin:v.toString(),container_id:n}}),ZD("init_abha_app",{platform:t,method:a||"",mobile:c||"",accessToken:x.auth||"",oid:x["X-User-ID"]||"",appVersion:s||"",isEkaAppLogin:v.toString(),container_id:n}),(t==="androiddoc"||t==="doctor-app-ios"||t==="doctor-ipad-ios"||t==="doc-web")&&(_=!0,T.getState().setIsDocAppRequest(_)),T.getState().setInitAbhaAppMethod(a==="create_abha_with_mobile"?"create_abha_with_mobile":"login_with_abha"),Ob({clientId:t,env:w==="DEV"?"DEV":"PROD",...x&&{extraHeaders:x}});const h=ve.LOGIN_OR_CREATE_ABHA;T.getState().setInitState({screen:[h],urlParams:r}),T.getState().setAbhaAuthFlowMethod(X.MOBILE);const g=/[^0-9]/g,y=c||((A=window.EkaAbha)==null?void 0:A.mobileNumber),E=y==null?void 0:y.replace(g,""),R=E==null?void 0:E.slice(-10);R&&R.length===10&&T.getState().setInitAbhaAppMobileNumber(R);const C=()=>{T.getState().clearAbhaAuthStore(),Ci.removeQueries(),to==null||to.unmount(),u()},k=document.getElementById(n);if(!k){const B=`Element with id ${n} not found`;console.error(B),l({error:B}),C();return}return bn=o,to=B2(k),to.render(m.jsx(XD,{})),jt=C,window.closeAbhaApp=C,C}window.initAbhaApp=JD;function ZD(e,t={}){var a;const n=T.getState().clientId||"unknown-platform",r={...t,platform:n};console.log("Tracking Event:",e,r),(a=window.curio)!=null&&a.pushToMixpanel?(console.log("Pushing to Mixpanel:",e,r),window.curio.pushToMixpanel(e,r)):(console.log("Curio not available. Queuing event:",e,r),console.error("Curio not available. Could not push event to Mixpanel."))}
136
+ pds2-transition-colors`,children:[m.jsx("input",{type:"radio",name:"ekaProfile",value:D.oid,checked:M,onChange:()=>$({profile:D}),className:"pds2-self-start pds2-mt-4 pds2-w-14 pds2-h-14"}),m.jsxs("div",{className:"pds2-flex pds2-flex-row pds2-items-center pds2-gap-x-8 pds2-flex-1",children:[m.jsx("div",{className:"TitlesSubheadline pds2-text-text-primary",children:D.fln}),m.jsx("span",{className:"pds2-ml-auto pds2-text-text-brand pds2-text-14 pds2-font-600",children:"Link"})]})]},D.oid)})}),m.jsx(Hc,{title:"or"}),m.jsx(gi,{title:"Create new Family Member",prefixIcon:m.jsx(iw,{}),className:"pds2-justify-center pds2-text-text-brand pds2-border-bg-fab-bg-brand-04 Body1Semibold",onClick:B})]})]}),m.jsxs("div",{className:"pds2-sticky pds2-bottom-0 pds2-left-0 pds2-right-0 pds2-bg-bg-white pds2-shadow-lg pds2-p-16",children:[f&&m.jsx("div",{className:"pds2-text-text-error pds2-text-center pds2-mb-8",children:f}),m.jsx(dn,{title:"Continue",state:a===null||l===q.LOADING?"disabled":"enabled",isLoading:l===q.LOADING,className:"pds2-w-full",onClick:F})]})]}),m.jsx(Xr,{onSubmitClick:H}),m.jsx(ml,{open:c,setOpen:d})]})},KD=()=>{const e=T(r=>r.clientId);p.useEffect(()=>{var r;if((r=window.EkaAbha)!=null&&r.changeStatusBarColor)return window.EkaAbha.changeStatusBarColor("#F2F4F7"),()=>{var a,i;(a=window.EkaAbha)!=null&&a.changeStatusBarColor&&((i=window==null?void 0:window.EkaAbha)==null||i.changeStatusBarColor("#FFFFFF"))}},[]);const t=()=>{var r;(r=window.EkaAbha)==null||r.onAbhaClose(),jt()},n=["eka-web","phr"];return m.jsxs("div",{className:"pds2-bg-bg-01 pds2-pt-36",children:[!n.includes(e)&&m.jsx(Ta,{prefixIcon:m.jsx("button",{onClick:t,children:m.jsx(Gr,{})}),title:"",className:"pds2-bg-bg-01"}),m.jsx(qD,{})]})},qD=()=>{const e=T(J=>J.abhaAuthFlowMethod||X.MOBILE),t=T(J=>J.setAbhaAuthFlowMethod),[n,r]=p.useState(""),[a,i]=p.useState(q.IDLE),s=T(J=>J.isEkaAppLogin),[o,l]=p.useState(""),u=T(J=>J.setSelectedAbhaAddress),c=T(J=>J.setLoginIdentifierValue),d=T(J=>J.setScreen),[f,w]=p.useState({aadhaar:q.IDLE,mobile:q.IDLE}),x=T(J=>J.setRegistrationType),v=T(J=>J.setAadhaarInitResponse),_=T(J=>J.setMobileInitResponse),h=T(J=>J.initAbhaAppMobileNumber),[g,y]=p.useState(""),[E,R]=p.useState(!1),[C,k]=p.useState(!1),[A,B]=p.useState(""),[$,F]=p.useState(""),[H,I]=p.useState(""),D=T(J=>J.isNewLoginOrCreateFlow),M=T(J=>J.setIsNewLoginOrCreateFlow),O=T(J=>J.clientId),P=p.useRef(!1),b=T(J=>J.isInitApiTriggered),L=T(J=>J.setIsInitApiTriggered),N=T(J=>J.setIdentityValue);T(J=>J.identityValue);const z=Vn(),W=T(J=>J.setSelectedAbhaFlow),S=T(J=>J.isDocAppRequest),U=T(J=>J.txnId);p.useEffect(()=>{j({name:"abha_login_or_create_screen",data:{flow:e.toString()}})}),p.useEffect(()=>{if(h&&e===X.MOBILE){r(h),R(h.length===10),l(null);return}r(""),l(null),R(!1)},[e]),p.useEffect(()=>{b||P.current||g&&g.length===10&&(L(!0),P.current=!0,oe("auto_submit_mobile"))},[g]),p.useEffect(()=>{b||P.current||A&&A.length===12&&(L(!0),P.current=!0,oe("auto_submit_aadhaar"))},[A]);const j=({name:J,data:Y={}})=>{var Se,qe;const Ce={...{login_platform:O,is_eka_app_login:s?"true":"false",is_new_login_or_create_flow:D?"true":"false",oid:z!=null&&z["X-User-ID"]?"true":"false",access_token:z!=null&&z.auth?"true":"false",txn_id:U||"missing txnId",flow:e??""},...Y};Qe({eventName:J,eventData:Ce}),(qe=(Se=window.curio)==null?void 0:Se.pushToMixpanel)==null||qe.call(Se,J,Ce)},K=Ie.useMemo(()=>{switch(e){case X.MOBILE:return"Enter your Mobile Number";case X.AADHAR_NUMBER:return"Enter your Aadhaar Number";default:return""}},[e]),ee=J=>{const Y=J.target.value;switch(e){case X.PHR_ADDRESS:if(Y.length>20)return;I(Y),r(Y);break;case X.MOBILE:if(Y&&!/^[0-9]+$/.test(Y)||Y.length>10)return;y(Y),R(!0),r(Y);break;case X.ABHA_NUMBER:if(!/^[\d-]*$/.test(Y)||Y.length>17)return;const Z=J.target.value.replace(/-/g,"");let Ce="";return Z.length>0&&(Ce+=Z.slice(0,2)),Z.length>2&&(Ce+=`-${Z.slice(2,6)}`),Z.length>6&&(Ce+=`-${Z.slice(6,10)}`),Z.length>10&&(Ce+=`-${Z.slice(10,14)}`),F(Ce),r(Ce.trim());case X.AADHAR_NUMBER:if(Y&&!/^[0-9]+$/.test(Y)||Y.length>12)return;B(Y),k(!0),r(Y);break}r(Y.trim())},fe=e===X.MOBILE&&!!h,re=Ie.useMemo(()=>{switch(e){case X.PHR_ADDRESS:return n.length>=4&&n.length<=20;case X.MOBILE:return n.length===10;case X.ABHA_NUMBER:return n.length===17;case X.AADHAR_NUMBER:return n.length===12}},[e,n]),ue=(J,Y)=>{w(Z=>({...Z,[J]:Y}))},he=({inputVal:J})=>{J.length===12&&(r(J),B(J),k(!0))};p.useEffect(()=>{console.log("selectedMethod changed:==================>",e)},[e]);const oe=async J=>{var Ce,Se,qe;M(!0),j({name:"abha_login_next_click",data:{flow_step_type:J}}),i(q.LOADING),x(Ln.LOGIN);let Y="";if(!s){const ke=await nh();j({name:ke?"abha_logout_success":"abha_logout_failure",data:{platform:O}});const{txn_id:Pe,error:$e}=await eh({method:tl.ABHA});if(!Pe||$e){j({name:"abha_auth_init_failure",data:{flow_step_type:"init",authTxnId:Y,error_message:$e||"missing_txnId_or_unknown_error",error_message_exists:!!$e,txn_id_exists:!!Pe}}),l(($e==null?void 0:$e.message)||"Something went wrong. Please try again."),i(q.REJECTED);return}Y=Pe,j({name:"abha_auth_init_success.",data:{flow_step_type:"init",auth_txnId:Y}})}const Z=e===X.PHR_ADDRESS?`${n}${No()}`:n;if(e===X.MOBILE||e===X.ABHA_NUMBER||e===X.PHR_ADDRESS){const{txn_id:ke,error:Pe,action:$e,hint:Ge}=await rh({method:e,identifier:Z});if(N(Z),j({name:"abha_login_init_triggered",data:{flow_step_type:"init",authTxnId:Y,ndhmTxnId:ke,method:e}}),e===X.PHR_ADDRESS&&u(Z),Pe||!ke){if(((Ce=$e==null?void 0:$e.cta)==null?void 0:Ce.pid)==="abha_mobile_enroll"){ue("mobile",q.LOADING),x(Ln.CREATE);const{txn_id:_t,hint:mt,error:Tt,action:Et}=await ih({mobile_number:n});if(N(n),W("mobile"),_t&&mt){_({authTxnId:Y,txnId:_t,mobileOtpSentToHint:mt}),j({name:"abha_mobile_registration_init_success",data:{flow_step_type:"init",authTxnId:Y,ndhmTxnId:ke,error_message:Tt,error_action:$e}}),ue("mobile",q.RESOLVED),i(q.RESOLVED),x(Ln.CREATE),d(ve.ABHA_PHONE_NUMBER_VERIFICATION);return}if(ue("mobile",q.REJECTED),j({name:"abha_mobile_registration_init_failure",data:{flow_step_type:"init",authTxnId:Y,error_message:Tt||"unknown_error",error_message_exists:!!Tt,error_action_exists:!!Et}}),Et){if((Se=Et==null?void 0:Et.cta)!=null&&Se.pid)return d(ve.LOGIN_OR_CREATE_ABHA)}else l(Tt||"Something went wrong");l(Tt||"Something went wrong. Please try again."),i(q.REJECTED);return}j({name:"abha_login_init_failure",data:{flow_step_type:"init",authTxnId:Y,error_message:Pe||"unknown_error",error_message_exists:!!Pe,error_action_exists:!!$e}}),l(Pe||"Something went wrong. Please try again."),i(q.REJECTED);return}j({name:"abha_login_init_success",data:{flow_step_type:"init",authTxnId:Y,ndhmTxnId:ke,hint:Ge}}),v({authTxnId:Y,txnId:ke,aadhaarOtpSentToHint:Ge||null}),c(Z),i(q.RESOLVED),d(ve.VERIFY_OTP_LOGIN_WITH_ABHA);return}if(e===X.AADHAR_NUMBER){ue("aadhaar",q.LOADING),j({name:"aadhaar_registration_init_start",data:{flow_step_type:"init",authTxnId:Y,aadhaarNumber:n}});const{txn_id:ke,hint:Pe,error:$e,action:Ge}=await ah({aadhaar_number:n});if(N(n),W("aadhaar"),ke&&Pe){v({authTxnId:Y,txnId:ke,aadhaarOtpSentToHint:Pe}),j({name:"aadhaar_registration_init_success",data:{flow_step_type:"verify",ndhmTxnId:ke,authTxnId:Y}}),ue("aadhaar",q.RESOLVED),x(Ln.CREATE),i(q.RESOLVED),d(ve.ABHA_OTP_AND_MOBILE);return}if(j({name:"abha_registration_init_failure",data:{error_message:$e||"unknown_error",error_message_exists:!!$e,auth_txn_id:Y,error_action:Ge,error_action_exists:!!Ge}}),ue("aadhaar",q.REJECTED),i(q.REJECTED),Ge||$e){(qe=Ge==null?void 0:Ge.cta)!=null&&qe.pid?d(ve.LOGIN_OR_CREATE_ABHA):l($e||"Something went wrong");return}}},[le,ge]=p.useState(!1),[ne,ye]=p.useState(!1),[He,be]=p.useState(!1);return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"pds2-p-16 pds2-bg-bg-01 pds2-space-y-16 pds2-text-center",children:[m.jsx("div",{className:"pds2-flex pds2-justify-center pds2-items-center pds2-gap-16",children:m.jsx("div",{className:"pds2-bg-bg-white pds2-rounded-16",children:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"abha",className:"pds2-w-64 pds2-h-64"})})}),m.jsx("div",{className:"Heading3Semibold pds2-text-text-black",children:O==="phr"?"Login or Create your ABHA":S?"Add Patient via ABHA":"Create your ABHA"}),m.jsx("div",{className:"pds2-text-text-03",style:{marginTop:"4px"},children:e===X.MOBILE?"Enter your Mobile Number":e===X.AADHAR_NUMBER?"Enter your Aadhaar Number":e===X.ABHA_NUMBER?"Enter your ABHA Number":e===X.PHR_ADDRESS?"Enter your ABHA Address":K}),(e===X.MOBILE||e===X.AADHAR_NUMBER)&&m.jsxs("div",{className:"pds2-flex pds2-mt-4 pds2-bg-bg-02 pds2-rounded-lg pds2-overflow-hidden pds2-p-1",children:[m.jsxs("button",{onClick:()=>t(X.MOBILE),className:`pds2-flex-1 pds2-py-3 pds2-flex pds2-items-center pds2-justify-center pds2-gap-8 pds2-relative ${e===X.MOBILE?"pds2-bg-bg-white":"pds2-bg-bg-seperator-dark"}`,style:{clipPath:"polygon(8px 0%, calc(100% - 8px) 0%, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0% calc(100% - 8px), 0% 8px)"},children:[m.jsx(Sc,{className:"pds2-w-14 pds2-h-14 pds2-text-icon-success-02"}),m.jsx("span",{className:`pds2-text-base ${e===X.MOBILE?"pds2-font-bold pds2-text-fg-default":"pds2-font-normal pds2-text-fg-subtle"}`,style:e===X.MOBILE?{fontWeight:700}:{fontWeight:400},children:"Mobile"})]}),m.jsxs("button",{onClick:()=>t(X.AADHAR_NUMBER),className:`pds2-flex-1 pds2-py-3 pds2-flex pds2-items-center pds2-justify-center pds2-gap-8 pds2-relative pds2-ml-1 ${e===X.AADHAR_NUMBER?"pds2-bg-bg-white":"pds2-bg-bg-seperator-dark"}`,style:{clipPath:"polygon(8px 0%, calc(100% - 8px) 0%, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 0% calc(100% - 8px), 0% 8px)"},children:[m.jsx("img",{src:"https://cdn.eka.care/vagus/cm5mcdm3h00070tfs9fjkepff.webp",alt:"Aadhaar",className:"pds2-w-24 pds2-h-24"}),m.jsx("span",{className:`pds2-text-base ${e===X.AADHAR_NUMBER?"pds2-font-bold pds2-text-fg-default":"pds2-font-normal pds2-text-fg-subtle"}`,style:e===X.AADHAR_NUMBER?{fontWeight:700}:{fontWeight:400},children:"Aadhaar"})]})]}),(e===X.MOBILE||e===X.AADHAR_NUMBER)&&m.jsx("div",{className:"pds2-mt-16 pds2-w-full pds2-max-w-md pds2-mx-auto pds2-px-4 pds2-relative",children:e===X.AADHAR_NUMBER?m.jsx(jc,{numberOfInputs:3,length:4,placeholder:"XXXX",onSubmit:he,setIsValid:k}):m.jsx(Hr,{value:n,onChange:ee,type:"tel",placeholder:"Mobile Number",disabled:fe,inputMode:"numeric",autoFocus:!0,maxLength:10,PrefixComponent:m.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-x-8 pds2-border-r pds2-border-border-brand-02 pds2-pr-24",children:[m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4mlct2900000tg98p8u967s.webp",alt:"India Flag",className:"pds2-w-24 pds2-h-24"}),m.jsx("span",{className:"pds2-text-text-black pds2-text-sm",children:"+91"})]})})}),o&&m.jsx("div",{className:"pds2-text-text-error Body3Regular",children:o}),(e===X.MOBILE||e===X.AADHAR_NUMBER)&&m.jsx(dn,{title:"Next",IconComponent:()=>m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!re||a===q.LOADING?"disabled":"enabled",isLoading:a===q.LOADING,onClick:()=>oe("aadhaar_or_mobile_on_click"),className:"pds2-w-full"})]}),m.jsx("div",{className:"pds2-mt-24 pds2-mx-16 pds2-mb-48 pds2-pb-36",children:m.jsxs("div",{className:"pds2-bg-bg-white pds2-rounded-16 pds2-border pds2-border-border-03 pds2-overflow-hidden",children:[m.jsxs("button",{onClick:()=>ge(!le),className:"pds2-w-full pds2-flex pds2-items-center pds2-justify-between pds2-p-16 pds2-bg-bg-white hover:pds2-bg-bg-02 pds2-transition-colors",children:[m.jsx("span",{className:"pds2-text-text-03",children:"Other login options for ABHA"}),m.jsx(Pr,{className:`pds2-w-16 pds2-h-16 pds2-text-text-03 pds2-transition-transform ${le?"pds2-rotate-180":""}`})]}),le&&m.jsxs("div",{children:[m.jsxs("button",{onClick:()=>{ge(!1),t(X.ABHA_NUMBER),ye(!0)},className:"pds2-w-full pds2-flex pds2-items-center pds2-justify-between pds2-p-12 hover:pds2-bg-bg-02 pds2-transition-colors",children:[m.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-12",children:[m.jsx("div",{className:"pds2-w-40 pds2-h-40 pds2-rounded-full pds2-bg-bg-02 pds2-flex pds2-items-center pds2-justify-center",children:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA",className:"pds2-w-24 pds2-h-24"})}),m.jsx("span",{className:"Body1Regular pds2-text-text-black",children:"Login with ABHA Number"})]}),m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-text-text-03"})]}),m.jsxs("button",{onClick:()=>{ge(!1),t(X.PHR_ADDRESS),be(!0)},className:"pds2-w-full pds2-flex pds2-items-center pds2-justify-between pds2-p-12 hover:pds2-bg-bg-02 pds2-transition-colors",children:[m.jsxs("div",{className:"pds2-flex pds2-items-center pds2-gap-12",children:[m.jsx("div",{className:"pds2-w-40 pds2-h-40 pds2-rounded-full pds2-bg-bg-02 pds2-flex pds2-items-center pds2-justify-center",children:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA",className:"pds2-w-24 pds2-h-24"})}),m.jsx("span",{className:"Body1Regular pds2-text-text-black",children:"Login with ABHA Address"})]}),m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-text-text-03"})]})]})]})}),m.jsx(py,{isOpen:ne,setIsOpen:ye,children:m.jsxs("div",{className:"pds2-p-24 pds2-text-center pds2-h-full pds2-flex pds2-flex-col",children:[m.jsx("div",{className:"pds2-flex pds2-justify-end pds2-mb-16",children:m.jsx("button",{onClick:()=>{ye(!1),t(X.MOBILE)},className:"pds2-w-24 pds2-h-24 pds2-flex pds2-items-center pds2-justify-center pds2-text-text-03 hover:pds2-text-text-black",children:"✕"})}),m.jsxs("div",{className:"pds2-flex-1 pds2-flex pds2-flex-col pds2-justify-start",children:[m.jsx("div",{className:"pds2-flex pds2-justify-center pds2-mb-16",children:m.jsx("div",{className:"pds2-w-64 pds2-h-64 pds2-rounded-full pds2-bg-bg-01 pds2-flex pds2-items-center pds2-justify-center",children:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA Logo",className:"pds2-w-48 pds2-h-48"})})}),m.jsx("h2",{className:"Heading3Semibold pds2-text-text-black",children:"Login with ABHA Number"}),m.jsx("p",{className:"Body2Regular pds2-text-text-03 pds2-mb-24",children:"Enter your 14 digit ABHA Number"}),m.jsx("div",{className:"pds2-mb-24",children:m.jsx(Hr,{value:n,onChange:ee,placeholder:"00-0000-0000-0000",padding:"pds2-p-18",textStyle:"Body2Regular pds2-text-center pds2-text-lg",borderStyle:"focus-within:pds2-border-border-brand-01",type:"tel",inputMode:"numeric",autoFocus:!0})}),o&&m.jsx("div",{className:"pds2-text-text-error Body3Regular",children:o}),m.jsx(dn,{title:"Next",IconComponent:()=>m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!n||a===q.LOADING?"disabled":"enabled",onClick:()=>oe("after_enter_abha_number_on_click_by_user"),className:"pds2-w-full",isLoading:a===q.LOADING})]})]})}),m.jsx(py,{isOpen:He,setIsOpen:be,children:m.jsxs("div",{className:"pds2-p-24 pds2-text-center pds2-h-full pds2-flex pds2-flex-col",children:[m.jsx("div",{className:"pds2-flex pds2-justify-end pds2-mb-16",children:m.jsx("button",{onClick:()=>{be(!1),t(X.MOBILE)},className:"pds2-w-24 pds2-h-24 pds2-flex pds2-items-center pds2-justify-center pds2-text-text-03 hover:pds2-text-text-black",children:"✕"})}),m.jsxs("div",{className:"pds2-flex-1 pds2-flex pds2-flex-col pds2-justify-start",children:[m.jsx("div",{className:"pds2-flex pds2-justify-center pds2-mb-16",children:m.jsx("div",{className:"pds2-w-64 pds2-h-64 pds2-rounded-full pds2-bg-bg-01 pds2-flex pds2-items-center pds2-justify-center",children:m.jsx("img",{src:"https://cdn.eka.care/vagus/cm4ml1lwu00000tfs1okl7hs9.webp",alt:"ABHA Logo",className:"pds2-w-48 pds2-h-48"})})}),m.jsx("h2",{className:"Heading3Semibold pds2-text-text-black",children:"Login with ABHA Address"}),m.jsx("p",{className:"Body2Regular pds2-text-text-03 pds2-mb-24",children:"Enter your ABHA Address below"}),m.jsxs("div",{className:"pds2-mb-24 pds2-relative",children:[m.jsx(Hr,{value:n,onChange:ee,placeholder:"Enter ABHA Address",inputMode:"text",autoFocus:!0}),m.jsx("div",{className:"pds2-absolute pds2-right-16 pds2-top-16 Body1Regular pds2-text-text-03",children:No()})]}),o&&m.jsx("div",{className:"pds2-text-text-error Body3Regular",children:o}),m.jsx(dn,{title:"Next",IconComponent:()=>m.jsx(Pr,{className:"pds2-w-16 pds2-h-16 -pds2-rotate-90 pds2-ml-8"}),state:!n||a===q.LOADING?"disabled":"enabled",onClick:()=>oe("after_enter_abha_address_on_click_by_user"),className:"pds2-w-full",isLoading:a===q.LOADING})]})]})})]})},py=({isOpen:e,setIsOpen:t,children:n,overlayClassName:r="pds2-bg-text-black pds2-bg-opacity-50"})=>e?m.jsxs("div",{className:"pds2-absolute pds2-inset-0 pds2-z-50 pds2-flex pds2-items-end",children:[m.jsx("div",{className:`pds2-absolute pds2-inset-0 ${r}`,style:{backgroundColor:"rgba(0, 0, 0, 0.5)"},onClick:()=>t(!1)}),m.jsx("div",{className:"pds2-relative pds2-bg-bg-white pds2-rounded-t-24 pds2-w-full",style:{height:"75%",maxHeight:"600px",overflowY:"auto"},children:n})]}):null,QD=()=>{const e=T(n=>n.screen);switch(e[e.length-1]){case ve.LOGIN_WITH_ABHA:return m.jsx(VD,{});case ve.VERIFY_OTP_LOGIN_WITH_ABHA:return m.jsx(xD,{});case ve.CREATE_ABHA_WITH_AADHAAR:return m.jsx(CD,{});case ve.ABHA_OTP_AND_MOBILE:return m.jsx(OD,{});case ve.ABHA_PHONE_NUMBER_VERIFICATION:return m.jsx(PD,{});case ve.AADHAAR_VERIFICATION_STATUS:return m.jsx(jC,{});case ve.ABHA_MOBILE_LINKING_STATUS:return m.jsx(bD,{});case ve.SELECT_ABHA_FROM_LIST:return m.jsx(WD,{});case ve.SELECT_EKA_PROFILE:return m.jsx(GD,{});case ve.CREATE_ABHA_ADDRESS:return m.jsx(LD,{});case ve.CREATE_EKA_PROFILE:return m.jsx(fy,{});case ve.CREATE_PHR_EKA_PROFILE:return m.jsx(fy,{});case ve.GET_ALL_PROFILES:return m.jsx($D,{});case ve.LOGIN_OR_CREATE_ABHA:return m.jsx(KD,{});default:return m.jsx(m.Fragment,{})}},Ci=new hC;function XD(){return p.useEffect(()=>()=>{jt()},[]),m.jsx(wC,{client:Ci,children:m.jsx("div",{className:"pds2-h-full pds2-w-full pds2-bg-darwin-neutral-0",style:{position:"relative",height:"100vh",overflowY:"auto"},children:m.jsx(QD,{})})})}let to=null,jt,bn;function JD(e){var A;console.log("clear the abha auth store for every sdk invocation",e),T.getState().clearAbhaAuthStore();const{clientId:t,containerId:n,urlParams:r,method:a,data:i,appVersion:s,onSuccess:o,onError:l,onAbhaClose:u}=e,{mobile:c,accessToken:d,oid:f,env:w}=i||{},x={};d&&(x.auth=d),f&&(x["X-User-ID"]=f),console.log("set headers in headers"),console.log("invoked initAbhaApp",x);const v=x!==null&&("auth"in x||"X-User-ID"in x);T.getState().setIsEkaAppLogin(v),t==="doc-web"&&T.getState().setIsEkaAppLogin(!0),console.log("clientId ",t),console.log("isEkaAppLogin",T.getState().isEkaAppLogin),t==="androiddoc"||t==="doctor-app-ios"||t==="doctor-ipad-ios"||t==="doc-web"?T.getState().setClientId("doctor"):t==="androidp"||t==="patient-app-ios"?T.getState().setClientId("phr"):t==="www-eka"?T.getState().setClientId("eka-web"):(console.log("here"),T.getState().setClientId("phr"));let _=!1;Qe({eventName:"init_abha_app",eventData:{platform:t,method:a||"",mobile:c||"",accessToken:d||"",oid:f||"",appVersion:s||"",isEkaAppLogin:v.toString(),container_id:n}}),ZD("init_abha_app",{platform:t,method:a||"",mobile:c||"",accessToken:x.auth||"",oid:x["X-User-ID"]||"",appVersion:s||"",isEkaAppLogin:v.toString(),container_id:n}),(t==="androiddoc"||t==="doctor-app-ios"||t==="doctor-ipad-ios"||t==="doc-web")&&(_=!0,T.getState().setIsDocAppRequest(_)),T.getState().setInitAbhaAppMethod(a==="create_abha_with_mobile"?"create_abha_with_mobile":"login_with_abha"),Ob({clientId:t,env:w==="DEV"?"DEV":"PROD",...x&&{extraHeaders:x}});const h=ve.LOGIN_OR_CREATE_ABHA;T.getState().setInitState({screen:[h],urlParams:r}),T.getState().setAbhaAuthFlowMethod(X.MOBILE);const g=/[^0-9]/g,y=c||((A=window.EkaAbha)==null?void 0:A.mobileNumber),E=y==null?void 0:y.replace(g,""),R=E==null?void 0:E.slice(-10);R&&R.length===10&&T.getState().setInitAbhaAppMobileNumber(R);const C=()=>{T.getState().clearAbhaAuthStore(),Ci.removeQueries(),to==null||to.unmount(),u()},k=document.getElementById(n);if(!k){const B=`Element with id ${n} not found`;console.error(B),l({error:B}),C();return}return bn=o,to=B2(k),to.render(m.jsx(XD,{})),jt=C,window.closeAbhaApp=C,C}window.initAbhaApp=JD;function ZD(e,t={}){var a;const n=T.getState().clientId||"unknown-platform",r={...t,platform:n};console.log("Tracking Event:",e,r),(a=window.curio)!=null&&a.pushToMixpanel?(console.log("Pushing to Mixpanel:",e,r),window.curio.pushToMixpanel(e,r)):(console.log("Curio not available. Queuing event:",e,r),console.error("Curio not available. Could not push event to Mixpanel."))}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eka-care/abha",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "VITE_APP_MODE=DEBUG vite",