import{r as l,t as z,x as G,q as K,af as y,c as $,z as X,bA as J,y as P,a as Q,f5 as Z,j as t,b5 as ee,b1 as te,n as se,L as ae,dn as re,f6 as ne,f7 as ie,f8 as oe,B as C,T as L,V as le,cV as ce,Y as de,bi as ue,an as me,cc as S,dp as ge,eD as he,f9 as pe,fa as fe,fb as ye,bI as be,fc as xe,fd as _e,f4 as Ne,cj as ve,fe as Te}from"./index-CNnTZTc7.js";import{L as I}from"./index-DHW9g59_.js";import{G as Ae}from"./getTrustedformCertURL-D1EGlseA.js";const Pe="_alreadyRegistered_g300g_88",Ce="_bannerWithBackgroundColorHeader_g300g_94",Le="_disclaimer_g300g_98",Se="_HealthDisclaimer_g300g_112",Ie="_createAccountContent_g300g_116",ke="_body3_g300g_134",je="_lastUpdated_g300g_139",we="_heading5_g300g_145",Be="_modalAlreadyRegistered_g300g_150",Fe="_modalHeading5_g300g_156",Ee="_modalText_g300g_161",De="_modalTextAsLink_g300g_167",Re="_modalSubmitButton_g300g_172",qe="_terms_g300g_176",He="_fieldsRequired_g300g_182",Me="_requiredText_g300g_187",Ue="_textAsLink_g300g_192",Oe="_submitButtonContainer_g300g_196",Ve="_submitButton_g300g_196",s={alreadyRegistered:Pe,bannerWithBackgroundColorHeader:Ce,disclaimer:Le,HealthDisclaimer:Se,createAccountContent:Ie,body3:ke,lastUpdated:je,heading5:we,modalAlreadyRegistered:Be,modalHeading5:Fe,modalText:Ee,modalTextAsLink:De,modalSubmitButton:Re,terms:qe,fieldsRequired:He,requiredText:Me,textAsLink:Ue,submitButtonContainer:Oe,submitButton:Ve},Ge=l.forwardRef(({isModal:i=!1},k)=>{const{formState:{errors:c,isDirty:j},handleSubmit:w,register:d,setError:g}=z(),b=G(),B=K(),h=new URLSearchParams(window.location.search),[r]=l.useState(y(ue)),[F,x]=l.useState(!1),[p,_]=l.useState(""),{Post:E}=$("https://ae-api.medicarecenter.com/ae-consumer-service/api/v1.0/Account/Register",!0),{zipCode:N,county:u,state:D,counties:R}=l.useContext(X),{purlAgentData:a}=l.useContext(J),q=P(e=>e.planTypeDetail.selectedPlanType),{selectedSubSidyLevelOption:v}=P(e=>e.medicaidDetails),{loginWithRedirect:H,isAuthenticated:M}=Q();Z();const U=async()=>{try{await H(),me()}catch(e){console.error("sign in error: ",e)}},O=async e=>{var T;S("create_account_submit"),x(!0);const f=await ge(e==null?void 0:e.email);let m=!0;((T=f==null?void 0:f.email)==null?void 0:T.status)==="invalid"&&(g("email",{type:"pattern"}),m=!1),(e==null?void 0:e.firstName.length)<2&&(g("firstName",{type:"pattern"}),m=!1),(e==null?void 0:e.lastName.length)<2&&(g("lastName",{type:"pattern"}),m=!1),e.zip=N||"",e.county=u||"",e.phone="",e.leadIdGuid=he(),e.dateOfBirth=r!=null&&r.dateOfBirth?new Date(r.dateOfBirth):null,e.hasMedicAid=null;const W=Ae();if(e.trustedformUrl=W,e.subsidyLevel=v?pe[v]:fe,r&&(e.height=Number(r.heightInFT)*12+Number(r.heightIn),e.weight=r.weight?Number(r.weight):0,e.gender=r.gender,e.isTobaccoUser=r.tobaccoUse==="Yes",e.productType=q),a){const n=a==null?void 0:a.virtualNumber,o=n==null?void 0:n.substring(2);e.Purl=a.agentPurlCode,e.agentNPN=a.agentNpn,e.AgentPhoneNumber=o,e.isMedicareAgent=a.isMedicareAgent,e.isFinalExpenseAgent=a.isFinalExpenseAgent}const Y=a?{agentPurlCode:a.agentPurlCode,agentNPN:a.agentNpn,agentLastName:a.agentLastName,agentFirstName:a.agentFirstName,agentMiddleName:a.agentMiddleName,isPurlToggledOn:a.isPurlToggledOn,email:a.email,virtualNumber:a.virtualNumber,caLicense:a.caLicense}:{};if(e.agentPurlDetails=Y,N&&u&&(e.countyFips=u,e.statecode=D,R.forEach(n=>{n.countyFIPS===u&&(e.county=n.countyName)})),m){const n=await E(e,!0),o=await ye(n);if(n.status>=200&&n.status<300){const A=y(be,[]);A.length>0&&await xe({consumerId:o.consumerId,authToken:"",stateCode:y(_e),healthConditionData:A,leadId:o.leadId}),S("create_account_submit"),localStorage.setItem("verifyEmail",e.email),localStorage.setItem("verifyEmailUserId",o.userId),i&&b(Ne(!1)),i&&b(ve()),B.push(Te,{email:e.email,userId:o.userId})}else _(o.value)}x(!1)};function V(){document.getElementById("modalSubmitButton").click()}return l.useImperativeHandle(k,()=>({formSubmit:V})),t.jsxs(t.Fragment,{children:[t.jsxs("form",{onSubmit:w(e=>O(e)),id:"theForm",children:[t.jsx(ee,{}),t.jsxs("div",{className:s.createAccountContent,children:[p&&p.length>0&&j?t.jsx(te,{severity:"success",text:p.replace("User Name already Exists","Email address already in use"),onClose:()=>_("")}):null,t.jsx(se,{id:"firstName",register:d,required:!0,defaultValue:h.get("first_name")||"",autoFocus:!0,error:c.firstName,labelText:"First Name",disablePattern:!0}),t.jsx(ae,{defaultValue:h.get("last_name")||"",error:c.lastName,id:"lastName",labelText:"Last Name",register:d,required:!0,disablePattern:!0}),t.jsx(re,{defaultValue:h.get("email")||"",error:c.email,id:"email",labelText:"Email Address",register:d,required:!0}),t.jsx(ne,{error:c.password,id:"password",labelText:"Create a Password",register:d,required:!0}),t.jsx("div",{className:s.disclaimer,children:t.jsxs(t.Fragment,{children:[t.jsx("p",{className:s.HealthDisclaimer,children:"This is a solicitation for insurance and I understand by providing my phone number and information and clicking Complete Profile, I am giving permission to contact me for the purpose of marketing insurance products and services. I also understand I may be contacted by a properly licensed insurance agent who can answer my questions and provide information about Medicare Supplement, Medicare Advantage, Prescription Drug (Part D), or life insurance products and services. The licensed insurance agents who might contact me are not connected with or endorsed by any government agency or program. By completing the contact form above you will be directed to a licensed sales agent who can answer your questions and provide information about Medicare options, such as Medicare Advantage, Prescription Drug (Part D), and Medicare Supplement insurance plans. This is a solicitation for insurance. The communications consented to above include marketing of insurance products. Licensed insurance agents are not connected with or endorsed by the U.S. government or the federal Medicare program. Submitting this form does NOT affect your current enrollment, nor will it enroll you in a Medicare Advantage Plan, Prescription Drug Plan, or other Medicare plan. A Medicare Advantage Plan is a health insurance plan provided through a private insurer and delivers Medicare Part A and Part B benefits. A Part D Drug Plan is a prescription drug insurance plan provided through a private insurer and delivers Medicare Part D benefits."}),t.jsxs("p",{children:["By clicking the Complete Profile button, I expressly consent by electronic signature to receive communications by telephone, by email, or by text message from PlanEnroll at the telephone number above (even if my number is currently listed on any state, federal, local, or corporate Do Not Call list) including my wireless number if provided. Carrier message and data rates may apply. I understand that my consent is not required as a condition of purchasing any goods or services and that I may revoke my consent at any time. I also acknowledge that I have read and agree to the"," ",t.jsx(ie,{className:s.disclaimerLink})," ","and"," ",t.jsx(oe,{className:s.disclaimerLink}),". If you do not want to share your information, please click on Do Not Sell My Information for more details."]})]})}),i&&t.jsxs("div",{className:s.fieldsRequired,children:[t.jsx(C,{className:s.modalSubmitButton,id:"modalSubmitButton",label:"Create Profile",type:"submit"}),t.jsx(L,{className:s.requiredText,id:"requiredText",children:"*All fields required"})]}),!i&&t.jsxs("div",{className:s.submitButtonContainer,children:[t.jsx(C,{className:s.submitButton,disabled:F,label:"Create Profile",type:"submit",id:"submitButton"}),t.jsx(le,{className:s.body3,text:"*All fields required",id:"requiredText"})]})]})]}),!M&&t.jsxs("div",{className:i?s.modalAlreadyRegistered:s.alreadyRegistered,children:[t.jsx(ce,{className:i?s.modalHeading5:s.heading5,text:"Already Registered?",id:"alreadyRegistered"}),t.jsx(de,{className:i?s.modalTextAsLink:s.textAsLink,onClick:U,text:"Sign In",id:"SignInLink"})]}),t.jsx("div",{className:s.terms,children:t.jsxs(L,{className:`${i&&s.modalText}`,children:["By signing up, I agree to"," ",t.jsx(I,{text:"Terms of Services",url:"/terms-of-service",id:"termsOfServicesLink"})," ","and"," ",t.jsx(I,{text:"Privacy Policy",url:"/privacy-notice",id:"privacyPolicyLink"}),"."]})})]})});export{Ge as C}; //# sourceMappingURL=CreateAccountContent-DZGa2EVX.js.map