import{d as h,a as n}from"./vue.runtime.esm-esM0TXTr.chunk.mjs";import{c as C,s as r,l as s,S as F}from"./index-VfyFTmuq.chunk.mjs";import{a as g,b as f}from"./collectionFetcher-DOI412ME.chunk.mjs";import{A as u}from"./AbortControllerMixin-B9m47d-C.chunk.mjs";const b=h({name:"FetchCollectionContentMixin",data(){return{fetchSemaphore:new F(1),loadingCollection:!1,loadingCollectionFiles:!1,errorFetchingCollection:null,errorFetchingCollectionFiles:null}},mixins:[u],methods:{async fetchCollection(l,i,e){if(this.loadingCollection)return null;try{this.loadingCollection=!0,this.errorFetchingCollection=null;const t=await f(l,{signal:this.abortController.signal},i,e);return this.$store.dispatch("addCollections",{collections:[t]}),t}catch(t){if(t.response?.status===404)return this.errorFetchingCollection=404,null;this.errorFetchingCollection=t,s.error("[PublicCollectionContent] Error fetching collection",{error:t}),r(n("photos","Failed to fetch collection."))}finally{this.loadingCollection=!1}return null},async fetchCollectionFiles(l,i=[],e){if(this.loadingCollectionFiles)return[];i=[...i,...C];const t=await this.fetchSemaphore.acquire();try{this.errorFetchingCollectionFiles=null,this.loadingCollectionFiles=!0;const o=await g(l,{signal:this.abortController.signal},i,e),c=o.map(a=>a.fileid?.toString());return this.$store.dispatch("appendFiles",o),await this.$store.commit("setCollectionFiles",{collectionFileName:l,fileIds:c}),o}catch(o){if(o.response?.status===404)return this.errorFetchingCollectionFiles=404,[];this.errorFetchingCollectionFiles=o,r(n("photos","Failed to fetch collections list.")),s.error("[PublicCollectionContent] Error fetching collection files",{error:o})}finally{this.loadingCollectionFiles=!1,this.fetchSemaphore.release(t)}return[]}}});export{b as F};
//# sourceMappingURL=FetchCollectionContentMixin-DI4OjG7z.chunk.mjs.map
