import{r as w,W as g,j as s}from"./app-Dory5LSx.js";import{T as n,I as d}from"./InputError-CQtLR-0E.js";import{I as c}from"./InputLabel-BXurWe64.js";import{P as _}from"./PrimaryButton-CTvXnBiS.js";import{q as N}from"./transition-DQuJwdlY.js";function S({className:f=""}){const p=w.useRef(null),u=w.useRef(null),{data:e,setData:a,errors:o,put:x,reset:t,processing:j,recentlySuccessful:h}=g({current_password:"",password:"",password_confirmation:""}),v=r=>{r.preventDefault(),x(route("password.update"),{preserveScroll:!0,onSuccess:()=>t(),onError:l=>{var i,m;l.password&&(t("password","password_confirmation"),(i=p.current)==null||i.focus()),l.current_password&&(t("current_password"),(m=u.current)==null||m.focus())}})};return s.jsxs("section",{className:f,children:[s.jsxs("header",{children:[s.jsx("h2",{className:"text-lg font-medium text-foreground",children:"Update Password"}),s.jsx("p",{className:"mt-1 text-sm text-secondary-foreground",children:"Ensure your account is using a long, random password to stay secure."})]}),s.jsxs("form",{onSubmit:v,className:"mt-6 space-y-6",children:[s.jsxs("div",{children:[s.jsx(c,{htmlFor:"current_password",value:"Current Password"}),s.jsx(n,{id:"current_password",ref:u,value:e.current_password,onChange:r=>a("current_password",r.target.value),type:"password",className:"mt-1 block w-full",autoComplete:"current-password"}),s.jsx(d,{message:o.current_password,className:"mt-2"})]}),s.jsxs("div",{children:[s.jsx(c,{htmlFor:"password",value:"New Password"}),s.jsx(n,{id:"password",ref:p,value:e.password,onChange:r=>a("password",r.target.value),type:"password",className:"mt-1 block w-full",autoComplete:"new-password"}),s.jsx(d,{message:o.password,className:"mt-2"})]}),s.jsxs("div",{children:[s.jsx(c,{htmlFor:"password_confirmation",value:"Confirm Password"}),s.jsx(n,{id:"password_confirmation",value:e.password_confirmation,onChange:r=>a("password_confirmation",r.target.value),type:"password",className:"mt-1 block w-full",autoComplete:"new-password"}),s.jsx(d,{message:o.password_confirmation,className:"mt-2"})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(_,{disabled:j,children:"Save"}),s.jsx(N,{show:h,enter:"transition ease-in-out",enterFrom:"opacity-0",leave:"transition ease-in-out",leaveTo:"opacity-0",children:s.jsx("p",{className:"text-sm text-foreground",children:"Saved."})})]})]})]})}export{S as default};
