import{b as D,c as N}from"./chunk-KHRLI7AH.js";import{$ as p,B as c,C as R,Ic as v,Mc as m,T as x,Wf as h,Y as d,_f as A,af as H,j as E,m as f,p as l}from"./chunk-X3RCWQ3R.js";import{i}from"./chunk-SR6RTMQI.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:3d16453f213eb5db982e7e7dd90631843ac5d3f860726a614777c3e9e3f9b57e*/
//# sourceMappingURL=chunk-TE3DC7QT.js.map
