import{B as P}from"./Button-Dq6btUmD.js";import{C as U}from"./Container-D2fLqW0L.js";import{L as Y}from"./ListItem-DYjdeEgj.js";import{aw as T,J as I,aN as a,b9 as w,a4 as D,i as S,aP as d,L as z,ax as _,ay as r,o as i,aD as n,aG as o,az as g,aQ as F,ag as h,aE as E,M as x,ad as X,bf as k,aL as p,b2 as J,aC as W,aH as j,aT as R,aJ as M,aB as b,E as V,bp as A,cC as q,aM as H}from"./index-DhxwW1_d.js";import{S as Q}from"./constants-CXMxJR4j.js";import{V as K}from"./VToolbar-69Rn7taX.js";import"./index-kQIztB-E.js";const Z={style:{"margin-bottom":"10px"}},ee={class:"line-clamp-1"},te={class:"line-clamp-1"},pe=T({__name:"Players",setup(ae){const u=W(),l=I([]),L=a.subscribe_multi([w.PLAYER_CONFIG_UPDATED],()=>{y()});D(L);const v=S(()=>Object.values(a.providers).filter(e=>e.available&&(e.supported_features.includes(d.CREATE_GROUP_PLAYER)||e.supported_features.includes(d.SYNC_PLAYERS))).sort((e,t)=>(e.name||a.providerManifests[e.domain].name).toUpperCase()>(t.name||a.providerManifests[t.domain].name).toUpperCase()?1:-1)),y=async function(){l.value=(await a.getPlayerConfigs()).filter(e=>e.provider!="builtin_player").sort((e,t)=>c(e).localeCompare(c(t)))},B=function(e){a.removePlayer(e).then(()=>{l.value=l.value.filter(t=>t.player_id!=e)})},f=function(e,t){a.getProvider(t)&&u.push(`/settings/editplayer/${e}`)},C=function(e){u.push(`/settings/editplayer/${e}/dsp`)},N=function(e){u.push(`/settings/addgroup/${e.lookup_key}`)},$=function(e){const t=a.players[e];return t?t.type===A.GROUP?t.player_id.startsWith(Q)||a.getProvider(t.provider)?.supported_features.includes(d.REMOVE_GROUP_PLAYER):a.getProvider(t.provider)?.supported_features.includes(d.REMOVE_PLAYER):!0},G=function(e){e.enabled=!e.enabled,a.savePlayerConfig(e.player_id,{enabled:e.enabled})},c=function(e){return e.name||a.players[e.player_id]?.name||e.default_name||e.player_id},O=function(e,t){const s=[{label:"settings.configure",labelArgs:[],action:()=>{f(t.player_id,t.provider)},icon:"mdi-cog",disabled:!a.getProvider(t.provider)},{label:"open_dsp_settings",labelArgs:[],action:()=>{C(t.player_id)},icon:"mdi-equalizer",hide:a.players[t.player_id]?.type===A.GROUP},{label:t.enabled?"settings.disable":"settings.enable",labelArgs:[],action:()=>{G(t)},icon:"mdi-cancel",hide:!a.getProvider(t.provider)},{label:"settings.documentation",labelArgs:[],action:()=>{q(a.getProviderManifest(t.provider)?.documentation||"")},icon:"mdi-bookshelf",disabled:!a.getProviderManifest(t.provider)?.documentation},{label:"settings.delete",labelArgs:[],action:()=>{B(t.player_id)},icon:"mdi-delete",hide:!$(t.player_id)}];H.emit("contextmenu",{items:s,posX:e.clientX,posY:e.clientY})};return z(()=>a.players,e=>{e&&y()},{immediate:!0}),(e,t)=>(r(),_("div",Z,[i(K,{density:"compact",class:"titlebar",color:"transparent",style:{height:"55px"}},{title:n(()=>[k(p(e.$t("settings.players")),1)]),append:n(()=>[v.value.length>0?(r(),o(J,{key:0,scrim:""},{activator:n(({props:s})=>[i(x,X(s,{color:"accent",variant:"outlined"}),{default:n(()=>[k(p(e.$t("settings.add_group_player")),1)]),_:1},16)]),default:n(()=>[i(F,{density:"compact"},{default:n(()=>[(r(!0),_(h,null,E(v.value,s=>(r(),o(j,{key:s.domain,style:{"padding-top":"0","padding-bottom":"0","margin-bottom":"0"},title:s.name,onClick:m=>N(s)},{prepend:n(()=>[i(R,{domain:s.domain,size:26,class:"media-thumb",style:{"margin-left":"10px"}},null,8,["domain"])]),_:2},1032,["title","onClick"]))),128))]),_:1})]),_:1})):g("",!0)]),_:1}),i(U,null,{default:n(()=>[(r(!0),_(h,null,E(l.value,s=>(r(),o(Y,{key:s.player_id,"show-menu-btn":"",link:"",onMenu:m=>O(m,s),onClick:m=>f(s.player_id,s.provider)},{prepend:n(()=>[i(R,{domain:b(a).getProviderManifest(s.provider)?.domain||"",size:40,class:"listitem-media-thumb"},null,8,["domain"])]),title:n(()=>[V("div",ee,p(c(s)),1)]),subtitle:n(()=>[V("div",te,p(b(a).getProviderManifest(s.provider)?.name||s.provider),1)]),append:n(()=>[s.enabled?b(a).players[s.player_id]?.available?g("",!0):(r(),o(P,{key:1,icon:"",title:e.$t("settings.player_not_available")},{default:n(()=>[i(M,{icon:"mdi-timer-sand"})]),_:1},8,["title"])):(r(),o(P,{key:0,icon:"",title:e.$t("settings.player_disabled")},{default:n(()=>[i(M,{icon:"mdi-cancel"})]),_:1},8,["title"]))]),_:2},1032,["onMenu","onClick"]))),128))]),_:1})]))}});export{pe as default};
