import{d as $,an as E,r as L,b as a,a7 as Y,a as F,z as S,P as T,N as I,c as i,g as f,f as r,w as o,Y as g,t as d,e as c,j as v,F as D,h as R,u,i as P}from"./index-5e5d70f8.js";import{_ as j,e as z}from"./eventbus-5e9bd59e.js";import{B as h}from"./Button-558e640e.js";import{L as G}from"./ListItem-f9f543a5.js";import{C as O}from"./Container-39ff39e9.js";import{s as U,w as k}from"./VListItem-a276ed14.js";import{V as X}from"./VToolbar-c09ee689.js";import"./_plugin-vue_export-helper-c27b6911.js";/* empty css              */const x={style:{"margin-bottom":"10px"}},W={class:"line-clamp-1"},q={class:"line-clamp-1"},oe=$({__name:"Players",setup(H){const m=E(),l=L([]),C=a.subscribe_multi([Y.PLAYER_CONFIG_UPDATED],()=>{_()});F(C);const w=S(()=>Object.values(a.players).filter(e=>{var t;return e.available&&e.can_sync_with.length&&((t=a.getProvider(e.provider))==null?void 0:t.supported_features.includes(T.SYNC_PLAYERS))})),_=async function(){l.value=(await a.getPlayerConfigs()).sort((e,t)=>p(e).localeCompare(p(t)))},N=function(e){a.removePlayerConfig(e),l.value=l.value.filter(t=>t.player_id!=e)},b=function(e){e in a.players&&m.push(`/settings/editplayer/${e}`)},B=function(e){m.push("/settings/addsyncgroup")},V=function(e){e.enabled=!e.enabled,a.savePlayerConfig(e.player_id,{enabled:e.enabled})},p=function(e){var t;return e.name||((t=a.players[e.player_id])==null?void 0:t.display_name)||e.default_name||e.player_id},A=function(e){window.open(e,"_blank")},M=function(e,t){var n;const s=[{label:"settings.configure",labelArgs:[],action:()=>{b(t.player_id)},icon:"mdi-cog",disabled:!a.getProvider(t.provider)},{label:t.enabled?"settings.disable":"settings.enable",labelArgs:[],action:()=>{V(t)},icon:"mdi-cancel",disabled:!a.getProvider(t.provider)},{label:"settings.documentation",labelArgs:[],action:()=>{var y;A(((y=a.getProviderManifest(t.provider))==null?void 0:y.documentation)||"")},icon:"mdi-bookshelf",disabled:!((n=a.getProviderManifest(t.provider))!=null&&n.documentation)},{label:"settings.delete",labelArgs:[],action:()=>{N(t.player_id)},icon:"mdi-delete"}];z.emit("contextmenu",{items:s,posX:e.clientX,posY:e.clientY})};return I(()=>a.players,e=>{e&&_()},{immediate:!0}),(e,t)=>(i(),f("div",x,[r(X,{density:"compact",class:"titlebar",color:"transparent",style:{height:"55px"}},{title:o(()=>[g(d(e.$t("settings.players")),1)]),append:o(()=>[w.value.length?(i(),c(U,{key:0,color:"accent",variant:"outlined",onClick:B},{default:o(()=>[g(d(e.$t("settings.add_group_player")),1)]),_:1})):v("",!0)]),_:1}),r(O,null,{default:o(()=>[(i(!0),f(D,null,R(l.value,s=>(i(),c(G,{key:s.player_id,"show-menu-btn":"",link:"",onMenu:n=>M(n,s),onClick:n=>b(s.player_id)},{prepend:o(()=>{var n;return[r(j,{domain:((n=u(a).getProviderManifest(s.provider))==null?void 0:n.domain)||"",size:40,class:"listitem-media-thumb"},null,8,["domain"])]}),title:o(()=>[P("div",W,d(p(s)),1)]),subtitle:o(()=>{var n;return[P("div",q,d(((n=u(a).getProviderManifest(s.provider))==null?void 0:n.name)||s.provider),1)]}),append:o(()=>{var n;return[s.enabled?(n=u(a).players[s.player_id])!=null&&n.available?v("",!0):(i(),c(h,{key:1,icon:"",title:e.$t("settings.player_not_available")},{default:o(()=>[r(k,{icon:"mdi-timer-sand"})]),_:1},8,["title"])):(i(),c(h,{key:0,icon:"",title:e.$t("settings.player_disabled")},{default:o(()=>[r(k,{icon:"mdi-cancel"})]),_:1},8,["title"]))]}),_:2},1032,["onMenu","onClick"]))),128))]),_:1})]))}});export{oe as default};
