const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/form9.js?v=1763625242172","js/index.vue_vue_type_script_setup_true_lang.js?v=1763625242172","js/vue.js?v=1763625242172","js/__commonjsHelpers__.js?v=1763625242172","js/naive.js?v=1763625242172","js/common.js?v=1763625242172","js/term.js?v=1763625242172","js/page_layout.js?v=1763625242172","js/public.js?v=1763625242172","css/public.css?v=1763625242172","css/page_layout.css?v=1763625242172"])))=>i.map(i=>d[i]);
import{x as e,a as t,b as o,c as a}from"./xterm.js?v=1763625242172";import{x as n}from"./xterm-addon-canvas.js?v=1763625242172";import{_ as s,k as d,P as i,af as r,a0 as l,r as c,w as u,ap as p,o as v,b as m,R as f,S as w,n as h}from"./vue.js?v=1763625242172";import{a as x,dE as A,p as _}from"./page_layout.js?v=1763625242172";import{u as b,C as g}from"./public.js?v=1763625242172";const S=e=>{b({title:e.title,width:600,footer:!0,data:e.data,component:s((()=>x((()=>import("./form9.js?v=1763625242172")),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))))})},O=_(d({__name:"terminal",props:{data:{},active:{type:Boolean}},emits:["updateState","connectSuccess"],setup(s,{expose:d,emit:x}){const{t:_}=i(),b=s,{data:O}=b,{active:y}=r(b),C=x,j=A(),{isFull:k}=l(j),{ws:E,status:T,send:R,open:D,close:z}=g("/webssh",{verifyData:{host:O.host,port:O.port,id:O.id,ps:O.ps,sort:0},onMessage:(e,t)=>{const o=t.data;return o.indexOf("Authentication timeout.")>-1&&(P.value=!0),-1==o.indexOf("@127.0.0.1:")&&-1==o.indexOf("@localhost:")||-1==o.indexOf("Authentication failed")?-1==o.indexOf("127.0.0.1:")&&-1==o.indexOf("localhost:")||-1==o.indexOf("Password or private key cannot both be empty")?"\\r\\nlogout\\r\\n"==o||"logout\\r\\n"==o||"\r\nlogout\r\n"==o||"logout\r\n"==o||o.search(/logout[\r\n]+$/)>-1?(C("updateState",O.id,!1),L.write("\r"+_("Component.Terminal.index_1")+"\r"),V(),void z()):void C("connectSuccess",o):(C("updateState",O.id,!1),z(),V(),void F()):(C("updateState",O.id,!1),z(),void V())}}),F=()=>{S({title:"Edit server",data:{isEdit:!0,tips:!0,localhost:!0,onRefresh:()=>{q()}}})};let L,M;const P=c(!1),B=c(null),I=()=>{const e=E.value;e&&(L.loadAddon(M),L.loadAddon(new n.CanvasAddon),L.loadAddon(new o.WebLinksAddon),L.loadAddon(new a.AttachAddon(e)),setTimeout((()=>{M.fit();const e=B.value;e&&(W.value="".concat(e.clientHeight,"px"))}),100))},H=()=>{B.value&&L.open(B.value)};let N=!1;const V=()=>{N=!1},W=c(""),$=()=>{L.focus(),L.onData((e=>{const t=E.value;"\r"===e&&P.value&&(P.value=!1,L.write("\r\n"),q()),void 0!==t||"\r"!==e||N||(N=!0,L.write("\r\n"+_("Component.Terminal.index_2")+"\r\n"),q())}))},q=()=>{D(),$();const e=E.value;e&&(L.loadAddon(new a.AttachAddon(e)),C("updateState",O.id,!0))},G=()=>{h((()=>{if(M.fit(),"CLOSED"!==T.value){C("updateState",O.id,!0);const{cols:e,rows:t}=L;R({cols:e,rows:t,resize:1})}}))};u((()=>k.value),(e=>{const t=B.value;t&&!e&&(t.style.height=W.value)}));let J=!0;const K=new ResizeObserver((()=>{y.value&&p((()=>{J?J=!1:G()}),200)()}));return d({send:R}),v((()=>{L=new e.Terminal({cursorBlink:!0,fontSize:14,fontFamily:"Monaco, Menlo, Consolas, 'Courier New', monospace",theme:{background:"#333",foreground:"#ececec"}}),M=new t.FitAddon,I(),H(),$(),G(),(()=>{const e=B.value;e&&K.observe(e)})()})),m((()=>{null==K||K.disconnect()})),(e,t)=>(f(),w("div",{ref_key:"terminalRef",ref:B,class:"w-full box"},null,512))}}),[["__scopeId","data-v-12768f9a"]]);export{O as T,S as o};
