import{u as A,a as $,S as v}from"./T09L0pCq.js";import{d as j,r as z,c as B,b as L,e as l,w as o,s as r,f as e,E as n,l as g,F as C,y as N,t as V,k as D,H,D as S,Z as M,J as U,j as s,L as E,A as b,K as F,Q as I}from"./DrjE4E2T.js";import{u as O,B as k}from"./Dm_4r1sC.js";import{S as J}from"./DgeknOkP.js";import{A as K}from"./CNBo3Qsw.js";import{l as w}from"./Cay67bh1.js";import{I as f}from"./Bzcv36_K.js";const Q={key:0,class:"flex"},Z={class:"flex flex-col w-full text-sm divide-y divide-border"},h={key:0,class:"select-none text-xs text-muted-foreground"},q=["innerHTML"],G={key:1,class:"text-sm text-muted-foreground text-center py-8"},P=j({__name:"terminal",props:{logs:{},date:{type:Boolean}},setup(y){const x=y,_=O();z({});const m=B(()=>{const p=new K({fg:w.zinc[50],bg:w.zinc[950],newline:!1});return x.logs.map(a=>({text:p.toHtml(a.text.trim()),date:a.date,type:a.type}))});return(p,t)=>{const a=J;return l(),L(a,{class:"flex flex-col h-full justify-center justify-content-flex-start"},{default:o(()=>[e(m)&&e(m).length>0?(l(),r("pre",Q,[t[5]||(t[5]=n("      ")),g("code",Z,[t[3]||(t[3]=n(`
        `)),(l(!0),r(C,null,N(e(m),i=>(l(),r("span",{class:V(["flex items-center gap-2 py-px pl-3 pr-2",e(D)({"bg-cyan-950/25":i.type==="meta","bg-red-950/25":i.type==="error"})])},[t[0]||(t[0]=n(`
          `)),p.date?(l(),r("span",h,S(e(_)(i.date).format("LTS")),1)):H("",!0),t[1]||(t[1]=n(`
          `)),g("div",{class:"text-wrap brightness-75 dark:brightness-150",innerHTML:i.text.trim()},null,8,q),t[2]||(t[2]=n(`
        `))],2))),256)),t[4]||(t[4]=n(`
      `))]),t[6]||(t[6]=n(`
    `))])):(l(),r("p",G,"No logs yet."))]),_:1})}}}),R=Object.assign(P,{__name:"UtilityTerminal"}),W={class:"flex w-fit flex-col gap-1.5"},X={key:0,class:"flex gap-2"},Y={class:"flex gap-2"},ee=j({__name:"terminal",props:{id:{}},setup(y){const x=y,{getScript:_,killScript:m}=A(),p=O(),t=M("terminal-date",!1,{initOnMounted:!0}),a=B(()=>x.id?_(x.id):void 0);return(i,c)=>(l(),L(e(U),{class:"flex min-h-0 flex-grow flex-col"},{default:o(()=>[s(e(F),{class:"flex flex-row justify-between gap-2"},{default:o(()=>{var u,T;return[g("div",W,[s(e(E),null,{default:o(()=>c[2]||(c[2]=[n("Command Logs")])),_:1}),e(a)?(l(),r("div",X,[s(e(k),{class:"flex gap-2"},{default:o(()=>{var d;return[s(e(f),{icon:"lucide:clock"}),n(" "+S(e(p)((d=e(a))==null?void 0:d.createdAt).format("LT")),1)]}),_:1}),s(e(k),{class:"flex gap-2 font-mono"},{default:o(()=>[s(e(f),{icon:"lucide:terminal"}),n(" "+S(e($)({dynamic:e(a).command},"packages/@vaxla/ui")),1)]),_:1}),s(e(k),{variant:((u=e(a))==null?void 0:u.status)===e(v).Opened?"success":"destructive",class:"flex gap-2"},{default:o(()=>{var d;return[s(e(f),{icon:"lucide:stethoscope"}),((d=e(a))==null?void 0:d.status)===e(v).Opened?(l(),r(C,{key:0},[n("Opened")],64)):(l(),r(C,{key:1},[n("Closed")],64))]}),_:1},8,["variant"])])):H("",!0)]),g("div",Y,[s(e(b),{variant:e(t)?"default":"secondary",size:"icon",onClick:c[0]||(c[0]=d=>t.value=!e(t))},{default:o(()=>[s(e(f),{icon:"lucide:clock"})]),_:1},8,["variant"]),s(e(b),{disabled:((T=e(a))==null?void 0:T.status)!==e(v).Opened,variant:"destructive",size:"icon",onClick:c[1]||(c[1]=d=>e(m)(i.id))},{default:o(()=>[s(e(f),{icon:"lucide:trash-2"})]),_:1},8,["disabled"])])]}),_:1}),s(e(I),{class:"min-h-0 px-0"},{default:o(()=>{var u;return[s(R,{logs:((u=e(a))==null?void 0:u.logs)??[],date:e(t)},null,8,["logs","date"])]}),_:1})]),_:1}))}}),ie=Object.assign(ee,{__name:"CardsTerminal"});export{ie as T};
