(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2626],{75380:function(e,t,a){Promise.resolve().then(a.bind(a,71193))},87138:function(e,t,a){"use strict";a.d(t,{default:function(){return r.a}});var n=a(231),r=a.n(n)},16463:function(e,t,a){"use strict";var n=a(71169);a.o(n,"usePathname")&&a.d(t,{usePathname:function(){return n.usePathname}}),a.o(n,"useRouter")&&a.d(t,{useRouter:function(){return n.useRouter}}),a.o(n,"useSearchParams")&&a.d(t,{useSearchParams:function(){return n.useSearchParams}})},53782:function(e,t,a){"use strict";a.d(t,{U0:function(){return o},zf:function(){return i}});var n=a(42477),r=a(2265),s=(0,r.createContext)({client:n.ZP});function i(e){var t=e.children,a=e.client,i=e.apiKey,o=e.options,l=(0,r.useMemo)(function(){return(a&&i&&console.warn("[PostHog.js] You have provided both a client and an apiKey to PostHogProvider. The apiKey will be ignored in favour of the client."),a&&o&&console.warn("[PostHog.js] You have provided both a client and options to PostHogProvider. The options will be ignored in favour of the client."),a)?a:(i&&(n.ZP.__loaded&&console.warn("[PostHog.js] was already loaded elsewhere. This may cause issues."),n.ZP.init(i,o)),n.ZP)},[a,i]);return r.createElement(s.Provider,{value:{client:l}},t)}var o=function(){return(0,r.useContext)(s).client}},71193:function(e,t,a){"use strict";a.r(t),a.d(t,{default:function(){return w}});var n=a(57437),r=a(64967),s=a(93639),i=a(63481),o=a(23085),l=a(89506),d=a(71830),c=a(737),u=a(762),m=a(42126),f=a(93375),h=a(5186),g=a(87138),p=a(16463),v=a(2265),x=a(39343);function w(){let{updateUserData:e}=(0,v.useContext)(c.V);(0,p.useRouter)();let[t,a]=(0,v.useState)(""),[w,b]=(0,v.useState)(!1),{register:j,handleSubmit:y,formState:{errors:C}}=(0,x.cI)(),k=async e=>{let t=localStorage.getItem("previousPath"),{email:n,password:r}=e;b(!0);try{let e=(await (0,h.e5)(l.I8,n,r)).user,a=e.displayName||"Unknown User";d.Z.track("Sign In",{method:"Email and Password",userName:a}),b(!1),(0,f.setCookie)("currentUserUid",e.uid,u.mb),t?window.location.assign(t):window.location.assign("/search")}catch(e){b(!1),"auth/wrong-password"===e.code?a("Invalid Password"):"auth/user-not-found"===e.code?a("User with that email doesn't exist"):a("Something Went Wrong. Please try again!"),console.log("Error is",e.code)}},N=async()=>{let e=localStorage.getItem("previousPath");try{var t,a;let n=await (0,h.rh)(l.I8,l.Ap),s=n.user.displayName,i=n.user.uid,c=n.user.photoURL,g=n.user.email,p=await m.Z.get("".concat(r._,"/check-user/").concat(i));if(null==p?void 0:p.data)d.Z.track("Sign In",{method:"Google",userName:n.user.displayName}),(0,f.setCookie)("currentUserUid",null==n?void 0:null===(a=n.user)||void 0===a?void 0:a.uid,u.mb),e?window.location.assign(e):window.location.assign("/search");else{await m.Z.post("".concat(r._,"/signup"),{FullName:s,uid:i,email:g,photo:c}),d.Z.track("Sign Up",{method:"Google",FullName:s});let e={email:g,firstName:(0,u.cF)(s).firstName,lastName:(0,u.cF)(s).lastName};await (0,o.xQ)(e,"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"),(0,u.XA)("You've Signed Up Successfully"),(0,f.setCookie)("currentUserUid",null==n?void 0:null===(t=n.user)||void 0===t?void 0:t.uid,u.mb),window.location.assign("/onboarding")}}catch(e){console.log("Google error",e)}};return(0,n.jsx)(i.Z,{children:(0,n.jsx)("div",{className:"flex justify-center items-center h-[85vh]",children:(0,n.jsxs)("div",{className:"bg-[#fff] dark:bg-[#1a1b1f] p-10 rounded-xl w-full max-w-[500px]",children:[(0,n.jsx)("p",{className:"text-center text-[24px] mb-8",children:"Log in to your account"}),t&&(0,n.jsx)("div",{className:"p-2 mb-4 bg-red-200 border border-red-500 text-center text-red-500 rounded-md",children:t}),(0,n.jsxs)("form",{onSubmit:y(k),children:[(0,n.jsxs)("div",{className:"mb-6",children:[(0,n.jsx)("label",{htmlFor:"email",children:"Email"}),(0,n.jsx)("input",{id:"email",className:"p-3 rounded-md w-full text-[#000] bg-[#f7f7f7] dark:bg-[#fff]",type:"email",placeholder:"Enter email...",...j("email",{required:!0,pattern:/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/})}),C.email&&(0,n.jsx)("p",{className:"text-red-500 mt-2",children:"Invalid email."})]}),(0,n.jsxs)("div",{className:"mb-6",children:[(0,n.jsx)("label",{htmlFor:"password",children:"Password"}),(0,n.jsx)("input",{id:"password",className:"p-3 rounded-md w-full text-[#000] bg-[#f7f7f7] dark:bg-[#fff]",type:"password",placeholder:"Enter password...",...j("password",{required:!0,minLength:6})}),C.password&&(0,n.jsx)("p",{className:"text-red-500 mt-2",children:"Password must be at least 6 characters long."})]}),(0,n.jsx)("button",{type:"submit",className:"w-full p-3 flex justify-center items-center bg-[#E36B20] disabled:bg-gray-300 dark:disabled:bg-gray-500 rounded-lg mb-4",children:w?(0,n.jsx)(s.Z,{}):"Login"})]}),(0,n.jsxs)("button",{onClick:N,className:"w-full p-3 flex justify-center items-center gap-3 rounded-lg bg-[#f7f7f7] dark:bg-[#282828]",children:[(0,n.jsxs)("svg",{width:15,height:16,viewBox:"0 0 19 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,n.jsx)("path",{d:"M18.9892 10.1871C18.9892 9.36767 18.9246 8.76973 18.7847 8.14966H9.68848V11.848H15.0277C14.9201 12.767 14.3388 14.1512 13.047 15.0812L13.0289 15.205L15.905 17.4969L16.1042 17.5173C17.9342 15.7789 18.9892 13.221 18.9892 10.1871Z",fill:"#4285F4"}),(0,n.jsx)("path",{d:"M9.68813 19.9314C12.3039 19.9314 14.4999 19.0455 16.1039 17.5174L13.0467 15.0813C12.2286 15.6682 11.1306 16.0779 9.68813 16.0779C7.12612 16.0779 4.95165 14.3395 4.17651 11.9366L4.06289 11.9465L1.07231 14.3273L1.0332 14.4391C2.62638 17.6946 5.89889 19.9314 9.68813 19.9314Z",fill:"#34A853"}),(0,n.jsx)("path",{d:"M4.17667 11.9366C3.97215 11.3165 3.85378 10.6521 3.85378 9.96562C3.85378 9.27905 3.97215 8.6147 4.16591 7.99463L4.1605 7.86257L1.13246 5.44363L1.03339 5.49211C0.37677 6.84302 0 8.36005 0 9.96562C0 11.5712 0.37677 13.0881 1.03339 14.4391L4.17667 11.9366Z",fill:"#FBBC05"}),(0,n.jsx)("path",{d:"M9.68807 3.85336C11.5073 3.85336 12.7344 4.66168 13.4342 5.33718L16.1684 2.59107C14.4892 0.985496 12.3039 0 9.68807 0C5.89885 0 2.62637 2.23672 1.0332 5.49214L4.16573 7.99466C4.95162 5.59183 7.12608 3.85336 9.68807 3.85336Z",fill:"#EB4335"})]}),(0,n.jsx)("span",{children:"Login with Google"})]}),(0,n.jsxs)("p",{className:"text-center text-sm mt-8 font-normal",children:["Don't have an account? Click here to"," ",(0,n.jsx)(g.default,{className:"text-primaryColor font-semibold",href:"/signup",children:"SignUp"})]}),(0,n.jsx)(g.default,{className:"text-primaryColor text-sm underline block mt-2 text-center",href:"/forgot-password",children:"Forgot Password?"})]})})})}},93639:function(e,t,a){"use strict";a.d(t,{Z:function(){return s}});var n=a(57437);a(2265);var r=a(27485);function s(){return(0,n.jsx)("div",{className:"loader-spinner-container",children:(0,n.jsx)(r.g4,{height:"40",width:"30",radius:"9",color:"#5a5a5a",ariaLabel:"three-dots-loading",wrapperStyle:{},visible:!0})})}},63481:function(e,t,a){"use strict";a.d(t,{Z:function(){return r}});var n=a(57437);function r(e){let{children:t,className:a,containerClassname:r}=e;return(0,n.jsx)("main",{className:a,children:(0,n.jsx)("div",{className:"mt-[110px] max-w-full lg:max-w-[95vw] mx-auto px-3 md:px-6 ".concat(r),children:t})})}a(2265)},71830:function(e,t,a){"use strict";var n=a(4681),r=a.n(n);r().init("5a54bab568d5f61842f09277a9c88bb8",{debug:!0,track_pageview:!0,persistence:"localStorage"}),t.Z=r()},737:function(e,t,a){"use strict";a.d(t,{H:function(){return f},V:function(){return m}});var n=a(57437),r=a(64967),s=a(89506),i=a(42126),o=a(5186),l=a(2265),d=a(93375),c=a(762),u=a(53782);let m=(0,l.createContext)(null),f=e=>{let{children:t}=e,a=(0,u.U0)(),[f,h]=(0,l.useState)(null),[g,p]=(0,l.useState)(null),[v,x]=(0,l.useState)(!1),[w,b]=(0,l.useState)(null),j=async()=>{try{var e,t,n,s,o;let l=await i.Z.get("".concat(r._,"/check-user/").concat(null==f?void 0:f.uid));return null==a||a.identify(null==l?void 0:null===(e=l.data)||void 0===e?void 0:e.uid,{name:null==l?void 0:null===(t=l.data)||void 0===t?void 0:t.username,email:null==l?void 0:null===(n=l.data)||void 0===n?void 0:n.email}),(0,d.setCookie)("isAdmin",null!=l&&null!==(s=l.data)&&void 0!==s&&!!s.isAdmin,c.mb),p(null==l?void 0:l.data),x(null==l?void 0:null===(o=l.data)||void 0===o?void 0:o.isAdmin),l.data}catch(e){return console.error(e),[]}},y=async e=>{try{let t=await fetch("".concat(r._,"/user/stackRecommendations/").concat(e)),a=await t.json();b(a.recommendations)}catch(e){console.error("Failed to fetch user recommendations:",e)}};return(0,l.useEffect)(()=>{let e=(0,o.Aj)(s.I8,e=>{h(e),e?(0,d.setCookie)("currentUserUid",null==e?void 0:e.uid,c.mb):(0,d.setCookie)("currentUserUid","")});return()=>{e()}},[]),(0,l.useEffect)(()=>{(null==f?void 0:f.uid)&&j()},[f]),(0,n.jsx)(m.Provider,{value:{currentUser:f,currentUserData:g,updateUserData:()=>{j()},isAdmin:v,userRecommendations:w,fetchUserRecommendations:y},children:t})}}},function(e){e.O(0,[4358,7205,6990,5878,9571,6603,5220,3540,231,7407,168,3661,2971,7023,1744],function(){return e(e.s=75380)}),_N_E=e.O()}]);