import{I as f}from"./ItemsListing-9290f7b8.js";import{d as h,aa as b,r as d,o as v,b as a,ac as r,a as I,c as g,e as D,M as n,aq as l,ai as E,V as T}from"./index-dc4d9f26.js";import"./VCheckbox-f1104d05.js";import"./eventbus-a8c2de56.js";import"./VListItem-65135f8c.js";import"./VCheckboxBtn-3cfb51c2.js";import"./VList-4daf9b39.js";import"./VCardText-fea590bb.js";import"./VCard-299e9447.js";import"./VMenu-44fbbe6a.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./ListItem-6e7890fa.js";import"./Button-d230f8d5.js";import"./VSpacer-cde6537e.js";/* empty css              */import"./PanelviewItemCompact-105c1437.js";import"./VAlert-562d62e3.js";import"./Container-43bdd9c6.js";import"./Toolbar-8f128710.js";import"./VToolbar-131f9d53.js";import"./VTextField-e3de4b3e.js";import"./VVirtualScroll-73f2affe.js";import"./VInfiniteScroll-da869181.js";import"./layout-64805198.js";const Q=h({name:"Radios",__name:"LibraryRadios",setup(w){const{t:s}=b(),c=d([]),i=d(!1),u=["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([r.MEDIA_ITEM_ADDED,r.MEDIA_ITEM_UPDATED,r.MEDIA_ITEM_DELETED],e=>{var o;(o=e.object_id)!=null&&o.startsWith("library://radio")&&(i.value=!0)});I(t)});const _=async function(t){if(t.refresh&&!i.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 i.value=!1,await a.getLibraryRadios(t.favoritesOnly||void 0,t.search,t.limit,t.offset,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.RADIO,t,"builtin").then(e=>{var p;const o=prompt(s("enter_name"),e.name);e.name=o||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(f,{itemtype:"radios",items:c.value,"show-duration":!1,"show-provider":!1,"show-favorites-only-filter":!0,"load-paged-data":_,"sort-keys":u,"update-available":i.value,title:t.$t("radios"),"show-search-button":!0,"allow-key-hooks":!0,"extra-menu-items":[{label:"add_url_item",labelArgs:[],action:()=>{y()},icon:"mdi-playlist-plus"}],icon:"mdi-access-point","restore-state":!0},null,8,["items","update-available","title","extra-menu-items"]))}});export{Q as default};
