import{l as y,L as _,r as o,o as d,H as i,P as v,ao as r,b,v as h,x as E,M as p,ap as l}from"./index-dcf0de03.js";import{_ as w}from"./ItemsListing.vue_vue_type_style_index_0_lang-38bc2f50.js";import"./ListviewItem-2c46c8ee.js";import"./MediaItemThumb.vue_vue_type_style_index_0_lang-b38d9ae1.js";import"./ListItem-6dad7331.js";import"./VBtn-a0da5efe.js";import"./VMenu-3bdd1b96.js";import"./index-0afee102.js";import"./VListItem-943ee224.js";import"./VCheckboxBtn-d54a899d.js";import"./VCard-111cabcf.js";/* empty css                             */import"./PanelviewItem.vue_vue_type_style_index_0_lang-44df1bef.js";import"./contextmenu-ec34ccac.js";import"./eventbus-d154090d.js";import"./Alert-eb81bdeb.js";import"./Container-d623752d.js";/* empty css              */import"./VToolbar-dfba6de4.js";import"./VTextField-f81f9175.js";import"./VBadge-8be61727.js";import"./VRow-73379099.js";const z=y({__name:"LibraryPlaylists",setup(T){const{t:m}=_(),u=o([]),s=o(!1),n=o([]),c=async function(t){if(t.refresh){for(i.startSync([p.PLAYLIST]),await l(250);i.syncTasks.value.length>0&&i.syncTasks.value.filter(e=>e.media_types.includes(p.PLAYLIST)).length!=0;)await l(500);await l(500)}return s.value=!1,await i.getLibraryPlaylists(t.favoritesOnly||void 0,t.search,t.limit,t.offset,t.sortBy)};d(()=>{for(const e of Object.values(i.providers).filter(a=>a.available&&a.supported_features.includes(v.PLAYLIST_CREATE)))n.value.push({label:"create_playlist",labelArgs:[e.name],action:()=>{f(e.instance_id)},icon:"mdi-sync"});const t=i.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")&&(s.value=!0)});b(t)});const f=async function(t){const e=prompt(m("new_playlist_name"));e&&await i.createPlaylist(e,t).then(()=>location.reload()).catch(a=>alert(a))};return(t,e)=>(h(),E(w,{itemtype:"playlists",items:u.value,"show-duration":!1,"show-provider":!0,"show-favorites-only-filter":!0,"load-data":c,"show-library":!0,"sort-keys":["sort_name","timestamp_added DESC"],"update-available":s.value,title:t.$t("playlists"),"allow-key-hooks":!0,"show-search-button":!0,"context-menu-items":n.value},null,8,["items","update-available","title","context-menu-items"]))}});export{z as default};
