import{C as M}from"./Container-Ps6BlEWu.js";import{Q as v,c as V,a4 as w,be as R,ax as h,ag as S,Z as p,S as i,as as I,B as u,U as d,a9 as _,W as B,ab as U,an as $,a0 as E,am as A,G as b,$ as C,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-Bduq4vJM.js";import{W as x}from"./WidgetRow-Dh5C0NEV.js";import{a as G}from"./PlayerCard-B7OAdn7z.js";import{V as J}from"./VToolbar-CG7bivmQ.js";import{a as Y,b as j}from"./VBtn-DWiYTBpb.js";import{_ as P}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{T as z}from"./Toolbar-MtNZFNYL.js";import"./VContainer-BVUS8uFb.js";/* empty css              */import"./PanelviewItemCompact-C9loINH4.js";import"./MediaItemThumb-CN4TRL8T.js";import"./VCheckbox-BiGeI08h.js";import"./VCheckboxBtn-DLibXb0-.js";import"./VAlert-BjDi0iTj.js";import"./Button-DDaesvMx.js";import"./VSlider-ZsJroA_b.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 a=V(()=>Object.values(w.players).filter(e=>R(e)).sort((e,n)=>{var t;return e.display_name.toUpperCase()>((t=n.display_name)==null?void 0:t.toUpperCase())?1:-1}).sort((e,n)=>s(e)-s(n))),m=r;function c(e){N.activePlayerId=e.player_id}function s(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,n)=>{const t=S("swiper-slide"),o=S("swiper");return i(),p("div",{class:I(`widget-row ${e.settings&&!e.settings.enabled?"disabled":""}`)},[u(J,{class:"header",color:"transparent"},{prepend:d(()=>[u($,{icon:"mdi-speaker"})]),title:d(()=>[B("span",F,U(e.$t("players")),1)]),append:d(()=>[e.editMode?(i(),p("div",Q,[u(Y,{icon:e.settings.enabled?"mdi-checkbox-marked":"mdi-checkbox-blank-outline",onClick:n[0]||(n[0]=l=>m("update:settings",{...e.settings,enabled:!e.settings.enabled}))},null,8,["icon"])])):_("",!0)]),_:1}),u(o,{"slides-per-view":1.1,"space-between":10,"free-mode":!1,navigation:!E(A)({breakpoint:"mobile"}),mousewheel:{forceToAxis:!0,releaseOnEdges:!0},breakpoints:{320:{slidesPerView:1.1,spaceBetween:15},480:{slidesPerView:1.8,spaceBetween:15},640:{slidesPerView:2.1,spaceBetween:15},960:{slidesPerView:3.1,spaceBetween:15},1280:{slidesPerView:4.1,spaceBetween:15}}},{default:d(()=>[(i(!0),p(b,null,C(a.value,l=>(i(),g(t,{key:l.player_id},{default:d(()=>[(i(),g(G,{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:"315px",height:"70px"},onClick:k=>c(l)},null,8,["id","player","onClick"]))]),_:2},1024))),128))]),_:1},8,["navigation"])],2)}}}),q=P(Z,[["__scopeId","data-v-d371030e"]]),K=v({__name:"HomeWidgetRows",props:{editMode:{type:Boolean,default:!1}},setup(y){const r=f([]),a=f({}),m=async function(){const s=localStorage.getItem("widgetRowSettings");a.value=s?JSON.parse(s):{players:{position:0,enabled:!0}};const e=await w.getRecommendations(),n=[];let t=0;for(const o of e){t++;const l=a.value[o.uri]||{position:t,enabled:!0},k=o.translation_key?O(`recommendations.${o.translation_key}`,o.name):o.name;n.push({...o,settings:l,title:k}),r.value=n}};T(()=>{m();const s=w.subscribe(W.MEDIA_ITEM_PLAYED,async e=>{e.data&&!e.data.is_playing&&m()});D(s)});const c=function(s,e){for(const n of r.value)if(n.uri===s){n.settings=e;break}a.value[s]=e,localStorage.setItem("widgetRowSettings",JSON.stringify(a.value))};return(s,e)=>{var n;return i(),p(b,null,[(n=a.value.players)!=null&&n.enabled||s.editMode?(i(),g(q,{key:0,settings:a.value.players,"edit-mode":s.editMode,"onUpdate:settings":e[0]||(e[0]=t=>c("players",t))},null,8,["settings","edit-mode"])):_("",!0),(i(!0),p(b,null,C(r.value.filter(t=>t.items.length&&(t.settings.enabled||s.editMode)).sort((t,o)=>t.settings.position-o.settings.position),t=>(i(),p("div",{key:t.uri},[r.value.length?(i(),g(x,{key:0,"widget-row":t,"edit-mode":s.editMode,"onUpdate:settings":o=>c(t.uri,o)},null,8,["widget-row","edit-mode","onUpdate:settings"])):_("",!0)]))),128))],64)}}}),X=v({__name:"HomeView",setup(y){const r=f(localStorage.getItem("frontend.settings.hide_settings")=="true"),a=f(!1),m=V(()=>[{label:"settings.settings",icon:"mdi-cog-outline",action:()=>{H.push({path:"settings"})},hide:r.value},{label:a.value?"homescreen_edit_disable":"homescreen_edit_enable",icon:"mdi-pencil",action:()=>{a.value=!a.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(M,{variant:"panel"},{default:d(()=>[(i(),g(L,null,{fallback:d(()=>[u(j,{indeterminate:""})]),default:d(()=>[B("div",null,[u(K,{"edit-mode":a.value},null,8,["edit-mode"])])]),_:1}))]),_:1})]))}}),_e=P(X,[["__scopeId","data-v-56b2bcc6"]]);export{_e as default};
