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