"use strict";(self.webpackChunkhhgDiscoverV1=self.webpackChunkhhgDiscoverV1||[]).push([[448],{Z0qH:function(e,o,i){i.d(o,{B:function(){return p},F:function(){return _},G:function(){return f},S:function(){return u},a:function(){return fetchSSOV2ApiJson},c:function(){return checkUserExist},f:function(){return fetchSSOV2Api},g:function(){return getUserInfo},h:function(){return handleAuthSuccess},l:function(){return c},r:function(){return resetPassword},u:function(){return updateUserInfo},w:function(){return v}});var t=i("vEfc");if(8068==i.j)var n=i("GOBr");var l=i("8TMT"),r=i("+u84");if(8068==i.j)var d=i("27Mu");var a=i("4BRW");if(8068==i.j)var s=i("xrdX");let u={LOGIN_BY_SOCIAL:"member/social-login",EMAIL:{REGISTER_BY_SEND_OTP:"login/login-with-email",LOGIN_BY_PASSWORD:"member/login",VERIFY_BY_OTP:"login/email-verify-code",SEND_OTP:"login/email-resend-otp-code"},PHONE:{REGISTER_BY_SEND_OTP:"login/login-with-sms",SEND_OTP:"login/sms/sent-otp",VERIFY_BY_OTP:"login/phone-verify-code",LOGIN_BY_PASSWORD:"member/login-by-phone",UPDATE_PHONE_SEND_OTP:"login/sms-social/sent-otp",UPDATE_PHONE_VERIFY_OTP:"login/sms-social/phone-verify-code"},WHATSAPP:{LOGIN_OTP_WHATSAPP:"login/login-otp-whatsapp",REGISTER_BY_SEND_OTP:"login/login-with-whatsapp",SEND_OTP:"login/whatsapp/sent-otp",UPDATE_PHONE_SEND_OTP:"login/sms-social/whatsapp/sent-otp",UPDATE_PHONE_VERIFY_OTP:"login/sms-social/whatsapp-verify-code",VERIFY_BY_OTP:"login/whatsapp-verify-code"},ZALO:{REGISTER_BY_SEND_OTP:"login/login-with-zalo",SEND_OTP:"login/zalo/sent-otp",VERIFY_BY_OTP:"login/zalo-verify-code",UPDATE_PHONE_SEND_OTP:"login/sms-social/zalo/sent-otp",UPDATE_PHONE_VERIFY_OTP:"login/sms-social/zalo-verify-code"},RESET_PASSWORD:"login/reset-password",CHECK_USER_EXIST:"member/check-user-exist",UPDATE_USER_INFO:"login/update-first-info",SETUP_USER_INFO:"login/setup-first-info",ECOM_CARE:{SEND_OTP:"login/ecom-care/send-email-otp-code",VERIFY_OTP:"login/ecom-care/email-verify-code",RESEND_OTP:"login/ecom-care/resend-email-otp-code"}},c="vi-VN",v={[a.L.Vietnam]:"1",[a.L.Indonesia]:"2",[a.L.Malaysia]:"3"}[c];r.L[c].PHONE;let getSSOV2ApiUrl=e=>(0,l.e)(`${(0,l.a)(c)}/api/v2/${e}`),getSSOApiUrl=e=>(0,l.e)(`${(0,l.a)(c)}/api/${e}`),p="hhg_user_token",fetchSSOV2Api=(e,o={},i)=>(0,t._)(void 0,void 0,void 0,function*(){var t;let n;let l=i?"":null===(t=document.cookie.split("; ").find(e=>e.startsWith(p)))||void 0===t?void 0:t.split("=")[1];try{o.body instanceof FormData&&(o.body.append("ga_client_id",(0,d.Ri)("_ga")||""),o.body.append("referrer",window.location.href)),n=yield fetch(getSSOV2ApiUrl(e),l?Object.assign(Object.assign({},o),{headers:Object.assign({Authorization:`Bearer ${l}`},null==o?void 0:o.headers)}):o)}catch(e){return console.error(e),null}return null==n?void 0:n.json()}),fetchSSOV2ApiJson=(e,o,i)=>(0,t._)(void 0,void 0,void 0,function*(){var t;let n;let l=i?"":null===(t=document.cookie.split("; ").find(e=>e.startsWith(p)))||void 0===t?void 0:t.split("=")[1];try{n=yield fetch(getSSOV2ApiUrl(e),{method:"POST",headers:Object.assign({Accept:"application/json","Content-Type":"application/json"},l?{Authorization:`Bearer ${l}`}:{}),body:JSON.stringify(o)})}catch(e){return console.error(e),null}return null==n?void 0:n.json()}),fetchSSOApi=(e,o={},i)=>(0,t._)(void 0,void 0,void 0,function*(){var t;let n;let l=i?"":null===(t=document.cookie.split("; ").find(e=>e.startsWith(p)))||void 0===t?void 0:t.split("=")[1];try{n=yield fetch(getSSOApiUrl(e),l?Object.assign(Object.assign({},o),{headers:Object.assign({Authorization:`Bearer ${l}`},null==o?void 0:o.headers)}):o)}catch(e){return console.error(e),null}return null==n?void 0:n.json()}),resetPassword=(e,o)=>(0,t._)(void 0,void 0,void 0,function*(){let i=new FormData;return i.append("password",e),i.append("confirm-password",o),fetchSSOV2Api(u.RESET_PASSWORD,{method:"POST",body:i})}),checkUserExist=({email:e,phone:o})=>(0,t._)(void 0,void 0,void 0,function*(){let i=new FormData;return e?i.append("email",e):i.append("phone_number",o),fetchSSOV2Api(u.CHECK_USER_EXIST,{method:"POST",body:i})}),updateUserInfo=e=>(0,t._)(void 0,void 0,void 0,function*(){let o=new FormData;return Object.keys(e).forEach(i=>{let t=e[i];null!=t&&("string"!=typeof t||t.trim())&&o.append(i,e[i])}),fetchSSOV2Api(u.SETUP_USER_INFO,{method:"POST",body:o})}),f=8068==i.j?n.K?"289442006438-040a42cbidr6v5d178f3iqi9q95821r3.apps.googleusercontent.com":"289442006438-cihobuq1h3r4426pur7u0e43fqdnep59.apps.googleusercontent.com":null,_="2759888574045636",getUserInfo=()=>(0,t._)(void 0,void 0,void 0,function*(){return fetchSSOApi("user/profile",{method:"POST"})}),handleAuthSuccess=e=>{(null==e?void 0:e.token)&&(0,d.TV)(p,e.token,{domain:"localhost"===window.location.hostname?"localhost":`.${s.y[c]}`,expires:new Date(1e3*e.expire_in).toUTCString()}),(null==e?void 0:e.refresh_token)&&(0,d.TV)(r.k,e.refresh_token,{domain:"localhost"===window.location.hostname?"localhost":`.${s.y[c]}`})}},"8TMT":function(e,o,i){i.d(o,{a:function(){return getCurrentSsoUrl},b:function(){return getTogetherApiDomain},c:function(){return getDiscoverApiDomain},d:function(){return getCareApiDomain},e:function(){return normalizeLinkSlash},g:function(){return getCurrentBaseUrl},n:function(){return normalizeLink},r:function(){return resolveDiscoverNavLink}});var t=i("xrdX"),n=i("GOBr"),l=i("yNk5");let getCurrentBaseUrl=(e,o)=>{let i=!n.K;return`https://${i?o?"fe.":"discover.":o?"www.":""}${t.y[o?"vi-VN_MB":e]}`},getCurrentSsoUrl=(e,o)=>l.env.UNIFY_SSO_API||`https://${n.K?"id.":"staging-id."}${t.y[o?"vi-VN_MB":e]}`,getTogetherApiDomain=()=>l.env.UNIFY_INTERNAL_TOGETHER_API||l.env.UNIFY_TOGETHER_API||`https://${n.K?"together.":"staging-together."}hellohealthgroup.com`,getDiscoverApiDomain=e=>{let o=e.endsWith("_MB");return o?`https://${n.K?"wp.":"staging."}${t.y[e]}`:l.env.UNIFY_INTERNAL_DISCOVER_API||l.env.UNIFY_DISCOVER_API||`https://${n.K?"wp.":"staging."}${t.y[e]}`},getCareApiDomain=()=>l.env.UNIFY_INTERNAL_CARE_API||l.env.UNIFY_CARE_API||`https://${n.K?"health-care.":"service-health-care."}hellohealthgroup.com`,normalizeLinkSlash=e=>e.replace(/([^:]\/)\/+/g,"$1"),forceEndSlash=e=>e.replace(/\/?$/,"/"),normalizeLink=e=>normalizeLinkSlash(forceEndSlash(e)),resolveDiscoverNavLink=(e,o="")=>{if(!o)return normalizeLinkSlash(e);if(o.startsWith("http://")||o.startsWith("https://"))return normalizeLinkSlash(o);let i=o.startsWith("/")?o:`/${o}`;return normalizeLinkSlash(`${e}${i}`)}},D7zM:function(e,o,i){i.d(o,{I:function(){return IS_SSOV2_ENABLED},S:function(){return n},a:function(){return v},b:function(){return isPhoneNotVerifedYet},c:function(){return isLoginWithPhoneNotVerifedYet},d:function(){return isFlowFinishedSetup},i:function(){return isUserFinishedSetup},r:function(){return redirect},s:function(){return splitPhone},u:function(){return p}});var t,n,l=i("vEfc"),r=i("VNqU"),d=i("Z0qH");if(8068==i.j)var a=i("A9bs");var s=i("+u84"),u=i("27Mu"),c=i("yNk5");let mergePhone=(e,o)=>{let i=o.startsWith("+")?o:`+${o}`,t=e.startsWith("0")?e.slice(1):e;return`${i}${t}`},splitPhone=e=>{if(!e)return{areaCode:void 0,phoneNumber:void 0};let o=(0,a.parsePhoneNumber)(e);return{areaCode:o.countryCallingCode?"+"+o.countryCallingCode:"",phoneNumber:o.nationalNumber||""}};(t=n||(n={})).FIRST="first",t.WHATSAPP_PHONE_VERIFY="whatsapp_phone_verify",t.WHATSAPP_OTP="whatsapp_otp",t.EMAIL="email",t.VERIFY_PHONE="verify_phone",t.PASSWORD="password",t.UPDATE_EMAIL="update_email",t.FORGOT_PASSWORD_PHONE="forgot_password_phone",t.FORGOT_PASSWORD_SETUP="forgot_password_setup",t.OTP="otp",t.SETUP_FULL="setup_full";let v=(0,r.vt)(e=>({currentStepIndex:0,steps:[{type:n.FIRST}],setSteps:o=>e(e=>({steps:"function"==typeof o?o(e.steps):o})),addStep:o=>{e(e=>({steps:[...e.steps,o]}))},goNext:()=>{e(e=>({currentStepIndex:e.currentStepIndex+1}))},goBack:()=>{e(e=>({currentStepIndex:e.currentStepIndex-1,steps:e.steps.slice(0,e.steps.length-1)}))}})),p=(0,r.vt)()((e,o)=>({isHaveReadAndAgreePolicy:!1,setIsHaveReadAndAgreePolicy:o=>e({isHaveReadAndAgreePolicy:o}),isGetUpdateFromHHG:!1,setIsGetUpdateFromHHG:o=>e({isGetUpdateFromHHG:o}),userInfo:void 0,abTestFlow:"A",setABTestFlow(o){e({abTestFlow:o})},setUserInfo:o=>e({userInfo:o}),isOpen:!1,setOpen:o=>e({isOpen:o}),returnUrl:void 0,setReturnUrl:o=>e({returnUrl:o}),mounted:!1,setMounted:o=>e({mounted:o}),source:void 0,setSource:o=>e({source:o}),setupSource:void 0,setSetupSource:o=>e({setupSource:o}),setOnCloseProp:o=>e({onCloseProp:o}),triggerLogin:i=>{var t,l;let{source:r,returnUrl:d}=i||{},a=(0,u.Ri)(s.B);a?(redirect(null==i?void 0:i.returnUrl,null==i?void 0:i.source,null==i?void 0:i.forceReloadOnClose),e({isOpen:!1}),null===(l=(t=o()).onCloseProp)||void 0===l||l.call(t)):(v.setState({steps:[{type:n.FIRST,config:{legalTextType:((null==d?void 0:d.includes("joincommunity=1"))?"community":null==i?void 0:i.legalTextType)||"default"}}],currentStepIndex:0}),e({isOpen:!0,returnUrl:d,source:r,overrideClose:void 0,forceReloadOnClose:null!=d&&!!d.includes("joincommunity=1")||(null==i?void 0:i.forceReloadOnClose)||!1,flowData:void 0,userInfo:void 0}))},triggerWhatsappLogin:o=>{let{source:i,returnUrl:t,referrer:l,forceReloadOnClose:r,isAlreadyLogin:d,phone_number:a,area_code:s}=o||{},u=d&&a&&s;if(u){let e=mergePhone(String(a),s);v.setState({steps:[{type:n.WHATSAPP_OTP,config:{phone:e,referrer:l,useAuthenticatedWhatsAppApis:!0}}],currentStepIndex:0})}else v.setState({steps:[{type:n.WHATSAPP_PHONE_VERIFY,config:Object.assign({referrer:l},d?{useAuthenticatedWhatsAppApis:!0}:{})}],currentStepIndex:0});e({isOpen:!0,returnUrl:t,source:i,overrideClose:void 0,forceReloadOnClose:r||!1,flowData:{method:"whatsapp",flow:"login"},userInfo:void 0})},triggerCareEmailPhoneVerify:i=>(0,l._)(void 0,void 0,void 0,function*(){var t,r,a;let s=yield(0,d.g)();(null===(t=null==s?void 0:s._data)||void 0===t?void 0:t.first_time_login)&&(s._data.first_time_login=0),e({userInfo:null==s?void 0:s._data});let forceUpdatePhoneEmail=t=>(0,l._)(void 0,void 0,void 0,function*(){var l,r,a,s,u,c,p,f,_,h,S,g,m,O,P;let E=yield(0,d.g)(),T=null===(l=null==E?void 0:E._data)||void 0===l?void 0:l.email,A=!T||T.endsWith("@hhg.com")||T.endsWith("@facebook.com")?void 0:T,I=(null==i?void 0:i.email)||A,U=!!(null===(r=null==E?void 0:E._data)||void 0===r?void 0:r.phone)&&!!(null===(a=null==E?void 0:E._data)||void 0===a?void 0:a.phone_verified_at),w=!!(null===(s=null==E?void 0:E._data)||void 0===s?void 0:s.email)&&!!(null===(u=null==E?void 0:E._data)||void 0===u?void 0:u.email_verified_at)&&!(null===(p=null===(c=null==E?void 0:E._data)||void 0===c?void 0:c.email)||void 0===p?void 0:p.endsWith("@hhg.com"))&&!(null===(_=null===(f=null==E?void 0:E._data)||void 0===f?void 0:f.email)||void 0===_?void 0:_.endsWith("@facebook.com")),y=!!(null===(h=null==E?void 0:E._data)||void 0===h?void 0:h.name),R=!!(null===(S=null==E?void 0:E._data)||void 0===S?void 0:S.birthday),N="number"==typeof(null===(g=null==E?void 0:E._data)||void 0===g?void 0:g.gender),D=null===(m=null==E?void 0:E._data)||void 0===m?void 0:m.provider;U&&w?(null==i?void 0:i.skipForceSetup)||y&&R&&N?(redirect(null==i?void 0:i.returnUrl,null==i?void 0:i.source,!0),e({isOpen:!1,forceReloadOnClose:!1}),null===(P=(O=o()).onCloseProp)||void 0===P||P.call(O)):(v.setState({steps:[{type:n.SETUP_FULL,config:{userInfo:E._data}}],currentStepIndex:0}),e(e=>Object.assign({source:null==i?void 0:i.source,returnUrl:null==i?void 0:i.returnUrl,isOpen:!0,overrideClose:void 0,forceReloadOnClose:!0},t&&!e.flowData?{flowData:getSSOFlowFromUserProfile(null==E?void 0:E._data)}:{}))):(v.setState({steps:[{type:U?n.UPDATE_EMAIL:n.VERIFY_PHONE,config:U||w?{provider:D,afterAction:(null==i?void 0:i.skipForceSetup)?"done":"setup",email:I}:{provider:D,afterAction:"update-email",email:I}}],currentStepIndex:0}),e(e=>Object.assign({source:null==i?void 0:i.source,returnUrl:null==i?void 0:i.returnUrl,isOpen:!0,overrideClose:void 0,forceReloadOnClose:!0},t&&!e.flowData?{flowData:getSSOFlowFromUserProfile(null==E?void 0:E._data)}:{})))});if(null===(r=null==s?void 0:s._data)||void 0===r?void 0:r.id)forceUpdatePhoneEmail(!0);else{v.setState({steps:[{type:n.FIRST,config:{legalTextType:((null===(a=null==i?void 0:i.returnUrl)||void 0===a?void 0:a.includes("joincommunity=1"))?"community":null==i?void 0:i.legalTextType)||"default"}}],currentStepIndex:0}),e({isOpen:!0,overrideClose:forceUpdatePhoneEmail,source:null==i?void 0:i.source,returnUrl:null==i?void 0:i.returnUrl,forceReloadOnClose:!0,flowData:void 0});return}}),triggerCommunityEmailVerify:i=>(0,l._)(void 0,void 0,void 0,function*(){var t,r,a;let s=yield(0,d.g)();(null===(t=null==s?void 0:s._data)||void 0===t?void 0:t.first_time_login)&&(s._data.first_time_login=0),e({userInfo:null==s?void 0:s._data});let forceUpdateEmail=t=>(0,l._)(void 0,void 0,void 0,function*(){var l,r,a,s,u,c,p,f,_,h,S,g;let m=yield(0,d.g)(),O=!!(null===(l=null==m?void 0:m._data)||void 0===l?void 0:l.email)&&!!(null===(r=null==m?void 0:m._data)||void 0===r?void 0:r.email_verified_at)&&!(null===(s=null===(a=null==m?void 0:m._data)||void 0===a?void 0:a.email)||void 0===s?void 0:s.endsWith("@hhg.com"))&&!(null===(c=null===(u=null==m?void 0:m._data)||void 0===u?void 0:u.email)||void 0===c?void 0:c.endsWith("@facebook.com")),P=!!(null===(p=null==m?void 0:m._data)||void 0===p?void 0:p.name),E=!!(null===(f=null==m?void 0:m._data)||void 0===f?void 0:f.birthday),T="number"==typeof(null===(_=null==m?void 0:m._data)||void 0===_?void 0:_.gender),A=null===(h=null==m?void 0:m._data)||void 0===h?void 0:h.provider;O?P&&E&&T?(redirect(null==i?void 0:i.returnUrl,null==i?void 0:i.source,!0),e({isOpen:!1,forceReloadOnClose:!1}),null===(g=(S=o()).onCloseProp)||void 0===g||g.call(S)):(v.setState({steps:[{type:n.SETUP_FULL,config:{userInfo:m._data}}],currentStepIndex:0}),e(e=>Object.assign({source:null==i?void 0:i.source,returnUrl:null==i?void 0:i.returnUrl,isOpen:!0,overrideClose:void 0,forceReloadOnClose:!0},t&&!e.flowData?{flowData:getSSOFlowFromUserProfile(null==m?void 0:m._data)}:{}))):(v.setState({steps:[{type:n.UPDATE_EMAIL,config:{provider:A,afterAction:"setup"}}].filter(Boolean),currentStepIndex:0}),e(e=>Object.assign({source:null==i?void 0:i.source,returnUrl:null==i?void 0:i.returnUrl,isOpen:!0,overrideClose:void 0,forceReloadOnClose:(null==i?void 0:i.forceReloadOnClose)||!1},t&&!e.flowData?{flowData:getSSOFlowFromUserProfile(null==m?void 0:m._data)}:{})))});if(null===(r=null==s?void 0:s._data)||void 0===r?void 0:r.id)forceUpdateEmail(!0);else{v.setState({steps:[{type:n.FIRST,config:{legalTextType:((null===(a=null==i?void 0:i.returnUrl)||void 0===a?void 0:a.includes("joincommunity=1"))?"community":null==i?void 0:i.legalTextType)||"default"}}],currentStepIndex:0}),e({isOpen:!0,overrideClose:forceUpdateEmail,source:null==i?void 0:i.source,returnUrl:null==i?void 0:i.returnUrl,forceReloadOnClose:!0,flowData:void 0});return}}),forceReloadOnClose:!1})),redirect=(e,o,i)=>{if(i){let i;return i=(null==e?void 0:e.startsWith("http"))||(null==e?void 0:e.startsWith("//"))?new URL(e):e?new URL(e,window.location.href):new URL(window.location.href),o&&i.searchParams.set("source",o),window.location.href=i.href,!0}let t=new URL(window.location.href);if(e){let i;i=e.startsWith("http")||e.startsWith("//")?new URL(e):new URL(e,window.location.href);let n=i.searchParams.get("source");t.searchParams.delete("source"),i.searchParams.delete("source");let l=n||o;if(t.href!==i.href)return l&&i.searchParams.set("source",l||""),window.location.href=i.href,!0}if(o){t.searchParams.set("source",o),window.history.replaceState({},"",t.href);return}},f=["vi-VN","id-ID","ms-MY"],IS_SSOV2_ENABLED=e=>!c.env.NEXT_PUBLIC_MARRY_BABY&&f.includes(e||c.env.UNIFY_LOCALE||"vi-VN"),getSSOFlowFromUserProfile=e=>{if(!e)throw Error("userInfo is required");let o=!!(null==e?void 0:e.name),i=!!(null==e?void 0:e.birthday),t="number"==typeof(null==e?void 0:e.gender);return{flow:o&&i&&t?"signup":"login",method:(null==e?void 0:e.provider)||"email"}},isUserFinishedSetup=e=>{if(!e)throw Error("userInfo is required");let o=!!(null==e?void 0:e.name),i=!!(null==e?void 0:e.birthday),t="number"==typeof(null==e?void 0:e.gender);return o&&i&&t},isFlowFinishedSetup=e=>{var o,i,t;return(null===(o=null==e?void 0:e.metaData)||void 0===o?void 0:o.is_gender)&&(null===(i=null==e?void 0:e.metaData)||void 0===i?void 0:i.is_name)&&(null===(t=null==e?void 0:e.metaData)||void 0===t?void 0:t.is_birthday)},isPhoneNotVerifedYet=e=>!(null==e?void 0:e.phone_verified_at)||!(null==e?void 0:e.phone),isLoginWithPhoneNotVerifedYet=(e,o)=>(null==e?void 0:e.flow)==="login"&&(null==o?void 0:o.phone)&&(null==o?void 0:o.area_code)&&!(null==o?void 0:o.phone_verified_at)}}]);