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