import{K as L,Z as M,at as R,aB as X,as as i,c9 as v,ar as z,au as w,r as D,S as p,L as q,M as n,V as l,P as y,a7 as G,U as H,b as e,az as _,N as K,O as Q,T as $,X as S,W as B}from"./vendor-bSWkQivH.js";import{Q as W,aT as Z}from"./index-Dqv5IkpS.js";import{u as j,_ as J}from"./password-tips.vue_vue_type_script_setup_true_lang-B1kt45HN.js";const Y={class:"mt-5 max-sm:text-center"},f=64,re=L({__name:"change-password-form",emits:["succeeded"],setup(ee,{emit:N}){const T=N,{t:h}=M(),{changePassword:k,loading:x,user:O}=W(),{passwordRequirements:P}=j(),{translate:U}=Z("identity_error"),A=R(X({oldPassword:i().required(),newPassword:i().required().when("oldPassword",{is:s=>!!s,then:s=>s.required().notOneOf([v("oldPassword")],h("common.messages.password_new_same_old"))}),confirmPassword:i().required().oneOf([v("newPassword")],h("common.messages.passwords_do_not_match"))})),{errors:r,meta:g,handleSubmit:C,resetForm:F}=z({validationSchema:A,initialValues:{oldPassword:"",newPassword:"",confirmPassword:""},validateOnMount:!1}),{value:t}=w("oldPassword"),{value:d}=w("newPassword"),{value:m}=w("confirmPassword"),c=D(),V=C(async s=>{c.value=await k({userId:O.value.id,newPassword:s.newPassword,oldPassword:s.oldPassword}),c.value.succeeded&&(F(),T("succeeded"))});return(s,o)=>{var b;const u=p("VcInput"),I=p("VcAlert"),E=p("VcButton");return n(),q("form",{class:"w-full text-start",onSubmit:o[3]||(o[3]=(...a)=>e(V)&&e(V)(...a))},[l(u,{modelValue:e(t),"onUpdate:modelValue":o[0]||(o[0]=a=>_(t)?t.value=a:null),class:"mb-5",label:s.$t("shared.account.change_password_form.current_pass_label"),placeholder:s.$t("shared.account.change_password_form.current_pass_placeholder"),type:"password",required:"",message:e(r).oldPassword,error:!!e(r).oldPassword,autocomplete:"off",maxlength:f},null,8,["modelValue","label","placeholder","message","error"]),l(u,{modelValue:e(d),"onUpdate:modelValue":o[1]||(o[1]=a=>_(d)?d.value=a:null),class:"mb-5",label:s.$t("shared.account.change_password_form.new_pass_label"),placeholder:s.$t("shared.account.change_password_form.new_pass_placeholder"),type:"password",required:"",message:e(r).newPassword,error:!!e(r).newPassword,autocomplete:"off",maxlength:f},null,8,["modelValue","label","placeholder","message","error"]),l(u,{modelValue:e(m),"onUpdate:modelValue":o[2]||(o[2]=a=>_(m)?m.value=a:null),class:"mb-5",label:s.$t("shared.account.change_password_form.confirm_new_pass_label"),placeholder:s.$t("shared.account.change_password_form.confirm_new_pass_placeholder"),type:"password",required:"",message:e(r).confirmPassword,error:!!e(r).confirmPassword,autocomplete:"off",maxlength:f},null,8,["modelValue","label","placeholder","message","error"]),e(P)?(n(),y(J,{key:0,requirements:e(P)},null,8,["requirements"])):G("",!0),(n(!0),q(K,null,Q((b=c.value)==null?void 0:b.errors,a=>(n(),y(I,{key:a.code,color:"danger",class:"my-5 text-xs",icon:""},{default:$(()=>[S(B(e(U)(a)),1)]),_:2},1024))),128)),H("div",Y,[l(E,{disabled:!e(g).valid||e(g).pending,loading:e(x),type:"submit","min-width":"12rem"},{default:$(()=>[S(B(s.$t("common.buttons.change")),1)]),_:1},8,["disabled","loading"])])],32)}}});export{re as _};
//# sourceMappingURL=change-password-form.vue_vue_type_script_setup_true_lang-Db0gDa6q.js.map
