import{I as f}from"./ItemsListing-D_KqSTZS.js";import{ay as v,bN as b,J as l,ax as p,a3 as h,aP as s,aR as I,bb as r,a4 as E,aI as w,aA as P}from"./index-BRUnowC8.js";import"./Container-ZHtGcXZO.js";import"./index-kQIztB-E.js";import"./Toolbar-BEJzY0mB.js";import"./VToolbar-DS4mUdOC.js";import"./Button-BKv4xLAv.js";import"./ListItem-jfbxOrad.js";import"./userPreferences-DBWZCHKf.js";import"./VCheckboxBtn-D390s4L9.js";import"./VSelectionControl-Co1cRcmS.js";import"./MediaItemThumb-CIE9_Elw.js";import"./PanelviewItemCompact-CsJmi5IT.js";import"./VInfiniteScroll-BORsRMGl.js";import"./VVirtualScroll-htzu2YXu.js";import"./VAlert-DQxypmdN.js";const N=v({name:"Playlists",__name:"LibraryPlaylists",setup(A){const{t:c}=b(),o=l(!1),i=l(p.libraryPlaylistsCount),n=l([]),d=["name","name_desc","sort_name","sort_name_desc","timestamp_added","timestamp_added_desc","timestamp_modified","timestamp_modified_desc","last_played","last_played_desc","play_count","play_count_desc"],y=async function(t){return o.value=!1,m(t),await s.getLibraryPlaylists(t.favoritesOnly||void 0,t.search,t.limit,t.offset,t.sortBy,t.provider&&t.provider.length>0?t.provider:void 0)},m=async function(t){if(!t.favoritesOnly&&!t.provider){i.value=p.libraryPlaylistsCount;return}if(t.provider&&t.provider.length>0){i.value=void 0;return}i.value=await s.getLibraryPlaylistsCount(t.favoritesOnly||!1)};h(()=>{const t=[];for(const e of Object.values(s.providers).filter(u=>u.available&&u.supported_features.includes(I.PLAYLIST_CREATE)))t.push({label:"create_playlist_on",labelArgs:[e.name],action:()=>{_(e.instance_id)},icon:"mdi-playlist-plus"});t.length&&n.value.push({label:"create_playlist_on",icon:"mdi-playlist-plus",subItems:t});const a=s.subscribe_multi([r.MEDIA_ITEM_ADDED,r.MEDIA_ITEM_UPDATED,r.MEDIA_ITEM_DELETED],e=>{e.object_id?.startsWith("library://playlist")&&(o.value=!0)});E(a)});const _=async function(t){const a=prompt(c("new_playlist_name"));a&&await s.createPlaylist(a,t).then(()=>location.reload()).catch(e=>alert(e))};return(t,a)=>(P(),w(f,{itemtype:"playlists",path:"libraryplaylists","show-duration":!1,"show-provider":!0,"show-favorites-only-filter":!0,"load-paged-data":y,"show-library":!0,"sort-keys":d,"update-available":o.value,title:t.$t("playlists"),"allow-key-hooks":!0,"show-search-button":!0,"extra-menu-items":n.value,icon:"mdi-playlist-play","restore-state":!0,total:i.value,"show-provider-filter":!0},null,8,["update-available","title","extra-menu-items","total"]))}});export{N as default};
