import{Et as e,Ft as t,Ht as n,Lt as r,P as i,Qt as a,St as o,Tt as s,Vt as c,Yt as l,Zt as u,an as d,bt as f,dn as p,gt as m,hn as h,ot as g,st as _,vt as v,w as y,wt as b,xt as x,yt as S,zt as C}from"./design-system-components-Y2tugS6v.mjs";import{N as w,P as T,pt as E}from"./src-BQa3ZgC3.mjs";import{In as D,Tr as O,Zt as k,ci as A,jn as j,mt as M,yi as N}from"./composables-DDr4AJUl.mjs";import{c as P,f as F,z as I}from"./src-C-XpxEWy.mjs";var L=e({name:`ActivityList`,components:{ResourceListItem:I},props:{activity:{type:Object,required:!0}},setup(e){let n=A(),{current:r}=i(),a=d(),o=d(!1),s=v(()=>{let t=y.fromISO(e.activity.times.recordedTime);return t>y.now().minus({hour:1})?D(t,r):j(t,r)});return t(async()=>{try{a.value=await n.webdav.getFileInfo(p(e.activity.template.variables?.space),{fileId:e.activity.template.variables?.resource?.id})}catch{o.value=!0}}),{recordedDateTime:s,resource:a,resourceNotAccessible:o}}}),R={class:`flex items-center activity-item [&>*]:flex-1`},z={class:`flex items-center text-left`},B=[`textContent`],V={class:`truncate text-left`},H={key:1,class:`text-role-on-surface-variant flex items-center p-1`},U=[`textContent`],W={class:`text-right`},G=[`textContent`];function K(e,t,i,l,u,d){let p=c(`oc-avatar`),m=c(`resource-list-item`),g=c(`oc-icon`),_=n(`oc-tooltip`);return r(),o(`div`,R,[S(`div`,z,[s(p,{width:36,"user-name":e.activity.template.variables?.user?.displayName},null,8,[`user-name`]),t[0]||=b(),S(`span`,{class:`ml-2`,textContent:h(e.activity.template.variables?.user?.displayName)},null,8,B)]),t[3]||=b(),t[4]||=S(`div`,{class:`text-left`},`activity unknown`,-1),t[5]||=b(),S(`div`,V,[e.resource?(r(),f(m,{key:0,resource:e.resource,"is-resource-clickable":!1},null,8,[`resource`])):x(``,!0),t[2]||=b(),e.resourceNotAccessible?a((r(),o(`div`,H,[s(g,{name:`eye-off`}),t[1]||=b(),S(`span`,{class:`ml-2`,textContent:h(e.activity.template.variables?.resource?.name)},null,8,U)])),[[_,e.$gettext(`The resource is unavailable, it may have been deleted.`)]]):x(``,!0)]),t[6]||=b(),S(`div`,W,[S(`span`,{textContent:h(e.recordedDateTime)},null,8,G)])])}var q=e({name:`ActivityList`,components:{ActivityItem:_(L,[[`render`,K]])},props:{activities:{type:Array,required:!0}},setup(e){let{current:t}=i();return{activitiesDateCategorized:v(()=>e.activities.reduce((e,t)=>{let n=y.fromISO(t.times.recordedTime).toISODate();return e[n]||(e[n]=[]),e[n].push(t),e},{})),getDateHeadline:e=>{let n=y.fromISO(e);return n.hasSame(y.now(),`day`)||n.hasSame(y.now().minus({day:1}),`day`)?n.toRelativeCalendar({locale:t}):j(n,t,y.DATE_MED_WITH_WEEKDAY)}}}}),J=[`textContent`];function Y(e,t,n,i,a,l){let d=c(`ActivityItem`),p=c(`oc-list`);return r(),f(p,{class:`activity-list max-w-5xl`},{default:u(()=>[(r(!0),o(m,null,C(e.activitiesDateCategorized,(n,i)=>(r(),o(`li`,{key:i,class:`mb-6`},[S(`h2`,{class:`font-semibold text-role-on-surface-variant activity-list-date text-base capitalize`,textContent:h(e.getDateHeadline(i))},null,8,J),t[0]||=b(),s(p,{class:`ml-2 mt-2 timeline`},{default:u(()=>[(r(!0),o(m,null,C(n,e=>(r(),o(`li`,{key:e.id},[s(d,{activity:e},null,8,[`activity`])]))),128))]),_:2},1024)]))),128))]),_:1})}var X=e({name:`App`,components:{ActivityList:_(q,[[`render`,Y]]),NoContentMessage:P,ItemFilter:F,AppLoadingSpinner:M},setup(){let{spaces:e}=g(k()),n=A(),r=d([]),i=N(`q_location`),a=v(()=>[...p(e)].filter(e=>!e.disabled&&(T(e)||w(e))).sort((e,t)=>w(e)===w(t)?e.name.localeCompare(t.name):w(e)?-1:1)),o=O(function*(e){let t=[`sort:desc`,`limit:100`];p(i)&&t.push(`itemid:${p(i)}`),r.value=yield*E(n.graphAuthenticated.activities.listActivities(t.join(` AND `),{signal:e}))}),s=v(()=>o.isRunning||!o.last);return t(()=>{o.perform()}),l(i,()=>{o.perform()}),{activities:r,filterableSpaces:a,getLocationFilterIcon:e=>w(e)?`folder`:`layout-grid`,isLoading:s}}}),Z=[`textContent`],Q={class:`w-full mb-4`},$=[`textContent`],ee=[`textContent`];function te(e,t,n,i,a,l){let d=c(`oc-icon`),p=c(`item-filter`),g=c(`app-loading-spinner`),_=c(`no-content-message`),v=c(`ActivityList`);return r(),o(m,null,[S(`h1`,{class:`text-lg`,textContent:h(e.$gettext(`Activities`))},null,8,Z),t[1]||=b(),S(`div`,Q,[s(p,{ref:`mediaTypeFilter`,"allow-multiple":!1,"filter-label":e.$gettext(`Location`),"filterable-attributes":[`name`],"option-filter-label":e.$gettext(`Filter location`),"show-option-filter":!0,items:e.filterableSpaces,"close-on-click":!0,class:`mr-2`,"display-name-attribute":`name`,"filter-name":`location`},{image:u(({item:t})=>[s(d,{name:e.getLocationFilterIcon(t)},null,8,[`name`])]),item:u(({item:e})=>[S(`div`,{textContent:h(e.name)},null,8,$)]),_:1},8,[`filter-label`,`option-filter-label`,`items`])]),t[2]||=b(),e.isLoading?(r(),f(g,{key:0})):(r(),o(m,{key:1},[e.activities.length?(r(),f(v,{key:1,activities:e.activities},null,8,[`activities`])):(r(),f(_,{key:0,icon:`pulse`},{message:u(()=>[S(`span`,{textContent:h(e.$gettext(`No activities found`))},null,8,ee)]),_:1}))],64))],64)}var ne=_(X,[[`render`,te]]);export{ne as default};