import{d as R,aj as T,r as F,b as n,a7 as G,a as I,z as U,P as y,N as j,c as i,g as u,f as r,w as o,Y as P,t as c,e as l,G as z,F as C,h,j as k,u as m,i as V}from"./index-103db515.js";import{_ as M,e as D}from"./eventbus-6e1536e2.js";import{B as w}from"./Button-412f73ce.js";import{L as O}from"./ListItem-91f42136.js";import{C as S}from"./Container-d98651c4.js";import{s as x,V as X,w as A}from"./VListItem-ab7a82e2.js";import{V as W}from"./VCard-d4f085fd.js";import{V as q}from"./VMenu-482e7fbc.js";import{V as H}from"./VToolbar-dcf67568.js";import"./_plugin-vue_export-helper-c27b6911.js";/* empty css              */import"./VCardText-1a59cac1.js";const J={style:{"margin-bottom":"10px"}},K={class:"line-clamp-1"},Q={class:"line-clamp-1"},ue=R({__name:"Players",setup(Z){const _=T(),d=F([]),E=n.subscribe_multi([G.PLAYER_CONFIG_UPDATED],()=>{b()});I(E);const f=U(()=>Object.values(n.providers).filter(e=>e.available&&e.supported_features.includes(y.PLAYER_GROUP_CREATE)||e.supported_features.includes(y.SYNC_PLAYERS)).sort((e,t)=>(e.name||n.providerManifests[e.domain].name).toUpperCase()>(t.name||n.providerManifests[t.domain].name).toUpperCase()?1:-1)),b=async function(){d.value=(await n.getPlayerConfigs()).sort((e,t)=>p(e).localeCompare(p(t)))},N=function(e){n.removePlayerConfig(e),d.value=d.value.filter(t=>t.player_id!=e)},g=function(e){e in n.players&&_.push(`/settings/editplayer/${e}`)},$=function(e){_.push(`/settings/addgroup/${e}`)},B=function(e){e.enabled=!e.enabled,n.savePlayerConfig(e.player_id,{enabled:e.enabled})},p=function(e){var t;return e.name||((t=n.players[e.player_id])==null?void 0:t.display_name)||e.default_name||e.player_id},L=function(e){window.open(e,"_blank")},Y=function(e,t){var s;const a=[{label:"settings.configure",labelArgs:[],action:()=>{g(t.player_id)},icon:"mdi-cog",disabled:!n.getProvider(t.provider)},{label:t.enabled?"settings.disable":"settings.enable",labelArgs:[],action:()=>{B(t)},icon:"mdi-cancel",disabled:!n.getProvider(t.provider)},{label:"settings.documentation",labelArgs:[],action:()=>{var v;L(((v=n.getProviderManifest(t.provider))==null?void 0:v.documentation)||"")},icon:"mdi-bookshelf",disabled:!((s=n.getProviderManifest(t.provider))!=null&&s.documentation)},{label:"settings.delete",labelArgs:[],action:()=>{N(t.player_id)},icon:"mdi-delete"}];D.emit("contextmenu",{items:a,posX:e.clientX,posY:e.clientY})};return j(()=>n.players,e=>{e&&b()},{immediate:!0}),(e,t)=>(i(),u("div",J,[r(H,{density:"compact",class:"titlebar",color:"transparent",style:{height:"55px"}},{title:o(()=>[P(c(e.$t("settings.players")),1)]),append:o(()=>[f.value.length?(i(),l(q,{key:0,scrim:""},{activator:o(({props:a})=>[r(x,z(a,{color:"accent",variant:"outlined"}),{default:o(()=>[P(c(e.$t("settings.add_group_player")),1)]),_:2},1040)]),default:o(()=>[r(W,null,{default:o(()=>[(i(!0),u(C,null,h(f.value,a=>(i(),l(X,{key:a.instance_id,style:{"padding-top":"0","padding-bottom":"0","margin-bottom":"0"},title:a.name,onClick:s=>$(a.instance_id)},{prepend:o(()=>[r(M,{domain:a.domain,size:26,class:"media-thumb",style:{"margin-left":"10px"}},null,8,["domain"])]),_:2},1032,["title","onClick"]))),128))]),_:1})]),_:1})):k("",!0)]),_:1}),r(S,null,{default:o(()=>[(i(!0),u(C,null,h(d.value,a=>(i(),l(O,{key:a.player_id,"show-menu-btn":"",link:"",onMenu:s=>Y(s,a),onClick:s=>g(a.player_id)},{prepend:o(()=>{var s;return[r(M,{domain:((s=m(n).getProviderManifest(a.provider))==null?void 0:s.domain)||"",size:40,class:"listitem-media-thumb"},null,8,["domain"])]}),title:o(()=>[V("div",K,c(p(a)),1)]),subtitle:o(()=>{var s;return[V("div",Q,c(((s=m(n).getProviderManifest(a.provider))==null?void 0:s.name)||a.provider),1)]}),append:o(()=>{var s;return[a.enabled?(s=m(n).players[a.player_id])!=null&&s.available?k("",!0):(i(),l(w,{key:1,icon:"",title:e.$t("settings.player_not_available")},{default:o(()=>[r(A,{icon:"mdi-timer-sand"})]),_:1},8,["title"])):(i(),l(w,{key:0,icon:"",title:e.$t("settings.player_disabled")},{default:o(()=>[r(A,{icon:"mdi-cancel"})]),_:1},8,["title"]))]}),_:2},1032,["onMenu","onClick"]))),128))]),_:1})]))}});export{ue as default};
