import{b as D,c as N}from"./chunk-K6LRUFYU.js";import{$ as p,B as c,C as R,Jc as v,Nc as m,T as x,Xf as h,Y as d,bf as H,bg as A,j as E,m as f,p as l}from"./chunk-QXV2GR6R.js";import{i}from"./chunk-JJ4RDTEF.js";var k=(()=>{let t=class t{constructor(r,o){i(this,"authHttp");i(this,"restExtractor");i(this,"store",new Map);this.authHttp=r,this.restExtractor=o}getVideoFileToken({videoUUID:r,videoPassword:o}){let a=this.store.get(r);return a?E(a):this.createVideoFileToken(r,o).pipe(x(n=>this.store.set(r,{token:n.token,expires:new Date(n.expires)})))}createVideoFileToken(r,o){let a=D.buildVideoPasswordHeader(o);return this.authHttp.post(`${N.BASE_VIDEO_URL}/${r}/token`,{},{headers:a}).pipe(f(({files:n})=>n),c(n=>this.restExtractor.handleError(n)))}};i(t,"\u0275fac",function(o){return new(o||t)(p(m),p(h))}),i(t,"\u0275prov",d({token:t,factory:t.\u0275fac}));let u=t;return u})();var s=class s{constructor(t,e,r){i(this,"authHttp");i(this,"restService");i(this,"restExtractor");this.authHttp=t,this.restService=e,this.restExtractor=r}updateRedundancy(t,e){let r=s.BASE_REDUNDANCY_URL+"/"+t,o={redundancyAllowed:e};return this.authHttp.put(r,o).pipe(c(a=>this.restExtractor.handleError(a)))}listVideoRedundancies(t){let{pagination:e,sort:r,target:o}=t,a=new v;return a=this.restService.addRestGetParams(a,e,r),o&&(a=a.append("target",o)),this.authHttp.get(s.BASE_REDUNDANCY_URL+"/videos",{params:a}).pipe(c(n=>this.restExtractor.handleError(n)))}addVideoRedundancy(t){return this.authHttp.post(s.BASE_REDUNDANCY_URL+"/videos",{videoId:t.id}).pipe(c(e=>this.restExtractor.handleError(e)))}removeVideoRedundancies(t){let e=t.redundancies.streamingPlaylists.map(r=>r.id).concat(t.redundancies.files.map(r=>r.id)).map(r=>this.removeRedundancy(r));return l(...e).pipe(R())}removeRedundancy(t){return this.authHttp.delete(s.BASE_REDUNDANCY_URL+"/videos/"+t).pipe(c(e=>this.restExtractor.handleError(e)))}};i(s,"BASE_REDUNDANCY_URL",H.apiUrl+"/api/v1/server/redundancy"),i(s,"\u0275fac",function(e){return new(e||s)(p(m),p(A),p(h))}),i(s,"\u0275prov",d({token:s,factory:s.\u0275fac}));var j=s;export{k as a,j as b};
/**i18n:224bcada6943fe8b17ea60808c2d370cec9507c3bd670ebe71692d099a3befa1*/
//# sourceMappingURL=chunk-4Y64SOUG.js.map
