import{b as D,c as N}from"./chunk-NJ5QGAXC.js";import{C as c,D as R,Kc as v,Oc as m,Rf as h,U as x,Xf as A,Ye as H,Z as d,aa as p,j as E,n as f,q as l}from"./chunk-4JM6MIZ5.js";import{i as n}from"./chunk-QJQRWPYR.js";var k=(()=>{let t=class t{authHttp;restExtractor;store=new Map;constructor(r,i){this.authHttp=r,this.restExtractor=i}getVideoFileToken({videoUUID:r,videoPassword:i}){let o=this.store.get(r);return o?E(o):this.createVideoFileToken(r,i).pipe(x(s=>this.store.set(r,{token:s.token,expires:new Date(s.expires)})))}createVideoFileToken(r,i){let o=D.buildVideoPasswordHeader(i);return this.authHttp.post(`${N.BASE_VIDEO_URL}/${r}/token`,{},{headers:o}).pipe(f(({files:s})=>s),c(s=>this.restExtractor.handleError(s)))}};n(t,"\u0275fac",function(i){return new(i||t)(p(m),p(h))}),n(t,"\u0275prov",d({token:t,factory:t.\u0275fac}));let u=t;return u})();var a=class a{authHttp;restService;restExtractor;constructor(t,e,r){this.authHttp=t,this.restService=e,this.restExtractor=r}updateRedundancy(t,e){let r=a.BASE_REDUNDANCY_URL+"/"+t,i={redundancyAllowed:e};return this.authHttp.put(r,i).pipe(c(o=>this.restExtractor.handleError(o)))}listVideoRedundancies(t){let{pagination:e,sort:r,target:i}=t,o=new v;return o=this.restService.addRestGetParams(o,e,r),i&&(o=o.append("target",i)),this.authHttp.get(a.BASE_REDUNDANCY_URL+"/videos",{params:o}).pipe(c(s=>this.restExtractor.handleError(s)))}addVideoRedundancy(t){return this.authHttp.post(a.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).map(r=>this.removeRedundancy(r));return l(...e).pipe(R())}removeRedundancy(t){return this.authHttp.delete(a.BASE_REDUNDANCY_URL+"/videos/"+t).pipe(c(e=>this.restExtractor.handleError(e)))}};n(a,"BASE_REDUNDANCY_URL",H.apiUrl+"/api/v1/server/redundancy"),n(a,"\u0275fac",function(e){return new(e||a)(p(m),p(A),p(h))}),n(a,"\u0275prov",d({token:a,factory:a.\u0275fac}));var j=a;export{k as a,j as b};
/**i18n:68865f44f2a527c44cf5136a17c76a0ff8308c2bae5c7c8d50070a5fb9847c44*/
//# sourceMappingURL=chunk-CE2LQAHG.js.map
