import{_}from"./ItemsListing.vue_vue_type_style_index_0_lang-8114fc79.js";import{v as f,Q as y,r as m,o as b,L as a,ak as o,b as k,y as v,z as h,x as T,M as i,al as n,K as E}from"./index-20675090.js";import"./ListviewItem-ea07a19b.js";import"./VBadge-778cac01.js";import"./ListItem-e092a77b.js";import"./forwardRefs-67412654.js";import"./VMenu-ae4158ef.js";import"./VCheckboxBtn-bbfa74a1.js";import"./VSlideGroup-14bb6bf6.js";import"./VCard-30020028.js";import"./VCardText-5e149cd1.js";import"./VTooltip-cf009865.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-4e768a3d.js";import"./contextmenu-ec90c658.js";import"./Alert-daf9024b.js";import"./Container-e8fef44d.js";/* empty css              */import"./VToolbar-7174c765.js";import"./VTextField-8bb22937.js";import"./VVirtualScroll-b47ffb64.js";const W=f({__name:"LibraryTracks",setup(D){const{t:l}=y(),c=m([]),r=m(!1),u={name:"sort_name",recent:"timestamp_added DESC",artist:"sort_artist, sort_name",album:"albums.sort_name, tracks.sort_name",duration:"duration",duration_desc:"duration DESC"};b(()=>{const t=a.subscribe_multi([o.MEDIA_ITEM_ADDED,o.MEDIA_ITEM_UPDATED,o.MEDIA_ITEM_DELETED],e=>{var s;(s=e.object_id)!=null&&s.startsWith("library://track")&&(r.value=!0)});k(t)});const p=async function(t){if(t.favoritesOnly=t.favoritesOnly||void 0,t.refresh&&!r.value){for(a.startSync([i.TRACK]),await n(250);a.syncTasks.value.length>0&&a.syncTasks.value.filter(e=>e.media_types.includes(i.TRACK)).length!=0;)await n(500);await n(500)}return r.value=!1,await a.getLibraryTracks(t.favoritesOnly,t.search,t.limit,t.offset,u[t.sortBy])},d=async function(){const t=prompt(l("enter_url"));t&&a.getItem(i.TRACK,t,"url").then(e=>{const s=prompt(l("enter_name"),e.name);e.name=s||e.name,a.addItemToLibrary(e).then(()=>r.value=!0)}).catch(e=>alert(e))};return(t,e)=>(v(),h(_,{itemtype:"tracks",items:c.value,"show-provider":!1,"show-favorites-only-filter":!0,"show-track-number":!1,"load-paged-data":p,"sort-keys":Object.keys(u),"show-album":!0,"update-available":r.value,title:T(E)("bp4")?t.$t("tracks"):"","show-search-button":!0,"allow-key-hooks":!0,"context-menu-items":[{label:"add_url_item",labelArgs:[],action:()=>{d()},icon:"mdi-link-plus"}]},null,8,["items","sort-keys","update-available","title","context-menu-items"]))}});export{W as default};
