import{a as A}from"./chunk-RKQVCQGG.js";import{$ as c,B as a,Ic as x,If as S,Mc as f,T as l,Wf as H,Y as u,_f as N,af as C,e as d,kg as R,m}from"./chunk-X3RCWQ3R.js";import{i as e}from"./chunk-SR6RTMQI.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:3d16453f213eb5db982e7e7dd90631843ac5d3f860726a614777c3e9e3f9b57e*/
//# sourceMappingURL=chunk-7MB5OJWB.js.map
