import{_ as x,u as B,d as m,g as V,i as P,o as n,a,t as d,s as b,T as S,c as _,w as h,b as v,v as w,e as f,p as E,r as p,k as T}from"./index-DcK5qV02.js";import{a as A}from"./modules-DLxePyvQ.js";import{B as L}from"./BarberLayout-BsaeNXgD.js";import{E as M}from"./ErrorMessage-Tp1tOCV-.js";const N={class:"card profile-card"},U={class:"profile-avatar"},q={class:"profile-info"},$={class:"profile-name"},D={class:"profile-email"},I={class:"card"},R={key:0,class:"modal-overlay"},j={class:"modal-card"},z={class:"input-group"},F={class:"input-group"},G={class:"input-group"},H={key:1,class:"success-text"},J={class:"modal-actions"},K=["disabled"],O={__name:"BarberPerfilView",setup(Q){const g=P(),l=B(),t=p(!1),i=p(!1),r=p(""),u=p(!1),e=T({current_password:"",new_password:"",confirm_password:""}),y=E(()=>(l.user?.name||"").split(" ").map(s=>s[0]).join("").substring(0,2).toUpperCase()||"BR"),C=async()=>{await l.logout(),g.push("/login")},k=async()=>{if(r.value="",u.value=!1,e.new_password!==e.confirm_password){r.value="Las contraseñas no coinciden";return}i.value=!0;try{await A.changePassword(e.current_password,e.new_password),u.value=!0,setTimeout(()=>{t.value=!1,e.current_password="",e.new_password="",e.confirm_password="",u.value=!1},1500)}catch(c){r.value=c.response?.data?.message||"Error al cambiar contraseña"}finally{i.value=!1}};return(c,s)=>(n(),m(L,null,{default:V(()=>[s[11]||(s[11]=a("h2",{style:{margin:"0 0 5px 0","font-size":"22px"}},"Perfil",-1)),s[12]||(s[12]=a("p",{class:"title-sm",style:{"margin-top":"0"}},"Tu información",-1)),a("div",N,[a("div",U,d(y.value),1),a("div",q,[a("p",$,d(b(l).user?.name),1),a("p",D,d(b(l).user?.email),1)])]),a("div",I,[s[6]||(s[6]=a("h3",{class:"title-sm",style:{"margin-top":"0"}},"Acciones",-1)),a("button",{onClick:s[0]||(s[0]=o=>t.value=!0),class:"btn btn-outline",style:{"margin-bottom":"12px"}}," Cambiar Contraseña "),a("button",{onClick:C,class:"btn btn-outline",style:{background:"transparent","border-color":"var(--danger)",color:"var(--danger)"}}," Cerrar Sesión ")]),(n(),m(S,{to:"body"},[t.value?(n(),_("div",R,[a("div",{class:"modal-backdrop",onClick:s[1]||(s[1]=o=>t.value=!1)}),a("div",j,[s[10]||(s[10]=a("h3",{class:"modal-title"},"Cambiar Contraseña",-1)),a("form",{onSubmit:h(k,["prevent"])},[a("div",z,[s[7]||(s[7]=a("label",null,"Contraseña Actual",-1)),v(a("input",{"onUpdate:modelValue":s[2]||(s[2]=o=>e.current_password=o),type:"password",class:"input-control",required:""},null,512),[[w,e.current_password]])]),a("div",F,[s[8]||(s[8]=a("label",null,"Nueva Contraseña",-1)),v(a("input",{"onUpdate:modelValue":s[3]||(s[3]=o=>e.new_password=o),type:"password",class:"input-control",required:"",minlength:"6"},null,512),[[w,e.new_password]])]),a("div",G,[s[9]||(s[9]=a("label",null,"Confirmar Nueva",-1)),v(a("input",{"onUpdate:modelValue":s[4]||(s[4]=o=>e.confirm_password=o),type:"password",class:"input-control",required:""},null,512),[[w,e.confirm_password]])]),r.value?(n(),m(M,{key:0,message:r.value},null,8,["message"])):f("",!0),u.value?(n(),_("p",H,"Contraseña cambiada exitosamente")):f("",!0),a("div",J,[a("button",{type:"button",onClick:s[5]||(s[5]=o=>t.value=!1),class:"btn btn-outline btn-sm"},"Cancelar"),a("button",{type:"submit",disabled:i.value,class:"btn btn-gold btn-sm"},d(i.value?"Cambiando...":"Cambiar"),9,K)])],32)])])):f("",!0)]))]),_:1}))}},ss=x(O,[["__scopeId","data-v-382a5e95"]]);export{ss as default};
