import{l as _,Q as d,r as o,o as v,L as s,P as b,a9 as r,b as h,y as E,z as w,x as T,M as p,K as I}from"./index-c2905444.js";import{_ as k}from"./ItemsListing.vue_vue_type_style_index_0_lang-17edc154.js";import{s as l}from"./utils-a855eb36.js";import"./ListviewItem-90d92dc7.js";import"./ListItem-e72ce29c.js";import"./VImg-ee22af0e.js";import"./VMenu-8ba8f078.js";import"./VTooltip-54e33c2a.js";import"./VCheckboxBtn-020d02eb.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-74d21d61.js";import"./VCard-a2a52f2b.js";import"./contextmenu-c9d825c5.js";import"./eventbus-d154090d.js";import"./Alert-854e6197.js";import"./Container-920d5187.js";/* empty css              */import"./VToolbar-0b568cf9.js";import"./VTextField-b3baf9d7.js";import"./VBadge-78c551e8.js";import"./VRow-a177c0dd.js";import"./VVirtualScroll-da9f2ada.js";const q=_({__name:"LibraryPlaylists",setup(A){const{t:c}=d(),m=o([]),i=o(!1),n=o([]),u={name:"sort_name",recent:"timestamp_added DESC"},y=async function(t){if(t.refresh&&!i.value){for(s.startSync([p.PLAYLIST]),await l(250);s.syncTasks.value.length>0&&s.syncTasks.value.filter(e=>e.media_types.includes(p.PLAYLIST)).length!=0;)await l(500);await l(500)}return i.value=!1,await s.getLibraryPlaylists(t.favoritesOnly||void 0,t.search,t.limit,t.offset,u[t.sortBy])};v(()=>{for(const e of Object.values(s.providers).filter(a=>a.available&&a.supported_features.includes(b.PLAYLIST_CREATE)))n.value.push({label:"create_playlist",labelArgs:[e.name],action:()=>{f(e.instance_id)},icon:"mdi-sync"});const t=s.subscribe_multi([r.MEDIA_ITEM_ADDED,r.MEDIA_ITEM_UPDATED,r.MEDIA_ITEM_DELETED],e=>{var a;(a=e.object_id)!=null&&a.startsWith("library://playlist")&&(i.value=!0)});h(t)});const f=async function(t){const e=prompt(c("new_playlist_name"));e&&await s.createPlaylist(e,t).then(()=>location.reload()).catch(a=>alert(a))};return(t,e)=>(E(),w(k,{itemtype:"playlists",items:m.value,"show-duration":!1,"show-provider":!0,"show-favorites-only-filter":!0,"load-data":y,"show-library":!0,"sort-keys":Object.keys(u),"update-available":i.value,title:T(I)("bp4")?t.$t("playlists"):"","allow-key-hooks":!0,"show-search-button":!0,"context-menu-items":n.value},null,8,["items","sort-keys","update-available","title","context-menu-items"]))}});export{q as default};
