import{l as f,Q as _,r as u,o as y,L as a,a9 as s,b,y as h,z as v,x as D,M as i,K as E}from"./index-c2905444.js";import{_ as I}from"./ItemsListing.vue_vue_type_style_index_0_lang-17edc154.js";import{s as n}from"./utils-a855eb36.js";import"./ListviewItem-90d92dc7.js";import"./ListItem-e72ce29c.js";import"./VImg-ee22af0e.js";import"./VMenu-8ba8f078.js";import"./VTooltip-54e33c2a.js";import"./VCheckboxBtn-020d02eb.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-74d21d61.js";import"./VCard-a2a52f2b.js";import"./contextmenu-c9d825c5.js";import"./eventbus-d154090d.js";import"./Alert-854e6197.js";import"./Container-920d5187.js";/* empty css              */import"./VToolbar-0b568cf9.js";import"./VTextField-b3baf9d7.js";import"./VBadge-78c551e8.js";import"./VRow-a177c0dd.js";import"./VVirtualScroll-da9f2ada.js";const q=f({__name:"LibraryRadios",setup(k){const{t:l}=_(),p=u([]),o=u(!1),m={name:"sort_name",recent:"timestamp_added DESC"};y(()=>{const t=a.subscribe_multi([s.MEDIA_ITEM_ADDED,s.MEDIA_ITEM_UPDATED,s.MEDIA_ITEM_DELETED],e=>{var r;(r=e.object_id)!=null&&r.startsWith("library://radio")&&(o.value=!0)});b(t)});const c=async function(t){if(t.refresh&&!o.value){for(a.startSync([i.RADIO]),await n(250);a.syncTasks.value.length>0&&a.syncTasks.value.filter(e=>e.media_types.includes(i.RADIO)).length!=0;)await n(500);await n(500)}return o.value=!1,await a.getLibraryRadios(t.favoritesOnly||void 0,t.search,t.limit,t.offset,m[t.sortBy])},d=async function(){const t=prompt(l("enter_url"));t&&a.getItem(i.RADIO,t,"url").then(e=>{const r=prompt(l("enter_name"),e.name);e.name=r||e.name,a.addItemToLibrary(e).then(()=>o.value=!0)}).catch(e=>alert(e))};return(t,e)=>(h(),v(I,{itemtype:"radios",items:p.value,"show-duration":!1,"show-provider":!1,"show-favorites-only-filter":!0,"load-data":c,"sort-keys":Object.keys(m),"update-available":o.value,title:D(E)("bp4")?t.$t("radios"):"","show-search-button":!0,"allow-key-hooks":!0,"context-menu-items":[{label:"add_url_item",labelArgs:[],action:()=>{d()},icon:"mdi-link-plus"}]},null,8,["items","sort-keys","update-available","title","context-menu-items"]))}});export{q as default};
