(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8295],{7984:(e,s,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/login",function(){return r(35723)}])},35723:(e,s,r)=>{"use strict";r.r(s),r.d(s,{__N_SSP:()=>_,default:()=>S});var i=r(37876),o=r(89572),t=r(76841),a=r(947),n=r(52001),l=r(14232),c=r(36038),d=r(89099),p=r(60513),u=r(88992),h=r(13810),w=r(54761),f=r(52447),g=r(5336),x=r(48230),y=r.n(x),m=r(37747),j=r(4439);let b=p.z.object({email:p.z.string().email(),password:p.z.string().min(1)});var _=!0;function S(){let{sendGenericError:e,sendToast:s}=(0,n.Yf)(),{register:r,...p}=(0,u.mN)({resolver:(0,h.u)(b)}),x=(0,d.useRouter)(),_=function(e){if(!e)return"/";let s=Array.isArray(e)?e[0]:e;return s&&s.startsWith("/")?s:"/"}(x.query.redirectTo),[S,E]=(0,l.useState)("Idle"),N=async s=>{E("Loading");try{let e=await fetch("/api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),r=await e.json();if("error"in r)throw Error(r.error);E("Success"),window.location.href=_}catch(r){if(r instanceof Error&&"Please confirm your account before logging in."===r.message)return void x.push({pathname:"/confirm/expired",query:{email:s.email}});e(r),E("Idle")}};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(j.p,{title:"Login | Are.na"}),(0,i.jsx)(m.n,{children:(0,i.jsxs)(o.a,{as:"form",method:"POST",action:"/api/login",onSubmit:p.handleSubmit(N,e=>{Object.entries(e).forEach(e=>{let[r,i]=e;i&&s({title:(0,f.NK)(r),description:i.message,variant:"error"})})}),css:{display:"flex",flexDirection:"column",gap:"$4"},children:[(0,i.jsx)(a.pd,{id:"Login--email",...r("email"),type:"email",placeholder:"Enter your email",autoFocus:!0}),(0,i.jsx)(c.y,{id:"Login--password",...r("password"),placeholder:"Enter your password",value:p.watch("password")}),(0,i.jsxs)(w.Es,{css:{justifyContent:"space-between"},children:[(0,i.jsx)(g.E,{size:"xs",as:y(),href:"/forgot",css:{fontWeight:"bold",color:"$link"},children:"Forgot password?"}),(0,i.jsx)(t.$,{type:"submit",disabled:"Loading"===S||"Success"===S,children:{Idle:"Log in",Loading:"Logging in",Success:"Redirecting"}[S]})]})]})})]})}},36038:(e,s,r)=>{"use strict";r.d(s,{y:()=>c});var i=r(37876),o=r(84147),t=r(33210),a=r(39220),n=r(77680),l=r(14232);let c=(0,l.forwardRef)((e,s)=>{let[r,c]=(0,l.useState)("password");return(0,i.jsx)(t.o,{ref:s,type:r,label:(0,i.jsx)(a.m_,{label:"password"===r?"Show password":"Hide password",children:(0,i.jsx)(o.D,{onClick:()=>{c(e=>"password"===e?"text":"password")},css:{display:"flex"},"aria-label":"password"===r?"Show password":"Hide password",children:"password"===r?(0,i.jsx)(n.N5q,{}):(0,i.jsx)(n.luy,{})})}),...e})});c.displayName="PasswordInput"},37747:(e,s,r)=>{"use strict";r.d(s,{n:()=>c});var i=r(37876),o=r(4068),t=r(68944),a=r(12209),n=r(88024),l=r(1261);let c=e=>{let{children:s,span:r="narrow"}=e;return(0,i.jsx)(n.Y,{css:{py:0,color:"$link"},children:(0,i.jsx)(a.e,{children:(0,i.jsxs)(a.VP,{span:r,css:{display:"flex",flexDirection:"column",justifyContent:"center",minHeight:"calc(100dvh - ".concat(t.MJ,"px)"),py:"$6","@bp1":{py:"$3"}},children:[(0,i.jsx)(o.g,{css:{width:20,height:12,color:"$slate"}}),(0,i.jsx)(l.h,{y:"$4"}),s]})})})}}},e=>{var s=s=>e(e.s=s);e.O(0,[636,6593,8792],()=>s(7984)),_N_E=e.O()}]);