"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8809],{58809:function(e,s,t){t.d(s,{Z:function(){return o}});var a=t(57437),i=t(7449),r=t.n(i),n=t(28382);function o(e){let{isSeller:s=!1}=e;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r(),{children:(0,a.jsx)("title",{children:"Log in"})}),(0,a.jsx)("main",{className:"w-full bg-darker-gray h-screen flex flex-col items-center justify-center px-4 sm:px-4",children:(0,a.jsx)(n.Z,{isSeller:s})})]})}},28382:function(e,s,t){t.d(s,{Z:function(){return f}});var a=t(57437),i=t(16463),r=t(2265),n=t(71907),o=t(29039),l=t(99795),c=t(23386),d=t(14393),u=t(98145),m=t(5186),h=t(8407);let g=async(e,s)=>{try{return(await (0,m.e5)(h.I8,e,s)).user}catch(e){if(console.warn("[signin.emailSignIn]: ".concat(e.code," ").concat(e.message),e),"auth/wrong-password"===e.code)throw Error("Wrong password");throw e}},x=async()=>{try{let e=new m.hJ;e.setCustomParameters({prompt:"select_account"});let s=m.rh,t=(await s(h.I8,e)).user;return(0,o.JG)("/api/login"),t}catch(e){alert("failed to login via google: ".concat(e.code," ").concat(e.message))}},p=async()=>{try{let e=prompt("Enter your email address.");e.trim(),await (0,m.LS)(h.I8,e),alert("Password reset email sent to ".concat(e))}catch(e){console.warn("[sendPasswordReset] Failed to reset password: ".concat(e.code," ").concat(e.message))}};var f=e=>{let{isSeller:s=!1,customRedirectURL:t="",signInCompleted:m}=e,[h,f]=(0,r.useState)("signin"),w=r.createRef(),y=(0,i.useRouter)(),j=(0,i.usePathname)(),[v,b]=(0,r.useState)(void 0),[N,C]=(0,r.useState)({code:"",email:"",password:""}),[k,P]=(0,r.useState)({password:!1,loading:!1}),[L,S]=(0,r.useState)({password:!1,email:!1}),[E,_]=(0,r.useState)({password:!1,email:!1}),[Z,A]=(0,r.useState)(!1),{mutate:H}=(0,o.ZP)("/api/login");(0,r.useEffect)(()=>{I(!1)},[N]);let I=e=>{(e||N.email&&!E.email)&&(E.email=!0),(e||N.password&&!E.password)&&(E.password=!0);let s={...L,email:N.email.includes("@"),password:N.password.length>5};return S(s),_({...E}),s.email&&s.password},z=()=>{let e="verify/sms?redirectTo=".concat(t);return s?"/seller/".concat(e):"/user/".concat(e)},D=async()=>{let e=await x();await (0,d.D2)("replicate-new-user",{uid:e.uid,provider:"google"}),console.log("[Login] Google signin complete"),A(!0);try{if((await (0,u.Ai)(e.uid)).sms_verified){if(console.log("[Login] Phone verified"),t){if(t===j){H(),m&&m();return}y.push(t);return}y.push("/")}else console.log("[Login] Phone does not verified"),y.push(z())}catch(e){console.log("[Login] User does not exist"),A(!1),y.push(z())}},F=async e=>{if(e.preventDefault(),I(!0)){console.log("[Login] ".concat(h," with email"),N.email),w.current.execute(),A(!0);try{if(b(void 0),P({...k,loading:!0}),"signin"!==h){let s=await (0,c.P)(e,"create-user",N,A,()=>{},{no_auth:!0});if(console.log("[Login] create-user response",s),s.error&&"Email already exists"!==s.error){b({error:"error",body:"Error signing up :(. Please try again or change credentials."});return}if(s.success){let e=await g(N.email,N.password);await H("/api/login"),await H("/api/profile/".concat(e.uid)),y.push(z());return}}let s=await g(N.email,N.password);if(console.log("[Login] Successful login"),s&&s.uid){let e=await (0,u.Ai)(s.uid);if(e&&e.sms_verified){if(console.log("[Login] Phone verified"),t){if(t===j){H(),m&&m();return}y.push(t);return}y.push("/")}else console.log("[Login] Phone not verified"),y.push(z())}else console.log("[Login] No user returned from sign in")}catch(e){A(!1),console.error("[Login] Error: ".concat(e)),b({type:"error",body:"auth/user-not-found"===e.code?"Wrong email address or password.":"".concat(e)})}}};return(0,a.jsxs)("div",{className:"w-full max-w-sm space-y-5 text-white",children:[(0,a.jsx)("div",{className:"mx-auto",children:(0,a.jsx)(l.Z,{width:100,height:100,textSizePx:70})}),(0,a.jsx)("div",{className:"pb-8 text-center",children:(0,a.jsx)("div",{className:"mt-5",children:(0,a.jsx)("h3",{className:"text-2xl font-bold text-gray-200 sm:text-3xl",children:"signin"===h?"Log in to your account":"Create a new account"})})}),(0,a.jsxs)("button",{type:"button",onClick:()=>D(),className:"mt-5 flex w-full items-center justify-center gap-x-3 rounded-lg border bg-white py-2.5 text-sm font-medium text-black duration-150 hover:bg-gray-200 active:bg-gray-100",children:[(0,a.jsxs)("svg",{className:"h-5 w-5",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[(0,a.jsxs)("g",{clipPath:"url(#clip0_17_40)",children:[(0,a.jsx)("path",{d:"M47.532 24.5528C47.532 22.9214 47.3997 21.2811 47.1175 19.6761H24.48V28.9181H37.4434C36.9055 31.8988 35.177 34.5356 32.6461 36.2111V42.2078H40.3801C44.9217 38.0278 47.532 31.8547 47.532 24.5528Z",fill:"#4285F4"}),(0,a.jsx)("path",{d:"M24.48 48.0016C30.9529 48.0016 36.4116 45.8764 40.3888 42.2078L32.6549 36.2111C30.5031 37.675 27.7252 38.5039 24.4888 38.5039C18.2275 38.5039 12.9187 34.2798 11.0139 28.6006H3.03296V34.7825C7.10718 42.8868 15.4056 48.0016 24.48 48.0016Z",fill:"#34A853"}),(0,a.jsx)("path",{d:"M11.0051 28.6006C9.99973 25.6199 9.99973 22.3922 11.0051 19.4115V13.2296H3.03298C-0.371021 20.0112 -0.371021 28.0009 3.03298 34.7825L11.0051 28.6006Z",fill:"#FBBC04"}),(0,a.jsx)("path",{d:"M24.48 9.49932C27.9016 9.44641 31.2086 10.7339 33.6866 13.0973L40.5387 6.24523C36.2 2.17101 30.4414 -0.068932 24.48 0.00161733C15.4055 0.00161733 7.10718 5.11644 3.03296 13.2296L11.005 19.4115C12.901 13.7235 18.2187 9.49932 24.48 9.49932Z",fill:"#EA4335"})]}),(0,a.jsx)("defs",{children:(0,a.jsx)("clipPath",{id:"clip0_17_40",children:(0,a.jsx)("rect",{width:"48",height:"48",fill:"white"})})})]}),"with Google"]}),(0,a.jsx)("br",{}),(0,a.jsx)("p",{className:"flex w-full items-center justify-center text-sm font-medium text-gray-200",children:"or continue with email"}),(0,a.jsxs)("form",{onSubmit:F,className:"space-y-5",children:[(0,a.jsx)(n.Z,{ref:w,size:"invisible",sitekey:"6LcmuGEhAAAAANpJzXTeSNCv5ZRDCkrweEMPWRFk",onChange:e=>{e&&(w.current.reset(),C({...N,code:e}))}}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"font-medium text-gray-200",children:"Email"}),(0,a.jsx)("input",{type:"email",id:"email",name:"email",placeholder:"Email",onChange:e=>C({...N,email:e.target.value}),className:"mt-2 w-full rounded-lg border bg-transparent px-3 py-2 leading-tight text-gray-50 shadow-sm outline-none focus:border-sky-500 focus:outline-none focus:ring-sky-500"}),!L.email&&E.email?(0,a.jsx)("span",{className:"text-xs text-red-500",children:"Email address is not valid."}):""]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"font-medium text-gray-200",children:"Password"}),(0,a.jsxs)("div",{className:"relative mt-2",children:[(0,a.jsx)("input",{type:k.password?"text":"password",autoComplete:"currentpassword",placeholder:"Password",id:"Password",name:"Password",onChange:e=>C({...N,password:e.target.value}),className:"mt-2 w-full rounded-lg border bg-transparent px-3 py-2 pr-10 leading-tight text-gray-50 shadow-sm outline-none focus:border-sky-500 focus:outline-none focus:ring-sky-500"}),(0,a.jsx)("button",{className:"absolute inset-y-0 right-3 py-4",onClick:()=>P({...k,password:!k.password}),tabIndex:-1,children:(0,a.jsx)("span",{className:"material-icons",children:k.password?"visibility_off":"visibility"})})]}),!L.password&&E.password?(0,a.jsx)("span",{className:"text-xs text-red-500",children:"Password is not valid."}):""]}),(0,a.jsxs)("div",{className:"flex items-center justify-between text-sm",children:[(0,a.jsx)("div",{className:"flex items-center gap-x-3",children:(0,a.jsx)("input",{type:"checkbox",id:"remember-me-checkbox",className:"checkbox-item peer hidden"})}),(0,a.jsx)("a",{onClick:()=>p(),className:"text-center text-gray-200 hover:cursor-pointer hover:text-red-600",children:"Forgot password?"})]}),(0,a.jsxs)("button",{type:"submit",className:"flex w-full items-center justify-center rounded-lg bg-logo-orange px-4 py-2 font-medium text-white duration-150 hover:bg-red-600 active:bg-red-400",disabled:Z,children:[Z&&(0,a.jsxs)("svg",{className:"-ml-1 mr-3 h-5 w-5 animate-spin text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,a.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"white",strokeWidth:"4"}),(0,a.jsx)("path",{className:"opacity-75",fill:"white",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"signin"===h?"Sign In":"Sign Up"]}),v&&(0,a.jsx)("span",{className:"mx-auto flex items-center justify-center text-xs text-red-500",children:v.body})]}),(0,a.jsxs)("p",{className:"text-center",children:["signin"===h?"Don't have an account? ":"Already have an account? ",(0,a.jsx)("button",{type:"button",className:"font-medium text-logo-orange hover:text-red-600",onClick:()=>f("signin"===h?"signup":"signin"),disabled:Z,children:"signin"===h?"Sign Up":"Sign In"})]})]})}},99795:function(e,s,t){t.d(s,{Z:function(){return n}});var a=t(57437),i=t(66648),r=t(73943);function n(e){let{width:s=32,height:t=32,textSizePx:n=24,textColorClassName:o="text-white"}=e;return(0,a.jsxs)("div",{className:"flex items-center justify-center gap-2",children:[(0,a.jsx)(i.default,{src:r.default,alt:"Logo",width:s,height:t,priority:!0}),(0,a.jsx)("h2",{className:"".concat(o," m-0"),style:{fontSize:n},children:"BidCloud"})]})}},23386:function(e,s,t){t.d(s,{P:function(){return i}});var a=t(14393);let i=async(e,s,t,i,r,n)=>{try{e.preventDefault(),i(!0);let o=await (0,a.D2)(s,t,n);return r(o.error?{type:"error",body:o.error}:{type:"success",body:"Completed successfully"}),o}catch(e){r({type:"error",body:e.message})}finally{i(!1)}}},73943:function(e,s,t){t.r(s),s.default={src:"/_next/static/media/logo-big.8aea1304.svg",height:63,width:80,blurWidth:0,blurHeight:0}}}]);