import{C as I}from"./Container-Doq3id7C.js";import{Q as b,c as k,a4 as _,be as V,ax as h,ag as P,Z as u,S as i,as as U,B as d,U as l,a9 as f,W as S,ab as $,an as B,G as w,$ as C,R as c,a2 as E,x as g,o as N,aU as W,b as A,a8 as D,b2 as T,bl as x}from"./index-NjNzsJZz.js";import{_ as H,W as L}from"./WidgetRow-BD6xMOLH.js";import{a as O}from"./PlayerCard-BvenMfNl.js";import{V as G}from"./VToolbar-foJ2MHub.js";import{a as J,b as Y}from"./VBtn-BMSa1vvR.js";import{_ as M}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{T as j}from"./Toolbar-BII0TB9u.js";import"./VContainer-8K-4ZDub.js";/* empty css              */import"./PanelviewItemCompact-DOGh0j6m.js";import"./MediaItemThumb-Et_an17N.js";import"./VCheckbox-CXmjKPs1.js";import"./VCheckboxBtn-xSdu6NP7.js";import"./VAlert-CTswA5gy.js";import"./Button-C4q1f0oo.js";import"./VSlider-C-UASzEy.js";const z={class:"mr-3"},F={key:0},Q=b({__name:"PlayersWidgetRow",props:{settings:{},editMode:{type:Boolean}},emits:["update:settings"],setup(y,{emit:r}){const a=k(()=>Object.values(_.players).filter(e=>V(e)).sort((e,o)=>{var t;return e.display_name.toUpperCase()>((t=o.display_name)==null?void 0:t.toUpperCase())?1:-1}).sort((e,o)=>n(e)-n(o))),m=r;function p(e){E.activePlayerId=e.player_id}function n(e){return e.state==h.PLAYING?0:e.state==h.PAUSED?1:e.current_media&&e.powered?3:e.current_media?4:99}return(e,o)=>{const t=P("swiper-slide");return i(),u("div",{class:U(`widget-row ${e.settings&&!e.settings.enabled?"disabled":""}`)},[d(G,{class:"header",color:"transparent"},{prepend:l(()=>[d(B,{icon:"mdi-speaker"})]),title:l(()=>[S("span",z,$(e.$t("players")),1)]),append:l(()=>[e.editMode?(i(),u("div",F,[d(J,{icon:e.settings.enabled?"mdi-checkbox-marked":"mdi-checkbox-blank-outline",onClick:o[0]||(o[0]=s=>m("update:settings",{...e.settings,enabled:!e.settings.enabled}))},null,8,["icon"])])):f("",!0)]),_:1}),d(H,null,{default:l(()=>[(i(!0),u(w,null,C(a.value,s=>(i(),c(t,{key:s.player_id,style:{width:"350px","min-width":"350px","margin-right":"0px"}},{default:l(()=>[(i(),c(O,{id:s.player_id,key:s.player_id,player:s,"show-volume-control":!1,"show-menu-button":!1,"show-sub-players":!1,"show-sync-controls":!1,style:{width:"315px",height:"70px"},onClick:v=>p(s)},null,8,["id","player","onClick"]))]),_:2},1024))),128))]),_:1})],2)}}}),Z=M(Q,[["__scopeId","data-v-5784ea28"]]),q=b({__name:"HomeWidgetRows",props:{editMode:{type:Boolean,default:!1}},setup(y){const r=g([]),a=g({}),m=async function(){const n=localStorage.getItem("widgetRowSettings");a.value=n?JSON.parse(n):{players:{position:0,enabled:!0}};const e=await _.getRecommendations(),o=[];let t=0;for(const s of e){t++;const v=a.value[s.uri]||{position:t,enabled:!0},R=s.translation_key?D(`recommendations.${s.translation_key}`,s.name):s.name;o.push({...s,settings:v,title:R}),r.value=o}};N(()=>{m();const n=_.subscribe(W.MEDIA_ITEM_PLAYED,async e=>{e.data&&!e.data.is_playing&&m()});A(n)});const p=function(n,e){for(const o of r.value)if(o.uri===n){o.settings=e;break}a.value[n]=e,localStorage.setItem("widgetRowSettings",JSON.stringify(a.value))};return(n,e)=>{var o;return i(),u(w,null,[(o=a.value.players)!=null&&o.enabled||n.editMode?(i(),c(Z,{key:0,settings:a.value.players,"edit-mode":n.editMode,"onUpdate:settings":e[0]||(e[0]=t=>p("players",t))},null,8,["settings","edit-mode"])):f("",!0),(i(!0),u(w,null,C(r.value.filter(t=>t.items.length&&(t.settings.enabled||n.editMode)).sort((t,s)=>t.settings.position-s.settings.position),t=>(i(),u("div",{key:t.uri},[r.value.length?(i(),c(L,{key:0,"widget-row":t,"edit-mode":n.editMode,"onUpdate:settings":s=>p(t.uri,s)},null,8,["widget-row","edit-mode","onUpdate:settings"])):f("",!0)]))),128))],64)}}}),K=b({__name:"HomeView",setup(y){const r=g(localStorage.getItem("frontend.settings.hide_settings")=="true"),a=g(!1),m=k(()=>[{label:"settings.settings",icon:"mdi-cog-outline",action:()=>{T.push({path:"settings"})},hide:r.value},{label:a.value?"homescreen_edit_disable":"homescreen_edit_enable",icon:"mdi-pencil",action:()=>{a.value=!a.value}}]);return(p,n)=>(i(),u("div",null,[d(j,{title:"Music Assistant","show-loading":!0,"enforce-overflow-menu":!0,"menu-items":m.value},null,8,["menu-items"]),d(I,{variant:"panel"},{default:l(()=>[(i(),c(x,null,{fallback:l(()=>[d(Y,{indeterminate:""})]),default:l(()=>[S("div",null,[d(q,{"edit-mode":a.value},null,8,["edit-mode"])])]),_:1}))]),_:1})]))}}),fe=M(K,[["__scopeId","data-v-56b2bcc6"]]);export{fe as default};
