import{B as b,b9 as h,bq as w,D as e,aw as _,c0 as A,ag as i,b$ as M,dj as v,K as y,o as C,bt as $,r as P,S as F,bV as H,aY as K,L,M as O,E as R,bu as q,F as E,G as V,bR as x,bE as S,I as Y,T as j,J as G,ah as f,ab as J,Q as c}from"./index-CNZMR1GT.js";const Q=t=>{const n=t.getFullYear().toString(),d=(t.getMonth()+1).toString().padStart(2,"0"),o=t.getDate().toString().padStart(2,"0"),g=t.getHours().toString().padStart(2,"0"),u=t.getMinutes().toString().padStart(2,"0"),a=t.getSeconds().toString().padStart(2,"0");return"".concat(n,"/").concat(d,"/").concat(o," ").concat(g,":").concat(u,":").concat(a)},r=[{name:"title",textAlign:"left",w:"calc(35% - 110px)"},{name:"fingerprint",textAlign:"left",w:"calc(65% - 110px)"},{name:"last_used",textAlign:"right",w:"140px"},{name:"operation",textAlign:"right",w:"80px"}],W=t=>{const n=C(),[d,o]=b(!1),[g,u]=t.isMine?h(()=>w.post("/me/sshkey/delete?id=".concat(t.id))):h(()=>w.post("/admin/user/sshkey/delete?uid=".concat(t.userId,"&id=").concat(t.id))),a={whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"};return e(F,{get when(){return!d()},get children(){return e(_,{w:"$full",p:"$2",get children(){return[e(A,{get w(){return r[0].w},size:"sm",get textAlign(){return r[0].textAlign},css:a,get children(){return t.title}}),e(i,{get w(){return r[1].w},size:"sm",get textAlign(){return r[1].textAlign},css:a,get children(){return t.fingerprint}}),e(i,{get w(){return r[2].w},size:"sm",get textAlign(){return r[2].textAlign},css:a,get children(){return Q(new Date(t.last_used_time))}}),e(M,{get w(){return r[3].w},gap:"$1",get children(){return[e(v,{}),e(y,{size:"sm",colorScheme:"danger",get loading(){return g()},onClick:async()=>{const l=await u();$(l,()=>{P.success(n("global.delete_success")),o(!0)})},get children(){return n("global.delete")}})]}})]}})}})},N=t=>{const n=C(),[d,o]=b([]),[g,u]=t.isMine?h(()=>w.get("/me/sshkey/list")):h(()=>w.get("/admin/user/sshkey/list?uid=".concat(t.userId))),[a,l]=H({title:"",key:""}),[I,D]=h(()=>w.post("/me/sshkey/add",a)),{isOpen:T,onOpen:z,onClose:k}=K(),p=async()=>{const s=await u();$(s,B=>{o(B.content)})};p();const m=s=>({fontWeight:"bold",fontSize:"$sm",color:"$neutral11",textAlign:s.textAlign});return e(f,{w:"$full",alignItems:"start",spacing:"$2",get children(){return[e(M,{w:"$full",get children(){return[e(A,{get children(){return n("users.ssh_keys.heading")}}),e(F,{get when(){return t.isMine},get children(){return[e(v,{}),e(y,{get loading(){return g()},onClick:z,get children(){return n("global.add")}}),e(L,{get opened(){return T()},onClose:k,scrollBehavior:"inside",get children(){return[e(O,{}),e(R,{get children(){return[e(q,{}),e(E,{get children(){return n("users.ssh_keys.add_heading")}}),e(V,{get children(){return[e(x,{mb:"$4",get children(){return[e(S,{for:"add_title",get children(){return n("users.ssh_keys.title")}}),e(Y,{id:"add_title",get value(){return a.title},onInput:s=>l("title",s.currentTarget.value)})]}}),e(x,{get children(){return[e(S,{for:"add_key",get children(){return n("users.ssh_keys.key")}}),e(j,{id:"add_key",get value(){return a.key},onInput:s=>l("key",s.currentTarget.value)})]}})]}}),e(G,{get children(){return e(y,{get loading(){return I()},onClick:async()=>{const s=await D();$(s,()=>{l("title",""),l("key",""),p(),k()})},get children(){return n("global.add")}})}})]}})]}})]}})]}}),e(f,{w:"$full",overflowX:"auto",shadow:"$md",rounded:"$lg",spacing:"$1",p:"$1",get children(){return[e(_,{class:"title",w:"$full",p:"$2",get children(){return[e(i,c({get w(){return r[0].w}},()=>m(r[0]),{get children(){return n("users.ssh_keys.".concat(r[0].name))}})),e(i,c({get w(){return r[1].w}},()=>m(r[1]),{get children(){return n("users.ssh_keys.".concat(r[1].name))}})),e(i,c({get w(){return r[2].w}},()=>m(r[2]),{get children(){return n("users.ssh_keys.".concat(r[2].name))}})),e(i,c({get w(){return r[3].w}},()=>m(r[3]),{get children(){return n("users.ssh_keys.".concat(r[3].name))}}))]}}),J(()=>d().map(s=>e(W,c(t,s))))]}})]}})};export{N as P};
