import{C as e,Ct as t,E as n,Mt as r,Qt as i,V as a,W as o,Y as s,_ as c,c as l,dt as u,g as d,h as f,lt as p,m,tn as h,v as g,w as _}from"./vendor/json-editor-vue-ddj4xtqm.js";import"./vendor/shiki-kunkft64.js";import{C as v,Fn as y,Ht as b,Jn as x,a as S,j as C,k as w,mt as T,q as E,tn as D}from"#entry";import{t as O}from"./composables-g8w9dpc0.js";import{n as k,t as A}from"./vendor/xterm-b39oya8c.js";var j={border:`t base`,flex:`~ gap-2`,"items-center":``,p2:``},M={"text-sm":``,op50:``},N=n({__name:`TerminalView`,props:{id:{}},setup(e){let n=e,r=t(),i=y(),s=t(),u;a(async()=>{u=new A({convertEol:!0,cols:80,screenReaderMode:!0});let e=new k;u.loadAddon(e),u.open(r.value),e.fit(),D(window,`resize`,()=>{e.fit()}),s.value=await b.getTerminalDetail(await E(),n.id),s.value?.buffer&&u.write(s.value.buffer),i.hook(`devtools:terminal:data`,({id:e,data:t})=>{e===n.id&&u.write(t)})});async function p(){b.runTerminalAction(await E(),n.id,`clear`),u?.clear()}async function m(){b.runTerminalAction(await E(),n.id,`restart`)}async function v(){b.runTerminalAction(await E(),n.id,`terminate`)}return(e,t)=>{let n=w;return o(),g(l,null,[f(`div`,{ref_key:`container`,ref:r,"h-full":``,"w-full":``,"of-auto":``,"bg-black":``},null,512),f(`div`,j,[_(n,{title:`Clear`,icon:`i-carbon-clean`,border:!1,onClick:t[0]||=e=>p()}),s.value?.restartable?(o(),d(n,{key:0,title:`Restart`,icon:`carbon-renew`,border:!1,onClick:t[1]||=e=>m()})):c(``,!0),s.value?.terminatable?(o(),d(n,{key:1,title:`Terminate`,icon:`carbon-delete`,border:!1,onClick:t[2]||=e=>v()})):c(``,!0),f(`span`,M,h(s.value?.description),1)])],64)}}}),P=Object.assign(N,{__name:`TerminalView`}),F={key:0,"h-full":``,"w-full":``,"of-hidden":``,grid:`~ rows-[max-content_1fr_max-content]`},I={flex:`~`,border:`b base`,"n-navbar-glass":``,"flex-1":``,"items-center":``},L=[`onClick`],R={key:1,p10:``},z={key:1,"h-full":``,flex:``,"items-center":``,"justify-center":``},B=n({__name:`TerminalPage`,setup(t){let n=T(),a=v(),u=m(()=>n.value?.find(e=>e.id===a.value));async function _(e){b.runTerminalAction(await E(),e,`remove`)}return p(()=>{!a.value&&n.value?.length&&(a.value=n.value[0].id)}),(t,p)=>{let m=C,v=w,y=P;return r(n)?.length?(o(),g(`div`,F,[f(`div`,I,[(o(!0),g(l,null,s(r(n),e=>(o(),g(`button`,{key:e.id,border:`r base`,flex:`~ gap-2`,"items-center":``,px3:``,py2:``,class:i(e.id===u.value?.id?`bg-active`:``),onClick:t=>a.value=e.id},[e.icon?(o(),d(m,{key:0,icon:e.icon},null,8,[`icon`])):c(``,!0),f(`span`,{class:i(e.id===u.value?.id?``:`op50`)},h(e.name)+h(e.isTerminated?` (terminated)`:``),3),e.isTerminated?(o(),d(v,{key:1,icon:`carbon-close`,"mx--2":``,border:!1,onClick:x(t=>_(e.id),[`stop`])},null,8,[`onClick`])):c(``,!0)],10,L))),128))]),u.value?(o(),d(y,{id:u.value.id,key:u.value.id},null,8,[`id`])):(o(),g(`div`,R,[p[0]||=e(` Terminal `,-1),f(`code`,null,h(r(a)),1),p[1]||=e(` not found `,-1)]))])):(o(),g(`div`,z,[...p[2]||=[f(`em`,{op50:``},`No terminal attached`,-1)]]))}}}),V=Object.assign(B,{__name:`TerminalPage`}),H=n({__name:`terminals`,setup(e){return(e,t)=>{let n=V,r=S;return o(),d(r,null,{default:u(()=>[_(n)]),_:1})}}});export{H as default};