function e(e){const r=h(),{to:a}=p(),[t,n]=b(()=>w.post(`/share/delete?id=${e.share.id}`)),[i,l]=b(()=>w.post(`/share/${e.share.disabled?"enable":"disable"}?id=${e.share.id}`));return[s(o,{get disabled(){return!e.canShare},onClick:()=>{a(`/@manage/shares/edit/${e.share.id}`)},get children(){return r("global.edit")}}),s(o,{get loading(){return i()},get colorScheme(){return e.share.disabled?"success":"warning"},onClick:async()=>{const r=await l();_(r,()=>{e.refresh()})},get children(){return r("global."+(e.share.disabled?"enable":"disable"))}}),s(X,{get name(){return e.share.id},get loading(){return t()},onClick:async()=>{const a=await n();$(a,()=>{x.success(r("global.delete_success")),e.refresh()})}})]}function r(r){const m=h(),{copy:p}=a();return s(u,{get children(){return[s(t,{get children(){return(()=>{if(0===r.share.files.length)return"";let e=r.share.files[0];return r.share.files.length>1&&(e+=m("shares.files_etc",{more:r.share.files.length-1})),e})()}}),s(t,{get children(){return r.share.id}}),s(n,{get when(){return i.is_admin(l())},get children(){return s(t,{get children(){return s(B,{get name(){return r.share.creator},get role(){return r.share.creator_role}})}})}}),s(t,{get children(){return c(()=>!!r.share.expires)()?new Date(r.share.expires).toLocaleString():""}}),s(t,{get children(){return r.share.max_accessed>0?`${r.share.accessed} / ${r.share.max_accessed}`:`${r.share.accessed}`}}),s(t,{get children(){return m("shares.status_list."+(r.share.disabled?"disabled":r.share.max_accessed>0&&r.share.accessed>=r.share.max_accessed||0===r.share.files.length||r.share.expires&&new Date(r.share.expires)<new Date?"invalid":r.share.creator!==l().username||r.canShare?"work":"denied"))}}),s(t,{get children(){return r.share.remark}}),s(t,{get children(){return s(d,{spacing:"$2",get children(){return[s(o,{colorScheme:"primary",onClick:()=>{const e=E(r.share,{site_title:f("site_title")}),a=g(f("share_summary_content"),e);p(a)},get children(){return m("shares.copy_msg")}}),s(e,r)]}})}})]}})}import{bU as a,E as s,dF as t,S as n,V as i,W as l,a1 as c,q as h,ao as d,a8 as o,bY as g,dC as u,cD as m,I as f,k as p,b7 as b,bq as w,b9 as _,bt as $,x,X as k,aO as S,aN as y,ae as C,dA as D,dB as v,G as j,dD as I,dE as O,a7 as q}from"./index-WdfADTOW.js";import{b as A}from"./useTitle-BZYCQV-b.js";import{m as E}from"./share-DuMdNkZH.js";import{D as X}from"./DeletePopover-C4TPX-K0.js";const B=e=>{if(e.role<0)return null;const r=["info","neutral","accent"];return s(m,{get colorScheme(){return r[e.role]},css:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},get children(){return e.name}})},F=()=>{const e=h();A("manage.sidemenu.shares");const{to:a}=p(),[t,g]=b(()=>w.get("/share/list")),[m,f]=k([]),_=async()=>{const e=await g();$(e,e=>f(e.content))},x=i.can(l(),S.findIndex(e=>"share"===e));return _(),s(q,{spacing:"$3",alignItems:"start",w:"$full",get children(){return[s(d,{spacing:"$2",gap:"$2",w:"$full",wrap:{"@initial":"wrap","@md":"unset"},get children(){return[s(o,{colorScheme:"accent",get loading(){return t()},onClick:_,get children(){return e("global.refresh")}}),s(n,{when:!x,get fallback(){return s(o,{onClick:()=>a("/@manage/shares/add"),get children(){return e("global.add")}})},get children(){return s(y,{withArrow:!0,get label(){return e("shares.no_permission_tip")},placement:"right",get children(){return s(o,{disabled:!0,get children(){return[" ",c(()=>e("global.add"))," "]}})}})}})]}}),s(C,{w:"$full",overflowX:"auto",get children(){return s(D,{highlightOnHover:!0,dense:!0,get children(){return[s(v,{get children(){return s(u,{get children(){return[s(j,{each:["files","id"],children:r=>s(I,{get children(){return e(`shares.${r}`)}})}),s(n,{get when(){return i.is_admin(l())},get children(){return s(I,{get children(){return e("shares.creator")}})}}),s(j,{each:["expires","accessed","status","remark"],children:r=>s(I,{get children(){return e(`shares.${r}`)}})}),s(I,{get children(){return e("global.operations")}})]}})}}),s(O,{get children(){return s(j,{get each(){return m()},children:e=>s(r,{share:e,refresh:_,canShare:x})})}})]}})}})]}})};export{F as default};
