import{a as v,b as k}from"./chunk-Y7LB4IT6.js";import{L as d,Qf as f,Z as g,Zg as P,ba as m,c as h,d as u,o,y as b}from"./chunk-L6W7X4TF.js";import{g as I,i as c}from"./chunk-WH5WJFMZ.js";var p=I(P());var n=(0,p.default)("peertube:search:FindInBulkService"),w=(()=>{let a=class a{searchService=m(k);advancedSearchForBulk;getVideoInBulk;getChannelInBulk;getPlaylistInBulk;constructor(){this.getVideoInBulk=this.buildBulkObservableObject(this.getVideosInBulk.bind(this)),this.getChannelInBulk=this.buildBulkObservableObject(this.getChannelsInBulk.bind(this)),this.getPlaylistInBulk=this.buildBulkObservableObject(this.getPlaylistsInBulk.bind(this)),this.advancedSearchForBulk=new v({searchTarget:"local"});}getVideo(e){return n("Schedule video fetch for uuid %s.",e),this.getData({observableObject:this.getVideoInBulk,finder:t=>t.uuid===e||t.shortUUID===e,param:e});}getChannel(e){return n("Schedule channel fetch for handle %s.",e),this.getData({observableObject:this.getChannelInBulk,finder:t=>t.nameWithHost===e||t.nameWithHostForced===e,param:e});}getPlaylist(e){return n("Schedule playlist fetch for uuid %s.",e),this.getData({observableObject:this.getPlaylistInBulk,finder:t=>t.uuid===e||t.shortUUID===e,param:e});}getData(e){let{observableObject:t,param:l,finder:B}=e;return new h(i=>{t.result.pipe(b(r=>r.params.includes(l)),d(),o(r=>r.response.data),o(r=>r.find(B))).subscribe({next:r=>{if(!r){i.error(new Error("Elementet "+l+" hittades inte"));return;}i.next(r),i.complete();},error:r=>i.error(r)}),t.notifier.next(l);});}getVideosInBulk(e){return n("Fetching videos %s.",e.join(", ")),this.searchService.searchVideos({uuids:e,componentPagination:{itemsPerPage:e.length,currentPage:1},skipCount:!0,advancedSearch:this.advancedSearchForBulk});}getChannelsInBulk(e){return n("Fetching channels %s.",e.join(", ")),this.searchService.searchVideoChannels({handles:e,componentPagination:{itemsPerPage:e.length,currentPage:1},advancedSearch:this.advancedSearchForBulk});}getPlaylistsInBulk(e){return n("Fetching playlists %s.",e.join(", ")),this.searchService.searchVideoPlaylists({uuids:e,componentPagination:{itemsPerPage:e.length,currentPage:1},advancedSearch:this.advancedSearchForBulk});}buildBulkObservableObject(e){let t=new u();return{notifier:t,result:f({time:100,bulkGet:e,notifierObservable:t.asObservable()})};}};c(a,"\u0275fac",function(t){return new(t||a)();}),c(a,"\u0275prov",g({token:a,factory:a.ɵfac}));let s=a;return s;})();export{w as a};/**i18n:ae7e6707fc51a9e1f6f015929aece8afe43a92a094f09f07f0463afe6c89573f*///# sourceMappingURL=chunk-QMKZXD7L.js.map