import{l as _,Q as f,r as u,o as y,L as a,a9 as s,b,y as k,z as h,x as v,M as i,K as T}from"./index-d8f9df52.js";import{_ as E}from"./ItemsListing.vue_vue_type_style_index_0_lang-3c57f819.js";import{s as n}from"./utils-9f654e0f.js";import"./ListviewItem-c40e4501.js";import"./ListItem-7f13d5f5.js";import"./VImg-4a7a1cb8.js";import"./VMenu-7da753a3.js";import"./VTooltip-c8363108.js";import"./VCheckboxBtn-a71f5d8b.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-7cb7ae2f.js";import"./VCard-45095a4d.js";import"./contextmenu-4e7016bd.js";import"./eventbus-d154090d.js";import"./Alert-6364676b.js";import"./Container-e16d8739.js";/* empty css              */import"./VToolbar-2e81aa20.js";import"./VTextField-98808566.js";import"./VBadge-e81619d5.js";import"./VRow-d7ad6808.js";import"./VVirtualScroll-fd913adb.js";const q=_({__name:"LibraryTracks",setup(D){const{t:l}=f(),c=u([]),r=u(!1),m={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"};y(()=>{const t=a.subscribe_multi([s.MEDIA_ITEM_ADDED,s.MEDIA_ITEM_UPDATED,s.MEDIA_ITEM_DELETED],e=>{var o;(o=e.object_id)!=null&&o.startsWith("library://track")&&(r.value=!0)});b(t)});const p=async function(t){if(t.favoritesOnly=t.favoritesOnly||void 0,t.refresh){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,m[t.sortBy])},d=async function(){const t=prompt(l("enter_url"));t&&a.getItem(i.TRACK,t,"url").then(e=>{const o=prompt(l("enter_name"),e.name);e.name=o||e.name,a.addItemToLibrary(e).then(()=>r.value=!0)}).catch(e=>alert(e))};return(t,e)=>(k(),h(E,{itemtype:"tracks",items:c.value,"show-provider":!1,"show-favorites-only-filter":!0,"show-track-number":!1,"load-data":p,"sort-keys":Object.keys(m),"show-album":!0,"update-available":r.value,title:v(T)("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{q as default};
