import{d as D,a1 as F,r as U,b as a,ah as G,a as I,l as Y,P as v,I as x,a5 as O,c as o,h as f,f as r,w as n,m as h,t as p,e as l,E as S,F as P,i as C,j as k,a6 as j,u as d,g as V}from"./index-0ae84607.js";import{C as z,L as E,_ as A}from"./Container-eb92362b.js";import{B as $}from"./Button-a1dfd3f5.js";import{V as W,b as w}from"./forwardRefs-d0d7c5bd.js";import{V as q}from"./VCard-e96ab32b.js";import{c as H}from"./VMenu-f26d3a19.js";import{V as J}from"./VToolbar-b7dd8339.js";/* empty css              */import"./VCardText-b1a0de89.js";const K={style:{"margin-bottom":"10px"}},Q={class:"line-clamp-1"},X={class:"line-clamp-1"},de=D({__name:"Players",setup(Z){const y=F(),c=U([]),B=a.subscribe_multi([G.PLAYER_CONFIG_UPDATED],()=>{g()});I(B);const b=Y(()=>Object.values(a.providers).filter(e=>e.available&&e.supported_features.includes(v.PLAYER_GROUP_CREATE)||e.supported_features.includes(v.SYNC_PLAYERS)).sort((e,i)=>(e.name||a.providerManifests[e.domain].name).toUpperCase()>(i.name||a.providerManifests[i.domain].name).toUpperCase()?1:-1)),g=async function(){c.value=(await a.getPlayerConfigs()).sort((e,i)=>m(e).localeCompare(m(i)))},N=function(e){a.removePlayerConfig(e),c.value=c.value.filter(i=>i.player_id!=e)},u=function(e){e in a.players&&y.push(`/settings/editplayer/${e}`)},L=function(e){y.push(`/settings/addgroup/${e}`)},M=function(e){e.enabled=!e.enabled,a.savePlayerConfig(e.player_id,{enabled:e.enabled})},m=function(e){var i;return e.name||((i=a.players[e.player_id])==null?void 0:i.display_name)||e.default_name||e.player_id},R=function(e){window.open(e,"_blank")};return x(()=>a.players,e=>{e&&g()},{immediate:!0}),(e,i)=>{const T=O("hold");return o(),f("div",K,[r(J,{density:"compact",class:"titlebar",color:"transparent",style:{height:"55px"}},{title:n(()=>[h(p(e.$t("settings.players")),1)]),append:n(()=>[b.value.length?(o(),l(H,{key:0},{activator:n(({props:t})=>[r(W,S(t,{color:"accent",variant:"outlined"}),{default:n(()=>[h(p(e.$t("settings.add_group_player")),1)]),_:2},1040)]),default:n(()=>[r(q,{density:"compact"},{default:n(()=>[(o(!0),f(P,null,C(b.value,t=>(o(),l(E,{key:t.instance_id,density:"compact",style:{"padding-top":"0","padding-bottom":"0","margin-bottom":"0"},title:t.name,onClick:_=>L(t.instance_id)},{prepend:n(()=>[r(A,{domain:t.domain,size:26,class:"media-thumb",style:{"margin-left":"10px"}},null,8,["domain"])]),_:2},1032,["title","onClick"]))),128))]),_:1})]),_:1})):k("",!0)]),_:1}),r(z,null,{default:n(()=>[(o(!0),f(P,null,C(c.value,t=>{var _;return j((o(),l(E,{key:t.player_id,link:"","context-menu-items":[{label:"settings.configure",labelArgs:[],action:()=>{u(t.player_id)},icon:"mdi-cog"},{label:t.enabled?"settings.disable":"settings.enable",labelArgs:[],action:()=>{M(t)},icon:"mdi-cancel"},{label:"settings.documentation",labelArgs:[],action:()=>{var s;R((s=d(a).getProviderManifest(t.provider))==null?void 0:s.documentation)},icon:"mdi-bookshelf",disabled:!((_=d(a).getProviderManifest(t.provider))!=null&&_.documentation)},{label:"settings.delete",labelArgs:[],action:()=>{N(t.player_id)},icon:"mdi-delete"}],onClick:s=>u(t.player_id)},{prepend:n(()=>{var s;return[r(A,{domain:(s=d(a).getProviderManifest(t.provider))==null?void 0:s.domain,size:40,class:"listitem-media-thumb"},null,8,["domain"])]}),title:n(()=>[V("div",Q,p(m(t)),1)]),subtitle:n(()=>{var s;return[V("div",X,p(((s=d(a).getProviderManifest(t.provider))==null?void 0:s.name)||t.provider),1)]}),append:n(()=>{var s;return[t.enabled?(s=d(a).players[t.player_id])!=null&&s.available?k("",!0):(o(),l($,{key:1,icon:"",title:e.$t("settings.player_not_available")},{default:n(()=>[r(w,{icon:"mdi-timer-sand"})]),_:1},8,["title"])):(o(),l($,{key:0,icon:"",title:e.$t("settings.player_disabled")},{default:n(()=>[r(w,{icon:"mdi-cancel"})]),_:1},8,["title"]))]}),_:2},1032,["context-menu-items","onClick"])),[[T,()=>{u(t.player_id)}]])}),128))]),_:1})])}}});export{de as default};
