import{t}from'./chunk-B32E78Jb.js';import{j}from'./chunk-BkaflMxL.js';import{g,dW as W,dl as Ie,dG as ze,aN as $,by as Z,fP as yHe,aY as S,bL as J,bM as _o}from'./main-BiUBeaMj.js';var v=J(_o());var n=(0,v.default)("peertube:search:FindInBulkService"),C=(()=>{class a{searchService=g(j);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 t({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:s,finder:k}=e;return new W(i=>{t.result.pipe(Ie(r=>r.params.includes(s)),ze(),$(r=>r.response.data),$(r=>r.find(k))).subscribe({next:r=>{if(!r){i.error(new Error("Element "+s+" nebyl nalezen"));return;}i.next(r),i.complete();},error:r=>i.error(r)}),t.notifier.next(s);});}getVideosInBulk(e){return n("Fetching videos %s.",e.join(", ")),this.searchService.searchVideos({uuids:e,componentPagination:{itemsPerPage:e.length,currentPage:1},skipCount:true,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 Z();return{notifier:t,result:yHe({time:100,bulkGet:e,notifierObservable:t.asObservable()})};}static ɵfac=function(t){return new(t||a)();};static ɵprov=S({token:a,factory:a.ɵfac});}return a;})();/**i18n:fad79908930cbb4c308e7550a5fe49bb3841dbb330066a6429aebaa006173605*/export{C};//# sourceMappingURL=chunk-DgowzBSy.js.map