import{I as y}from"./ItemsListing-6e3c9168.js";import{d as h,a4 as b,r as d,o as v,b as a,a6 as i,a as I,c as g,e as D,M as n,a9 as E,V as T}from"./index-0272dc54.js";import{n as l}from"./utils-a32c3776.js";import"./eventbus-e44cf169.js";import"./VListItem-a3b7f8b7.js";import"./ListItem-ab5df53d.js";import"./Button-7bab5496.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./VTextField-0a661ba3.js";import"./VVirtualScroll-c94c27f1.js";import"./VMenu-30df3a7b.js";import"./VCard-88cdf1d8.js";import"./VCardText-41d932c2.js";import"./VSpacer-39969d39.js";/* empty css              */import"./Alert-4069c5b8.js";import"./VAlert-fb48582c.js";import"./Container-3f082c46.js";import"./Toolbar-b074e682.js";import"./VList-21f55857.js";import"./VToolbar-3145d715.js";import"./VInfiniteScroll-d471d074.js";import"./layout-e087828e.js";import"./VChip-e0012620.js";const Q=h({name:"Radios",__name:"LibraryRadios",setup(w){const{t:s}=b(),u=d([]),o=d(!1),c=["name","name_desc","sort_name","sort_name_desc","timestamp_added","timestamp_added_desc","last_played","last_played_desc","play_count","play_count_desc"];v(()=>{const t=a.subscribe_multi([i.MEDIA_ITEM_ADDED,i.MEDIA_ITEM_UPDATED,i.MEDIA_ITEM_DELETED],e=>{var r;(r=e.object_id)!=null&&r.startsWith("library://radio")&&(o.value=!0)});I(t)});const _=async function(t){if(t.refresh&&!o.value){for(a.startSync([n.RADIO]),await l(250);a.syncTasks.value.length>0&&a.syncTasks.value.filter(e=>e.media_types.includes(n.RADIO)).length!=0;)await l(500);await l(500)}return o.value=!1,await a.getLibraryRadios(t.favoritesOnly||void 0,t.search,t.limit,t.offset,t.sortBy)},f=async function(){const t=prompt(s("enter_url"));if(t){if(!(t!=null&&t.startsWith("http"))){alert(s("invalid_input"));return}a.getItem(n.RADIO,t,"builtin").then(e=>{var p;const r=prompt(s("enter_name"),e.name);e.name=r||e.name,delete e.sort_name;const m=prompt(s("image_url"),(p=e.metadata.images)!=null&&p.length?e.metadata.images[0].path:"");m&&(e.metadata.images=[{type:E.THUMB,path:m,provider:"builtin",remotely_accessible:!0}]),a.addItemToLibrary(e).then(()=>T.go(0))}).catch(e=>alert(e))}};return(t,e)=>(g(),D(y,{itemtype:"radios",items:u.value,"show-duration":!1,"show-provider":!1,"show-favorites-only-filter":!0,"load-paged-data":_,"sort-keys":c,"update-available":o.value,title:t.$t("radios"),"show-search-button":!0,"allow-key-hooks":!0,"extra-menu-items":[{label:"add_url_item",labelArgs:[],action:()=>{f()},icon:"mdi-playlist-plus"}],icon:"mdi-access-point","restore-state":!0},null,8,["items","update-available","title","extra-menu-items"]))}});export{Q as default};
