import{b as V,c as f}from"./chunk-SGCHCWLM.js";import{C as c,D as b,E as C,Ee as y,R as p,Z as S,ae as l,ba as d,hf as A,ig as D,ih as T,j as m,k as u,l as g,o as s,ph as I,qd as v,vh as $}from"./chunk-NY4TI4KT.js";import{i as h}from"./chunk-IQVXR75E.js";var F=(()=>{let n=class n{authHttp=d(v);serverService=d($);restExtractor=d(T);confirmService=d(I);listCaptions(t,i){let r=V.buildVideoPasswordHeader(i);return this.authHttp.get(`${f.BASE_VIDEO_URL}/${t}/captions`,{headers:r}).pipe(p(e=>this.serverService.getServerLocale().pipe(s(o=>({captionsResult:e,translations:o})))),s(({captionsResult:e,translations:o})=>{for(let a of e.data)a.language.label=A(a.language.label,o);return e;}),s(e=>(y(e.data,"language","label"),e))).pipe(c(e=>this.restExtractor.handleError(e)));}removeCaption(t,i){return this.authHttp.delete(`${f.BASE_VIDEO_URL}/${t}/captions/${i}`).pipe(c(r=>this.restExtractor.handleError(r)));}addCaption(t,i,r){let o=D({captionfile:r});return this.authHttp.put(`${f.BASE_VIDEO_URL}/${t}/captions/${i}`,o).pipe(c(a=>this.restExtractor.handleError(a)));}updateCaptions(t,i){let r=u(void 0);for(let e of i)e.action==="CREATE"||e.action==="UPDATE"?r=r.pipe(p(()=>this.addCaption(t,e.language.id,e.captionfile))):e.action==="REMOVE"&&(r=r.pipe(p(()=>this.removeCaption(t,e.language.id))));return r;}getCaptionContent({fileUrl:t}){return this.authHttp.get(t,{responseType:"text"});}generateCaption(t){let{videos:i}=t;return m(i).pipe(C(r=>this.generateCaptionOfSpecificVideo({video:r,forceTranscription:!1})),b(),s(r=>r.reduce((e,o)=>(o==="success"&&(e.success+=1),o==="already-has-captions"&&(e.alreadyHasCaptions+=1),o==="already-being-transcribed"&&(e.alreadyBeingTranscribed+=1),e),{success:0,alreadyHasCaptions:0,alreadyBeingTranscribed:0})),c(r=>this.restExtractor.handleError(r)));}generateCaptionOfSpecificVideo(t){let{video:i,forceTranscription:r}=t,e={forceTranscription:r};return this.authHttp.post(`${f.BASE_VIDEO_URL}/${i.id}/captions/generate`,e).pipe(s(()=>"success"),c(o=>{let a=o.error;if(a?.code===l.VIDEO_ALREADY_BEING_TRANSCRIBED&&!r){let _="PeerTube\u306F\u3001\u52D5\u753B\""+i.name+"\"\u306E\u6587\u5B57\u8D77\u3053\u3057\u304C\u65E2\u306B\u958B\u59CB\u3055\u308C\u3066\u3044\u308B\u3068\u5224\u65AD\u3057\u307E\u3057\u305F\u3002"+"PeerTube\u5074\u306B\u554F\u984C\u304C\u3042\u308B\uFF08\u30AF\u30E9\u30C3\u30B7\u30E5\u306A\u3069\u304C\u539F\u56E0\u3067\u3001\u52D5\u753B\u304C\u4E88\u671F\u305B\u306C\u72B6\u614B\u3067\u3042\u308B\u306A\u3069\uFF09\u3068\u601D\u308F\u308C\u308B\u5834\u5408\u3001\u3053\u306E\u52D5\u753B\u306E\u6587\u5B57\u8D77\u3053\u3057\u3092\u624B\u52D5\u3067\u5B9F\u884C\u3067\u304D\u307E\u3059\u3002"+" Do you still want to run transcription?";return m(this.confirmService.confirm(_,"\u6587\u5B57\u8D77\u3053\u3057\u3092\u624B\u52D5\u5B9F\u884C")).pipe(p(O=>O===!1?g(()=>o):this.generateCaptionOfSpecificVideo({video:i,forceTranscription:!0})));}return a?.code===l.VIDEO_ALREADY_HAS_CAPTIONS?u("already-has-captions"):a?.code===l.VIDEO_ALREADY_BEING_TRANSCRIBED?u("already-being-transcribed"):g(()=>o);}));}};h(n,"\u0275fac",function(i){return new(i||n)();}),h(n,"\u0275prov",S({token:n,factory:n.ɵfac}));let E=n;return E;})();export{F as a};/**i18n:347eeb695970c32bc275618edc2e751c67145d9fc3012e70543c114a99b9e016*///# sourceMappingURL=chunk-JF6CNN2A.js.map