import{M as J,a as P,ab as ae,N as H,w as oe,r as S,k as b,L as U,ac as ge,ad as ie,ae as ke,af as be,ag as we,ah as Ce,ai as $e,aj as Se,d as x,u as z,ak as re,o as s,P as R,E as V,g as ce,U as G,i as o,t as d,h as t,e as i,_ as A,al as Q,am as Te,z as K,F as L,G as N,q as $,D as le,f as T,an as de,ao as ue,a4 as he,O as _e,ap as me,a8 as Ee,aq as ee,ar as De,a7 as Re,as as Me,c as Le,X as Ne,at as xe,au as ze,s as Ae,av as Ie,aw as Ve}from"./index-D92x6h1h.js";import{u as Pe}from"./useStaleDataRecovery-BuNK-94T.js";import{c as He}from"./setupGreeting-89tMXdwS.js";import{u as ve}from"./dvrEntries-CyzR5N-9.js";import{u as pe}from"./useBulkAction-UV8yZtrd.js";import{C as Oe}from"./circle-x-MT_qQnVa.js";import{s as te,l as Be,f as fe}from"./localDay-CoEbUe3O.js";import{P as Fe}from"./PlayCell-Bqj044wg.js";import{u as Ue}from"./status-CE0GKX14.js";import{C as ye}from"./circle-check-DOOMuisf.js";import{R as Ge}from"./radio-tower-CpGu9kPC.js";import{S as We}from"./SearchInput-DBHWpJgW.js";import{a as qe}from"./EpgEventDrawer-B9_gYZmG.js";import"./play-DDT_Ndp2.js";import"./ActionMenu-B3aKIJFu.js";import"./index-BG9mM10J.js";import"./index-7HNOjfAo.js";import"./circle-dot-BCp4dfsV.js";import"./useResizableDrawerWidth-BORt6i7d.js";/**
 * @license lucide-vue-next v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const je=J("CalendarClockIcon",[["path",{d:"M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5",key:"1osxxc"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M3 10h5",key:"r794hk"}],["path",{d:"M17.5 17.5 16 16.3V14",key:"akvzfd"}],["circle",{cx:"16",cy:"16",r:"6",key:"qoo3c4"}]]);/**
 * @license lucide-vue-next v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ye=J("CommandIcon",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]);/**
 * @license lucide-vue-next v0.460.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ne=J("ListChecksIcon",[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]]);async function j(n){const e=await U(n,{start:0,limit:0});return e.totalCount??e.total??0}function Ke(){const n=P(),e=ae(),u=S(null),r=S(null),g=S(null),_=S(!1),f=S(null),y=b(()=>!n.has("admin")||u.value===null||r.value===null||g.value===null?"healthy":e.isActive||u.value===0?"fresh":r.value===0?"channels-missing":g.value===0?"epg-missing":"healthy"),p=b(()=>({configure:n.has("admin"),record:n.has("dvr"),watch:!0}));async function m(){if(!n.has("admin")){_.value=!1;return}_.value=!0,f.value=null;try{const[a,c,l]=await Promise.all([j("mpegts/network/grid"),j("channel/grid"),j("epg/events/grid")]);u.value=a,r.value=c,g.value=l}catch(a){f.value=a instanceof Error?a:new Error(String(a))}finally{_.value=!1}}return H(m),oe(()=>n.has("admin"),a=>{a&&m()}),Pe({refetch:m}),{state:y,capabilities:p,channelCount:r,loading:_,error:f,refresh:m}}function I(n){return n==="epg-missing"||n==="healthy"}function Je(n){return(n.state==="fresh"||n.state==="channels-missing")&&!n.caps.configure}const Qe=[{id:"sign-in",tier:"guidance",kind:"action",icon:ge,title:"Sign in",description:"Sign in to access recordings, settings, and the rest of the UI.",action:"sign-in",visible:({authMode:n})=>n==="anonymous"},{id:"discover-palette",tier:"guidance",kind:"action",icon:Ye,title:"Try the command palette",description:"Press ⌘K (or Ctrl-K) to jump anywhere — search routes, channels, recordings, EPG.",action:"open-palette",visible:({state:n,seenPalette:e,touchOnly:u,authMode:r})=>I(n)&&!e&&!u&&r!=="anonymous"},{id:"discover-palette-touch",tier:"guidance",kind:"action",icon:ie,title:"Try the search button",description:"Tap the search icon to jump anywhere — routes, channels, recordings, EPG.",action:"open-palette",visible:({state:n,seenPalette:e,touchOnly:u,authMode:r})=>I(n)&&!e&&u&&r!=="anonymous"},{id:"setup-tv",tier:"guidance",kind:"action",icon:ke,title:"Set up live TV",description:"Scan for channels and get the guide running.",action:"start-wizard",visible:({state:n,caps:e})=>n==="fresh"&&e.configure},{id:"finish-channels",tier:"guidance",kind:"action",icon:ne,title:"Finish setting up channels",description:"Services were found — map them to channels to start watching.",action:"start-wizard",visible:({state:n,caps:e})=>n==="channels-missing"&&e.configure},{id:"not-ready",tier:"guidance",kind:"notice",icon:be,title:"No channels yet",description:"This server isn't set up for TV yet — that needs administrator access.",visible:Je},{id:"tv-guide",tier:"tv",kind:"nav",icon:we,title:"TV Guide",description:"Browse what's on now and what's coming up.",to:{name:"epg"},visible:({state:n})=>I(n)},{id:"all-recordings",tier:"tv",kind:"nav",icon:Ce,title:"Recordings",description:"Your scheduled and finished recordings.",to:{name:"dvr"},visible:({state:n,caps:e})=>I(n)&&e.record},{id:"setup-epg",tier:"tv",kind:"nav",icon:je,title:"Set up the TV guide",description:"No guide data yet — choose where it comes from.",to:{name:"config-channel-epg"},visible:({state:n,caps:e})=>n==="epg-missing"&&e.configure},{id:"scan-channels",tier:"server",kind:"action",icon:$e,title:"Scan for channels",description:"Look for new channels on every enabled network.",action:"scan-all-networks",visible:({state:n,caps:e})=>n!=="fresh"&&e.configure},{id:"refresh-epg",tier:"server",kind:"action",icon:Se,title:"Refresh TV guide",description:"Pull fresh listings from internal and over-the-air EPG grabbers.",action:"refresh-epg",visible:({state:n,caps:e})=>I(n)&&e.configure},{id:"manage-channels",tier:"server",kind:"nav",icon:ne,title:"Reorganize channels",description:"Reorder, tag and enable channels in bulk.",to:{name:"config-channel-channels",query:{manageMode:"true"}},visible:({state:n,caps:e})=>I(n)&&e.configure}],Xe={class:"home-card__text"},Ze={class:"home-card__title"},et={class:"home-card__desc"},tt={class:"home-card__text"},nt={class:"home-card__title"},st={class:"home-card__desc"},at={key:2,class:"home-card home-card--notice"},ot={class:"home-card__text"},it={class:"home-card__title"},rt={class:"home-card__desc"},ct=x({__name:"HomeCard",props:{card:{},primary:{type:Boolean}},emits:["action"],setup(n,{emit:e}){const u=e,{t:r}=z();return(g,_)=>{const f=re("RouterLink");return n.card.kind==="nav"&&n.card.to?(s(),R(f,{key:0,to:n.card.to,class:V(["home-card",{"home-card--primary":n.primary}])},{default:ce(()=>[(s(),R(G(n.card.icon),{size:22,"stroke-width":2,class:"home-card__icon"})),o("span",Xe,[o("span",Ze,d(t(r)(n.card.title)),1),o("span",et,d(t(r)(n.card.description)),1)])]),_:1},8,["to","class"])):n.card.kind==="action"?(s(),i("button",{key:1,type:"button",class:V(["home-card",{"home-card--primary":n.primary}]),onClick:_[0]||(_[0]=y=>n.card.action&&u("action",n.card.action))},[(s(),R(G(n.card.icon),{size:22,"stroke-width":2,class:"home-card__icon"})),o("span",tt,[o("span",nt,d(t(r)(n.card.title)),1),o("span",st,d(t(r)(n.card.description)),1)])],2)):(s(),i("div",at,[(s(),R(G(n.card.icon),{size:22,"stroke-width":2,class:"home-card__icon"})),o("span",ot,[o("span",it,d(t(r)(n.card.title)),1),o("span",rt,d(t(r)(n.card.description)),1)])]))}}}),Y=A(ct,[["__scopeId","data-v-cd93b900"]]),lt={key:0,class:"recording-now"},dt={class:"recording-now__title"},ut={class:"recording-now__list"},ht=["title","onClick"],_t={class:"recording-now__name"},mt={key:0,class:"recording-now__meta"},vt=["title"],pt=["disabled","title","aria-label","onClick"],ft=x({__name:"RecordingNow",setup(n){const{t:e}=z(),u=ve(),r=P(),g=Q(),{now:_}=Te(),f=pe({endpoint:"dvr/entry/cancel",confirmText:e("Do you really want to abort/unschedule the selection?"),confirmSeverity:"danger",failPrefix:e("Failed to abort")});H(()=>{r.has("dvr")&&u.ensure().catch(()=>{})});const y=b(()=>u.entries.filter(l=>l.sched_status.startsWith("recording")));function p(l){return l.sched_status==="recordingError"}function m(l){const C=l.stop-l.start;return C<=0?0:Math.max(0,Math.min(100,(_.value-l.start)/C*100))}function a(l){const C=m(l)*3.6;return{background:`conic-gradient(var(--tvh-primary) 0deg ${C}deg, var(--tvh-border) ${C}deg 360deg)`}}function c(l){f.run([{uuid:l}],u.refresh).catch(()=>{})}return(l,C)=>y.value.length?(s(),i("section",lt,[o("p",dt,[C[0]||(C[0]=o("span",{class:"recording-now__dot","aria-hidden":"true"},null,-1)),K(" "+d(t(e)("Recording now")),1)]),o("ul",ut,[(s(!0),i(L,null,N(y.value,h=>(s(),i("li",{key:h.uuid,class:"recording-now__item"},[o("button",{type:"button",class:V(["recording-now__entry",{"recording-now__entry--error":p(h)}]),title:p(h)?t(e)("Recording with errors"):void 0,onClick:M=>t(g).open(h.uuid)},[o("span",_t,d(h.disp_title||t(e)("Untitled recording")),1),h.channelname?(s(),i("span",mt,d(h.channelname),1)):$("",!0),o("span",{class:"recording-now__pie",style:le(a(h)),title:t(e)("{0}% recorded",Math.round(m(h)))},null,12,vt)],10,ht),o("button",{type:"button",class:"recording-now__abort",disabled:t(f).inflight.value,title:t(e)("Abort this recording"),"aria-label":t(e)("Abort this recording"),onClick:M=>c(h.uuid)},[T(t(Oe),{size:16,"aria-hidden":"true"})],8,pt)]))),128))])])):$("",!0)}}),yt=A(ft,[["__scopeId","data-v-1aca5931"]]),gt={class:"this-week"},kt={class:"this-week__title"},bt={class:"this-week__strip"},wt={class:"this-week__day-label"},Ct=["aria-label","onClick"],$t={key:1,class:"this-week__day-count"},se=7,St=x({__name:"ThisWeekStrip",setup(n){const{t:e}=z(),u=ve(),r=P(),g=Q();H(()=>{r.has("dvr")&&u.ensure().catch(()=>{})});const _=b(()=>{const p=te(Date.now()),m=[];for(let a=0;a<se;a++){const c=new Date(p);c.setDate(c.getDate()+a),m.push({label:a===0?e("Today"):c.toLocaleDateString(void 0,{weekday:"short"}),date:c,count:0,isToday:a===0,entries:[]})}for(const a of u.entries){if(!a.enabled)continue;const c=Be(te(a.start*1e3),p);c>=0&&c<se&&(m[c].count++,m[c].entries.push(a))}return m}),f=b(()=>[{field:"disp_title",label:e("Title")},{field:"channelname",label:e("Channel")},{field:"start",label:e("Start"),format:fe}]);function y(p){const m=p.entries.map(c=>({uuid:c.uuid,disp_title:c.disp_title,channelname:c.channelname,start:c.start})),a=p.isToday?e("Today's recordings"):e("Recordings on {0}",p.date.toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric"}));g.openList(m,f.value,a)}return(p,m)=>(s(),i("section",gt,[o("p",kt,d(t(e)("This week's recordings")),1),o("div",bt,[(s(!0),i(L,null,N(_.value,(a,c)=>(s(),i("div",{key:c,class:V(["this-week__day",{"this-week__day--today":a.isToday,"this-week__day--has":a.count>0}])},[o("span",wt,d(a.label),1),a.count>0?(s(),i("button",{key:0,type:"button",class:"this-week__day-count this-week__day-count--button","aria-label":t(e)("{0} recordings on {1}",a.count,a.label),onClick:l=>y(a)},d(a.count),9,Ct)):(s(),i("span",$t,"–"))],2))),128))])]))}}),Tt=A(St,[["__scopeId","data-v-00fe05e9"]]),Et={key:0,class:"recently-recorded"},Dt={class:"recently-recorded__header"},Rt={class:"recently-recorded__title"},Mt=["aria-label"],Lt={class:"recently-recorded__alert-text"},Nt={key:0,class:"recently-recorded__list"},xt=["onClick"],zt={class:"recently-recorded__name"},At={class:"recently-recorded__meta"},It=["disabled","title","aria-label","onClick"],Vt=4,Pt=7,Ht=x({__name:"RecentlyRecorded",setup(n){const{t:e}=z(),u=Q(),r=de(),g=pe({endpoint:"dvr/entry/remove",confirmText:e("Do you really want to remove the selected recordings from storage?"),confirmSeverity:"danger",failPrefix:e("Failed to remove")}),_=Pt*24*60*60,f=S([]),y=S(0),p={field:"_play",playPath:"dvrfile",playTitle:v=>{const E=String(v.disp_title??""),w=String(v.episode_disp??"");return w?`${E} / ${w}`:E},playEnabled:v=>typeof v.filesize=="number"&&v.filesize>0};async function m(){try{const v=await U("dvr/entry/grid_finished",{start:0,limit:Vt,sort:"start_real",dir:"DESC"});f.value=Array.isArray(v?.entries)?v.entries:[]}catch{f.value=[]}}async function a(){const E=[{field:"start_real",type:"numeric",value:Math.floor(Date.now()/1e3)-_,comparison:"gt"}];try{const w=await U("dvr/entry/grid_failed",{start:0,limit:1,filter:JSON.stringify(E)});y.value=typeof w?.total=="number"?w.total:0}catch{y.value=0}}function c(){r.push({name:"dvr-failed"}).catch(()=>{})}const l=P(),C=ue(()=>{m().catch(()=>{}),a().catch(()=>{})},500);let h=null;H(()=>{l.has("dvr")&&(m().catch(()=>{}),a().catch(()=>{}),h=he.on("dvrentry",()=>{C()}))}),_e(()=>{C.cancel(),h?.()});function M(v){return v?new Date(v*1e3).toLocaleDateString(void 0,{month:"short",day:"numeric"}):""}function O(v){g.run([v],()=>{m().catch(()=>{})}).catch(()=>{})}return(v,E)=>f.value.length||y.value>0?(s(),i("section",Et,[o("div",Dt,[o("p",Rt,d(t(e)("Recently recorded")),1),y.value>0?(s(),i("button",{key:0,type:"button",class:"recently-recorded__alert","aria-label":t(e)("{0} failed recordings in the last 7 days",y.value),onClick:c},[T(t(me),{size:14,"aria-hidden":"true"}),o("span",Lt,d(t(e)("{0} failed · last 7 days",y.value)),1),E[0]||(E[0]=o("span",{"aria-hidden":"true",class:"recently-recorded__alert-chevron"},"›",-1))],8,Mt)):$("",!0)]),f.value.length?(s(),i("ul",Nt,[(s(!0),i(L,null,N(f.value,w=>(s(),i("li",{key:w.uuid,class:"recently-recorded__item"},[T(Fe,{row:w,col:p},null,8,["row"]),o("button",{type:"button",class:"recently-recorded__entry",onClick:B=>t(u).open(w.uuid)},[o("span",zt,d(w.disp_title||t(e)("Untitled recording")),1),o("span",At,d([w.channelname,M(w.start_real)].filter(Boolean).join(" · ")),1)],8,xt),o("button",{type:"button",class:"recently-recorded__remove",disabled:t(g).inflight.value,title:t(e)("Remove this recording"),"aria-label":t(e)("Remove this recording"),onClick:B=>O(w)},[T(t(Ee),{size:16,"aria-hidden":"true"})],8,It)]))),128))])):$("",!0)])):$("",!0)}}),Ot=A(Ht,[["__scopeId","data-v-d8dcbf8e"]]),Bt={class:"health-line__verdict"},Ft={key:0,class:"health-line__disk"},Ut={class:"health-line__bar"},Gt={class:"health-line__disk-text"},Wt={class:"health-line__disk-pct"},qt={class:"health-line__streams"},jt={key:1},Yt=.1,Kt=x({__name:"HealthLine",setup(n){const{t:e}=z(),u=P(),r=Ue("status/inputs","input_status","uuid");H(()=>{u.has("admin")&&r.fetch().catch(()=>{})});const g=b(()=>r.entries.reduce((v,E)=>{const w=E.subs;return v+(typeof w=="number"?w:0)},0)),_=b(()=>{const v=g.value;return v===0?e("Idle"):v===1?e("1 active subscription"):e("{0} active subscriptions",v)}),f=b(()=>g.value>0&&u.has("admin"));function y(v){return typeof v=="number"&&v>=0?v:null}const p=b(()=>y(u.data?.totaldiskspace)),m=b(()=>y(u.data?.freediskspace)),a=b(()=>p.value!==null&&p.value>0&&m.value!==null),c=b(()=>a.value?Math.max(0,Math.min(1,m.value/p.value)):0),l=b(()=>Math.round((1-c.value)*100)),C=b(()=>Math.round(c.value*100)),h=b(()=>a.value&&c.value<Yt),M=b(()=>m.value===null?"—":ee(m.value)),O=b(()=>p.value===null?"—":ee(p.value));return(v,E)=>{const w=re("router-link");return s(),i("section",{class:V(["health-line",{"health-line--warn":h.value}])},[o("p",Bt,[(s(),R(G(h.value?t(me):t(ye)),{size:18,class:"health-line__icon","aria-hidden":"true"})),o("span",null,d(h.value?t(e)("Storage is running low"):t(e)("Everything's running smoothly")),1)]),a.value?(s(),i("div",Ft,[o("div",Ut,[o("div",{class:"health-line__bar-fill",style:le({width:l.value+"%"})},null,4)]),o("p",Gt,[K(d(t(e)("{0} free of {1}",M.value,O.value))+" ",1),o("span",Wt,"("+d(C.value)+"%)",1)])])):$("",!0),o("p",qt,[T(t(Ge),{size:14,class:"health-line__streams-icon","aria-hidden":"true"}),f.value?(s(),R(w,{key:0,to:{name:"status-subscriptions"},class:"health-line__streams-link",title:t(e)("Open Subscriptions")},{default:ce(()=>[K(d(_.value),1)]),_:1},8,["title"])):(s(),i("span",jt,d(_.value),1))])],2)}}}),Jt=A(Kt,[["__scopeId","data-v-8690f74c"]]),Qt=300,Xt=3,Zt=100;function en(){const n=S(""),e=S([]),u=S(0),r=S(!1),g=S(null);let _=0;function f(){e.value=[],u.value=0,g.value=null,r.value=!1}async function y(a){_+=1;const c=_;r.value=!0,g.value=null;try{const l=await U("epg/events/grid",{title:a,limit:Zt,sort:"start",dir:"ASC"});if(c!==_)return;e.value=l.entries??[],u.value=l.totalCount??l.total??e.value.length}catch(l){if(c!==_)return;e.value=[],u.value=0,g.value=l instanceof Error?l:new Error(String(l))}finally{c===_&&(r.value=!1)}}const p=ue(a=>{y(a)},Qt);oe(n,a=>{p.cancel();const c=a.trim();if(c.length<Xt){_+=1,f();return}p(c)}),De(()=>{p.cancel(),_+=1});function m(){n.value=""}return{query:n,events:e,totalCount:u,loading:r,error:g,clear:m}}const tn={class:"home-search"},nn={class:"home-search__input"},sn={key:0,class:"home-search__status"},an={key:1,class:"home-search__status home-search__status--error"},on={key:0,class:"home-search__overflow"},rn={class:"home-search__list"},cn=["onClick"],ln={class:"home-search__title"},dn={class:"home-search__meta"},un={key:0},hn={key:1},_n={key:2},mn={key:3,class:"home-search__status"},vn=3,pn=x({__name:"HomeSearchCard",setup(n){const{t:e}=z(),{query:u,events:r,totalCount:g,loading:_,error:f}=en(),y=S(null),p=S(null),{isAtBottom:m}=Re(p,{slopPx:2});function a(l){y.value=l}function c(){y.value=null}return(l,C)=>(s(),i("section",tn,[o("div",nn,[T(t(ie),{size:18,class:"home-search__icon","aria-hidden":"true"}),T(We,{modelValue:t(u),"onUpdate:modelValue":C[0]||(C[0]=h=>Me(u)?u.value=h:null),placeholder:t(e)("Search the TV guide…"),"aria-label":t(e)("Search the TV guide"),class:"home-search__field"},null,8,["modelValue","placeholder","aria-label"])]),t(_)?(s(),i("div",sn,d(t(e)("Searching…")),1)):t(f)?(s(),i("div",an,d(t(e)("Search failed."))+" "+d(t(f).message),1)):t(r).length>0?(s(),i("div",{key:2,class:V(["home-search__results",{"home-search__results--has-bottom":!t(m)}])},[o("div",{ref_key:"scrollEl",ref:p,class:"home-search__scroll"},[t(g)>t(r).length?(s(),i("output",on,d(t(e)("Showing first {0} of {1} matches — refine to narrow.",t(r).length,t(g))),1)):$("",!0),o("ul",rn,[(s(!0),i(L,null,N(t(r),h=>(s(),i("li",{key:h.eventId},[o("button",{type:"button",class:"home-search__row",onClick:M=>a(h)},[o("span",ln,d(h.title||t(e)("Untitled")),1),o("span",dn,[h.channelName?(s(),i("span",un,d(h.channelName),1)):$("",!0),h.channelName&&h.start?(s(),i("span",hn," · ")):$("",!0),h.start?(s(),i("span",_n,d(t(fe)(h.start)),1)):$("",!0)])],8,cn)]))),128))])],512)],2)):t(u).trim().length>=vn?(s(),i("div",mn,d(t(e)("No upcoming events match.")),1)):$("",!0),T(qe,{event:y.value,onClose:c},null,8,["event"])]))}}),fn=A(pn,[["__scopeId","data-v-bad06616"]]),yn={class:"view home"},gn={class:"view__header"},kn={key:0,class:"home__greeting"},bn={class:"home__greeting-text"},wn=["aria-label"],Cn={key:1,class:"home__status"},$n={key:2,class:"home__status"},Sn={key:0,class:"home__guidance"},Tn={key:1,class:"home__tier"},En={class:"home__tier-title"},Dn={key:0,class:"home__activity"},Rn={key:1,class:"home__cards"},Mn={key:2,class:"home__tier"},Ln={class:"home__tier-title"},Nn={key:1,class:"home__cards"},xn={key:3,class:"home__status"},zn=x({__name:"HomeView",setup(n){const{t:e}=z(),u=de(),r=Le(),g=ae(),{state:_,capabilities:f,loading:y,error:p}=Ke(),m=xe(),a=P(),c=S(!1);let l;function C(){l&&(c.value=l.matches)}typeof globalThis.matchMedia=="function"&&(l=globalThis.matchMedia("(hover: none)"),C(),l.addEventListener("change",C)),_e(()=>{l?.removeEventListener("change",C)});const h=S(He()),M=S(null);H(async()=>{if(h.value)try{const k=await U("channel/grid",{start:0,limit:0,filter:JSON.stringify([{field:"enabled",type:"boolean",value:!0}])});M.value=k.total??k.totalCount??0}catch{}});const O=b(()=>{const k=M.value;return k===null?e("Setup complete"):k===1?e("Setup complete — 1 channel ready"):e("Setup complete — {0} channels ready",k)}),v=b(()=>Qe.filter(k=>k.visible({state:_.value,caps:f.value,seenPalette:m.seenPalette.value,touchOnly:c.value,authMode:a.authMode}))),E=b(()=>v.value.filter(k=>k.tier==="guidance")),w=b(()=>v.value.filter(k=>k.tier==="tv")),B=b(()=>v.value.filter(k=>k.tier==="server")),X=b(()=>f.value.record&&(_.value==="epg-missing"||_.value==="healthy")),Z=b(()=>f.value.configure&&_.value!=="fresh"),F=S(null);async function W(k){if(F.value!==k){if(k==="open-palette"){m.open();return}if(k==="start-wizard"){await ze(g,u,r);return}if(k==="sign-in"){try{(await fetch(Ae("login"),{method:"GET",credentials:"include",cache:"no-store"})).ok&&he.reset()}catch{}return}if(k==="scan-all-networks"){F.value=k;try{await Ie(r)}finally{F.value=null}return}if(k==="refresh-epg"){F.value=k;try{await Ve(r)}finally{F.value=null}}}}return(k,q)=>(s(),i("article",yn,[o("header",gn,[o("h1",null,d(t(e)("Home")),1)]),h.value?(s(),i("output",kn,[T(t(ye),{size:20,class:"home__greeting-icon","aria-hidden":"true"}),o("span",bn,d(O.value),1),o("button",{type:"button",class:"home__greeting-dismiss","aria-label":t(e)("Dismiss"),onClick:q[0]||(q[0]=D=>h.value=!1)},[T(t(Ne),{size:16,"aria-hidden":"true"})],8,wn)])):$("",!0),t(y)?(s(),i("p",Cn,d(t(e)("Loading…")),1)):t(p)?(s(),i("p",$n,d(t(e)("Could not load the dashboard.")),1)):(s(),i(L,{key:3},[E.value.length?(s(),i("section",Sn,[(s(!0),i(L,null,N(E.value,D=>(s(),R(Y,{key:D.id,card:D,primary:D.kind==="action",onAction:W},null,8,["card","primary"]))),128))])):$("",!0),w.value.length||X.value?(s(),i("section",Tn,[o("h2",En,d(t(e)("TV")),1),T(fn),X.value?(s(),i("div",Dn,[T(yt),T(Tt),T(Ot)])):$("",!0),w.value.length?(s(),i("div",Rn,[(s(!0),i(L,null,N(w.value,D=>(s(),R(Y,{key:D.id,card:D,onAction:W},null,8,["card"]))),128))])):$("",!0)])):$("",!0),B.value.length||Z.value?(s(),i("section",Mn,[o("h2",Ln,d(t(e)("Server")),1),Z.value?(s(),R(Jt,{key:0,class:"home__health"})):$("",!0),B.value.length?(s(),i("div",Nn,[(s(!0),i(L,null,N(B.value,D=>(s(),R(Y,{key:D.id,card:D,onAction:W},null,8,["card"]))),128))])):$("",!0)])):$("",!0),v.value.length?$("",!0):(s(),i("p",xn,d(t(e)("Nothing to show here yet.")),1))],64))]))}}),es=A(zn,[["__scopeId","data-v-905aa9c3"]]);export{es as default};
