import{t}from'./chunk-BAzl70Bd.js';import{j}from'./chunk-L5A5rljK.js';import{g,dW as W,dl as Ie,dG as ze,aN as $,by as Z,fP as EHe,aY as S,bL as J,bM as wo}from'./main-ajlqprgK.js';var v=J(wo());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("Kh\xF4ng t\xECm th\u1EA5y th\xE0nh ph\u1EA7n "+s+""));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:EHe({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-311LbAVZ.js.map