import{a as v,b as k}from"./chunk-W2WMIABB.js";import{Jf as I,L as d,Z as g,aa as m,b as h,c as u,kf as f,n as o,y as b}from"./chunk-4JM6MIZ5.js";import{g as S,i as c}from"./chunk-QJQRWPYR.js";var p=S(I());var n=(0,p.default)("peertube:search:FindInBulkService"),C=(()=>{let a=class a{searchService;advancedSearchForBulk;getVideoInBulk;getChannelInBulk;getPlaylistInBulk;constructor(e){this.searchService=e,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("Element "+l+" ikke funnet"));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)(m(k));}),c(a,"\u0275prov",g({token:a,factory:a.ɵfac}));let s=a;return s;})();export{C as a};/**i18n:68865f44f2a527c44cf5136a17c76a0ff8308c2bae5c7c8d50070a5fb9847c44*///# sourceMappingURL=chunk-2X27RDBL.js.map