const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["js/form9.js?v=1764233927359","js/index.vue_vue_type_script_setup_true_lang.js?v=1764233927359","js/vue.js?v=1764233927359","js/__commonjsHelpers__.js?v=1764233927359","js/naive.js?v=1764233927359","js/common.js?v=1764233927359","js/page_layout.js?v=1764233927359","js/public.js?v=1764233927359","css/public.css?v=1764233927359","css/page_layout.css?v=1764233927359","js/xterm.js?v=1764233927359","js/xterm-addon-canvas.js?v=1764233927359","css/xterm-addon-canvas.css?v=1764233927359"])))=>i.map(i=>d[i]);
import{x as e,a as t,b as a,c as s}from"./xterm.js?v=1764233927359";import{x as o}from"./xterm-addon-canvas.js?v=1764233927359";import{r as n,_ as i,k as r,P as c,af as d,a0 as l,w as u,ap as p,o as m,b as v,R as _,V as f,n as h}from"./vue.js?v=1764233927359";import{bf as x,i as g,a as w,x as A,e as b,dF as y,p as S}from"./page_layout.js?v=1764233927359";import{u as O,d as T,C}from"./public.js?v=1764233927359";const{t:M}=g.global,I=e=>x.post("/xterm?action=create_host",e,{requestOptions:{loading:M("Security.Api.Index_4"),successMessage:!0}}),j=e=>x.post("/xterm?action=get_host_find",e),k=e=>x.post("/xterm?action=remove_host",e,{requestOptions:{loading:M("Security.Api.Index_3"),successMessage:!0}}),q=()=>x.post("/xterm?action=get_command_list"),D=e=>x.post("/xterm?action=create_command",e,{requestOptions:{loading:M("Security.Api.Index_4"),successMessage:!0}}),R=e=>x.post("/xterm?action=modify_command",e,{requestOptions:{loading:M("Crontab.Api.index_5"),successMessage:!0}}),E=e=>x.post("/xterm?action=remove_command",e,{requestOptions:{loading:M("Security.Api.Index_3"),successMessage:!0}}),{t:F}=g.global,L=e=>{O({title:e.title,width:600,footer:!0,data:e.data,component:i(()=>w(()=>import("./form9.js?v=1764233927359"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])))})},{loading:P}=T(),z=n([]),B=async()=>{const{message:e}=await x.post("/xterm?action=get_host_list");A(e)&&(z.value=e)},V=n("aaaaaaaaa"),H=n([{id:"aaaaaaaaa",host:"127.0.0.1",port:22,ps:F("Database.form.index_12"),state:!0}]),N=e=>{V.value=e},U=e=>{const t=b(9,"letter");H.value.push({id:t,host:e.host,port:e.port,ps:e.ps,state:!0}),setTimeout(()=>{N(t)},20)},W=(e,t)=>{H.value=H.value.map(a=>a.id===e?{...a,state:t}:a)},$=()=>({activeTerminalId:V,terminals:H,setActiveTerminal:N,onServerList:U,onUpdateState:W}),G=S(r({__name:"terminal",props:{data:{},active:{type:Boolean}},emits:["updateState","connectSuccess"],setup(i,{expose:r,emit:x}){const{t:g}=c(),w=i,{data:A}=w,{active:b}=d(w),S=x,O=y(),{isFull:T}=l(O),{ws:M,status:I,send:j,open:k,close:q}=C("/webssh",{get verifyData(){return{host:A.host,port:A.port,id:A.id,ps:A.ps,sort:0}},onMessage:(e,t)=>{const a=t.data;if(a.indexOf("Authentication timeout.")>-1)F.value=!0;else{if(!(-1===a.indexOf("127.0.0.1:")&&-1===a.indexOf("localhost:")||-1===a.indexOf("Password or private key cannot both be empty")&&-1===a.indexOf("Account or Password incorrect: Authentication failed")))return S("updateState",A.id,!1),q(),U(),void D();if("\\r\\nlogout\\r\\n"==a||"logout\\r\\n"==a||"\r\nlogout\r\n"==a||"logout\r\n"==a||a.search(/logout[\r\n]+$/)>-1)return S("updateState",A.id,!1),R.write("\r"+g("Component.Terminal.index_1")+"\r"),U(),void q()}S("connectSuccess",a)}}),D=()=>{L({title:g("Term.index_22"),data:{isEdit:!0,tips:!0,localhost:!0,onRefresh:()=>{A.host.includes("127.0.0.1")&&!A.host.includes("_22")&&(A.host=A.host.replace("127.0.0.1","127.0.0.1_22")),G()}}})};let R,E;const F=n(!1),P=n(null),V=()=>{const e=M.value;e&&(R.loadAddon(E),R.loadAddon(new o.CanvasAddon),R.loadAddon(new a.WebLinksAddon),R.loadAddon(new s.AttachAddon(e)),setTimeout(()=>{E.fit();const e=P.value;e&&(W.value="".concat(e.clientHeight,"px"))},100))},H=()=>{P.value&&R.open(P.value)};let N=!1;const U=()=>{N=!1},W=n(""),$=()=>{R.focus(),R.onData(e=>{const t=M.value;"\r"===e&&F.value&&(F.value=!1,R.write("\r\n"),G()),void 0!==t||"\r"!==e||N||(N=!0,R.write("\r\n"+g("Component.Terminal.index_2")+"\r\n"),G())})},G=()=>{k(),$();const e=M.value;e&&(R.loadAddon(new s.AttachAddon(e)),S("updateState",A.id,!0))},J=()=>{h(()=>{if(E.fit(),"CLOSED"!==I.value){S("updateState",A.id,!0);const{cols:e,rows:t}=R;j({cols:e,rows:t,resize:1})}})};u(()=>T.value,e=>{const t=P.value;t&&!e&&(t.style.height=W.value)});let K=!0;const Q=new ResizeObserver(()=>{b.value&&p(()=>{K?K=!1:J()},200)()});r({send:j});return m(async()=>{await(async()=>{await B(),z.value.some(e=>"127.0.0.1_22"===e.host)&&"127.0.0.1"===A.host&&(A.host="127.0.0.1_22")})(),R=new e.Terminal({cursorBlink:!0,fontSize:14,fontFamily:"Monaco, Menlo, Consolas, 'Courier New', monospace",theme:{background:"#333",foreground:"#ececec"}}),E=new t.FitAddon,V(),H(),$(),J(),(()=>{const e=P.value;e&&Q.observe(e)})()}),v(()=>{null==Q||Q.disconnect()}),(e,t)=>(f(),_("div",{ref_key:"terminalRef",ref:P,class:"w-full box"},null,512))}}),[["__scopeId","data-v-03ea5778"]]);export{G as T,D as a,E as b,q as c,k as d,R as e,I as f,B as g,j as h,P as l,L as o,z as s,$ as u};
