import{I as f}from"./ItemsListing-7bf0c0b0.js";import{d as b,a5 as h,r as u,s as v,o as I,b as a,a7 as r,a as g,c as w,e as D,M as n,ac as E}from"./index-103db515.js";import{s as l}from"./VCheckbox-ddd5d7c4.js";import"./eventbus-6e1536e2.js";import"./VListItem-ab7a82e2.js";import"./ListItem-91f42136.js";import"./Button-412f73ce.js";import"./_plugin-vue_export-helper-c27b6911.js";import"./VMenu-482e7fbc.js";import"./VCard-d4f085fd.js";import"./VCardText-1a59cac1.js";import"./VSpacer-adcb10ea.js";/* empty css              */import"./PanelviewItemCompact-5ede3757.js";import"./VAlert-4165d2e6.js";import"./Container-d98651c4.js";import"./Toolbar-908bc969.js";import"./VList-cac73f62.js";import"./VToolbar-dcf67568.js";import"./VTextField-73438668.js";import"./VCheckboxBtn-19bafbc9.js";import"./VInfiniteScroll-c2610a44.js";import"./layout-e7ad5131.js";import"./VVirtualScroll-b23fb9a8.js";const V=b({name:"Radios",__name:"LibraryRadios",setup(T){const{t:o}=h(),s=u(!1),m=u(v.libraryRadiosCount),c=["name","name_desc","sort_name","sort_name_desc","timestamp_added","timestamp_added_desc","last_played","last_played_desc","play_count","play_count_desc"];I(()=>{const t=a.subscribe_multi([r.MEDIA_ITEM_ADDED,r.MEDIA_ITEM_UPDATED,r.MEDIA_ITEM_DELETED],e=>{var i;(i=e.object_id)!=null&&i.startsWith("library://radio")&&(s.value=!0)});g(t)});const _=async function(t){if(t.refresh&&!s.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 s.value=!1,m.value=await a.getLibraryRadiosCount(t.favoritesOnly||!1),await a.getLibraryRadios(t.favoritesOnly||void 0,t.search,t.limit,t.offset,t.sortBy)},y=async function(){const t=prompt(o("enter_url"));if(t){if(!(t!=null&&t.startsWith("http"))){alert(o("invalid_input"));return}a.getItem(n.RADIO,t,"builtin").then(e=>{var d;const i=prompt(o("enter_name"),e.name);e.name=i||e.name,delete e.sort_name;const p=prompt(o("image_url"),(d=e.metadata.images)!=null&&d.length?e.metadata.images[0].path:"");p&&(e.metadata.images=[{type:E.THUMB,path:p,provider:"builtin",remotely_accessible:!0}]),a.addItemToLibrary(e).then(()=>window.location.reload())}).catch(e=>alert(e))}};return(t,e)=>(w(),D(f,{itemtype:"radios","show-duration":!1,"show-provider":!1,"show-favorites-only-filter":!0,"load-paged-data":_,"sort-keys":c,"update-available":s.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,total:m.value},null,8,["update-available","title","extra-menu-items","total"]))}});export{V as default};
