import{j as C,b9 as v,bq as u,B,dq as p,D as e,aw as h,K as o,o as _,an as T,dr as R,ds as x,dt as b,R as m,du as f,dv as D,dw as s,bt as g,r as $,ah as F,cz as P,aW as W,aV as q,a5 as z}from"./index-CNZMR1GT.js";import{b as H}from"./useTitle-BClow7LS.js";import{D as I}from"./DeletePopover-D42apEN8.js";import{W as L}from"./Wether-DITzMbFL.js";const M=t=>{const n=[{name:"general",color:"info"},{name:"guest",color:"neutral"},{name:"admin",color:"accent"}];return e(P,{get colorScheme(){return n[t.role].color},get children(){return n[t.role].name}})},V=t=>{const n=_(),i=a=>"$".concat(a?"success":"danger","9");return e(h,{spacing:"$0_5",get children(){return e(m,{each:W,children:(a,d)=>e(q,{get label(){return n("users.permissions.".concat(a))},get children(){return e(T,{boxSize:"$2",rounded:"$full",get bg(){return i(z.can(t.user,d()))}})}})})}})},A=()=>{const t=_();H("manage.sidemenu.users");const{to:n}=C(),[i,a]=v(()=>u.get("/admin/user/list")),[d,w]=B([]),l=async()=>{const r=await a();g(r,c=>w(c.content))};l();const[k,S]=p(r=>u.post("/admin/user/delete?id=".concat(r))),[U,y]=p(r=>u.post("/admin/user/cancel_2fa?id=".concat(r)));return e(F,{spacing:"$2",alignItems:"start",w:"$full",get children(){return[e(h,{spacing:"$2",get children(){return[e(o,{colorScheme:"accent",get loading(){return i()},onClick:l,get children(){return t("global.refresh")}}),e(o,{onClick:()=>{n("/@manage/users/add")},get children(){return t("global.add")}})]}}),e(T,{w:"$full",overflowX:"auto",get children(){return e(R,{highlightOnHover:!0,dense:!0,get children(){return[e(x,{get children(){return e(b,{get children(){return[e(m,{each:["username","base_path","role","permission","available"],children:r=>e(f,{get children(){return t("users.".concat(r))}})}),e(f,{get children(){return t("global.operations")}})]}})}}),e(D,{get children(){return e(m,{get each(){return d()},children:r=>e(b,{get children(){return[e(s,{get children(){return r.username}}),e(s,{get children(){return r.base_path}}),e(s,{get children(){return e(M,{get role(){return r.role}})}}),e(s,{get children(){return e(V,{user:r})}}),e(s,{get children(){return e(L,{get yes(){return!r.disabled}})}}),e(s,{get children(){return e(h,{spacing:"$2",get children(){return[e(o,{onClick:()=>{n("/@manage/users/edit/".concat(r.id))},get children(){return t("global.edit")}}),e(I,{get name(){return r.username},get loading(){return k()===r.id},onClick:async()=>{const c=await S(r.id);g(c,()=>{$.success(t("global.delete_success")),l()})}}),e(o,{colorScheme:"accent",get loading(){return U()===r.id},onClick:async()=>{const c=await y(r.id);g(c,()=>{$.success(t("users.cancel_2fa_success")),l()})},get children(){return t("users.cancel_2fa")}})]}})}})]}})})}})]}})}})]}})};export{A as default};
