import{C as P}from"./Container-CuH2YNr5.js";import{d as v,N as S,m as g,bj as B,aV as h,L as C,c as m,o,E as I,b as d,w as u,q as _,a as M,t as $,F as w,r as R,e as f,s as E,i as b,j as U,a_ as N,l as T,$ as A,bq as D}from"./index-LFx1jIjH.js";import{W}from"./WidgetRow-DQvw9AsK.js";import{a as L}from"./PlayerCard-CDAKLvCC.js";import{V as O}from"./VToolbar-Dc2WDt1C.js";import{a as j,b as H}from"./VBtn-BYKkZzw0.js";import{_ as V}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{T as q}from"./Toolbar-iQxHKI_C.js";import"./Button-SUce42c3.js";import"./VContainer-or1Uze2V.js";/* empty css              */import"./PanelviewItemCompact-Bf82DAtE.js";import"./NowPlayingBadge.vue_vue_type_style_index_0_lang-B4veTxLS.js";import"./VInput-B3Z2GK8Z.js";import"./MediaItemThumb-cYqdWFcl.js";import"./VAlert-Cyb25ra3.js";import"./VSlider-B0DY4XNd.js";const F={class:"mr-3"},J={key:0},Y=v({__name:"PlayersWidgetRow",props:{settings:{},editMode:{type:Boolean}},emits:["update:settings"],setup(y,{emit:a}){const n=S(()=>Object.values(g.players).filter(e=>B(e)).sort((e,t)=>e.name.toUpperCase()>t.name?.toUpperCase()?1:-1).sort((e,t)=>s(e)-s(t))),c=a;function p(e){E.activePlayerId=e.player_id}function s(e){return e.playback_state==h.PLAYING?0:e.playback_state==h.PAUSED?1:e.current_media&&e.powered?3:e.current_media?4:99}return(e,t)=>{const i=C("swiper-slide"),r=C("swiper");return o(),m("div",{class:I(`widget-row ${e.settings&&!e.settings.enabled?"disabled":""}`)},[d(O,{class:"header",color:"transparent"},{title:u(()=>[M("span",F,$(e.$t("players")),1)]),append:u(()=>[e.editMode?(o(),m("div",J,[d(j,{icon:e.settings.enabled?"mdi-checkbox-marked":"mdi-checkbox-blank-outline",onClick:t[0]||(t[0]=l=>c("update:settings",{...e.settings,enabled:!e.settings.enabled}))},null,8,["icon"])])):_("",!0)]),_:1}),d(r,{"slides-per-view":"auto","space-between":15,"free-mode":!1,navigation:!1,mousewheel:{forceToAxis:!0,releaseOnEdges:!0}},{default:u(()=>[(o(!0),m(w,null,R(n.value,l=>(o(),f(i,{key:l.player_id},{default:u(()=>[(o(),f(L,{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"},onClick:k=>p(l)},null,8,["id","player","onClick"]))]),_:2},1024))),128))]),_:1})],2)}}}),z=V(Y,[["__scopeId","data-v-771a3548"]]),G=v({__name:"HomeWidgetRows",props:{editMode:{type:Boolean,default:!1}},setup(y){const a=b([]),n=b({}),c=async function(){const s=localStorage.getItem("widgetRowSettings");n.value=s?JSON.parse(s):{players:{position:0,enabled:!0}};const e=await g.getRecommendations(),t=[];let i=0;for(const r of e){i++;const l=n.value[r.uri]||{position:i,enabled:!0},k=r.translation_key?A(`recommendations.${r.translation_key}`,r.name):r.name;t.push({...r,settings:l,title:k}),a.value=t}};U(()=>{c();const s=g.subscribe(N.MEDIA_ITEM_PLAYED,async e=>{e.data&&!e.data.is_playing&&c()});T(s)});const p=function(s,e){for(const t of a.value)if(t.uri===s){t.settings=e;break}n.value[s]=e,localStorage.setItem("widgetRowSettings",JSON.stringify(n.value))};return(s,e)=>(o(),m(w,null,[n.value.players?.enabled||s.editMode?(o(),f(z,{key:0,settings:n.value.players,"edit-mode":s.editMode,"onUpdate:settings":e[0]||(e[0]=t=>p("players",t))},null,8,["settings","edit-mode"])):_("",!0),(o(!0),m(w,null,R(a.value.filter(t=>t.items.length&&(t.settings.enabled||s.editMode)).sort((t,i)=>t.settings.position-i.settings.position),t=>(o(),m("div",{key:t.uri},[a.value.length?(o(),f(W,{key:0,"widget-row":t,"edit-mode":s.editMode,"onUpdate:settings":i=>p(t.uri,i)},null,8,["widget-row","edit-mode","onUpdate:settings"])):_("",!0)]))),128))],64))}}),K=v({__name:"HomeView",setup(y){const a=b(!1),n=S(()=>[{label:a.value?"homescreen_edit_disable":"homescreen_edit_enable",icon:"mdi-pencil",action:()=>{a.value=!a.value}}]);return(c,p)=>(o(),m("div",null,[d(q,{"show-loading":!0,"enforce-overflow-menu":!0,"menu-items":n.value,home:!0,color:"background",class:"editButton"},null,8,["menu-items"]),d(P,{variant:"comfortable"},{default:u(()=>[(o(),f(D,null,{fallback:u(()=>[d(H,{indeterminate:""})]),default:u(()=>[M("div",null,[d(G,{"edit-mode":a.value},null,8,["edit-mode"])])]),_:1}))]),_:1})]))}}),pe=V(K,[["__scopeId","data-v-d7f1cb62"]]);export{pe as default};
