import{_ as S}from"./Brk5FU9k.js";import{d as w,p as x,j as t,b as y,o as k,w as V,e as o,f,g as i,l as v,i as C,J as M}from"./dVzHJMF1.js";import U from"./UP-7C8ii.js";const A={class:"base-grid pb-2"},O={class:"col-span-12"},B={class:"col-span-12"},j={class:"flex flex-wrap gap-3 -mx-4 -mb-4 p-4 sm:sticky sm:bottom-0 bg-white border-t items-center justify-end"},D={class:"flex flex-wrap max-sm:w-full gap-3 items-center"},N=w({__name:"ModalAlterarSenha",setup(P,{expose:g}){const d=x(),a=t(!1),u=t(!1),m=t(),s=t(""),l=t("");g({openModalSenha:r=>{m.value=r,s.value="",l.value="",a.value=!0},closeModalSenha:()=>{a.value=!1,m.value=void 0}});async function b(){var r;if(!l.value||!s.value){d.add({severity:"error",life:1e4,summary:"Campos Obrigatórios",detail:"Os campos de senha não podem estar vazios."});return}if(s.value!==l.value){d.add({severity:"error",life:1e4,summary:"Senhas Divergentes",detail:"As senhas informadas não coincidem."});return}u.value=!0;try{await C.usuarios.resetPassword({idUsuario:m.value,novaSenha:s.value}),d.add({severity:"success",summary:"Sucesso",detail:"Senha alterada com sucesso!",life:5e3}),a.value=!1}catch(e){const c=e;d.add({severity:"error",life:1e4,summary:"Erro ao alterar senha",detail:((r=c.data)==null?void 0:r.message)||"Ocorreu um erro inesperado."})}finally{u.value=!1}}function _(){a.value=!1}return(r,e)=>{const c=U,p=S,h=M;return k(),y(h,{visible:i(a),"onUpdate:visible":e[2]||(e[2]=n=>v(a)?a.value=n:null),modal:"",header:"Alterar Senha",draggable:!1,closable:!1,onHide:e[3]||(e[3]=n=>m.value=void 0)},{default:V(()=>[o("div",A,[o("div",O,[e[4]||(e[4]=o("label",{for:"password"},"Senha:",-1)),f(c,{id:"senha",modelValue:i(s),"onUpdate:modelValue":e[0]||(e[0]=n=>v(s)?s.value=n:null),feedback:!1,"toggle-mask":"",fluid:"",autofocus:""},null,8,["modelValue"])]),o("div",B,[e[5]||(e[5]=o("label",{for:"confirm-password"},"Confirmar senha:",-1)),f(c,{modelValue:i(l),"onUpdate:modelValue":e[1]||(e[1]=n=>v(l)?l.value=n:null),fluid:"",feedback:!1,"toggle-mask":""},null,8,["modelValue"])])]),o("div",j,[o("div",D,[f(p,{mode:"cancel",class:"max-sm:w-full",disabled:i(u),onClick:_},null,8,["disabled"]),f(p,{mode:"save",class:"max-sm:w-full",loading:i(u),onClick:b},null,8,["loading"])])])]),_:1},8,["visible"])}}}),H=Object.assign(N,{__name:"ConfiguracoesSegurancaUsuariosModalAlterarSenha"});export{H as M};
