import{a as v,b as k}from"./chunk-AKYES5GO.js";import{$ as m,K as d,Of as I,Y as g,b as h,c as u,m as o,pf as f,x as b}from"./chunk-QXV2GR6R.js";import{g as S,i as a}from"./chunk-JJ4RDTEF.js";var p=S(I());var i=(0,p.default)("peertube:search:FindInBulkService"),C=(()=>{let n=class n{constructor(e){a(this,"searchService");a(this,"advancedSearchForBulk");a(this,"getVideoInBulk");a(this,"getChannelInBulk");a(this,"getPlaylistInBulk");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 i("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 i("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 i("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:c,finder:B}=e;return new h(s=>{t.result.pipe(b(r=>r.params.includes(c)),d(),o(r=>r.response.data),o(r=>r.find(B))).subscribe({next:r=>{if(!r){s.error(new Error("Elementet "+c+" hittades inte"));return;}s.next(r),s.complete();},error:r=>s.error(r)}),t.notifier.next(c);});}getVideosInBulk(e){return i("Fetching videos %s.",e.join(", ")),this.searchService.searchVideos({uuids:e,componentPagination:{itemsPerPage:e.length,currentPage:1},skipCount:!0,advancedSearch:this.advancedSearchForBulk});}getChannelsInBulk(e){return i("Fetching channels %s.",e.join(", ")),this.searchService.searchVideoChannels({handles:e,componentPagination:{itemsPerPage:e.length,currentPage:1},advancedSearch:this.advancedSearchForBulk});}getPlaylistsInBulk(e){return i("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()})};}};a(n,"\u0275fac",function(t){return new(t||n)(m(k));}),a(n,"\u0275prov",g({token:n,factory:n.ɵfac}));let l=n;return l;})();export{C as a};/**i18n:224bcada6943fe8b17ea60808c2d370cec9507c3bd670ebe71692d099a3befa1*///# sourceMappingURL=chunk-ONXESYFZ.js.map