import{_ as f}from"./ItemsListing.vue_vue_type_style_index_0_lang-02893598.js";import{d as b,k as h,r as d,o as k,b as a,ah as i,a as v,c as E,e as D,M as n,ai as l,a7 as T,D as g}from"./index-0ae84607.js";import"./ListviewItem-156d947d.js";import"./VBadge-bfb26993.js";import"./Container-eb92362b.js";import"./forwardRefs-d0d7c5bd.js";import"./Button-a1dfd3f5.js";import"./VMenu-f26d3a19.js";/* empty css              */import"./VInput-00e20677.js";import"./VSlideGroup-18f8a11f.js";import"./VCard-e96ab32b.js";import"./VCardText-b1a0de89.js";import"./VTooltip-054ea37d.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-a0b4c306.js";import"./contextmenu-5ae46870.js";import"./Alert-ee4ff93d.js";import"./VAlert-212471f5.js";import"./VToolbar-b7dd8339.js";import"./VTextField-4bf39c0d.js";import"./VVirtualScroll-06bbaaf5.js";import"./layout-f3684635.js";const N=b({name:"Tracks",__name:"LibraryTracks",setup(w){const{t:s}=h(),u=d([]),r=d(!1),m={name:"name",name_desc:"name DESC",sort_name:"sort_name",sort_name_desc:"sort_name DESC",artist:"artists.name, name",year:"year",year_desc:"year DESC",album:"albums.name, tracks.name",duration:"duration",duration_desc:"duration DESC",timestamp_added:"timestamp_added",timestamp_added_desc:"timestamp_added DESC",last_played:"last_played",last_played_desc:"last_played DESC",play_count:"play_count",play_count_desc:"play_count DESC"};k(()=>{const t=a.subscribe_multi([i.MEDIA_ITEM_ADDED,i.MEDIA_ITEM_UPDATED,i.MEDIA_ITEM_DELETED],e=>{var o;(o=e.object_id)!=null&&o.startsWith("library://track")&&(r.value=!0)});v(t)});const _=async function(t){if(t.favoritesOnly=t.favoritesOnly||void 0,t.refresh&&!r.value){for(a.startSync([n.TRACK]),await l(250);a.syncTasks.value.length>0&&a.syncTasks.value.filter(e=>e.media_types.includes(n.TRACK)).length!=0;)await l(500);await l(500)}return r.value=!1,await a.getLibraryTracks(t.favoritesOnly,t.search,t.limit,t.offset,m[t.sortBy])},y=async function(){const t=prompt(s("enter_url"));if(t){if(!(t!=null&&t.startsWith("http"))){alert(s("invalid_input"));return}a.getItem(n.TRACK,t,"builtin").then(e=>{var p;const o=prompt(s("enter_name"),e.name);e.name=o||e.name,delete e.sort_name;const c=prompt(s("image_url"),(p=e.metadata.images)!=null&&p.length?e.metadata.images[0].path:"");c&&(e.metadata.images=[{type:T.THUMB,path:c,provider:"builtin",remotely_accessible:!0}]),a.addItemToLibrary(e).then(()=>g.go(0))}).catch(e=>alert(e))}};return(t,e)=>(E(),D(f,{itemtype:"tracks",items:u.value,"show-provider":!1,"show-favorites-only-filter":!0,"show-track-number":!1,"load-paged-data":_,"sort-keys":Object.keys(m),"show-album":!0,"update-available":r.value,title:t.$t("tracks"),"show-search-button":!0,"allow-key-hooks":!0,"context-menu-items":[{label:"add_url_item",labelArgs:[],action:()=>{y()},icon:"mdi-link-plus"}]},null,8,["items","sort-keys","update-available","title","context-menu-items"]))}});export{N as default};
