"use strict";(self.webpackChunkhhgHealthCareV1=self.webpackChunkhhgHealthCareV1||[]).push([[1171],{61092:function(o,e,i){i.d(e,{B:function(){return p},F:function(){return E},G:function(){return O},S:function(){return v},c:function(){return g},f:function(){return f},g:function(){return S},h:function(){return T},l:function(){return s},r:function(){return h},u:function(){return m},w:function(){return c}});var n=i(46587);if(8068==i.j)var t=i(6432);var l=i(93202),d=i(68383);if(8068==i.j)var r=i(6806);var a=i(50345);if(8068==i.j)var u=i(27516);const v={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:{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"}},s="vi-VN",c={[a.L.Vietnam]:"1",[a.L.Indonesia]:"2",[a.L.Malaysia]:"3"}[s];d.L[s].PHONE;const p="hhg_user_token",f=(o,e={},i)=>(0,n.a)(void 0,void 0,void 0,(function*(){var n;let t;const d=i?"":null===(n=document.cookie.split("; ").find((o=>o.startsWith(p))))||void 0===n?void 0:n.split("=")[1];try{e.body instanceof FormData&&(e.body.append("ga_client_id",(0,r.Ri)("_ga")||""),e.body.append("referrer",window.location.href)),t=yield fetch((o=>(0,l.n)(`${(0,l.a)(s)}/api/v2/${o}`))(o),d?Object.assign(Object.assign({},e),{headers:Object.assign({Authorization:`Bearer ${d}`},null===e||void 0===e?void 0:e.headers)}):e)}catch(a){return console.error(a),null}return null===t||void 0===t?void 0:t.json()})),_=(o,e={},i)=>(0,n.a)(void 0,void 0,void 0,(function*(){var n;let t;const d=i?"":null===(n=document.cookie.split("; ").find((o=>o.startsWith(p))))||void 0===n?void 0:n.split("=")[1];try{t=yield fetch((o=>(0,l.n)(`${(0,l.a)(s)}/api/${o}`))(o),d?Object.assign(Object.assign({},e),{headers:Object.assign({Authorization:`Bearer ${d}`},null===e||void 0===e?void 0:e.headers)}):e)}catch(r){return console.error(r),null}return null===t||void 0===t?void 0:t.json()})),h=(o,e)=>(0,n.a)(void 0,void 0,void 0,(function*(){const i=new FormData;return i.append("password",o),i.append("confirm-password",e),f(v.RESET_PASSWORD,{method:"POST",body:i})})),g=({email:o,phone:e})=>(0,n.a)(void 0,void 0,void 0,(function*(){const i=new FormData;return o?i.append("email",o):i.append("phone_number",e),f(v.CHECK_USER_EXIST,{method:"POST",body:i})})),m=o=>(0,n.a)(void 0,void 0,void 0,(function*(){const e=new FormData;return Object.keys(o).forEach((i=>{const n=o[i];"undefined"===typeof n||null===n||"string"===typeof n&&!n.trim()||e.append(i,o[i])})),f(v.SETUP_USER_INFO,{method:"POST",body:e})})),O=8068==i.j?t.K?"289442006438-040a42cbidr6v5d178f3iqi9q95821r3.apps.googleusercontent.com":"289442006438-cihobuq1h3r4426pur7u0e43fqdnep59.apps.googleusercontent.com":null,E="2759888574045636",S=()=>(0,n.a)(void 0,void 0,void 0,(function*(){return _("user/profile",{method:"POST"})})),T=o=>{(null===o||void 0===o?void 0:o.token)&&(0,r.TV)(p,o.token,{domain:"localhost"===window.location.hostname?"localhost":`.${u.y[s]}`,expires:new Date(1e3*o.expire_in).toUTCString()}),(null===o||void 0===o?void 0:o.refresh_token)&&(0,r.TV)(d.h,o.refresh_token,{domain:"localhost"===window.location.hostname?"localhost":`.${u.y[s]}`})}},93202:function(o,e,i){i.d(e,{a:function(){return r},b:function(){return a},c:function(){return u},d:function(){return v},e:function(){return c},g:function(){return d},n:function(){return s}});var n=i(27516),t=i(6432),l=i(65606);const d=(o,e)=>`https://${!t.K?e?"fe.":"discover.":e?"www.":""}${n.y[e?"vi-VN_MB":o]}`,r=(o,e)=>l.env.UNIFY_SSO_API||`https://${t.K?"id.":"staging-id."}${n.y[e?"vi-VN_MB":o]}`,a=()=>l.env.UNIFY_INTERNAL_TOGETHER_API||l.env.UNIFY_TOGETHER_API||`https://${t.K?"together.":"staging-together."}hellohealthgroup.com`,u=o=>o.endsWith("_MB")?`https://${t.K?"wp.":"staging."}${n.y[o]}`:l.env.UNIFY_INTERNAL_DISCOVER_API||l.env.UNIFY_DISCOVER_API||`https://${t.K?"wp.":"staging."}${n.y[o]}`,v=()=>l.env.UNIFY_INTERNAL_CARE_API||l.env.UNIFY_CARE_API||`https://${t.K?"health-care.":"service-health-care."}hellohealthgroup.com`,s=o=>o.replace(/([^:]\/)\/+/g,"$1"),c=o=>s((o=>o.replace(/\/?$/,"/"))(o))},21171:function(o,e,i){i.d(e,{I:function(){return f},S:function(){return n},a:function(){return v},b:function(){return m},c:function(){return O},d:function(){return g},i:function(){return h},r:function(){return c},u:function(){return s}});var n,t=i(46587),l=i(44745),d=i(61092),r=i(68383),a=i(6806),u=i(65606);!function(o){o.FIRST="first",o.EMAIL="email",o.VERIFY_PHONE="verify_phone",o.PASSWORD="password",o.UPDATE_EMAIL="update_email",o.FORGOT_PASSWORD_PHONE="forgot_password_phone",o.FORGOT_PASSWORD_SETUP="forgot_password_setup",o.OTP="otp",o.SETUP_FULL="setup_full"}(n||(n={}));const v=(0,l.vt)((o=>({currentStepIndex:0,steps:[{type:n.FIRST}],setSteps:e=>o((o=>({steps:"function"===typeof e?e(o.steps):e}))),addStep:e=>{o((o=>({steps:[...o.steps,e]})))},goNext:()=>{o((o=>({currentStepIndex:o.currentStepIndex+1})))},goBack:()=>{o((o=>({currentStepIndex:o.currentStepIndex-1,steps:o.steps.slice(0,o.steps.length-1)})))}}))),s=(0,l.vt)()(((o,e)=>({userInfo:void 0,abTestFlow:"A",setABTestFlow(e){o({abTestFlow:e})},setUserInfo:e=>o({userInfo:e}),isOpen:!1,setOpen:e=>o({isOpen:e}),returnUrl:void 0,setReturnUrl:e=>o({returnUrl:e}),mounted:!1,setMounted:e=>o({mounted:e}),source:void 0,setSource:e=>o({source:e}),setupSource:void 0,setSetupSource:e=>o({setupSource:e}),setOnCloseProp:e=>o({onCloseProp:e}),triggerLogin:i=>{var t,l;const{source:d,returnUrl:u}=i||{};(0,a.Ri)(r.B)?(c(null===i||void 0===i?void 0:i.returnUrl,null===i||void 0===i?void 0:i.source,null===i||void 0===i?void 0:i.forceReloadOnClose),o({isOpen:!1}),null===(l=(t=e()).onCloseProp)||void 0===l||l.call(t)):(v.setState({steps:[{type:n.FIRST,config:{legalTextType:((null===u||void 0===u?void 0:u.includes("joincommunity=1"))?"community":null===i||void 0===i?void 0:i.legalTextType)||"default"}}],currentStepIndex:0}),o({isOpen:!0,returnUrl:u,source:d,overrideClose:void 0,forceReloadOnClose:!!(null===u||void 0===u?void 0:u.includes("joincommunity=1"))||((null===i||void 0===i?void 0:i.forceReloadOnClose)||!1),flowData:void 0,userInfo:void 0}))},triggerCareEmailPhoneVerify:i=>(0,t.a)(void 0,void 0,void 0,(function*(){var l,r,a;const u=yield(0,d.g)();(null===(l=null===u||void 0===u?void 0:u._data)||void 0===l?void 0:l.first_time_login)&&(u._data.first_time_login=0),o({userInfo:null===u||void 0===u?void 0:u._data});const s=l=>(0,t.a)(void 0,void 0,void 0,(function*(){var t,r,a,u,s,p,f,h,g,m,O,E,S,T;const P=yield(0,d.g)(),I=!!(null===(t=null===P||void 0===P?void 0:P._data)||void 0===t?void 0:t.phone)&&!!(null===(r=null===P||void 0===P?void 0:P._data)||void 0===r?void 0:r.phone_verified_at),R=!!(null===(a=null===P||void 0===P?void 0:P._data)||void 0===a?void 0:a.email)&&!!(null===(u=null===P||void 0===P?void 0:P._data)||void 0===u?void 0:u.email_verified_at)&&!(null===(p=null===(s=null===P||void 0===P?void 0:P._data)||void 0===s?void 0:s.email)||void 0===p?void 0:p.endsWith("@hhg.com"))&&!(null===(h=null===(f=null===P||void 0===P?void 0:P._data)||void 0===f?void 0:f.email)||void 0===h?void 0:h.endsWith("@facebook.com")),w=!!(null===(g=null===P||void 0===P?void 0:P._data)||void 0===g?void 0:g.name),y=!!(null===(m=null===P||void 0===P?void 0:P._data)||void 0===m?void 0:m.birthday),U="number"===typeof(null===(O=null===P||void 0===P?void 0:P._data)||void 0===O?void 0:O.gender),D=null===(E=null===P||void 0===P?void 0:P._data)||void 0===E?void 0:E.provider,N=w&&y&&U;I&&R?(null===i||void 0===i?void 0:i.skipForceSetup)||N?(c(null===i||void 0===i?void 0:i.returnUrl,null===i||void 0===i?void 0:i.source,!0),o({isOpen:!1,forceReloadOnClose:!1}),null===(T=(S=e()).onCloseProp)||void 0===T||T.call(S)):(v.setState({steps:[{type:n.SETUP_FULL,config:{userInfo:P._data}}],currentStepIndex:0}),o((o=>Object.assign({source:null===i||void 0===i?void 0:i.source,returnUrl:null===i||void 0===i?void 0:i.returnUrl,isOpen:!0,overrideClose:void 0,forceReloadOnClose:!0},l&&!o.flowData?{flowData:_(null===P||void 0===P?void 0:P._data)}:{})))):(v.setState({steps:[{type:I?n.UPDATE_EMAIL:n.VERIFY_PHONE,config:I||R?{provider:D,afterAction:(null===i||void 0===i?void 0:i.skipForceSetup)?"done":"setup"}:{provider:D,afterAction:"update-email"}}],currentStepIndex:0}),o((o=>Object.assign({source:null===i||void 0===i?void 0:i.source,returnUrl:null===i||void 0===i?void 0:i.returnUrl,isOpen:!0,overrideClose:void 0,forceReloadOnClose:!0},l&&!o.flowData?{flowData:_(null===P||void 0===P?void 0:P._data)}:{}))))}));if(!(null===(r=null===u||void 0===u?void 0:u._data)||void 0===r?void 0:r.id))return v.setState({steps:[{type:n.FIRST,config:{legalTextType:((null===(a=null===i||void 0===i?void 0:i.returnUrl)||void 0===a?void 0:a.includes("joincommunity=1"))?"community":null===i||void 0===i?void 0:i.legalTextType)||"default"}}],currentStepIndex:0}),void o({isOpen:!0,overrideClose:s,source:null===i||void 0===i?void 0:i.source,returnUrl:null===i||void 0===i?void 0:i.returnUrl,forceReloadOnClose:!0,flowData:void 0});s(!0)})),triggerCommunityEmailVerify:i=>(0,t.a)(void 0,void 0,void 0,(function*(){var l,r,a;const u=yield(0,d.g)();(null===(l=null===u||void 0===u?void 0:u._data)||void 0===l?void 0:l.first_time_login)&&(u._data.first_time_login=0),o({userInfo:null===u||void 0===u?void 0:u._data});const s=l=>(0,t.a)(void 0,void 0,void 0,(function*(){var t,r,a,u,s,p,f,h,g,m,O,E;const S=yield(0,d.g)(),T=!!(null===(t=null===S||void 0===S?void 0:S._data)||void 0===t?void 0:t.email)&&!!(null===(r=null===S||void 0===S?void 0:S._data)||void 0===r?void 0:r.email_verified_at)&&!(null===(u=null===(a=null===S||void 0===S?void 0:S._data)||void 0===a?void 0:a.email)||void 0===u?void 0:u.endsWith("@hhg.com"))&&!(null===(p=null===(s=null===S||void 0===S?void 0:S._data)||void 0===s?void 0:s.email)||void 0===p?void 0:p.endsWith("@facebook.com")),P=!!(null===(f=null===S||void 0===S?void 0:S._data)||void 0===f?void 0:f.name),I=!!(null===(h=null===S||void 0===S?void 0:S._data)||void 0===h?void 0:h.birthday),R="number"===typeof(null===(g=null===S||void 0===S?void 0:S._data)||void 0===g?void 0:g.gender),w=null===(m=null===S||void 0===S?void 0:S._data)||void 0===m?void 0:m.provider;T?P&&I&&R?(c(null===i||void 0===i?void 0:i.returnUrl,null===i||void 0===i?void 0:i.source,!0),o({isOpen:!1,forceReloadOnClose:!1}),null===(E=(O=e()).onCloseProp)||void 0===E||E.call(O)):(v.setState({steps:[{type:n.SETUP_FULL,config:{userInfo:S._data}}],currentStepIndex:0}),o((o=>Object.assign({source:null===i||void 0===i?void 0:i.source,returnUrl:null===i||void 0===i?void 0:i.returnUrl,isOpen:!0,overrideClose:void 0,forceReloadOnClose:!0},l&&!o.flowData?{flowData:_(null===S||void 0===S?void 0:S._data)}:{})))):(v.setState({steps:[{type:n.UPDATE_EMAIL,config:{provider:w,afterAction:"setup"}}].filter(Boolean),currentStepIndex:0}),o((o=>Object.assign({source:null===i||void 0===i?void 0:i.source,returnUrl:null===i||void 0===i?void 0:i.returnUrl,isOpen:!0,overrideClose:void 0,forceReloadOnClose:(null===i||void 0===i?void 0:i.forceReloadOnClose)||!1},l&&!o.flowData?{flowData:_(null===S||void 0===S?void 0:S._data)}:{}))))}));if(!(null===(r=null===u||void 0===u?void 0:u._data)||void 0===r?void 0:r.id))return v.setState({steps:[{type:n.FIRST,config:{legalTextType:((null===(a=null===i||void 0===i?void 0:i.returnUrl)||void 0===a?void 0:a.includes("joincommunity=1"))?"community":null===i||void 0===i?void 0:i.legalTextType)||"default"}}],currentStepIndex:0}),void o({isOpen:!0,overrideClose:s,source:null===i||void 0===i?void 0:i.source,returnUrl:null===i||void 0===i?void 0:i.returnUrl,forceReloadOnClose:!0,flowData:void 0});s(!0)})),forceReloadOnClose:!1}))),c=(o,e,i)=>{if(i){let i;return i=(null===o||void 0===o?void 0:o.startsWith("http"))||(null===o||void 0===o?void 0:o.startsWith("//"))?new URL(o):o?new URL(o,window.location.href):new URL(window.location.href),e&&i.searchParams.set("source",e),window.location.href=i.href,!0}const n=new URL(window.location.href);if(o){let i;i=o.startsWith("http")||o.startsWith("//")?new URL(o):new URL(o,window.location.href);const t=i.searchParams.get("source");n.searchParams.delete("source"),i.searchParams.delete("source");const l=t||e;if(n.href!==i.href)return l&&i.searchParams.set("source",l||""),window.location.href=i.href,!0}if(e)return n.searchParams.set("source",e),void window.history.replaceState({},"",n.href)},p=8068==i.j?["vi-VN","id-ID","ms-MY"]:null,f=o=>!u.env.NEXT_PUBLIC_MARRY_BABY&&p.includes(o||u.env.UNIFY_LOCALE||"vi-VN"),_=o=>{if(!o)throw new Error("userInfo is required");const e=!!(null===o||void 0===o?void 0:o.name),i=!!(null===o||void 0===o?void 0:o.birthday),n="number"===typeof(null===o||void 0===o?void 0:o.gender);return{flow:e&&i&&n?"signup":"login",method:(null===o||void 0===o?void 0:o.provider)||"email"}},h=o=>{if(!o)throw new Error("userInfo is required");const e=!!(null===o||void 0===o?void 0:o.name),i=!!(null===o||void 0===o?void 0:o.birthday),n="number"===typeof(null===o||void 0===o?void 0:o.gender);return e&&i&&n},g=o=>{var e,i,n;return(null===(e=null===o||void 0===o?void 0:o.metaData)||void 0===e?void 0:e.is_gender)&&(null===(i=null===o||void 0===o?void 0:o.metaData)||void 0===i?void 0:i.is_name)&&(null===(n=null===o||void 0===o?void 0:o.metaData)||void 0===n?void 0:n.is_birthday)},m=o=>!(null===o||void 0===o?void 0:o.phone_verified_at)||!(null===o||void 0===o?void 0:o.phone),O=(o,e)=>"login"===(null===o||void 0===o?void 0:o.flow)&&(null===e||void 0===e?void 0:e.phone)&&(null===e||void 0===e?void 0:e.area_code)&&!(null===e||void 0===e?void 0:e.phone_verified_at)}}]);