import{I as h}from"./ItemsListing-BTyg07hS.js";import{s as d,a,k as s,E as u,e as m,t as T,$ as _}from"./index-KrUTRSho.js";import{d as L,r as p,o as P,a3 as w,G as D,u as f,aC as g,b as C}from"./lucide-DMa8pBeQ.js";import"./Container-CCPBqGnj.js";import"./index-kQIztB-E.js";import"./vuetify-CbR4Ou0u.js";import"./Toolbar-5SbHDXXe.js";import"./userPreferences-C8yXcknh.js";import"./vue-router-DHedY1l9.js";import"./Button-CKfLEnzZ.js";import"./ListItem-BUF9DGtO.js";import"./NowPlayingBadge.vue_vue_type_style_index_0_lang-kbJcSVI9.js";import"./MediaItemThumb-JkxOeIdn.js";import"./ProviderIcon.vue_vue_type_style_index_0_lang-e-wXPlLi.js";import"./vue-i18n-BEWj6xw2.js";import"./PanelviewItemCompact-DHPMQAz2.js";import"./qrcode-Cnwj8xOV.js";import"./marked-BPdRUrA1.js";import"./color-CqFg8eif.js";import"./vueuse-BL7kbX9s.js";/* empty css            */import"./swiper-DftkhebG.js";const Z=L({name:"Playlists",__name:"LibraryPlaylists",setup(S){const l=p(!1),o=p(d.libraryPlaylistsCount),n=p([]),y=["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"],v=async function(t){return l.value=!1,E(t),await a.getLibraryPlaylists(t.favoritesOnly||void 0,t.search,t.limit,t.offset,t.sortBy,t.provider&&t.provider.length>0?t.provider:void 0,t.genreIds)},E=async function(t){if(!t.favoritesOnly&&!t.provider){o.value=d.libraryPlaylistsCount;return}if(t.provider&&t.provider.length>0){o.value=void 0;return}o.value=await a.getLibraryPlaylistsCount(t.favoritesOnly||!1)};P(()=>{const t=[];for(const i of Object.values(a.providers).filter(e=>e.available&&(e.supported_features.includes(s.PLAYLIST_CREATE)||e.supported_features.includes(s.PLAYLIST_CREATE_TRACKS)||e.supported_features.includes(s.PLAYLIST_CREATE_AUDIOBOOKS)||e.supported_features.includes(s.PLAYLIST_CREATE_PODCAST_EPISODES)||e.supported_features.includes(s.PLAYLIST_CREATE_RADIOS))))t.push({label:"create_playlist_on",labelArgs:[i.name],action:()=>{b(i.instance_id)},icon:"mdi-playlist-plus",overflowAllowed:!0});t.length&&n.value.push({label:"create_playlist_on",icon:"mdi-playlist-plus",subItems:t,overflowAllowed:!0}),n.value.push({label:"import_playlist",action:()=>{A()},icon:"mdi-file-import",overflowAllowed:!0});const r=a.subscribe_multi([u.MEDIA_ITEM_ADDED,u.MEDIA_ITEM_UPDATED,u.MEDIA_ITEM_DELETED],i=>{i.object_id?.startsWith("library://playlist")&&(l.value=!0)});w(r)});const b=function(t){m.emit("createPlaylist",{providerId:t})},A=()=>{const t=document.createElement("input");t.type="file",t.accept=".m3u,.m3u8",t.onchange=async r=>{const i=r.target.files?.[0];if(!i)return;const e=await i.text();if(!e.trimStart().startsWith("#EXTM3U")){T.error(_("import_playlist_invalid_file"));return}const c=e.match(/^#PLAYLIST:(.+)$/m),I=c?c[1].trim():i.name.replace(/\.m3u8?$/i,"");m.emit("importPlaylistDialog",{m3uData:e,playlistName:I})},t.click()};return(t,r)=>(C(),D(h,{itemtype:"playlists",path:"libraryplaylists","show-duration":!1,"show-provider":!0,"show-favorites-only-filter":!0,"load-paged-data":v,"show-library":!0,"sort-keys":y,"update-available":l.value,title:f(_)("playlists"),"allow-key-hooks":!0,"show-search-button":!0,"show-genre-filter":!0,"extra-menu-items":n.value,icon:f(g),"restore-state":!0,total:o.value,"show-provider-filter":!0},null,8,["update-available","title","extra-menu-items","icon","total"]))}});export{Z as default};
