import{C as I}from"./Container-CEsuepd5.js";import{Q as v,c as C,a4 as _,be as B,ax as k,ag as S,Z as p,S as i,as as P,B as u,U as d,a9 as w,W as M,ab as U,an as $,a0 as E,am as A,G as b,$ as R,R as g,a2 as N,x as f,o as T,aU as W,b as D,a8 as O,b2 as H,bl as L}from"./index-CjKqSS7W.js";import{W as G}from"./WidgetRow-jUUvGwj9.js";import{a as J}from"./PlayerCard-DaG8yKi5.js";import{V as Y}from"./VToolbar-CtTowi2z.js";import{a as j,b as x}from"./VBtn-CIAN6k9R.js";import{_ as V}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{T as z}from"./Toolbar-kbNl1QNN.js";import"./VContainer-Cjucexo-.js";/* empty css              */import"./PanelviewItemCompact-BmWmXS-a.js";import"./MediaItemThumb-Bya9ATIE.js";import"./VCheckbox-CtuLMwoL.js";import"./VCheckboxBtn-Yw1fo7EH.js";import"./VAlert-uW_UuQw8.js";import"./Button-DRhzEmCu.js";import"./VSlider-B9z5HH84.js";const F={class:"mr-3"},Q={key:0},Z=v({__name:"PlayersWidgetRow",props:{settings:{},editMode:{type:Boolean}},emits:["update:settings"],setup(y,{emit:r}){const n=C(()=>Object.values(_.players).filter(e=>B(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)=>s(e)-s(o))),m=r;function c(e){N.activePlayerId=e.player_id}function s(e){return e.state==k.PLAYING?0:e.state==k.PAUSED?1:e.current_media&&e.powered?3:e.current_media?4:99}return(e,o)=>{const t=S("swiper-slide"),a=S("swiper");return i(),p("div",{class:P(`widget-row ${e.settings&&!e.settings.enabled?"disabled":""}`)},[u(Y,{class:"header",color:"transparent"},{prepend:d(()=>[u($,{icon:"mdi-speaker"})]),title:d(()=>[M("span",F,U(e.$t("players")),1)]),append:d(()=>[e.editMode?(i(),p("div",Q,[u(j,{icon:e.settings.enabled?"mdi-checkbox-marked":"mdi-checkbox-blank-outline",onClick:o[0]||(o[0]=l=>m("update:settings",{...e.settings,enabled:!e.settings.enabled}))},null,8,["icon"])])):w("",!0)]),_:1}),u(a,{"slides-per-view":e.$vuetify.display.width/340,"space-between":15,"free-mode":!1,navigation:!E(A)({breakpoint:"mobile"}),mousewheel:{forceToAxis:!0,releaseOnEdges:!0}},{default:d(()=>[(i(!0),p(b,null,R(n.value,l=>(i(),g(t,{key:l.player_id},{default:d(()=>[(i(),g(J,{id:l.player_id,key:l.player_id,player:l,"show-volume-control":!1,"show-menu-button":!1,"show-sub-players":!1,"show-sync-controls":!1,style:{width:"305px",height:"70px"},onClick:h=>c(l)},null,8,["id","player","onClick"]))]),_:2},1024))),128))]),_:1},8,["slides-per-view","navigation"])],2)}}}),q=V(Z,[["__scopeId","data-v-167556df"]]),K=v({__name:"HomeWidgetRows",props:{editMode:{type:Boolean,default:!1}},setup(y){const r=f([]),n=f({}),m=async function(){const s=localStorage.getItem("widgetRowSettings");n.value=s?JSON.parse(s):{players:{position:0,enabled:!0}};const e=await _.getRecommendations(),o=[];let t=0;for(const a of e){t++;const l=n.value[a.uri]||{position:t,enabled:!0},h=a.translation_key?O(`recommendations.${a.translation_key}`,a.name):a.name;o.push({...a,settings:l,title:h}),r.value=o}};T(()=>{m();const s=_.subscribe(W.MEDIA_ITEM_PLAYED,async e=>{e.data&&!e.data.is_playing&&m()});D(s)});const c=function(s,e){for(const o of r.value)if(o.uri===s){o.settings=e;break}n.value[s]=e,localStorage.setItem("widgetRowSettings",JSON.stringify(n.value))};return(s,e)=>{var o;return i(),p(b,null,[(o=n.value.players)!=null&&o.enabled||s.editMode?(i(),g(q,{key:0,settings:n.value.players,"edit-mode":s.editMode,"onUpdate:settings":e[0]||(e[0]=t=>c("players",t))},null,8,["settings","edit-mode"])):w("",!0),(i(!0),p(b,null,R(r.value.filter(t=>t.items.length&&(t.settings.enabled||s.editMode)).sort((t,a)=>t.settings.position-a.settings.position),t=>(i(),p("div",{key:t.uri},[r.value.length?(i(),g(G,{key:0,"widget-row":t,"edit-mode":s.editMode,"onUpdate:settings":a=>c(t.uri,a)},null,8,["widget-row","edit-mode","onUpdate:settings"])):w("",!0)]))),128))],64)}}}),X=v({__name:"HomeView",setup(y){const r=f(localStorage.getItem("frontend.settings.hide_settings")=="true"),n=f(!1),m=C(()=>[{label:"settings.settings",icon:"mdi-cog-outline",action:()=>{H.push({path:"settings"})},hide:r.value},{label:n.value?"homescreen_edit_disable":"homescreen_edit_enable",icon:"mdi-pencil",action:()=>{n.value=!n.value}}]);return(c,s)=>(i(),p("div",null,[u(z,{title:"Music Assistant","show-loading":!0,"enforce-overflow-menu":!0,"menu-items":m.value},null,8,["menu-items"]),u(I,{variant:"panel"},{default:d(()=>[(i(),g(L,null,{fallback:d(()=>[u(x,{indeterminate:""})]),default:d(()=>[M("div",null,[u(K,{"edit-mode":n.value},null,8,["edit-mode"])])]),_:1}))]),_:1})]))}}),we=V(X,[["__scopeId","data-v-56b2bcc6"]]);export{we as default};
