import{k as e,b7 as r,bq as n,X as t,dz as a,E as s,ao as c,a8 as l,q as i,ae as o,dA as u,dB as d,dC as g,G as h,dD as m,dE as p,dF as b,bt as f,x as $,a7 as _,cD as k,aO as w,aN as C,V as j}from"./index-WdfADTOW.js";import{b as v}from"./useTitle-BZYCQV-b.js";import{D as x}from"./DeletePopover-C4TPX-K0.js";import{W as y}from"./Wether-CvBrurPJ.js";const D=e=>{const r=[{name:"general",color:"info"},{name:"guest",color:"neutral"},{name:"admin",color:"accent"}];return s(k,{get colorScheme(){return r[e.role].color},get children(){return r[e.role].name}})},S=e=>{const r=i();return s(c,{spacing:"$0_5",get children(){return s(h,{each:w,children:(n,t)=>s(C,{get label(){return r(`users.permissions.${n}`)},get children(){return s(o,{boxSize:"$2",rounded:"$full",get bg(){return`$${j.can(e.user,t())?"success":"danger"}9`}})}})})}})},q=()=>{const k=i();v("manage.sidemenu.users");const{to:w}=e(),[C,j]=r(()=>n.get("/admin/user/list")),[q,z]=t([]),E=async()=>{const e=await j();f(e,e=>z(e.content))};E();const[O,W]=a(e=>n.post(`/admin/user/delete?id=${e}`)),[X,A]=a(e=>n.post(`/admin/user/cancel_2fa?id=${e}`));return s(_,{spacing:"$2",alignItems:"start",w:"$full",get children(){return[s(c,{spacing:"$2",get children(){return[s(l,{colorScheme:"accent",get loading(){return C()},onClick:E,get children(){return k("global.refresh")}}),s(l,{onClick:()=>{w("/@manage/users/add")},get children(){return k("global.add")}})]}}),s(o,{w:"$full",overflowX:"auto",get children(){return s(u,{highlightOnHover:!0,dense:!0,get children(){return[s(d,{get children(){return s(g,{get children(){return[s(h,{each:["username","base_path","role","permission","available"],children:e=>s(m,{get children(){return k(`users.${e}`)}})}),s(m,{get children(){return k("global.operations")}})]}})}}),s(p,{get children(){return s(h,{get each(){return q()},children:e=>s(g,{get children(){return[s(b,{get children(){return e.username}}),s(b,{get children(){return e.base_path}}),s(b,{get children(){return s(D,{get role(){return e.role}})}}),s(b,{get children(){return s(S,{user:e})}}),s(b,{get children(){return s(y,{get yes(){return!e.disabled}})}}),s(b,{get children(){return s(c,{spacing:"$2",get children(){return[s(l,{onClick:()=>{w(`/@manage/users/edit/${e.id}`)},get children(){return k("global.edit")}}),s(x,{get name(){return e.username},get loading(){return O()===e.id},onClick:async()=>{const r=await W(e.id);f(r,()=>{$.success(k("global.delete_success")),E()})}}),s(l,{colorScheme:"accent",get loading(){return X()===e.id},onClick:async()=>{const r=await A(e.id);f(r,()=>{$.success(k("users.cancel_2fa_success")),E()})},get children(){return k("users.cancel_2fa")}})]}})}})]}})})}})]}})}})]}})};export{q as default};
