(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[3597],{43314:(t,i,e)=>{"use strict";e.r(i),e.d(i,{default:()=>s});consts={props:["collection-id","profile-id"],data:function(){return{config:window.App.config,loaded:!1,limit:8,step:1,title:"",description:"",collection:{title:"",description:"",visibility:"draft"},id:"",posts:[],tab:"add",tabs:["all","add","order"],recentPosts:[],selectedPost:""}},beforeMount:function(){vart=this;axios.get("/api/local/collection/"+this.collectionId).then((function(i){t.collection=i.data}))},mounted:function(){this.fetchRecentPosts(),this.fetchItems(),axios.get("/api/pixelfed/v1/accounts/verify_credentials").then((function(t){window._sharedData.curUser=t.data,window.App.util.navatar()}))},methods:{addToIds:function(t){vari=this;axios.post("/api/local/collection/item",{collection_id:this.collectionId,post_id:t}).then((function(t){i.fetchItems(),i.fetchRecentPosts(),i.tab="all",i.id=""})).catch((function(t){swal("Invalid URL","The post you entered was invalid","error"),i.id=""}))},fetchItems:function(){vart=this;axios.get("/api/local/collection/items/"+this.collectionId).then((function(i){t.posts=i.data,t.loaded=!0}))},addId:function(){vart=this.config.uploader.max_collection_length;if(this.posts.length>=t)swal("Error","You can only add "+t+" posts per collection","error");else{vari=this.id,e=window.location.origin,s=i.split("/");if(i.slice(0,e.length)!==e&&(swal("Invalid URL","You can only add posts from this instance","error"),this.id=""),i.includes("/i/web/post/")||i.includes("/p/")){varo=s[s.length-1];returnconsole.log("adding "+o),voidthis.addToIds(o)}swal("Invalid URL","Invalid URL","error"),this.id=""}},previewUrl:function(t){returnt.sensitive?"/storage/no-preview.png?v="+(newDate).getTime():t.media_attachments[0].preview_url},previewBackground:function(t){return"background-image: url("+this.previewUrl(t)+");background-size:cover;"},fetchRecentPosts:function(){vart=this;axios.get("/api/v1/accounts/"+this.profileId+"/statuses",{params:{only_media:!0,min_id:1,limit:40}}).then((function(i){t.recentPosts=i.data.filter((function(i){vare=t.posts.map((function(t){returnt.id}));return"public"==i.visibility&&0==i.sensitive&&-1==e.indexOf(i.id)}))}))},selectPost:function(t){this.selectedPost=t.id,this.id=t.url},publish:function(){0!=this.posts.length?axios.post("/api/local/collection/"+this.collectionId+"/publish",{title:this.collection.title,description:this.collection.description,visibility:this.collection.visibility}).then((function(t){window.location.href=t.data.url})).catch((function(t){swal("Something went wrong","There was a problem with your request, please try again later.","error")})):swal("Error","You cannot publish an empty collection")},save:function(){axios.post("/api/local/collection/"+this.collectionId,{title:this.collection.title,description:this.collection.description,visibility:this.collection.visibility}).then((function(t){swal("Saved!","You have successfully saved this collection.","success")}))},deleteCollection:function(){window.confirm("Are you sure you want to delete this collection?")&&axios.delete("/api/local/collection/"+this.collectionId).then((function(t){window.location.href="/"}))}}}},56648:(t,i,e)=>{"use strict";e.r(i),e.d(i,{render:()=>s,staticRenderFns:()=>o});vars=function(){vart=this,i=t._self._c;returni("div",{staticClass:"container"},[t.loaded?i("div",{staticClass:"row"},[t._m(0),t._v(" "),i("div",{staticClass:"col-12 col-md-4 pt-3"},[i("div",{staticClass:"card rounded-0 shadow-none border",staticStyle:{"min-height":"440px"}},[i("div",{staticClass:"card-body"},[i("div",[i("form",[i("div",{staticClass:"form-group"},[i("label",{staticClass:"font-weight-bold text-muted",attrs:{for:"title"}},[t._v("Title")]),t._v(" "),i("input",{directives:[{name:"model",rawName:"v-model",value:t.collection.title,expression:"collection.title"}],staticClass:"form-control",attrs:{type:"text",id:"title",placeholder:"Collection Title",maxlength:"50"},domProps:{value:t.collection.title},on:{input:function(i){i.target.composing||t.$set(t.collection,"t