import{x as I,az as R,r as Y,I as a,ag as D,b as T,c as z,P,w as F,y as o,D as h,n as r,A as n,S as k,J as d,F as S,E as x,z as u,G as m,B as A,K as G,aR as O}from"./index-DuDRe8hE.js";import{_ as U}from"./ProviderIcon.vue_vue_type_script_setup_true_lang-CHFYJo9W.js";import{B as E,L as X}from"./ListItem-xrpNnThP.js";import{C as j}from"./Container-CQhyPPl2.js";import{e as q}from"./eventbus-CGRXT3Tn.js";import{V as C}from"./VToolbar-Dhcm-C4i.js";import{v as J,w as B}from"./VListItem-CuoSvcqW.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./VContainer-CCoTeKDA.js";/* empty css              */const K={style:{"margin-bottom":"10px"}},H={class:"line-clamp-1"},Q={class:"line-clamp-1"},de=I({__name:"Players",setup(W){const c=R(),l=Y([]),V=a.subscribe_multi([D.PLAYER_CONFIG_UPDATED],()=>{_()});T(V),z(()=>Object.values(a.players).filter(e=>{var t;return e.available&&((t=a.getProvider(e.provider))==null?void 0:t.supported_features.includes(P.SYNC_PLAYERS))}));const _=async function(){l.value=(await a.getPlayerConfigs()).sort((e,t)=>p(e).localeCompare(p(t)))},M=function(e){a.removePlayerConfig(e),l.value=l.value.filter(t=>t.player_id!=e)},b=function(e,t){t in a.providers&&c.push(`/settings/editplayer/${e}`)},N=function(e){c.push(`/settings/editplayer/${e}/dsp`)},$=function(e){c.push("/settings/addgroup")},w=function(e){e.enabled=!e.enabled,a.savePlayerConfig(e.player_id,{enabled:e.enabled})},p=function(e){var t;return e.name||((t=a.players[e.player_id])==null?void 0:t.display_name)||e.default_name||e.player_id},L=function(e,t){var s,v,y,f;const i=[{label:"settings.configure",labelArgs:[],action:()=>{b(t.player_id,t.provider)},icon:"mdi-cog",disabled:!a.getProvider(t.provider)},{label:"open_dsp_settings",labelArgs:[],action:()=>{N(t.player_id)},icon:"mdi-equalizer",disabled:!((s=a.players[t.player_id])!=null&&s.available)},{label:t.enabled?"settings.disable":"settings.enable",labelArgs:[],action:()=>{w(t)},icon:"mdi-cancel",hide:!a.getProvider(t.provider)},{label:"settings.documentation",labelArgs:[],action:()=>{var g;O(((g=a.getProviderManifest(t.provider))==null?void 0:g.documentation)||"")},icon:"mdi-bookshelf",disabled:!((v=a.getProviderManifest(t.provider))!=null&&v.documentation)},{label:"settings.delete",labelArgs:[],action:()=>{M(t.player_id)},icon:"mdi-delete",hide:!(!((y=a.players[t.player_id])!=null&&y.available)||(f=a.getProvider(t.provider))!=null&&f.supported_features.includes(P.REMOVE_PLAYER))}];q.emit("contextmenu",{items:i,posX:e.clientX,posY:e.clientY})};return F(()=>a.players,e=>{e&&_()},{immediate:!0}),(e,t)=>(o(),h("div",K,[r(C,{density:"compact",class:"titlebar",color:"transparent",style:{height:"55px"}},{title:n(()=>[k(d(e.$t("settings.players")),1)]),append:n(()=>[r(J,{color:"accent",variant:"outlined",onClick:$},{default:n(()=>[k(d(e.$t("settings.add_group_player")),1)]),_:1})]),_:1}),r(j,null,{default:n(()=>[(o(!0),h(S,null,x(l.value,i=>(o(),u(X,{key:i.player_id,"show-menu-btn":"",link:"",onMenu:s=>L(s,i),onClick:s=>b(i.player_id,i.provider)},{prepend:n(()=>{var s;return[r(U,{domain:((s=m(a).getProviderManifest(i.provider))==null?void 0:s.domain)||"",size:40,class:"listitem-media-thumb"},null,8,["domain"])]}),title:n(()=>[A("div",H,d(p(i)),1)]),subtitle:n(()=>{var s;return[A("div",Q,d(((s=m(a).getProviderManifest(i.provider))==null?void 0:s.name)||i.provider),1)]}),append:n(()=>{var s;return[i.enabled?(s=m(a).players[i.player_id])!=null&&s.available?G("",!0):(o(),u(E,{key:1,icon:"",title:e.$t("settings.player_not_available")},{default:n(()=>[r(B,{icon:"mdi-timer-sand"})]),_:1},8,["title"])):(o(),u(E,{key:0,icon:"",title:e.$t("settings.player_disabled")},{default:n(()=>[r(B,{icon:"mdi-cancel"})]),_:1},8,["title"]))]}),_:2},1032,["onMenu","onClick"]))),128))]),_:1})]))}});export{de as default};
