import{I as y}from"./ItemsListing-Dm2I73m8.js";import{d as v,r as l,s as c,o as b,b as a,a4 as n,a as k,c as T,h,f as d,u as E,F as w,M as u}from"./index-BXI2qIml.js";import{_ as D}from"./AddManualLink.vue_vue_type_script_setup_true_lang-EoZEV69a.js";import{s as m}from"./VCheckbox-CHc9r84S.js";import"./eventbus-BJAYFFrB.js";import"./VListItem-BqDOQjsf.js";import"./ListItem-BKs0yHtA.js";import"./Button-B3YUuwUS.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./VMenu-B1bAKgcw.js";import"./VCard-zMIp_65-.js";import"./VCardText-Cn4KBJZu.js";import"./VSpacer-BPlqGA6z.js";/* empty css              */import"./PanelviewItemCompact-CN1qE3EN.js";import"./VAlert-fx710Vuu.js";import"./Container-CyLsZkwx.js";import"./Toolbar-BIkV8o49.js";import"./VToolbar-7C-gZgX7.js";import"./VList-Oj0sJwE3.js";import"./VTextField-B9f9UP4e.js";import"./VCheckboxBtn-D9hm3Yab.js";import"./VInfiniteScroll-BrsQ2CdR.js";import"./layout-DdVnEUE9.js";import"./VVirtualScroll-BfYXPzfs.js";import"./VDialog-CavDLFW2.js";const Y=v({name:"Tracks",__name:"LibraryTracks",setup(A){const o=l(!1),r=l(c.libraryTracksCount),i=l(!1),p=["name","name_desc","sort_name","sort_name_desc","duration","duration_desc","timestamp_added","timestamp_added_desc","last_played","last_played_desc","play_count","play_count_desc"];b(()=>{const t=a.subscribe_multi([n.MEDIA_ITEM_ADDED,n.MEDIA_ITEM_UPDATED,n.MEDIA_ITEM_DELETED],e=>{var s;(s=e.object_id)!=null&&s.startsWith("library://track")&&(o.value=!0)});k(t)});const f=async function(t){if(t.favoritesOnly=t.favoritesOnly||void 0,t.refresh&&!o.value){for(a.startSync([u.TRACK]),await m(250);a.syncTasks.value.length>0&&a.syncTasks.value.filter(e=>e.media_types.includes(u.TRACK)).length!=0;)await m(500);await m(500)}return o.value=!1,_(t),await a.getLibraryTracks(t.favoritesOnly,t.search,t.limit,t.offset,t.sortBy)},_=async function(t){if(!t.favoritesOnly){r.value=c.libraryTracksCount;return}r.value=await a.getLibraryTracksCount(t.favoritesOnly||!1)};return(t,e)=>(T(),h(w,null,[d(y,{itemtype:"tracks","show-provider":!1,"show-favorites-only-filter":!0,"show-track-number":!1,"load-paged-data":f,"sort-keys":p,"show-album":!0,"update-available":o.value,title:t.$t("tracks"),"show-search-button":!0,"allow-key-hooks":!0,"extra-menu-items":[{label:"add_url_item",labelArgs:[],action:()=>{i.value=!0},icon:"mdi-playlist-plus"}],icon:"mdi-music-note","restore-state":!0,total:r.value},null,8,["update-available","title","extra-menu-items","total"]),d(D,{modelValue:i.value,"onUpdate:modelValue":e[0]||(e[0]=s=>i.value=s),type:E(u).RADIO},null,8,["modelValue","type"])],64))}});export{Y as default};
