import{k as e,b7 as r,bq as n,X as t,dv as a,E as s,ao as c,a8 as l,q as i,ae as o,dw as u,dx as d,dy as g,G as h,dz as m,dA as p,dB as b,bt as f,x as $,a7 as _,cD as w,aO as k,aN as v,V as x}from"./index-C-dDkA_D.js";import{b as y}from"./useTitle-Dwsro-_9.js";import{D as C}from"./DeletePopover-Dp7l6lur.js";import{W as j}from"./Wether-CKVTyf1f.js";const S=e=>{const r=[{name:"general",color:"info"},{name:"guest",color:"neutral"},{name:"admin",color:"accent"}];return s(w,{get colorScheme(){return r[e.role].color},get children(){return r[e.role].name}})},D=e=>{const r=i();return s(c,{spacing:"$0_5",get children(){return s(h,{each:k,children:(n,t)=>s(v,{get label(){return r(`users.permissions.${n}`)},get children(){return s(o,{boxSize:"$2",rounded:"$full",get bg(){return`$${x.can(e.user,t())?"success":"danger"}9`}})}})})}})},q=()=>{const w=i();y("manage.sidemenu.users");const{to:k}=e(),[v,x]=r(()=>n.get("/admin/user/list")),[q,z]=t([]),O=async()=>{const e=await x();f(e,e=>z(e.content))};O();const[W,X]=a(e=>n.post(`/admin/user/delete?id=${e}`)),[A,B]=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 v()},onClick:O,get children(){return w("global.refresh")}}),s(l,{onClick:()=>{k("/@manage/users/add")},get children(){return w("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 w(`users.${e}`)}})}),s(m,{get children(){return w("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(S,{get role(){return e.role}})}}),s(b,{get children(){return s(D,{user:e})}}),s(b,{get children(){return s(j,{get yes(){return!e.disabled}})}}),s(b,{get children(){return s(c,{spacing:"$2",get children(){return[s(l,{onClick:()=>{k(`/@manage/users/edit/${e.id}`)},get children(){return w("global.edit")}}),s(C,{get name(){return e.username},get loading(){return W()===e.id},onClick:async()=>{const r=await X(e.id);f(r,()=>{$.success(w("global.delete_success")),O()})}}),s(l,{colorScheme:"accent",get loading(){return A()===e.id},onClick:async()=>{const r=await B(e.id);f(r,()=>{$.success(w("users.cancel_2fa_success")),O()})},get children(){return w("users.cancel_2fa")}})]}})}})]}})})}})]}})}})]}})};export{q as default};
