"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9480],{15641:(e,r,t)=>{t.d(r,{k:()=>g});var o=t(75302),l=t(24847),i=t(73923),n=t(83531),a=t(28430),c=t(53876),u=t(42292),s=t(16151),d=t(92700);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}}},19480:(e,r,t)=>{t.d(r,{GoogleAuthScript:()=>w});var o=t(76792),l=t(73675),i=t(42292),n=t(75302),a=t(47421),c=t(53876),u=t(29851),s=t(83531),d=t(28430),g=t(15641),h=t(89170),m=t(46003),p=t(79442);function w(e){let{onLoad:r,prompt:t=!0}=e,w=(0,a.c3)("GoogleLogin"),f=(0,n.Xr)(m.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)},[])}}(),{DISCONNECTED_user:{isUserLoggedIn:b}={}}=(0,h.J)();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(),!b&&t&&(null==l||l.prompt())},id:"google-gsi-script"}),(0,o.jsx)(p.lG,{open:!!v,onOpenChange:e=>!e&&P(),children:(0,o.jsx)(p.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")}})})]})}},28430:(e,r,t)=>{t.d(r,{g:()=>s});var o=t(75302),l=t(33845),i=t(29851),n=t(83531),a=t(89170),c=t(71666),u=t(1313);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}}},46003:(e,r,t)=>{t.d(r,{R:()=>o});let o=(0,t(11854).eU)(!1)},53876:(e,r,t)=>{t.d(r,{A:()=>i,b:()=>l});var o=t(55198);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},73923:(e,r,t)=>{t.d(r,{_:()=>o});let o=new(t(6502)).UPSXClient({baseUrl:"https://upsx.weather.com"})}}]);