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