"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4890],{25993:(e,r,t)=>{t.d(r,{A:()=>i,b:()=>l});var o=t(1068);let l=()=>{let e=(0,o.useRouter)();return{navigate:function(r){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{mpa:o=!0,replace:l=!1}=t;o?l?window.location.replace(r):window.location.href=r:l?e.replace(r):e.push(r)},refresh:function(){let r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{mpa:t=!0}=r;t?window.location.reload():e.refresh()},router:e}},i=l},36749:(e,r,t)=>{t.d(r,{_:()=>o});let o=new(t(5669)).UPSXClient({baseUrl:"https://upsx.weather.com"})},38738:(e,r,t)=>{t.d(r,{R:()=>o});let o=(0,t(28449).eU)(!1)},49341:(e,r,t)=>{t.d(r,{g:()=>s});var o=t(9933),l=t(10212),i=t(80068),n=t(95112),a=t(58544),c=t(44641),u=t(76279);function s(){let{user:{isUserLoggedIn:e}}=(0,a.J)(),[r,t]=(0,o.fp)(l.JK),[s,d]=(0,o.fp)(n.YA),g=async e=>{try{await i._.preference.updatePreference(e)}catch(e){return console.error("Failed to sync preferences with server:",e),null}},h=async function(o){let l=!(arguments.length>1)||void 0===arguments[1]||arguments[1];try{let i=(e=>{let o={...r,...e};return t(o),d({...s,...e}),o})(o);if(null==o?void 0:o.unit){let e=(0,c.xP)(o.unit),r=(null==e?void 0:e.code)||"e";r&&(0,u.setCookie)(c.lr,r,{domain:"weather.com"})}return l&&e&&await g(i),{success:!0}}catch(e){return console.error("Failed to update preferences:",e),{success:!1,error:e instanceof Error?e.message:"Failed to update preferences"}}};return{syncPreferencesFromUpsx:async()=>{try{let e=await i._.preference.getPreference();if(!(null==e?void 0:e.userID))return null;return h(e,!1),e}catch(e){return null}},updatePreferences:h}}},84890:(e,r,t)=>{t.d(r,{GoogleAuthScript:()=>p});var o=t(56707),l=t(69249),i=t(9251),n=t(9933),a=t(77746),c=t(25993),u=t(80068),s=t(95112),d=t(49341),g=t(89477),h=t(38738),m=t(13609);function p(e){let{onLoad:r,prompt:t=!0,isUserLoggedIn:p}=e,w=(0,a.c3)("GoogleLogin"),f=(0,n.Xr)(h.R),{loginWithGoogle:y,error:v,clearError:P}=function(){let e=(0,a.c3)("GoogleLogin"),[r,t]=(0,i.useState)(null),o=(0,n.Xr)(s.P9),{refresh:l}=(0,c.b)(),{syncPreferencesFromUpsx:h}=(0,d.g)(),{authSuccess:m}=(0,g.k)();return{loginWithGoogle:(0,i.useCallback)(async r=>{let{credential:o}=r;t(null);try{var l;let e=await u._.auth.loginWithGoogle({google_id_token:o});return await m({email:e.email,userID:e.userID,type:(null==e||null==(l=e.user)?void 0:l.isFirstLogin)?"signup":"login"}),!0}catch(r){console.error("Failed to login with Google",r);try{let o=null==r?void 0:r.data,l=null==o?void 0:o.messageCode;if(!l)throw Error("No Error Message");switch(l){case 1e3:case 1026:case 1033:t({header:e("emailAlreadyUsedGoogleHeader"),body:e.raw("emailAlreadyUsedGoogleBody")});break;case 1027:case 1030:t({header:e("emailAlreadyRegisteredGoogleHeader"),body:e("emailAlreadyRegisteredGoogleBody")});break;default:throw Error("No Specific Error")}}catch(r){t({header:e("somethingWentWrong")})}return!1}},[o,h,l,m]),error:r,clearError:(0,i.useCallback)(()=>{t(null)},[])}}();return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(l.default,{src:"https://accounts.google.com/gsi/client",onLoad:()=>{var e,o;let l=null==(o=window.google)||null==(e=o.accounts)?void 0:e.id;l&&(l.initialize({client_id:"797231885346-rai9vgnvf4u38enai8bhginnnrh5uvch.apps.googleusercontent.com",context:"signin",ux_mode:"popup",use_fedcm_for_prompt:!0,callback:e=>{y(e)}}),f(!0)),null==r||r(),!p&&t&&(null==l||l.prompt())},id:"google-gsi-script"}),(0,o.jsx)(m.lG,{open:!!v,onOpenChange:e=>!e&&P(),children:(0,o.jsx)(m.bt,{showCloseButton:!1,title:(null==v?void 0:v.header)||"",description:(0,o.jsx)("span",{dangerouslySetInnerHTML:{__html:(null==v?void 0:v.body)||""}}),primaryAction:{label:w("cancel")}})})]})}},89477:(e,r,t)=>{t.d(r,{k:()=>g});var o=t(9933),l=t(22853),i=t(36749),n=t(95112),a=t(49341),c=t(25993),u=t(9251),s=t(10782),d=t(91817);function g(){let e=(0,o.Xr)(n.P9),r=(0,o.md)(n.Qv),t=(0,o.md)(n.pX),g=(0,l.useGetCookie)(),{syncPreferencesFromUpsx:h,updatePreferences:m}=(0,a.g)(),{navigate:p}=(0,c.A)(),{login:w}=(()=>{let e=(0,s.G)(),r=(0,u.useCallback)(r=>{var t,o,l;if(!e)return console.warn("MParticle is not initialized"),Promise.reject(Error("MParticle is not initialized"));let i={userIdentities:{customerid:r.customerid,email:r.email,other:r.other}};return null==(l=window.mParticle)||null==(o=l.Identity)||null==(t=o.identify)?void 0:t.call(o,i)},[e]);return{identify:r,login:(0,u.useCallback)(r=>{var t,o,l;if(!e)return console.warn("MParticle is not initialized"),Promise.reject(Error("MParticle is not initialized"));let i={userIdentities:{customerid:r.customerid,email:r.email,facebook:r.facebook,facebookcustomaudienceid:r.facebookcustomaudienceid,google:r.google,microsoft:r.microsoft,other:r.other,other2:r.other2,other3:r.other3,other4:r.other4,twitter:r.twitter,yahoo:r.yahoo}};return null==(l=window.mParticle)||null==(o=l.Identity)||null==(t=o.login)?void 0:t.call(o,i)},[e]),logout:(0,u.useCallback)(()=>{var r,t,o;return e?null==(o=window.mParticle)||null==(t=o.Identity)||null==(r=t.logout)?void 0:r.call(t,{userIdentities:{}}):(console.warn("MParticle is not initialized"),Promise.reject(Error("MParticle is not initialized")))},[e])}})(),f=(()=>{let e=(0,s.G)(),r=(0,d.N)(),t=(0,u.useCallback)(function(o){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i={...r,...l};if(!e)return void console.warn("MParticle is not initialized");try{window.mParticle.logEvent(o,window.mParticle.EventType.Other,i),console.debug('MParticle: Event "'.concat(o,'" tracked'),i)}catch(e){console.error('MParticle: Event "'.concat(o,'" failed'),e)}return t},[r,e]);return t})(),y=async()=>{try{if(g("premium"))return null;return await i._.purchase.getPurchaseToken(),!0}catch(e){return console.error("Failed to get UPSX token:",e),!1}},v=async o=>{localStorage.setItem("PARTNERS_SYNC","true"),e(!0),await h()||await m({}),y(),(null==o?void 0:o.userID)&&(w({email:o.email,customerid:o.userID,other:t}),f("login"===o.type?"user-loggedin":"signup-complete",{url:window.location.pathname})),p(r,{mpa:!0})};return{login:async(e,r)=>{try{let t=await i._.auth.login({email:e,password:r});return t&&await v({email:t.email,userID:t.userID,type:"login"}),!0}catch(e){return console.error("Failed to login",e),!1}},authSuccess:v}}}}]);