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