import{d as a,f as n,t as i,k as l}from"./preload-helper-DadE4qT2.chunk.mjs";import{N as g}from"./NcEmptyContent-BKX-oWV6.chunk.mjs";import{x as c,l as h}from"./index-4VW8tlR1.chunk.mjs";import{L as d}from"./video-d0YXt7Dm.chunk.mjs";import{I as u,n as r}from"./icons-CFZwNZD8.chunk.mjs";import{A as o}from"./AbortControllerMixin-Bb5X6Yae.chunk.mjs";import"./createElementId-DhjFt1I9-B2HCdIOx.chunk.mjs";import"./index-BCevi9E9.chunk.mjs";const m=a({name:"TagCover",components:{RouterLink:d,ImageMultipleOutline:u},mixins:[o],props:{tag:{type:Object,required:!0}},data(){return{loadCover:!1,observer:null}},computed:{tags(){return this.$store.state.systemtags.tags},files(){return this.$store.state.files.files},coverUrl(){return this.loadCover?l(`/core/preview?fileId=${this.tag.attributes["reference-fileid"]}&x=512&y=512&forceIcon=0&a=1`):""},count(){return this.tag.attributes["files-assigned"]}},watch:{loadCover(){this.tag.attributes["files-assigned"]||this.$store.dispatch("fetchTagFiles",{id:this.tag.attributes.id,signal:this.abortController.signal})}},mounted(){this.observer=new IntersectionObserver(t=>{t[0].isIntersecting&&(this.loadCover=!0,this.observer?.disconnect())}),this.observer.observe(this.$el)},methods:{t:i,n}});var p=function(){var t=this,s=t._self._c;return t._self._setupProxy,s("RouterLink",{staticClass:"tag-cover",attrs:{to:`/tags/${t.tag.attributes["display-name"]}`}},[t.tag.attributes["files-assigned"]!==0?s("img",{staticClass:"tag-cover__image",attrs:{src:t.coverUrl}}):s("div",{staticClass:"tag-cover__image tag-cover__image--placeholder"},[s("ImageMultipleOutline",{attrs:{size:128}})],1),s("div",{staticClass:"tag-cover__details"},[s("div",{staticClass:"tag-cover__details__first-line"},[s("h3",{staticClass:"tag-cover__details__name"},[t._v(" "+t._s(t.t("recognize",t.tag.attributes["display-name"]))+" ")])]),s("div",{staticClass:"tag-cover__details__second-line"},[t._v(" "+t._s(t.n("photos","%n photo","%n photos",t.count))+" ")])])])},f=[],_=r(m,p,f,!1,null,"4e0e61e1");const v=_.exports,C=a({name:"TagsView",components:{TagCover:v,NcLoadingIcon:c,NcEmptyContent:g},mixins:[o],data(){return{error:null,loading:!1,showTags:!1}},computed:{files(){return this.$store.state.files.files},tags(){return this.$store.state.systemtags.tags},tagsNames(){return this.$store.state.systemtags.names},tagsList(){return Object.keys(this.tagsNames).map(t=>this.tags[this.tagsNames[t]]).filter(t=>t&&t.attributes.id)},popularTags(){return Object.keys(this.tagsNames).filter(t=>this.tags[this.tagsNames[t]].attributes["files-assigned"]>50).sort((t,s)=>this.tags[this.tagsNames[s]]["files-assigned"]-this.tags[this.tagsNames[t]]["files-assigned"]).slice(0,9).map(t=>this.tags[this.tagsNames[t]])}},async beforeMount(){await this.fetchRootContent()},methods:{async fetchRootContent(){window.OCA.Viewer.close(),this.error=null;try{this.tagsList.length||(this.loading=!0,await this.$store.dispatch("fetchAllTags",{signal:this.abortController.signal}))}catch(t){h.error("Failed to fetch tags",{error:t}),this.error=!0}finally{this.loading=!1}},t:i}});var b=function(){var t=this,s=t._self._c;return t._self._setupProxy,s("div",[t.error?s("NcEmptyContent",{attrs:{name:t.t("photos","An error occurred")}}):t._e(),!t.loading&&t.tagsList.length===0?s("NcEmptyContent",{attrs:{name:t.t("photos","No tags yet"),description:t.t("photos","Photos with tags will show up here")}}):t._e(),t.loading?s("NcLoadingIcon",{staticClass:"loader"}):s("div",{staticClass:"container"},[t.popularTags.length?s("h2",[t._v(" "+t._s(t.t("photos","Popular tags"))+" ")]):t._e(),s("div",{staticClass:"popular-tags"},t._l(t.popularTags,function(e){return s("TagCover",{key:e.attributes.id,attrs:{tag:e}})}),1),t.tagsList.length?s("h2",[t._v(" "+t._s(t.t("photos","All tags"))+" ")]):t._e(),s("div",{staticClass:"tags"},t._l(t.tagsList,function(e){return s("TagCover",{key:e.attributes.id,attrs:{tag:e}})}),1)])],1)},y=[],N=r(C,b,y,!1,null,"cb8dfce8");const A=N.exports;export{A as default};
//# sourceMappingURL=TagsView-5KwZpsoi.chunk.mjs.map
