import{_ as y}from"./ItemsListing.vue_vue_type_style_index_0_lang-e3f0c114.js";import{y as b,R as h,r as c,o as v,N as a,ap as s,b as g,A as D,B as I,z as E,O as n,aq as l,ai as k,X as T,M as A}from"./index-9b822783.js";import"./ListviewItem-030e11e6.js";import"./VBadge-c9fb58c5.js";import"./Container-05be0da0.js";import"./forwardRefs-af0663a3.js";import"./VMenu-8029677e.js";/* empty css              */import"./VInput-c159036c.js";import"./VSlideGroup-d3ac8eca.js";import"./VCard-0d72f9dd.js";import"./VCardText-bc96863a.js";import"./VTooltip-5955b4ca.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-846c4785.js";import"./contextmenu-b55bad56.js";import"./Alert-112324b3.js";import"./VAlert-fddf489c.js";import"./VToolbar-79c684b4.js";import"./VTextField-7d804c49.js";import"./VVirtualScroll-a3d1c1c9.js";import"./layout-71937d76.js";const G=b({__name:"LibraryRadios",setup(w){const{t:i}=h(),d=c([]),r=c(!1),m={name:"sort_name",recent:"timestamp_added DESC"};v(()=>{const t=a.subscribe_multi([s.MEDIA_ITEM_ADDED,s.MEDIA_ITEM_UPDATED,s.MEDIA_ITEM_DELETED],e=>{var o;(o=e.object_id)!=null&&o.startsWith("library://radio")&&(r.value=!0)});g(t)});const f=async function(t){if(t.refresh&&!r.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 r.value=!1,await a.getLibraryRadios(t.favoritesOnly||void 0,t.search,t.limit,t.offset,m[t.sortBy])},_=async function(){const t=prompt(i("enter_url"));if(t){if(!(t!=null&&t.startsWith("http"))){alert(i("invalid_input"));return}a.getItem(n.RADIO,t,"builtin").then(e=>{var u;const o=prompt(i("enter_name"),e.name);e.name=o||e.name;const p=prompt(i("image_url"),(u=e.metadata.images)!=null&&u.length?e.metadata.images[0].path:"");p&&(e.metadata.images=[{type:k.THUMB,path:p,provider:"builtin",remotely_accessible:!0}]),a.addItemToLibrary(e).then(()=>T.go(0))}).catch(e=>alert(e))}};return(t,e)=>(D(),I(y,{itemtype:"radios",items:d.value,"show-duration":!1,"show-provider":!1,"show-favorites-only-filter":!0,"load-paged-data":f,"sort-keys":Object.keys(m),"update-available":r.value,title:E(A)("bp4")?t.$t("radios"):"","show-search-button":!0,"allow-key-hooks":!0,"context-menu-items":[{label:"add_url_item",labelArgs:[],action:()=>{_()},icon:"mdi-link-plus"}]},null,8,["items","sort-keys","update-available","title","context-menu-items"]))}});export{G as default};
