export default{tag:"system-runtime-overview",context:()=>({procCount:null,workers:null,procs:null,busy:!1,_timer:null,countTree(r){let e=0;const t=r=>{for(const o of r||[])e++,o.children&&t(o.children)};return t(r),e},async load(){this.busy=!0;try{const[r,e,t]=await Promise.all([fetch(`${__ENV__.API}/processes/tree`).catch(()=>null),fetch(`${__ENV__.API}/workers`).catch(()=>null),fetch(`${__ENV__.API}/processors/status`).catch(()=>null)]);if(r?.ok){const e=await r.json();this.procCount=this.countTree(e.data??e.result??[])}if(e?.ok){const r=await e.json();this.workers=r.data??r.result??null}if(t?.ok){const r=await t.json(),e=r.data??r.result??{},o=e.envs??e,s=[];for(const r of Object.keys(o||{}))if(Array.isArray(o[r]))for(const e of o[r])s.push(e);this.procs=s}}catch{}finally{this.busy=!1}},get workerLine(){const r=this.workers;if(!r)return"—";if(0===r.scale)return"off (self-processing)";const e="auto"===r.scale?"auto":null!=r.scale?.max?`${r.scale.min}–${r.scale.max}`:`min ${r.scale?.min}`;return`${r.live} live · desired ${e}`},get procHealth(){if(!this.procs)return{text:"—",color:"var(--okdb-app-fg-subtle)"};if(0===this.procs.length)return{text:"none registered",color:"var(--okdb-app-fg-subtle)"};const r=this.procs.filter(r=>"error"===r.state).length,e=this.procs.filter(r=>(r.lag||0)>1e3).length;return r?{text:`${r} error`,color:"var(--okdb-danger)"}:e?{text:`${e} lagging`,color:"var(--okdb-warning)"}:{text:"all caught up",color:"var(--okdb-success)"}}}),init(){this.load(),this._timer=setInterval(()=>this.load(),4e3),this._timer.unref&&this._timer.unref()},unmount(){this._timer&&clearInterval(this._timer),this._timer=null},template:'\n        <div style="display:flex;flex-direction:column;gap:14px;">\n            <div style="font-size:12px;color:var(--okdb-method-default);">A snapshot of everything running under this root. Open a tab for detail and controls.</div>\n            <div style="display:grid;grid-template-columns:repeat(3,1fr);gap:12px;">\n\n                \x3c!-- Processes --\x3e\n                <div style="padding:14px 16px;background:var(--okdb-app-bg-2);border:1px solid var(--okdb-app-border);border-radius:8px;">\n                    <div style="font-size:11px;text-transform:uppercase;letter-spacing:.5px;color:var(--okdb-app-fg-subtle);">Processes</div>\n                    <div style="font-size:26px;font-weight:600;color:var(--okdb-app-fg-strong);margin-top:4px;">{{ procCount == null ? \'—\' : procCount }}</div>\n                    <div style="font-size:11px;color:var(--okdb-app-fg-subtle);">live processes under this root</div>\n                </div>\n\n                \x3c!-- Workers --\x3e\n                <div style="padding:14px 16px;background:var(--okdb-app-bg-2);border:1px solid var(--okdb-app-border);border-radius:8px;">\n                    <div style="font-size:11px;text-transform:uppercase;letter-spacing:.5px;color:var(--okdb-app-fg-subtle);">Workers</div>\n                    <div style="font-size:26px;font-weight:600;color:var(--okdb-app-fg-strong);margin-top:4px;">{{ workers ? workers.live : \'—\' }}</div>\n                    <div style="font-size:11px;color:var(--okdb-app-fg-subtle);">{{ workerLine }}</div>\n                    <if :="workers && workers.why"><div style="font-size:10px;color:var(--okdb-app-fg-muted);margin-top:3px;">{{ workers.why }}</div></if>\n                </div>\n\n                \x3c!-- Processors --\x3e\n                <div style="padding:14px 16px;background:var(--okdb-app-bg-2);border:1px solid var(--okdb-app-border);border-radius:8px;">\n                    <div style="font-size:11px;text-transform:uppercase;letter-spacing:.5px;color:var(--okdb-app-fg-subtle);">Processors</div>\n                    <div style="font-size:26px;font-weight:600;color:var(--okdb-app-fg-strong);margin-top:4px;">{{ procs == null ? \'—\' : procs.length }}</div>\n                    <div :style="\'font-size:11px;color:\' + procHealth.color + \';\'">{{ procHealth.text }}</div>\n                </div>\n            </div>\n        </div>\n    '};