"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[2654],{72654:function(e,t,l){l.r(t),l.d(t,{default:function(){return w}});var a=l(20641),s=l(90033),i=l(53751);const o={class:"collections items"},n=["onClick"],c={class:"image"},r=["src","alt","onError"],u={key:0,class:"name"},m={key:1,class:"float bottom-right"},d={key:0,class:"add-playlist floating-btn-container"},y={key:1,class:"add-playlist-modal"},f={class:"row buttons"};function p(e,t,l,p,h,b){const k=(0,a.g2)("FloatingButton"),C=(0,a.g2)("Modal");return(0,a.uX)(),(0,a.CE)("div",{class:(0,s.C4)(["collections index",{"is-root":!l.parentId}])},[(0,a.Lk)("div",o,[((0,a.uX)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(b.filteredItems,t=>((0,a.uX)(),(0,a.CE)("div",{class:"collection item",key:t.id,onClick:l=>e.$emit("select",t)},[(0,a.Lk)("div",c,[h.fallbackImageCollections[t.id]?((0,a.uX)(),(0,a.CE)("i",{key:1,class:(0,s.C4)(b.collectionsIcons[t.type]??"fas fa-folder")},null,2)):((0,a.uX)(),(0,a.CE)("img",{key:0,src:t.image,alt:t.name,onError:e=>b.onImageError(t)},null,40,r))]),h.fallbackImageCollections[t.id]||l.parentId?((0,a.uX)(),(0,a.CE)("div",u,[(0,a.Lk)("h2",null,(0,s.v_)(t.name),1)])):(0,a.Q3)("",!0),t.year?((0,a.uX)(),(0,a.CE)("div",m,[(0,a.Lk)("span",null,(0,s.v_)(t.year),1)])):(0,a.Q3)("",!0)],8,n))),128))]),b.isPlaylistsCollection?((0,a.uX)(),(0,a.CE)("div",d,[(0,a.bF)(k,{"icon-class":"fa fa-plus",title:"Create Playlist",disabled:h.loading,onClick:t[0]||(t[0]=e=>h.showNewPlaylist=!0)},null,8,["disabled"])])):(0,a.Q3)("",!0),h.showNewPlaylist?((0,a.uX)(),(0,a.CE)("div",y,[(0,a.bF)(C,{title:"Create Playlist",visible:!0,onClose:t[3]||(t[3]=e=>h.showNewPlaylist=!1)},{default:(0,a.k6)(()=>[(0,a.Lk)("form",{class:"modal-body",onSubmit:t[2]||(t[2]=(0,i.D$)((...e)=>b.createPlaylist&&b.createPlaylist(...e),["prevent"]))},[t[5]||(t[5]=(0,a.Lk)("div",{class:"row"},[(0,a.Lk)("label",{for:"newPlaylistName"},"Playlist Name"),(0,a.Lk)("input",{name:"name",type:"text",id:"newPlaylistName",placeholder:"Playlist Name",required:""})],-1)),t[6]||(t[6]=(0,a.Lk)("div",{class:"row"},[(0,a.Lk)("label",{for:"newPlaylistPublic"},"Public"),(0,a.Lk)("input",{name:"public",type:"checkbox",checked:"",id:"newPlaylistPublic"})],-1)),(0,a.Lk)("div",f,[(0,a.Lk)("button",{type:"button",onClick:t[1]||(t[1]=e=>h.showNewPlaylist=!1)},"Cancel"),t[4]||(t[4]=(0,a.Lk)("button",{type:"submit"},"Create",-1))])],32)]),_:1})])):(0,a.Q3)("",!0)],2)}l(74423),l(18111),l(22489);var h=l(30656),b=l(354),k=l(91387),C={mixins:[k.A],emits:["refresh","select"],components:{FloatingButton:h.A,Modal:b.A},props:{collection:{type:Object},filter:{type:String},items:{type:Array,default:()=>[]},batchItems:{type:Number,default:100},parentId:{type:String}},data(){return{fallbackImageCollections:{},loading:!1,maxResultIndex:this.batchItems,showNewPlaylist:!1}},computed:{collectionsIcons(){return{books:"fas fa-book",homevideos:"fas fa-video",movies:"fas fa-film",music:"fas fa-music",playlists:"fas fa-list",photos:"fas fa-image",series:"fas fa-tv"}},filteredItems(){return Object.values(this.items).filter(e=>!this.filter||e.name.toLowerCase().includes(this.filter.toLowerCase())).sort((e,t)=>"album"===e.item_type&&"album"===t.item_type&&e.year&&t.year&&e.year!==t.year?t.year-e.year:e.name.localeCompare(t.name)).slice(0,this.maxResultIndex)},isPlaylistsCollection(){return"playlists"===this.collection?.collection_type}},methods:{async createPlaylist(e){const t=new FormData(e.target);await this.request("media.jellyfin.create_playlist",{name:t.get("name"),public:"on"===t.get("public")}),this.$emit("refresh")},onImageError(e){this.fallbackImageCollections[e.id]=!0},onScroll(e){const t=e.target;if(!t)return;const l=t.scrollHeight-t.scrollTop<=t.clientHeight+150;l&&(this.maxResultIndex+=this.batchItems)}},watch:{showNewPlaylist(e){e&&this.$nextTick(()=>this.$el.querySelector('input[name="name"]').focus())}},mounted(){this.$el.parentElement?.addEventListener("scroll",this.onScroll)},unmounted(){this.$el.parentElement?.removeEventListener("scroll",this.onScroll)}},v=l(66262);const g=(0,v.A)(C,[["render",p],["__scopeId","data-v-2b3713e6"]]);var w=g}}]);
//# sourceMappingURL=2654.460d140d.js.map