1import{a as re,b as se}from"./chunk-YWMORIFE.js";import{d as H}from"./chunk-VAQV5NIY.js";import{a as ie}from"./chunk-4AYNN2OG.js";import{$ as p,$c as Y,$g as X,A as a,Ah as ee,B as R,C as T,Ce as Q,Ee as J,Fh as te,Gd as g,Hd as F,Md as W,P as U,X as D,Xc as z,Yc as v,_h as B,ad as A,bh as q,de as w,ee as f,fe as h,h as O,i as $,ie as j,j as _,ke as G,m as V,th as I,ug as P,uh as K,yh as Z}from"./chunk-VGQB5O46.js";import{a as y,b as L,c as N,j as m}from"./chunk-4BD4KICC.js";var x=class extends H{support;tags;downloadEnabled;commentsEnabled;commentsPolicy;likesPercent;dislikesPercent;trackerUrls;inputFileUpdatedAt;constructor(e,t={}){super(e,t),this.channel=new ie(e.channel),this.account=new q(e.account),this.tags=e.tags,this.support=e.support,this.commentsPolicy=e.commentsPolicy,this.downloadEnabled=e.downloadEnabled,this.inputFileUpdatedAt=e.inputFileUpdatedAt,this.trackerUrls=e.trackerUrls,this.buildLikeAndDislikePercents();}buildLikeAndDislikePercents(){this.likesPercent=this.likes/(this.likes+this.dislikes)*100,this.dislikesPercent=this.dislikes/(this.likes+this.dislikes)*100;}getHlsPlaylist(){return this.streamingPlaylists.find(e=>e.type===j.HLS);}hasHlsPlaylist(){return!!this.getHlsPlaylist();}};var n=class n{auth=p(K);authHttp=p(A);restExtractor=p(I);restService=p(Z);serverService=p(te);confirmService=p(ee);userService=p(B);getVideoViewUrl(e){return`${n.BASE_VIDEO_URL}/${e}/views`;}getVideo(e){let t=b.buildVideoPasswordHeader(e.videoPassword);return this.serverService.getServerLocale().pipe(U(i=>this.authHttp.get(`${n.BASE_VIDEO_URL}/${e.videoId}`,{headers:t}).pipe(V(r=>({videoHash:r,translations:i})))),V(({videoHash:i,translations:r})=>new x(i,r)),a(i=>this.restExtractor.handleError(i)));}updateVideo(e,t){let i=X(t);return this.authHttp.put(`${n.BASE_VIDEO_URL}/${e}`,i).pipe(a(r=>this.restExtractor.handleError(r)));}uploadVideo(e){let t=new Y("POST",`${n.BASE_VIDEO_URL}/upload`,e,{reportProgress:!0});return this.authHttp.request(t).pipe(a(i=>this.restExtractor.handleError(i)));}removeVideo(e){let t=G(e);return O(t).pipe(T(i=>this.authHttp.delete(`${n.BASE_VIDEO_URL}/${i}`)),R(),a(i=>this.restExtractor.handleError(i)));}listMyVideos(e){let{videoPagination:t,restPagination:i,sort:r,channelNameOneOf:s,privacyOneOf:o,search:d}=e,l=t?this.restService.componentToRestPagination(t):i,u=new v();u=this.restService.addRestGetParams(u,l,this.buildListSort(r));let E={};return Q(e.isLive)&&(E.isLive=e.isLive),e.search&&(E.search=d),e.privacyOneOf&&(E.privacyOneOf=o),u=this.restService.addObjectParams(u,E),s!==void 0&&s.length!==0&&(u=this.restService.addArrayParams(u,"channelNameOneOf",s)),this.authHttp.get(B.BASE_USERS_URL+"me/videos",{params:u}).pipe(U(C=>this.extractVideos(C)),a(C=>this.restExtractor.handleError(C)));}listAccountVideos(e){return this.listVideos(L(y({},e),{account:e.account}));}listChannelVideos(e){return this.listVideos(L(y({},e),{videoChannel:e.videoChannel}));}listVideos(e){let d=e,{account:t,videoChannel:i}=d,r=N(d,["account","videoChannel"]),s=new v();s=this.buildVideoListParams(y({params:s},r));let o;return i?o=se.BASE_VIDEO_CHANNEL_URL+i.nameWithHost+"/videos":t?o=re.BASE_ACCOUNT_URL+t.nameWithHost+"/videos":o=n.BASE_VIDEO_URL,this.authHttp.get(o,{params:s}).pipe(U(l=>this.extractVideos(l)),a(l=>this.restExtractor.handleError(l)));}buildVideoListParams(e){let M=e,{params:t,videoPagination:i,sort:r,categoryOneOf:s,languageOneOf:o,privacyOneOf:d,skipCount:l,search:u,nsfw:E,nsfwFlagsExcluded:C,nsfwFlagsIncluded:oe}=M,ne=N(M,["params","videoPagination","sort","categoryOneOf","languageOneOf","privacyOneOf","skipCount","search","nsfw","nsfwFlagsExcluded","nsfwFlagsIncluded"]),ae=i?this.restService.componentToRestPagination(i):void 0,c=this.restService.addRestGetParams(t,ae,this.buildListSort(r));return l&&(c=c.set("skipCount",l+"")),o!==void 0&&(c=this.restService.addArrayParams(c,"languageOneOf",o)),s!==void 0&&(c=this.restService.addArrayParams(c,"categoryOneOf",s)),d!==void 0&&(c=this.restService.addArrayParams(c,"privacyOneOf",d)),u&&(c=c.set("search",u)),c=this.buildNSFWParams(c,{nsfw:E,nsfwFlagsExcluded:C,nsfwFlagsIncluded:oe}
1),this.restService.addObjectParams(c,ne);}buildNSFWParams(e,t={}){let{nsfw:i,nsfwFlagsExcluded:r,nsfwFlagsIncluded:s}=t,o=this.auth.isLoggedIn()?void 0:this.userService.getAnonymousUser(),d=o?o.nsfwFlagsHidden:void 0,l=o?o.nsfwFlagsDisplayed|o.nsfwFlagsBlurred|o.nsfwFlagsWarned:void 0;return i!==void 0?e=e.set("nsfw",i):o?.nsfwPolicy&&(e=e.set("nsfw",this.nsfwPolicyToParam(o.nsfwPolicy))),r!==void 0?e=e.set("nsfwFlagsExcluded",r):d!==void 0&&(e=e.set("nsfwFlagsExcluded",d)),s!==void 0?e=e.set("nsfwFlagsIncluded",s):l!==void 0&&(e=e.set("nsfwFlagsIncluded",l)),e;}buildListSort(e){let t=this.restService.buildSortString(e);if(typeof t=="string")return this.auth.isLoggedIn()&&(t==="hot"||t==="-hot")?t.replace("hot","best"):t;}buildBaseFeedUrls(e,t=n.BASE_FEEDS_URL){let i=[{type:F.VIDEOS,format:g.RSS,label:"media rss 2.0",url:t+g.RSS.toLowerCase()},{type:F.VIDEOS,format:g.ATOM,label:"atom 1.0",url:t+g.ATOM.toLowerCase()},{type:F.VIDEOS,format:g.JSON,label:"json 1.0",url:t+g.JSON.toLowerCase()}];if(e&&e.keys().length!==0)for(let r of i)r.url+="?"+e.toString();return i;}getVideoFeedUrls(e,t,i){let r=this.restService.addRestGetParams(new v(),void 0,e);if(t&&(r=r.set("isLocal",t)),i)for(let s of i)r=r.append("categoryOneOf[]",s+"");return this.buildBaseFeedUrls(r);}getAccountFeedUrls(e){let t=this.restService.addRestGetParams(new v());return t=t.set("accountId",e.toString()),this.buildBaseFeedUrls(t);}getVideoChannelFeedUrls(e){let t=this.restService.addRestGetParams(new v());t=t.set("videoChannelId",e.toString());let i=this.buildBaseFeedUrls(t);return i.push({type:F.PODCAST,format:g.PODCAST,label:"podcast rss 2.0",url:n.PODCAST_FEEDS_URL+`?videoChannelId=${e}`}),i;}getVideoSubscriptionFeedUrls(e,t){let i=this.restService.addRestGetParams(new v());return i=i.set("accountId",e.toString()),i=i.set("token",t),this.buildBaseFeedUrls(i,n.BASE_SUBSCRIPTION_FEEDS_URL);}getVideoFileMetadata(e){return this.authHttp.get(e).pipe(a(t=>this.restExtractor.handleError(t)));}removeVideoFiles(e,t){return O(e).pipe(T(i=>this.authHttp.delete(n.BASE_VIDEO_URL+"/"+i+"/"+t)),R(),a(i=>this.restExtractor.handleError(i)));}removeFile(e,t,i){return this.authHttp.delete(n.BASE_VIDEO_URL+"/"+e+"/"+i+"/"+t).pipe(a(r=>this.restExtractor.handleError(r)));}removeSourceFile(e){return this.authHttp.delete(n.BASE_VIDEO_URL+"/"+e+"/source/file").pipe(a(t=>this.restExtractor.handleError(t)));}runTranscoding(e){let{videos:t,type:i,forceTranscoding:r}=e,s={transcodingType:i,forceTranscoding:r};return O(t).pipe(T(o=>this.authHttp.post(n.BASE_VIDEO_URL+"/"+o.uuid+"/transcoding",s).pipe(a(d=>{if(d.error?.code===W.VIDEO_ALREADY_BEING_TRANSCODED&&!r){let l="PeerTube considers video \""+o.name+"\" is already being transcoded."+" If you think PeerTube is wrong (video in broken state after a crash etc.), you can force transcoding on this video."+" Do you still want to run transcoding?";return O(this.confirmService.confirm(l,"Force transcoding")).pipe(U(u=>u===!1?_(()=>d):this.runTranscoding({videos:[o],type:i,forceTranscoding:!0})));}return _(()=>d);}))),R(),a(o=>this.restExtractor.handleError(o)));}generateDownloadUrl(e){let{video:t,files:i,videoFileToken:r}=e;return J({baseUrl:P.originServerUrl,videoFiles:i.map(s=>s.id),videoUUID:t.uuid,videoFileToken:r});}getStoryboards(e,t){let i=b.buildVideoPasswordHeader(t);return this.authHttp.get(n.BASE_VIDEO_URL+"/"+e+"/storyboards",{headers:i}).pipe(V(({storyboards:r})=>r),a(r=>r.status===404?$([]):this.restExtractor.handleError(r)));}getSource(e){return this.authHttp.get(n.BASE_VIDEO_URL+"/"+e+"/source").pipe(a(t=>t.status===404?$(void 0):this.restExtractor.handleError(t)));}setVideoLike(e,t){return this.setVideoRate(e,"like",t);}setVideoDislike(e,t){return this.setVideoRate(e,"dislike",t);}unsetVideoLike(e,t){return this.setVideoRate(e,"none",t);}getUserVideoRating(e){let t=B.BASE_USERS_URL+"me/videos/"+e+"/rating";return this.authHttp.get(t).pipe(a(i=>this.restExtractor.handleError(i)));}extractVideos(e){return this.serverService.getServerLocale().pipe(V(t=>{let i=e.data,r=e.total,s=[];for(let o of i)s.push(new H(o,t));return{total:r,data:s};}));}explainedPrivacyLabels(e,t=h.PUBLIC){let i={[h.PRIVATE]:"Only I can see this video",[h.UNLISTED]:"Only shareable via a private link",[h.PUBLIC]:"Anyone can see this video",[h.INT
1ERNAL]:"Only users of this platform can see this video",[h.PASSWORD_PROTECTED]:"Only users with the appropriate password can see this video"};return{videoPrivacies:e.map(s=>L(y({},s),{description:i[s.id]})),defaultPrivacyId:e.find(s=>s.id===t)?.id||e[0].id};}explainedLicenceLabels(e){let t={[f["CC-BY"]]:"CC-BY",[f["CC-BY-SA"]]:"CC-BY-SA",[f["CC-BY-ND"]]:"CC-BY-ND",[f["CC-BY-NC"]]:"CC-BY-NC",[f["CC-BY-NC-SA"]]:"CC-BY-NC-SA",[f["CC-BY-NC-ND"]]:"CC-BY-NC-ND",[f.CC0]:"",[f.PDM]:"Public domain mark",[f.COPYRIGHT]:"You are the owner of the content or you have the rights of the copyright holders"};return e.map(i=>L(y({},i),{description:t[i.id]}));}buildNSFWTooltip(e){let t=[];return(e.nsfwFlags&w.VIOLENT)===w.VIOLENT&&t.push("violence"),(e.nsfwFlags&w.EXPLICIT_SEX)===w.EXPLICIT_SEX&&t.push("explicit sex"),t.length===0?"This video contains sensitive content":"This video contains sensitive content: "+t.join(" - ")+"";}getHighestAvailablePrivacy(e){let t=[h.PRIVATE,h.INTERNAL,h.UNLISTED,h.PUBLIC];for(let i of t)if(e.find(r=>r.id===i))return i;throw new Error("No highest privacy available");}nsfwPolicyToParam(e){return e==="do_not_list"?"false":"both";}buildDefaultOwnerDisplayType(e){let t=e.account.name;return e.channel.displayName===`Default ${t} channel`||e.channel.displayName===`Main ${t} channel`||e.channel.name.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/)?"account":"videoChannel";}setVideoRate(e,t,i){let r=`${n.BASE_VIDEO_URL}/${e}/rate`,s={rating:t},o=b.buildVideoPasswordHeader(i);return this.authHttp.put(r,s,{headers:o}).pipe(a(d=>this.restExtractor.handleError(d)));}};m(n,"BASE_VIDEO_URL",P.apiUrl+"/api/v1/videos"),m(n,"BASE_FEEDS_URL",P.apiUrl+"/feeds/videos."),m(n,"PODCAST_FEEDS_URL",P.apiUrl+"/feeds/podcast/videos.xml"),m(n,"BASE_SUBSCRIPTION_FEEDS_URL",P.apiUrl+"/feeds/subscriptions."),m(n,"\u0275fac",function(t){return new(t||n)();}),m(n,"\u0275prov",D({token:n,factory:n.ɵfac}));var k=n;var S=class S{authHttp=p(A);restExtractor=p(I);static buildVideoPasswordHeader(e){return e?new z().set("x-peertube-video-password",e):void 0;}getVideoPasswords(e){return this.authHttp.get(`${k.BASE_VIDEO_URL}/${e.videoUUID}/passwords`).pipe(V(t=>t.data),a(t=>this.restExtractor.handleError(t)));}};m(S,"\u0275fac",function(t){return new(t||S)();}),m(S,"\u0275prov",D({token:S,factory:S.ɵfac}));var b=S;export{x as a,b,k as c};/**i18n:85d030b7fdd36d163c6d41dcef9178681a6baa573eb199e8b12fe27dbb057a98*/
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.