import{d as _,r as o,c as n,a as s,x as R,q as m,v,t as w,b as y,p as q,w as N,s as V,R as h,y as x,g as B,k as i,l as C,z as S,i as U,A as E}from"./index-DPtT_PqD.js";const T={class:"panel form-page"},M={key:0,class:"error"},z={class:"field"},A={class:"field"},D={class:"field"},L={key:0,class:"success"},j={key:1,class:"error"},F=["disabled"],I=_({__name:"ResetPasswordPage",setup(G){const f=x(),k=E(),u=o(String(f.query.email||"")),c=o(String(f.query.token||"")),a=o(""),l=o(""),d=o(""),t=o(""),p=o(!1),b=B(()=>!!(u.value&&c.value));async function P(){if(d.value="",t.value="",a.value.length<8){t.value="Password must be at least 8 characters.";return}if(a.value!==l.value){t.value="Password confirmation does not match.";return}p.value=!0;try{d.value=await S.resetPassword({email:u.value,token:c.value,password:a.value,password_confirmation:l.value}),setTimeout(()=>{k.push("/login")},800)}catch(g){t.value=U(g,"Unable to reset password.")}finally{p.value=!1}}return(g,e)=>(i(),n("section",T,[e[7]||(e[7]=s("h2",null,"Set New Password",-1)),e[8]||(e[8]=s("p",null,"Choose a new password for your BizNovia account.",-1)),b.value?(i(),n("form",{key:1,class:"form",onSubmit:R(P,["prevent"])},[s("div",z,[e[3]||(e[3]=s("label",{for:"email"},"Email",-1)),m(s("input",{id:"email","onUpdate:modelValue":e[0]||(e[0]=r=>u.value=r),autocomplete:"email",type:"email",required:""},null,512),[[v,u.value]])]),s("div",A,[e[4]||(e[4]=s("label",{for:"password"},"New Password",-1)),m(s("input",{id:"password","onUpdate:modelValue":e[1]||(e[1]=r=>a.value=r),autocomplete:"new-password",minlength:"8",type:"password",required:""},null,512),[[v,a.value]])]),s("div",D,[e[5]||(e[5]=s("label",{for:"password_confirmation"},"Confirm Password",-1)),m(s("input",{id:"password_confirmation","onUpdate:modelValue":e[2]||(e[2]=r=>l.value=r),autocomplete:"new-password",minlength:"8",type:"password",required:""},null,512),[[v,l.value]])]),d.value?(i(),n("p",L,w(d.value),1)):y("",!0),t.value?(i(),n("p",j,w(t.value),1)):y("",!0),s("button",{class:"button primary",type:"submit",disabled:p.value||a.value.length<8||a.value!==l.value},w(p.value?"Updating...":"Reset Password"),9,F)],32)):(i(),n("p",M,"Reset link is missing required information.")),q(V(h),{class:"muted-link",to:"/login"},{default:N(()=>[...e[6]||(e[6]=[C("Back to login",-1)])]),_:1})]))}});export{I as default};
