import{$n as e,M as t,an as n}from"./B-6m3w3Q.js";var r=1e3;const i=n(`kernel`,()=>{let n=e(null),i=e([]),a=e(!1),o=null,s=async()=>{n.value=await t().getKernelStatus()},c=async()=>{n.value=await t().startKernel()},l=async()=>{n.value=await t().stopKernel()},u=async()=>{n.value=await t().restartKernel()},d=async()=>{n.value=await t().rollbackKernel()},f=async()=>{n.value=await t().recoverKernel()},p=e=>{i.value.push(e),i.value.length>r&&i.value.splice(0,i.value.length-r)};return{state:n,logs:i,connected:a,fetchStatus:s,start:c,stop:l,restart:u,rollback:d,recover:f,connectLogs:()=>{o||(o=new EventSource(t().logsUrl()),a.value=!0,o.onmessage=e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=t;if(r.type===`log`)p({stream:r.stream,line:r.line,ts:r.ts});else if(r.type===`state`){let{type:e,...t}=r;n.value=t}},o.onerror=()=>{a.value=!1})},disconnectLogs:()=>{o?.close(),o=null,a.value=!1},clearLogs:()=>{i.value=[]}}});export{i as t};