import{l as y}from"./chunk-C6uGsfWa.js";import{Dr as Rg,Fa as er,Hi as Zt,Ja as g,Lr as Se,Mr as S,St as G,To as je,_c as wQ,at as Dm,br as Qc,ea as ae,fc as vn,pi as Wn,ro as he,va as cf,xa as cr}from"./chunk-b0nJCs5_.js";var _=class e{authHttp=g(Wn);restService=g(Rg);restExtractor=g(er);serverService=g(Zt);static BASE_VIDEO_IMPORT_URL=ae.apiUrl+`/api/v1/videos/imports/`;importVideo(t){let r=e.BASE_VIDEO_IMPORT_URL,o=wQ(t);return this.authHttp.post(r,o).pipe(he(a=>this.restExtractor.handleError(a)))}listMyVideoImports(t){let m=t,{pagination:r,sort:o}=m,a=y(m,[`pagination`,`sort`]),i=new vn;return i=this.restService.addRestGetParams(i,r,o),i=this.restService.addObjectParams(i,a),this.authHttp.get(Qc.BASE_USERS_URL+`me/videos/imports`,{params:i}).pipe(je(n=>this.extractVideoImports(n)),he(n=>this.restExtractor.handleError(n)))}deleteVideoImport(t){return this.authHttp.delete(e.BASE_VIDEO_IMPORT_URL+t.id).pipe(he(r=>this.restExtractor.handleError(r)))}cancelVideoImport(t){return this.authHttp.post(e.BASE_VIDEO_IMPORT_URL+t.id+`/cancel`,{}).pipe(he(r=>this.restExtractor.handleError(r)))}retryVideoImport(t){return this.authHttp.post(e.BASE_VIDEO_IMPORT_URL+t.id+`/retry`,{}).pipe(he(r=>this.restExtractor.handleError(r)))}retryVideoImportByVideos(t){let r={start:0,count:1},o={field:`createdAt`,order:-1};return Se(t).pipe(cr(a=>this.listMyVideoImports({pagination:r,sort:o,includeCollaborations:!0,videoId:a.id}).pipe(je(({data:i})=>{if(i.length===0)throw new Error(`No video import found for this video`);return this.authHttp.post(e.BASE_VIDEO_IMPORT_URL+i[0].id+`/retry`,{})}))),cf(),he(a=>this.restExtractor.handleError(a)))}extractVideoImports(t){return this.serverService.getServerLocale().pipe(G(r=>(t.data.forEach(o=>o.state.label=Dm(o.state.label,r)),t)))}static ɵfac=function(r){return new(r||e)};static ɵprov=S({token:e,factory:e.ɵfac})};export{_ as t};
//# debugId=1f143dbf-662f-583c-a1fe-d5fd10d66410
//# sourceMappingURL=chunk-DnSoF4cB.js.map