import{B as g}from"./Button-SUce42c3.js";import{C}from"./Container-CuH2YNr5.js";import{L as G}from"./ListItem-DhvO1M3C.js";import{d as T,i as w,m as a,a_ as I,l as D,N as F,P as d,ad as S,c as _,o as r,b as i,w as s,e as o,q as P,n as z,F as h,r as k,V as q,v as E,aA as x,b4 as V,t as p,aW as W,g as A,u as b,a as R,bJ as X,bf as M,ce as j,k as J}from"./index-LFx1jIjH.js";import{V as H}from"./VToolbar-Dc2WDt1C.js";import{a as K}from"./VBtn-BYKkZzw0.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";import"./VContainer-or1Uze2V.js";/* empty css              */const Q={style:{"margin-bottom":"10px"}},Z={class:"line-clamp-1"},ee={class:"line-clamp-1"},ue=T({__name:"Players",setup(te){const u=X(),l=w([]),L=a.subscribe_multi([I.PLAYER_CONFIG_UPDATED],()=>{y()});D(L);const v=F(()=>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)))},$=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}`)},B=function(e){u.push(`/settings/editplayer/${e}/dsp`)},N=function(e){u.push(`/settings/addgroup/${e.lookup_key}`)},O=function(e){const t=a.players[e];return t?t.type===M.GROUP?a.getProvider(t.provider)?.supported_features.includes(d.REMOVE_GROUP_PLAYER):a.getProvider(t.provider)?.supported_features.includes(d.REMOVE_PLAYER):!0},U=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},Y=function(e,t){const n=[{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:()=>{B(t.player_id)},icon:"mdi-equalizer",hide:a.players[t.player_id]?.type===M.GROUP},{label:t.enabled?"settings.disable":"settings.enable",labelArgs:[],action:()=>{U(t)},icon:"mdi-cancel",hide:!a.getProvider(t.provider)},{label:"settings.documentation",labelArgs:[],action:()=>{j(a.getProviderManifest(t.provider)?.documentation||"")},icon:"mdi-bookshelf",disabled:!a.getProviderManifest(t.provider)?.documentation},{label:"settings.delete",labelArgs:[],action:()=>{$(t.player_id)},icon:"mdi-delete",hide:!O(t.player_id)}];J.emit("contextmenu",{items:n,posX:e.clientX,posY:e.clientY})};return S(()=>a.players,e=>{e&&y()},{immediate:!0}),(e,t)=>(r(),_("div",Q,[i(H,{density:"compact",class:"titlebar",color:"transparent",style:{height:"55px"}},{title:s(()=>[V(p(e.$t("settings.players")),1)]),append:s(()=>[v.value.length>0?(r(),o(W,{key:0,scrim:""},{activator:s(({props:n})=>[i(K,x(n,{color:"accent",variant:"outlined"}),{default:s(()=>[V(p(e.$t("settings.add_group_player")),1)]),_:1},16)]),default:s(()=>[i(z,{density:"compact"},{default:s(()=>[(r(!0),_(h,null,k(v.value,n=>(r(),o(q,{key:n.domain,style:{"padding-top":"0","padding-bottom":"0","margin-bottom":"0"},title:n.name,onClick:m=>N(n)},{prepend:s(()=>[i(E,{domain:n.domain,size:26,class:"media-thumb",style:{"margin-left":"10px"}},null,8,["domain"])]),_:2},1032,["title","onClick"]))),128))]),_:1})]),_:1})):P("",!0)]),_:1}),i(C,null,{default:s(()=>[(r(!0),_(h,null,k(l.value,n=>(r(),o(G,{key:n.player_id,"show-menu-btn":"",link:"",onMenu:m=>Y(m,n),onClick:m=>f(n.player_id,n.provider)},{prepend:s(()=>[i(E,{domain:b(a).getProviderManifest(n.provider)?.domain||"",size:40,class:"listitem-media-thumb"},null,8,["domain"])]),title:s(()=>[R("div",Z,p(c(n)),1)]),subtitle:s(()=>[R("div",ee,p(b(a).getProviderManifest(n.provider)?.name||n.provider),1)]),append:s(()=>[n.enabled?b(a).players[n.player_id]?.available?P("",!0):(r(),o(g,{key:1,icon:"",title:e.$t("settings.player_not_available")},{default:s(()=>[i(A,{icon:"mdi-timer-sand"})]),_:1},8,["title"])):(r(),o(g,{key:0,icon:"",title:e.$t("settings.player_disabled")},{default:s(()=>[i(A,{icon:"mdi-cancel"})]),_:1},8,["title"]))]),_:2},1032,["onMenu","onClick"]))),128))]),_:1})]))}});export{ue as default};
