import{I as f}from"./ItemsListing-db2c60f3.js";import{d as v,ae as b,r as l,o as E,b as a,P as h,af as r,a as D,c as I,e as w,M as d,ag as m}from"./index-2dd0c7d2.js";import"./ListviewItem-a6570b10.js";import"./helpers-4d7c5bf6.js";import"./Container-fdf4c1f5.js";import"./VListItem-cb387084.js";import"./_plugin-vue_export-helper-c27b6911.js";/* empty css              */import"./VLabel-1f522f96.js";import"./VList-d110868a.js";import"./VCard-907b4685.js";import"./VCardText-0ed41581.js";import"./VMenu-97c1c955.js";import"./ListItem-87435fbb.js";import"./Button-69b906cf.js";import"./VTooltip-e62b61bd.js";import"./VCheckboxBtn-c3f9b6ff.js";import"./PanelviewItem-68416368.js";import"./VSpacer-e11897c6.js";import"./Alert-65a1093b.js";import"./VAlert-4eed3112.js";import"./Toolbar-1720c469.js";import"./VBadge-91055b8b.js";import"./VToolbar-6047eebf.js";import"./ItemContextMenu.vue_vue_type_style_index_0_scoped_7aadaa8c_lang-7ff19a96.js";import"./eventbus-d154090d.js";import"./VTextField-de7279c6.js";import"./VVirtualScroll-660ff9a6.js";import"./VSnackbar-6950ff68.js";import"./layout-42d7f450.js";const et=v({name:"Playlists",__name:"LibraryPlaylists",setup(T){const{t:c}=b(),u=l([]),o=l(!1),n=l([]),p={name:"name",name_desc:"name DESC",sort_name:"sort_name",sort_name_desc:"sort_name DESC",timestamp_added:"timestamp_added",timestamp_added_desc:"timestamp_added DESC",timestamp_modified:"timestamp_modified",timestamp_modified_desc:"timestamp_modified DESC",last_played:"last_played",last_played_desc:"last_played DESC",play_count:"play_count",play_count_desc:"play_count DESC"},_=async function(t){if(t.refresh&&!o.value){for(a.startSync([d.PLAYLIST]),await m(250);a.syncTasks.value.length>0&&a.syncTasks.value.filter(e=>e.media_types.includes(d.PLAYLIST)).length!=0;)await m(500);await m(500)}return o.value=!1,await a.getLibraryPlaylists(t.favoritesOnly||void 0,t.search,t.limit,t.offset,p[t.sortBy])};E(()=>{const t=[];for(const s of Object.values(a.providers).filter(i=>i.available&&i.supported_features.includes(h.PLAYLIST_CREATE)))t.push({label:"create_playlist_on",labelArgs:[s.name],action:()=>{y(s.instance_id)},icon:"mdi-playlist-plus"});t.length&&n.value.push({label:"create_playlist_on",icon:"mdi-playlist-plus",subItems:t});const e=a.subscribe_multi([r.MEDIA_ITEM_ADDED,r.MEDIA_ITEM_UPDATED,r.MEDIA_ITEM_DELETED],s=>{var i;(i=s.object_id)!=null&&i.startsWith("library://playlist")&&(o.value=!0)});D(e)});const y=async function(t){const e=prompt(c("new_playlist_name"));e&&await a.createPlaylist(e,t).then(()=>location.reload()).catch(s=>alert(s))};return(t,e)=>(I(),w(f,{itemtype:"playlists",items:u.value,"show-duration":!1,"show-provider":!0,"show-favorites-only-filter":!0,"load-paged-data":_,"show-library":!0,"sort-keys":Object.keys(p),"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"},null,8,["items","sort-keys","update-available","title","extra-menu-items"]))}});export{et as default};
