import{B as P}from"./Button-BMZw2h0c.js";import{C as Y}from"./Container-DVHdDHGo.js";import{L as C}from"./ListItem-CZP-Ank1.js";import{ay as I,J as S,aP as a,bb as T,a4 as D,i as w,aR as d,L as z,az as _,aA as r,o as i,aG as n,aI as o,aB as g,aS as F,ah as h,aH as E,M as X,ae as x,bh as k,aN as p,b4 as J,aE as W,aJ as j,aV as R,aL as A,aD as b,E as V,br as M,cA as q,aO as H}from"./index-It2prjj_.js";import{S as K}from"./constants-CXMxJR4j.js";import{V as Q}from"./VToolbar-d3S4vzQ8.js";import"./index-kQIztB-E.js";const Z={style:{"margin-bottom":"10px"}},ee={class:"line-clamp-1"},te={class:"line-clamp-1"},pe=I({__name:"Players",setup(ae){const u=W(),l=S([]),L=a.subscribe_multi([T.PLAYER_CONFIG_UPDATED],()=>{y()});D(L);const v=w(()=>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}`)},N=function(e){u.push(`/settings/editplayer/${e}/dsp`)},O=function(e){u.push(`/settings/addgroup/${e.lookup_key}`)},$=function(e){const t=a.players[e];return t?t.type===M.GROUP?t.player_id.startsWith(K)||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},U=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:()=>{N(t.player_id)},icon:"mdi-equalizer",hide:a.players[t.player_id]?.type===M.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(Q,{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=>O(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(Y,null,{default:n(()=>[(r(!0),_(h,null,E(l.value,s=>(r(),o(C,{key:s.player_id,"show-menu-btn":"",link:"",onMenu:m=>U(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(A,{icon:"mdi-timer-sand"})]),_:1},8,["title"])):(r(),o(P,{key:0,icon:"",title:e.$t("settings.player_disabled")},{default:n(()=>[i(A,{icon:"mdi-cancel"})]),_:1},8,["title"]))]),_:2},1032,["onMenu","onClick"]))),128))]),_:1})]))}});export{pe as default};
