1import{a as x,b as ne,c as de,d as le}from"./chunk-V3JZPFOE.js";import{$d as Q,Ae as X,Af as O,B as d,C as w,Ce as q,D as T,De as K,Oh as H,Pg as ie,Q as F,Ue as Z,Vd as y,Wd as U,We as ee,Y as D,aa as p,gh as B,hg as te,hh as re,i as A,j as M,jd as j,k as z,lh as se,md as V,n as S,nd as G,nh as oe,pd as I,th as ae,ue as J,ve as R,we as m,xe as h}from"./chunk-HVCWS4IF.js";import{a as b,b as L,c as _,j as f}from"./chunk-KJ7W2O2B.js";var k=class extends x{support;downloadEnabled;commentsPolicy;likesPercent;dislikesPercent;trackerUrls;inputFileUpdatedAt;embedPrivacyPolicy;constructor(e,t={}){super(e,t),this.channel=new ne(e.channel),this.account=new ie(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.embedPrivacyPolicy=e.embedPrivacyPolicy,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===X.HLS);}hasHlsPlaylist(){return!!this.getHlsPlaylist();}hasEmbedRestrictions(){return this.embedPrivacyPolicy.id!==J.ALL_ALLOWED;}getFilesForDownload(){let e=this.files;for(let t of this.getHlsPlaylist()?.files||[])e.some(i=>i.resolution.id===t.resolution.id&&i.fps===t.fps)||e.push(t);return K(e,"resolution","id").reverse();}};var a=class a{auth=p(re);authHttp=p(I);restExtractor=p(B);restService=p(se);serverService=p(ae);confirmService=p(oe);userService=p(H);getVideoViewUrl(e){return`${a.BASE_VIDEO_URL}/${e}/views`;}getVideo(e){let t=C.buildVideoPasswordHeader(e.videoPassword);return this.serverService.getServerLocale().pipe(F(i=>this.authHttp.get(`${a.BASE_VIDEO_URL}/${e.videoId}`,{headers:t}).pipe(S(r=>({videoHash:r,translations:i})))),S(({videoHash:i,translations:r})=>new k(i,r)),d(i=>this.restExtractor.handleError(i)));}updateVideo(e,t){let i=te(t);return this.authHttp.put(`${a.BASE_VIDEO_URL}/${e}`,i).pipe(d(r=>this.restExtractor.handleError(r)));}uploadVideo(e){let t=new G("POST",`${a.BASE_VIDEO_URL}/upload`,e,{reportProgress:!0});return this.authHttp.request(t).pipe(d(i=>this.restExtractor.handleError(i)));}removeVideo(e){let t=q(e);return A(t).pipe(T(i=>this.authHttp.delete(`${a.BASE_VIDEO_URL}/${i}`)),w(),d(i=>this.restExtractor.handleError(i)));}listMyVideos(e){let{videoPagination:t,restPagination:i,sort:r,channelNameOneOf:s,privacyOneOf:o,tagsOneOf:l,search:c,includeCollaborations:P}=e,$=t?this.restService.componentToRestPagination(t):i,u=new V();u=this.restService.addRestGetParams(u,$,this.buildListSort(r));let v={};return Z(e.isLive)&&(v.isLive=e.isLive),e.search&&(v.search=c),e.privacyOneOf&&(v.privacyOneOf=o),e.tagsOneOf&&(v.tagsOneOf=l),u=this.restService.addObjectParams(u,v),s!==void 0&&s.length!==0&&(u=this.restService.addArrayParams(u,"channelNameOneOf",s)),P&&(u=u.set("includeCollaborations","true")),this.authHttp.get(H.BASE_USERS_URL+"me/videos",{params:u}).pipe(F(g=>this.extractVideos(g)),d(g=>this.restExtractor.handleError(g)));}listAccountVideos(e){return this.listVideos(L(b({},e),{account:e.account}));}listChannelVideos(e){return this.listVideos(L(b({},e),{videoChannel:e.videoChannel}));}listVideos(e){let l=e,{account:t,videoChannel:i}=l,r=_(l,["account","videoChannel"]),s=new V();s=this.buildVideoListParams(b({params:s},r));let o;return i?o=le.BASE_VIDEO_CHANNEL_URL+i.nameWithHost+"/videos":t?o=de.BASE_ACCOUNT_URL+t.nameWithHost+"/videos":o=a.BASE_VIDEO_URL,this.authHttp.get(o,{params:s}).pipe(F(c=>this.extractVideos(c)),d(c=>this.restExtractor.handleError(c)));}buildVideoListParams(e){let Y=e,{params:t,videoPagination:i,sort:r,categoryOneOf:s,languageOneOf:o,privacyOneOf:l,skipCount:c,search:P,nsfw:$,nsfwFlagsExcluded:u,nsfwFlagsIncluded:v,autoTagOneOf:g,stateOneOf:W}=Y,ce=_(Y,["params","videoPagination","sort","categoryOneOf","languageOneOf","privacyOneOf","skipCount","search","nsfw","nsfwFlagsExcluded","nsfwFlagsIncluded","autoTagOneOf","stateOneOf"]),ue=i?this.restService.componentToRestPagination(i):void 0,n=this.restService.addRestGetParams(t,ue,this.buildListSort(r));return c&&(n=n.set("skipCount",c+"")),Array.isArray(o)&&(n=this.restService.addArrayParams(n,"languageOneOf",o)),Array.isArray(s)&&(n=this.restService.addArrayParams(n,"categoryOneOf",s)),Array.isArray(l)&&(n=this.restService.addArrayParams(n,"privacyOneOf",l)),Array.isArray(g)&&(n=this.restService.addArrayParams(n,"autoTagOneOf",g)),Array.isArray(g)&&(n=this.restService.addArrayParams(n,"autoTagOneOf",g)),Array.isArray(W)&&(n=this.restService.addArrayParams(n,"stateOneOf",W)),P&&(n=n.set("search",P)),n=this.buildNSFWParam
1s(n,{nsfw:$,nsfwFlagsExcluded:u,nsfwFlagsIncluded:v}),this.restService.addObjectParams(n,ce);}buildNSFWParams(e,t={}){let{nsfw:i,nsfwFlagsExcluded:r,nsfwFlagsIncluded:s}=t,o=this.auth.isLoggedIn()?void 0:this.userService.getAnonymousUser(),l=o?o.nsfwFlagsHidden:void 0,c=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):l!==void 0&&(e=e.set("nsfwFlagsExcluded",l)),s!==void 0?e=e.set("nsfwFlagsIncluded",s):c!==void 0&&(e=e.set("nsfwFlagsIncluded",c)),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=a.BASE_FEEDS_URL){let i=[{type:U.VIDEOS,format:y.RSS,label:"media rss 2.0",url:t+y.RSS.toLowerCase()},{type:U.VIDEOS,format:y.ATOM,label:"atom 1.0",url:t+y.ATOM.toLowerCase()},{type:U.VIDEOS,format:y.JSON,label:"json 1.0",url:t+y.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:U.PODCAST,format:y.PODCAST,label:"podcast rss 2.0",url:a.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,a.BASE_SUBSCRIPTION_FEEDS_URL);}getVideoFileMetadata(e){return this.authHttp.get(e).pipe(d(t=>this.restExtractor.handleError(t)));}removeVideoFiles(e,t){return A(e).pipe(T(i=>this.authHttp.delete(a.BASE_VIDEO_URL+"/"+i+"/"+t)),w(),d(i=>this.restExtractor.handleError(i)));}removeFile(e,t,i){return this.authHttp.delete(a.BASE_VIDEO_URL+"/"+e+"/"+i+"/"+t).pipe(d(r=>this.restExtractor.handleError(r)));}removeSourceFile(e){return this.authHttp.delete(a.BASE_VIDEO_URL+"/"+e+"/source/file").pipe(d(t=>this.restExtractor.handleError(t)));}runTranscoding(e){let{videos:t,type:i,forceTranscoding:r}=e,s={transcodingType:i,forceTranscoding:r};return A(t).pipe(T(o=>this.authHttp.post(a.BASE_VIDEO_URL+"/"+o.uuid+"/transcoding",s).pipe(d(l=>{if(l.error?.code===Q.VIDEO_ALREADY_BEING_TRANSCODED&&!r){let c="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 A(this.confirmService.confirm(c,"Force transcoding")).pipe(F(P=>P===!1?z(()=>l):this.runTranscoding({videos:[o],type:i,forceTranscoding:!0})));}return z(()=>l);}))),w(),d(o=>this.restExtractor.handleError(o)));}generateDownloadUrl(e){let{video:t,files:i,videoFileToken:r}=e;return ee({baseUrl:O.originServerUrl,videoFiles:i.map(s=>s.id),videoUUID:t.uuid,videoFileToken:r});}getStoryboards(e,t){let i=C.buildVideoPasswordHeader(t);return this.authHttp.get(a.BASE_VIDEO_URL+"/"+e+"/storyboards",{headers:i}).pipe(S(({storyboards:r})=>r),d(r=>r.status===404?M([]):this.restExtractor.handleError(r)));}getSource(e){return this.authHttp.get(a.BASE_VIDEO_URL+"/"+e+"/source").pipe(d(t=>t.status===404?M(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=H.BASE_USERS_URL+"me/videos/"+e+"/rating";return this.authHttp.get(t).pipe(d(i=>this.restExtractor.handleError(i)));}extractVideos(e){return this.serverService.getServerLocale().pipe(S(t=>{let i=e.data,r=e.total,s=[];for(let o of i)s.push(new x(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(b({},s),{description:i[s.id]})),defaultPrivacyId:e.find(s=>s.id===t)?.id||e[0].id};}explainedLicenceLabels(e){let t={[m["CC-BY"]]:"CC-BY",[m["CC-BY-SA"]]:"CC-BY-SA",[m["CC-BY-ND"]]:"CC-BY-ND",[m["CC-BY-NC"]]:"CC-BY-NC",[m["CC-BY-NC-SA"]]:"CC-BY-NC-SA",[m["CC-BY-NC-ND"]]:"CC-BY-NC-ND",[m.CC0]:"",[m.PDM]:"Public domain mark",[m.ALL_RIGHTS_RESERVED]:"You are the owner of the content or you have the rights of the copyright holders"};return e.map(i=>L(b({},i),{description:t[i.id]}));}buildNSFWTooltip(e){let t=[];return(e.nsfwFlags&R.VIOLENT)===R.VIOLENT&&t.push("violence"),(e.nsfwFlags&R.EXPLICIT_SEX)===R.EXPLICIT_SEX&&t.push("explicit sex"),t.length===0?"This video contains sensitive content":"This video contains sensitive content: "+t.join(" - ")+"";}getMostPrivatePrivacy(e){let t=[h.PRIVATE,h.INTERNAL,h.UNLISTED,h.PUBLIC];return this.getPrivacyFromOrder(e,t);}getPrivacyFromOrder(e,t){for(let i of t)if(e.find(r=>r.id===i))return i;throw new Error("No 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=`${a.BASE_VIDEO_URL}/${e}/rate`,s={rating:t},o=C.buildVideoPasswordHeader(i);return this.authHttp.put(r,s,{headers:o}).pipe(d(l=>this.restExtractor.handleError(l)));}};f(a,"BASE_VIDEO_URL",O.apiUrl+"/api/v1/videos"),f(a,"BASE_FEEDS_URL",O.apiUrl+"/feeds/videos."),f(a,"PODCAST_FEEDS_URL",O.apiUrl+"/feeds/podcast/videos.xml"),f(a,"BASE_SUBSCRIPTION_FEEDS_URL",O.apiUrl+"/feeds/subscriptions."),f(a,"\u0275fac",function(t){return new(t||a)();}),f(a,"\u0275prov",D({token:a,factory:a.ɵfac}));var N=a;var E=class E{authHttp=p(I);restExtractor=p(B);static buildVideoPasswordHeader(e){return e?new j().set("x-peertube-video-password",e):void 0;}getVideoPasswords(e){return this.authHttp.get(`${N.BASE_VIDEO_URL}/${e.videoUUID}/passwords`).pipe(S(t=>t.data),d(t=>this.restExtractor.handleError(t)));}};f(E,"\u0275fac",function(t){return new(t||E)();}),f(E,"\u0275prov",D({token:E,factory:E.ɵfac}));var C=E;export{k as a,C as b,N as c};/**i18n:347eeb695970c32bc275618edc2e751c67145d9fc3012e70543c114a99b9e016*/
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.