import{d as C,a3 as x,k as w,a4 as L,J as P,a5 as A,o as r,b as l,w as a,q as o,R as v,s as t,a6 as b,a7 as _,A as c,c as u,F as p,I as d,y as m,B as S,Q as B,a as z,a8 as R,a9 as U,aa as N,ab as $}from"./index-2e57ee69.js";import{V as D}from"./VMenu-9f22b74a.js";import{V as F,a as h,b as k,c as M}from"./VList-0b71c0f0.js";import{a as T,V as f}from"./VBadge-2ebabc99.js";import{V as q}from"./VDivider-29fb9868.js";const O=C({__name:"UserProfile",setup(E){const e=x(),y=w(),g=L(),V=()=>{e.remove(),y.push("/login").then(()=>{localStorage.removeItem("userAbilities"),g.update($)})},I=P(()=>[{type:"divider"},{type:"navItem",icon:"tabler-user-circle",title:"Mi perfil",to:{name:"personal-profile"}},...e.roles.length>1?[{type:"divider"},...e.roles.filter(i=>{var n;return i.id!==((n=e.user)==null?void 0:n.role.id)}).map(i=>({type:"navItem",icon:"tabler-arrows-exchange",title:`Cambiar a ${i.name.toLowerCase()}`,onClick:async()=>{await A(i.id,g),y.push("/")}}))]:[],{type:"divider"},{type:"navItem",icon:"tabler-logout",title:"Cerrar sesión",onClick:V}]);return(i,n)=>(r(),l(f,{dot:"",bordered:"",location:"bottom right","offset-x":"3","offset-y":"3",color:"success"},{default:a(()=>[o(v,{class:"cursor-pointer",color:t(e).user&&t(e).user.photo?void 0:"primary",variant:t(e).user&&t(e).user.photo?void 0:"tonal"},{default:a(()=>[t(e).user&&t(e).user.photo?(r(),l(b,{key:0,src:t(_).getUrlImage(t(e).user.photo)},null,8,["src"])):(r(),l(c,{key:1,icon:"tabler-user"})),o(D,{activator:"parent",location:"bottom end",offset:"14px"},{default:a(()=>[o(F,null,{default:a(()=>[o(h,null,{prepend:a(()=>[o(T,{start:""},{default:a(()=>[o(f,{dot:"",location:"bottom right","offset-x":"3","offset-y":"3",color:"success",bordered:""},{default:a(()=>[o(v,{color:t(e).user&&t(e).user.photo?void 0:"primary",variant:t(e).user&&t(e).user.photo?void 0:"tonal"},{default:a(()=>[t(e).user&&t(e).user.photo?(r(),l(b,{key:0,src:t(_).getUrlImage(t(e).user.photo)},null,8,["src"])):(r(),l(c,{key:1,icon:"tabler-user"}))]),_:1},8,["color","variant"])]),_:1})]),_:1})]),default:a(()=>[t(e).user!==null?(r(),u(p,{key:0},[o(k,{class:"font-weight-medium text-capitalize",style:{"max-width":"150px"}},{default:a(()=>[d(m(t(e).user.names.toLowerCase()),1)]),_:1}),o(M,{class:"text-capitalize"},{default:a(()=>[d(m(t(e).user.role.name.toLowerCase()),1)]),_:1})],64)):S("",!0)]),_:1}),o(t(B),{options:{wheelPropagation:!1}},{default:a(()=>[(r(!0),u(p,null,z(t(I),s=>(r(),u(p,{key:s.title},[s.type==="navItem"?(r(),l(h,{key:0,to:s.to,onClick:J=>s.onClick&&s.onClick()},R({prepend:a(()=>[o(c,{class:"me-2",icon:s.icon,size:"22"},null,8,["icon"])]),default:a(()=>[o(k,null,{default:a(()=>[d(m(s.title),1)]),_:2},1024)]),_:2},[s.badgeProps?{name:"append",fn:a(()=>[o(f,U(N(s.badgeProps)),null,16)]),key:"0"}:void 0]),1032,["to","onClick"])):(r(),l(q,{key:1,class:"my-2"}))],64))),128))]),_:1})]),_:1})]),_:1})]),_:1},8,["color","variant"])]),_:1}))}});export{O as _};
