import{a as v}from"./chunk-PIPCW6JA.js";import{$c as f,B as a,Eh as R,S as l,Xc as x,Y as u,aa as s,ah as N,e as d,n as m,sh as H,tg as C,xh as S}from"./chunk-GM43ZGTR.js";import{i}from"./chunk-SLIYHYWC.js";var n=class n{authHttp=s(f);restExtractor=s(H);accountLoaded=new d(1);getAccount(e){return this.authHttp.get(n.BASE_ACCOUNT_URL+e).pipe(m(t=>new N(t)),l(t=>this.accountLoaded.next(t)),a(t=>this.restExtractor.handleError(t)))}};i(n,"BASE_ACCOUNT_URL",C.apiUrl+"/api/v1/accounts/"),i(n,"\u0275fac",function(t){return new(t||n)}),i(n,"\u0275prov",u({token:n,factory:n.\u0275fac}));var L=n;var r=class r{authHttp=s(f);restService=s(S);restExtractor=s(H);serverService=s(R);videoChannelLoaded=new d(1);static extractVideoChannels(e){let t=[];for(let o of e.data)t.push(new v(o));return{data:t,total:e.total}}getVideoChannel(e){return this.authHttp.get(r.BASE_VIDEO_CHANNEL_URL+e).pipe(m(t=>new v(t)),l(t=>this.videoChannelLoaded.next(t)),a(t=>this.restExtractor.handleError(t)))}listAccountVideoChannels(e){let{account:t,componentPagination:o,withStats:c=!1,sort:h,search:E}=e,I=Math.min(this.serverService.getHTMLConfig().videoChannels.maxPerUser,100),V=o?this.restService.componentToRestPagination(o):{start:0,count:I},p=new x;p=this.restService.addRestGetParams(p,V,h),p=p.set("withStats",c+""),E&&(p=p.set("search",E));let g=L.BASE_ACCOUNT_URL+t.nameWithHost+"/video-channels";return this.authHttp.get(g,{params:p}).pipe(m(A=>r.extractVideoChannels(A)),a(A=>this.restExtractor.handleError(A)))}createVideoChannel(e){return this.authHttp.post(r.BASE_VIDEO_CHANNEL_URL,e).pipe(a(t=>this.restExtractor.handleError(t)))}updateVideoChannel(e,t){return this.authHttp.put(r.BASE_VIDEO_CHANNEL_URL+e,t).pipe(a(o=>this.restExtractor.handleError(o)))}changeVideoChannelImage(e,t,o){let c=r.BASE_VIDEO_CHANNEL_URL+e+"/"+o+"/pick";return this.authHttp.post(c,t).pipe(a(h=>this.restExtractor.handleError(h)))}deleteVideoChannelImage(e,t){let o=r.BASE_VIDEO_CHANNEL_URL+e+"/"+t;return this.authHttp.delete(o).pipe(a(c=>this.restExtractor.handleError(c)))}removeVideoChannel(e){return this.authHttp.delete(r.BASE_VIDEO_CHANNEL_URL+e.nameWithHost).pipe(a(t=>this.restExtractor.handleError(t)))}importVideos(e,t,o){let c=r.BASE_VIDEO_CHANNEL_URL+e+"/import-videos",h={externalChannelUrl:t,videoChannelSyncId:o};return this.authHttp.post(c,h).pipe(a(E=>this.restExtractor.handleError(E)))}};i(r,"BASE_VIDEO_CHANNEL_URL",C.apiUrl+"/api/v1/video-channels/"),i(r,"\u0275fac",function(t){return new(t||r)}),i(r,"\u0275prov",u({token:r,factory:r.\u0275fac,providedIn:"root"}));var U=r;export{L as a,U as b};
/**i18n:aa38438cfc6bb6877c9985433629bf5f310ba8cfd6183982ad2c0c8f601d3935*/
//# sourceMappingURL=chunk-VMNZR6KW.js.map
