"use strict";(self.webpackChunkhhgDiscoverV1=self.webpackChunkhhgDiscoverV1||[]).push([[9236],{aVqH:function(e,t,n){n.d(t,{$$:function(){return callApiWithLead},Gq:function(){return authorize},Hg:function(){return h},Q2:function(){return getWindowId},T7:function(){return callApiWithAuth},oX:function(){return postSSOApiFormData},px:function(){return callApi}});var r=n("dvDa"),i=n("iVi/"),o=n("p46w"),a=n.n(o),l=n("Q6jF"),c=n("LSb+"),u=n("/sjq"),s=n("9brV"),d=n("77FC"),g=n("JOt+");let h=s.Km.NEXT_PUBLIC_DEPLOY_LOCALE||"en-PH",createAxiosWithInterceptor=(e,t)=>{let n=r.A.create();return n.interceptors.request.use(n=>(e&&t&&(n.headers.Authorization="".concat(t," ").concat(e)),n),e=>{Promise.reject(e)}),n},fixedEncodeURI=e=>encodeURI(e).replace(/%5B/g,"[").replace(/%5D/g,"]"),callApi=async function(e,t,n){let r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];try{let i=createAxiosWithInterceptor(),o=await i({url:r?e:fixedEncodeURI(e),method:t,...n,params:{lang:"tl-PH"===s.Km.NEXT_PUBLIC_DEPLOY_LOCALE?"fil":void 0,...null==n?void 0:n.params},timeout:3e4});if(o)return o.data}catch(r){(0,d.H4)(null,e,t,null==n?void 0:n.requestFrom,r)}return null},callApiWithAuth=async(e,t,n,r)=>{try{let o=i.parse(r||""),l=o[s.ty],c=l||a().get(s.ty);if(c&&c.length){let r=createAxiosWithInterceptor(c,"Bearer"),i=await r({url:e,method:t,...n,params:{...null==n?void 0:n.params,lang:"tl-PH"===s.Km.NEXT_PUBLIC_DEPLOY_LOCALE?"fil":void 0},timeout:3e4});if(i)return i.data}else if(null==n?void 0:n.noAuthFallback)return callApi(e,t,n)}catch(r){if((0,d.H4)(null,e,t,null==n?void 0:n.requestFrom,r),null==n?void 0:n.noAuthFallback)return callApi(e,t,n);if(null==n?void 0:n.allowError)throw r}return null},callApiWithLead=async(e,t,n,o)=>{try{let c=i.parse(o||""),u=c[s.Y3],d=u||a().get(s.Y3),g=c[s.pJ]||a().get(s.pJ);if(!d){let e=(0,l.A)();d=e,a().set(s.Y3,e)}let h=await (0,r.A)({url:fixedEncodeURI(e),method:t,...n,data:{...null==n?void 0:n.data,cookie_id:d,ga_client_id:g||""},timeout:3e4});if(h)return h.data}catch(n){(0,d.H4)(null,e,t,"lead",n)}return null},authorize=async()=>{try{let n,i;try{n=await (0,g.callApiNew)(c.PATHS.USER_PROFILE.GET_PROFILE,{method:"POST"},"sso")}catch(e){i=e,n||(n=e.response)}if((null==n?void 0:n.code)==="SSO_ERR_041"||(null==n?void 0:n._status)!==1){let n=a().get(s.nN);if(n){var e,t;let i=await (0,r.A)({url:"https://id.hellobacsi.com/api/"+c.PATHS.USER_PROFILE.POST_USER_REFRESH,method:"POST",timeout:1e4,data:{refresh_token:n},headers:{"Content-Type":"application/json",Accept:"application/json"}});if(null==i?void 0:null===(t=i.data)||void 0===t?void 0:null===(e=t._data)||void 0===e?void 0:e.token)return a().set(s.ty,i.data._data.token,{domain:"localhost"===window.location.hostname?"localhost":".".concat(u.domainLocales[h]),expires:i.data._data.expire_in||void 0}),authorize()}}if(i)throw i;if(n)return n._data}catch(e){console.log({err:e})}return null},f=(0,l.A)(),getWindowId=()=>f,callSSOApi=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=a().get(s.ty);return n?(0,g.callApiNew)(e,{...t},"sso"):Promise.reject("[SSO API] Missing auth cookie when calling ".concat(e))},postSSOApiFormData=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=new FormData;for(let[e,n]of Object.entries(t))r.append(e,n);return callSSOApi(e,{method:"POST",data:r,headers:{"Content-Type":"multipart/form-data"},...n})}},bPK4:function(e,t,n){n.d(t,{GW:function(){return getCareAllSpecialtyUrl},JQ:function(){return getCareHospitalUrl},KG:function(){return getEcommerceApiPath},ME:function(){return getCareServiceUrl},Nh:function(){return getPathURLSearchParams},Nv:function(){return getCareSpecialtyUrl},PU:function(){return getSubotApiPath},Rg:function(){return getChatbotApiPath},SF:function(){return getCareDoctorUrl},WH:function(){return getLeadPath},at:function(){return getCurrentBaseUrl},e1:function(){return getTogetherPath},eB:function(){return getCareDomain},er:function(){return getApiPath},gQ:function(){return getUrlToRedirectToSSOWithReturnUrl},jA:function(){return getBabyVaccineToolPath},nN:function(){return getHellositePath},oN:function(){return getHelloSitesUrl},pN:function(){return getServiceUrl},vf:function(){return getLocalApiPath},vo:function(){return getApiTrackingPath},yZ:function(){return getCareSearchPageUrl}});var r=n("NmYn"),i=n.n(r),o=n("gY0P"),a=n.n(o),l=n("/sjq"),c=n("9brV");let u=c.Km.NEXT_PUBLIC_DEPLOY_LOCALE||"en-PH",formatString=function(){for(var e=arguments.length,t=Array(e),n=0;ne&&(!e.includes("=")||e.split("=")[1]));return 0===n.length?e:"".concat(e,"?").concat(n.join("&"))}return r},getLocalApiPath=(e,t)=>{let{NEXT_PUBLIC_BASE_API_URL:n}=c.Km;return n+"wp-json/api/"+formatString(e,{...t})},getApiPath=(e,t)=>{let{NEXT_PUBLIC_BASE_API_URL:n,WP_INTERNAL_API:r}=c.Km;return(r||n)+"wp-json/api/"+formatString(e,{...t})},getApiTrackingPath=(e,t)=>c.Km.NEXT_PUBLIC_BASE_API_URL+"wp-json/"+formatString(e,{...t}),getLeadPath=(e,t)=>c.Km.NEXT_PUBLIC_LEAD_API+"api/"+formatString(e,{...t}),getTogetherPath=(e,t,n)=>c.Km.NEXT_PUBLIC_TOGETHER_API+"api/".concat(n||"v1","/")+formatString(e,{...t}),getCurrentBaseUrl=e=>window.location.origin,getCareDomain=e=>{let t="production"===c.Km.DEPLOY_ENV;return t?"".concat(l.domainLocales[e],"/care"):"discover.".concat(l.domainLocales[e],"/care")},slugifiedNameWithId=(e,t,n,r)=>r&&t?"".concat(r,"-").concat(t):"".concat(i()(e||"",{lower:!0,locale:n||u}),"-").concat(t),getServiceUrl=e=>{var t,n;let{locale:r,citySlug:o}=e;return"/care/".concat(i()(o||(null===(t=c.ix[r||"vi-VN"])||void 0===t?void 0:t.CURRENT)||"",{lower:!0,locale:r}),"/").concat(null===(n=c.ix[r||"vi-VN"])||void 0===n?void 0:n.SERVICE)},getCareAllSpecialtyUrl=e=>{var t;let{locale:n}=e;return"/care/".concat(null===(t=c.ix[n||"vi-VN"])||void 0===t?void 0:t.SPECIALTIES)},getCareSpecialtyUrl=e=>{var t,n;let{locale:r,citySlug:o,slug:a}=e;return"/care/".concat(i()(o||(null===(t=c.ix[r||"vi-VN"])||void 0===t?void 0:t.ALL)||"",{lower:!0,locale:r}),"/").concat(null===(n=c.ix[r||"vi-VN"])||void 0===n?void 0:n.HOSPITAL,"/").concat(a)},getCareHospitalUrl=e=>{var t;let{name:n,id:r,locale:i,slug:o}=e;return"/care/".concat(null===(t=c.ix[i||"vi-VN"])||void 0===t?void 0:t.HOSPITAL,"/").concat(slugifiedNameWithId(n,r,i,o))},getCareDoctorUrl=e=>{var t;let{name:n,id:r,locale:i}=e;return"/care/".concat(null===(t=c.ix[i||"vi-VN"])||void 0===t?void 0:t.DOCTOR,"/").concat(slugifiedNameWithId(n,r))},getCareServiceUrl=e=>{var t;let{name:n,id:r,locale:i}=e;return"/care/".concat(null===(t=c.ix[i||"vi-VN"])||void 0===t?void 0:t.SERVICE,"/").concat(slugifiedNameWithId(n,r))},getCareSearchPageUrl=e=>{var t,n;let{type:r,locale:i,searchSlug:o}=e;return"/care/".concat(null===(t=c.ix[i])||void 0===t?void 0:t.CURRENT,"/").concat(null===(n=c.ix[i])||void 0===n?void 0:n[c.m4[r]],"/").concat(null!=o?o:"")},getBabyVaccineToolPath=(e,t)=>(c.Km.INTERNAL_VACCINATION_TOOL_API||c.Km.NEXT_PUBLIC_VACCINATION_TOOL_API)+formatString(e,{...t,domain:l.domainLocales[u]}),getUrlToRedirectToSSOWithReturnUrl=(e,t,n)=>{let r=e||window.location.href,i=t?"".concat(r.includes("?")?"&":"?","source=").concat(t):"",o=n?"".concat(r.includes("?")||i?"&":"?","action=").concat(n):"";return c.a5?"".concat(c.a5,"?returnUrl=").concat(encodeURIComponent("".concat(r).concat(i).concat(o))):"/"},getSubotApiPath=(e,t)=>{let{SUBOT_INTERNAL:n,NEXT_PUBLIC_SUBOT_API:r}=c.Km;return r+formatString(e,{...t})},getEcommerceApiPath=(e,t)=>{let{NEXT_PUBLIC_ECOMMERCE_API:n}=c.Km;return(n||"https://uat-ecommerce.hellobacsi.com/")+"rest/"+c.Km.NEXT_PUBLIC_STORE_CODE+"/V1/"+formatString(e,{...t})},getChatbotApiPath=(e,t)=>{let{NEXT_PUBLIC_CHAT_BOT_API:n="https://chatbot-staging.hellohealthgroup.com/"}=c.Km;return n+formatString(e,{...t})},getHelloSitesUrl=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],{DEPLOY_ENV:r}=c.Km,i=!t&&("localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname);return n?"https://".concat(l.domainLocales[e]):i?"http://".concat(window.location.host):"https://".concat("production"===r?"":"discover.").concat(l.domainLocales[e])};function getHellositePath(e){let{locale:t,slug:n,query:r}=e,i=getHelloSitesUrl(t);"tl-PH"===t&&(i+="/fil");let o="?";if(void 0!==r){let e="";Object.keys(r).map(t=>{let n=r[t];Array.isArray(n)&&(o+=e+n.map(e=>"".concat(t,"=").concat(e)).join("&"),e="&"),"string"==typeof n&&(o+=e+"".concat(t,"=").concat(n),e="&")})}"?"===o&&(o="");let a=[];return"string"==typeof n&&(a=n.split("/").filter(Boolean)),Array.isArray(n)&&(a=n.map(e=>e.split("/").filter(Boolean).join("/"),[])),i+"/"+a.join("/")+"/"+o}function getPathURLSearchParams(e,t){let n=e,r=new URLSearchParams(t),i=0;return r.forEach((e,t)=>{e?i++:r.delete(t)}),0!==i&&(n+="?".concat(r)),n}},"a5L+":function(e,t,n){n.d(t,{a:function(){return useIsMobile}});var r=n("bGjd");let useIsMobile=e=>{let{isMobile:t,isMobileSSR:n,isLargeMobile:i}=(0,r.lm)();return"boolean"==typeof t||"boolean"==typeof i?!!(e&&i||t):!!(e&&i||n)}},bGjd:function(e,t,n){n.d(t,{LB:function(){return ScreenSizeProvider},O4:function(){return ScreenSizeListener},lm:function(){return useScreenSize}});var r=n("BGKE"),i=n("+OUp"),o=n("sEfC"),a=n.n(o),l=n("oWg6"),c=n("VNqU"),u=n("a5vB");let getIsMobile=()=>window.innerWidth<768,getIsLargeMobile=()=>window.innerWidth>=768&&window.innerWidth<1112,useScreenSize=()=>{let{isMobile:e,isLargeMobile:t,isMobileSSR:n}=useScreenSizeContext(e=>({isMobile:e.isMobile,isLargeMobile:e.isLargeMobile,isMobileSSR:e.isMobileSSR}),u.x);return{isMobile:e,isLargeMobile:t,isMobileSSR:n}},useScreenSizeListener=()=>{let{setIsMobile:e,setIsLargeMobile:t}=useScreenSizeContext(e=>({setSSR:e.setSSR,setIsMobile:e.setIsMobile,setIsLargeMobile:e.setIsLargeMobile}),u.x);(0,i.useEffect)(()=>{let n=a()(()=>{let n=getIsMobile(),r=getIsLargeMobile();"boolean"==typeof n&&e(n),"boolean"==typeof r&&t(r)},200);return window.addEventListener("resize",n,{passive:!0}),()=>{window.removeEventListener("resize",n)}},[])},ScreenSizeListener=()=>(useScreenSizeListener(),null),createScreenSizeStore=e=>{let t={isMobile:getIsMobile(),isLargeMobile:getIsLargeMobile()};return(0,l.y)()(n=>({...t,...e,setIsMobile:e=>n({isMobile:e}),setIsLargeMobile:e=>n({isLargeMobile:e}),setSSR:e=>n({isMobileSSR:e})}))},s=(0,i.createContext)(null),ScreenSizeProvider=e=>{let{isMobileSSR:t,children:n}=e,o=(0,i.useRef)();return o.current||(o.current=createScreenSizeStore({isMobileSSR:t})),(0,r.Y)(s.Provider,{value:o.current,children:n})};function useScreenSizeContext(e,t){let n=(0,i.useContext)(s);if(!n)throw Error("Missing ScreenSizeContext.Provider in the tree");return(0,c.Pj)(n,e,t)}}}]);