import{bU as v,D as r,dw as i,S as b,a5 as f,a6 as o,ab as k,o as $,aw as x,K as c,bX as L,dt as T,cz as O,V as _,j as y,b9 as w,bq as S,bb as B,bt as D,r as R,B as U,aW as I,aV as V,an as F,dr as H,ds as M,R as m,du as g,dv as P,ah as W}from"./index-CNZMR1GT.js";import{b as X}from"./useTitle-BClow7LS.js";import{m as j}from"./share-BRMiJJnc.js";import{D as q}from"./DeletePopover-D42apEN8.js";function z(e){const t=$(),{to:l}=y(),[h,d]=w(()=>S.post("/share/delete?id=".concat(e.share.id))),[u,a]=w(()=>S.post("/share/".concat(e.share.disabled?"enable":"disable","?id=").concat(e.share.id)));return[r(c,{get disabled(){return!e.canShare},onClick:()=>{l("/@manage/shares/edit/".concat(e.share.id))},get children(){return t("global.edit")}}),r(c,{get loading(){return u()},get colorScheme(){return e.share.disabled?"success":"warning"},onClick:async()=>{const s=await a();B(s,()=>{e.refresh()})},get children(){return t("global.".concat(e.share.disabled?"enable":"disable"))}}),r(q,{get name(){return e.share.id},get loading(){return h()},onClick:async()=>{const s=await d();D(s,()=>{R.success(t("global.delete_success")),e.refresh()})}})]}const A=e=>{if(e.role<0)return null;const t=["info","neutral","accent"];return r(O,{get colorScheme(){return t[e.role]},css:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},get children(){return e.name}})};function K(e){const t=$(),l=()=>{if(e.share.files.length===0)return"";let a=e.share.files[0];return e.share.files.length>1&&(a+=t("shares.files_etc",{more:e.share.files.length-1})),a},h=()=>e.share.max_accessed>0?"".concat(e.share.accessed," / ").concat(e.share.max_accessed):"".concat(e.share.accessed),d=()=>e.share.disabled?"disabled":e.share.max_accessed>0&&e.share.accessed>=e.share.max_accessed||e.share.files.length===0||e.share.expires&&new Date(e.share.expires)<new Date?"invalid":e.share.creator===o().username&&!e.canShare?"denied":"work",{copy:u}=v();return r(T,{get children(){return[r(i,{get children(){return l()}}),r(i,{get children(){return e.share.id}}),r(b,{get when(){return f.is_admin(o())},get children(){return r(i,{get children(){return r(A,{get name(){return e.share.creator},get role(){return e.share.creator_role}})}})}}),r(i,{get children(){return k(()=>!!e.share.expires)()?new Date(e.share.expires).toLocaleString():""}}),r(i,{get children(){return h()}}),r(i,{get children(){return t("shares.status_list.".concat(d()))}}),r(i,{get children(){return e.share.remark}}),r(i,{get children(){return r(x,{spacing:"$2",get children(){return[r(c,{colorScheme:"primary",onClick:()=>{const a=j(e.share,{site_title:_("site_title")}),s=L(_("share_summary_content"),a);u(s)},get children(){return t("shares.copy_msg")}}),r(z,e)]}})}})]}})}const Q=()=>{const e=$();X("manage.sidemenu.shares");const{to:t}=y(),[l,h]=w(()=>S.get("/share/list")),[d,u]=U([]),a=async()=>{const n=await h();D(n,C=>u(C.content))},s=f.can(o(),I.findIndex(n=>n==="share"));return a(),r(W,{spacing:"$3",alignItems:"start",w:"$full",get children(){return[r(x,{spacing:"$2",gap:"$2",w:"$full",wrap:{"@initial":"wrap","@md":"unset"},get children(){return[r(c,{colorScheme:"accent",get loading(){return l()},onClick:a,get children(){return e("global.refresh")}}),r(b,{when:!s,get fallback(){return r(c,{onClick:()=>t("/@manage/shares/add"),get children(){return e("global.add")}})},get children(){return r(V,{withArrow:!0,get label(){return e("shares.no_permission_tip")},placement:"right",get children(){return r(c,{disabled:!0,get children(){return[" ",k(()=>e("global.add"))," "]}})}})}})]}}),r(F,{w:"$full",overflowX:"auto",get children(){return r(H,{highlightOnHover:!0,dense:!0,get children(){return[r(M,{get children(){return r(T,{get children(){return[r(m,{each:["files","id"],children:n=>r(g,{get children(){return e("shares.".concat(n))}})}),r(b,{get when(){return f.is_admin(o())},get children(){return r(g,{get children(){return e("shares.creator")}})}}),r(m,{each:["expires","accessed","status","remark"],children:n=>r(g,{get children(){return e("shares.".concat(n))}})}),r(g,{get children(){return e("global.operations")}})]}})}}),r(P,{get children(){return r(m,{get each(){return d()},children:n=>r(K,{share:n,refresh:a,canShare:s})})}})]}})}})]}})};export{Q as default};
