import{l as f,N as _,r as m,o as y,J as a,ai as r,b,v,x as h,q as D,M as i,aj as n,I}from"./index-e5db0b73.js";import{_ as E}from"./ItemsListing.vue_vue_type_style_index_0_lang-6fa46e09.js";import"./ListviewItem-7c178b7a.js";import"./VBadge-efd00f67.js";import"./ListItem-ac3869d3.js";import"./VImg-7a057c50.js";import"./VMenu-d9833a31.js";import"./VCheckboxBtn-46446b67.js";import"./VCard-c9b9f4e9.js";import"./VTooltip-71530943.js";import"./PanelviewItem.vue_vue_type_style_index_0_lang-221d4edc.js";import"./contextmenu-8eac6b44.js";import"./Alert-1172b8fb.js";import"./Container-238e2d02.js";import"./VToolbar-4e8dded4.js";import"./VTextField-46667b30.js";import"./VVirtualScroll-01555b84.js";const K=f({__name:"LibraryRadios",setup(k){const{t:l}=_(),c=m([]),o=m(!1),u={name:"sort_name",recent:"timestamp_added DESC"};y(()=>{const e=a.subscribe_multi([r.MEDIA_ITEM_ADDED,r.MEDIA_ITEM_UPDATED,r.MEDIA_ITEM_DELETED],t=>{var s;(s=t.object_id)!=null&&s.startsWith("library://radio")&&(o.value=!0)});b(e)});const p=async function(e){if(e.refresh&&!o.value){for(a.startSync([i.RADIO]),await n(250);a.syncTasks.value.length>0&&a.syncTasks.value.filter(t=>t.media_types.includes(i.RADIO)).length!=0;)await n(500);await n(500)}return o.value=!1,await a.getLibraryRadios(e.favoritesOnly||void 0,e.search,e.limit,e.offset,u[e.sortBy])},d=async function(){const e=prompt(l("enter_url"));e&&a.getItem(i.RADIO,e,"url").then(t=>{const s=prompt(l("enter_name"),t.name);t.name=s||t.name,a.addItemToLibrary(t).then(()=>o.value=!0)}).catch(t=>alert(t))};return(e,t)=>(v(),h(E,{itemtype:"radios",items:c.value,"show-duration":!1,"show-provider":!1,"show-favorites-only-filter":!0,"load-paged-data":p,"sort-keys":Object.keys(u),"update-available":o.value,title:D(I)("bp4")?e.$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{K as default};
