import{S as M}from"./StatusGrid-DAyEP9oU.js";import{d as $,e as v,i as w,D as L,E as I,t as V,z as O,F as R,q as N,k as n,o as _,_ as A,u as z,b as F,c as H,r as y,w as T,f as h,g as x,h as d,x as P,y as G,L as K}from"./index-D92x6h1h.js";import{A as U}from"./ActionMenu-B3aKIJFu.js";import{B as W,C as j}from"./BandwidthChartView-C_txU6C2.js";import"./DataGrid-CbtTsx8d.js";import"./index-BG9mM10J.js";import"./index-7HNOjfAo.js";import"./localDay-CoEbUe3O.js";import"./useGridLayout-DCIiMD42.js";import"./CollapsibleSection.vue_vue_type_style_index_0_lang-Cq2AVc9p.js";import"./sliders-horizontal-Am8f4Xsv.js";import"./status-CE0GKX14.js";import"./play-DDT_Ndp2.js";const q=["title"],J={class:"signal-bar-cell__track","aria-hidden":"true"},Y={class:"signal-bar-cell__text"},Q=65535,X=$({__name:"SignalBarCell",props:{value:{},row:{},col:{}},setup(S){const t=S,p=n(()=>t.col?.field==="snr"),m=n(()=>{const a=t.row?.[p.value?"snr_scale":"signal_scale"];return typeof a=="number"?a:0}),i=n(()=>typeof t.value=="number"?t.value:null),u=n(()=>i.value===null?null:m.value===1?"bar":m.value===2&&(!p.value||i.value>0)?"text":null),c=n(()=>Math.max(0,Math.min(100,(i.value??0)/Q*100))),g=n(()=>c.value>66?"good":c.value>33?"mid":"low"),f=n(()=>i.value===null?"":m.value===1?String(i.value):`${(i.value*.001).toFixed(1)} ${p.value?"dB":"dBm"}`),b=n(()=>`${Math.round(c.value)}%`);return(a,C)=>u.value==="bar"?(_(),v("span",{key:0,class:"signal-bar-cell",title:b.value},[w("span",J,[w("span",{class:I(["signal-bar-cell__fill",`signal-bar-cell__fill--${g.value}`]),style:L({width:`${c.value}%`})},null,6)]),w("span",Y,V(f.value),1)],8,q)):u.value==="text"?(_(),v(R,{key:1},[O(V(f.value),1)],64)):N("",!0)}}),B=A(X,[["__scopeId","data-v-e009655f"]]),Z={class:"status-view__row"},tt=["aria-label","aria-pressed"],k="tvh-bandwidth-show:status-streams",et=$({__name:"StreamView",setup(S){const{t}=z(),p=e=>typeof e=="number"?Math.round(e/1024).toString():"",m=e=>{if(!Array.isArray(e)||e.length===0)return"";const s=[...e].sort((r,o)=>r-o);return s[s.length-1]===65535?"all":s.join(", ")},i=[{field:"input",label:t("Input"),sortable:!0,minVisible:"phone",phoneRole:"primary"},{field:"stream",label:t("Stream"),sortable:!0,minVisible:"phone",phoneOrder:99},{field:"subs",label:t("Subs No."),sortable:!0,minVisible:"desktop"},{field:"weight",label:t("Weight"),sortable:!0,minVisible:"desktop"},{field:"pids",label:t("PID list"),sortable:!1,minVisible:"desktop",width:200,format:m},{field:"bps",label:t("Bandwidth (kb/s)"),sortable:!0,minVisible:"desktop",format:p},{field:"signal",label:t("Signal Strength"),sortable:!0,minVisible:"phone",phoneOrder:1,width:170,cellComponent:B},{field:"snr",label:t("SNR"),sortable:!0,minVisible:"phone",phoneOrder:2,width:170,cellComponent:B},{field:"unc",label:t("Uncorrected Blocks"),sortable:!0,minVisible:"desktop"},{field:"te",label:t("Transport Errors"),sortable:!0,minVisible:"desktop"},{field:"cc",label:t("Continuity Errors"),sortable:!0,minVisible:"desktop"}],u=y(!1),c=F(),g=H();async function f(e,s){const r=e.map(l=>l.uuid).filter(l=>typeof l=="string");if(!(r.length===0||!await c.ask(t("Clear statistics for selected input?")))){u.value=!0;try{await K("status/inputclrstats",{uuid:JSON.stringify(r)}),s()}catch(l){g.error(t("Failed to clear statistics: {0}",l instanceof Error?l.message:String(l)))}finally{u.value=!1}}}const b=y(null),a=y(C());function C(){try{return localStorage.getItem(k)==="1"}catch{return!1}}T(a,e=>{try{e?localStorage.setItem(k,"1"):localStorage.removeItem(k)}catch{}});function D(e){const s=typeof e.input=="string"?e.input:"",r=typeof e.stream=="string"?e.stream:"";return r?`${s} · ${r}`:s}function E(e,s){return[{id:"reset-stats",label:u.value?t("Clearing…"):t("Clear statistics"),tooltip:t("Clear statistics for selected inputs"),disabled:e.length===0||u.value,onClick:()=>f(e,s)}]}return(e,s)=>{const r=P("tooltip");return _(),v("div",Z,[h(M,{ref_key:"gridRef",ref:b,endpoint:"status/inputs","help-page":"status_stream","notification-class":"input_status",columns:i,"key-field":"uuid","default-sort":{key:"input",dir:"ASC"},"storage-key":"status-streams",class:"status-view__grid"},{toolbarActions:x(({selection:o,clearSelection:l})=>[h(U,{actions:E(o,l)},null,8,["actions"])]),toolbarMeta:x(({isPhone:o})=>[o?N("",!0):G((_(),v("button",{key:0,type:"button",class:I(["status-view__chart-toggle",{"status-view__chart-toggle--active":a.value}]),"aria-label":a.value?d(t)("Hide bandwidth chart"):d(t)("Show bandwidth chart"),"aria-pressed":a.value,onClick:s[0]||(s[0]=l=>a.value=!a.value)},[h(d(j),{size:16,"stroke-width":2})],10,tt)),[[r,a.value?d(t)("Hide bandwidth chart"):d(t)("Show bandwidth chart"),void 0,{bottom:!0}]])]),_:1},512),h(W,{visible:a.value,"onUpdate:visible":s[1]||(s[1]=o=>a.value=o),rows:()=>b.value?.selection??[],"key-field":"uuid",metrics:["bps"],units:"bits","row-label":D,noun:d(t)("input")},null,8,["visible","rows","noun"])])}}}),bt=A(et,[["__scopeId","data-v-f7f5dbc6"]]);export{bt as default};
