import{M as T,$ as E,av as M,aC as L,au as i,c6 as b,at as X,aw as w,r as z,U as p,N as v,O as n,X as l,R as $,a8 as D,W as G,e,az as _,P as H,Q,V as q,Z as y,Y as S}from"./vendor-CsGITfgk.js";import{a4 as W,at as Y}from"./index-GCDRvGOr.js";import{u as Z,_ as j}from"./password-tips.vue_vue_type_script_setup_true_lang-BDfw2T2Y.js";const J={class:"mt-5 max-sm:text-center"},f=64,oe=T({__name:"change-password-form",emits:["succeeded"],setup(K,{emit:B}){const N=B,{t:h}=E(),{changePassword:k,loading:x,user:C}=W(),{passwordRequirements:P}=Z(),{translate:O}=Y("identity_error"),U=M(L({oldPassword:i().required(),newPassword:i().required().when("oldPassword",{is:s=>!!s,then:s=>s.required().notOneOf([b("oldPassword")],h("common.messages.password_new_same_old"))}),confirmPassword:i().required().oneOf([b("newPassword")],h("common.messages.passwords_do_not_match"))})),{errors:r,meta:g,handleSubmit:A,resetForm:F}=X({validationSchema:U,initialValues:{oldPassword:"",newPassword:"",confirmPassword:""},validateOnMount:!1}),{value:t}=w("oldPassword"),{value:d}=w("newPassword"),{value:m}=w("confirmPassword"),c=z(),V=A(async s=>{c.value=await k({userId:C.value.id,newPassword:s.newPassword,oldPassword:s.oldPassword}),c.value.succeeded&&(F(),N("succeeded"))});return(s,o)=>{const u=p("VcInput"),I=p("VcAlert"),R=p("VcButton");return n(),v("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(),$(j,{key:0,requirements:e(P)},null,8,["requirements"])):D("",!0),(n(!0),v(H,null,Q(c.value?.errors,a=>(n(),$(I,{key:a.code,color:"danger",class:"my-5 text-xs",icon:""},{default:q(()=>[y(S(e(O)(a)),1)]),_:2},1024))),128)),G("div",J,[l(R,{disabled:!e(g).valid||e(g).pending,loading:e(x),type:"submit","min-width":"12rem"},{default:q(()=>[y(S(s.$t("common.buttons.change")),1)]),_:1},8,["disabled","loading"])])],32)}}});export{oe as _};
//# sourceMappingURL=change-password-form.vue_vue_type_script_setup_true_lang-CG4oGdgZ.js.map
