import{_ as j}from"./index.vue_vue_type_script_setup_true_lang-D8O2mMsP.js?v=1773287522785";import{u as L,t as O,h as Z,i as z}from"./terminal-CFfBeKvv.js?v=1773287522785";import{i as A}from"./index-BTglIPU2.js?v=1773287522785";import{u as F}from"./useLoading-CZ2gSAW7.js?v=1773287522785";import{ad as G,k as H,a1 as J,b as K,_ as M,a3 as Q,ag as W,B as X}from"./naive-ui--dJnpVcV.js?v=1773287522785";import{k as Y,R as ee,r as ae,e as te,w as oe,$ as i,Z as w,S as o,a8 as b,a9 as l,j as g,aa as v,ak as ne,a0 as t}from"./vue-core-DJjvd5ZC.js?v=1773287522785";import"./xterm-dpUsuiNl.js?v=1773287522785";import"./useSocket-DTHwGZgK.js?v=1773287522785";import"./data-BVsViUMm.js?v=1773287522785";import"./xterm-addon-canvas-DELv9KNm.js?v=1773287522785";import"./prismjs-BZPoR7_J.js?v=1773287522785";const re={class:"p-20px"},le={key:1},be=Y({__name:"form",props:{data:{}},setup($,{expose:h}){const x=L(),{t:u}=ee(),T=$,{isEdit:m,row:_,tips:C,localhost:S,onRefresh:d}=T.data,c=ae(null),{loading:U,setLoading:f}=F(),e=te({ip:"",port:22,account:"root",type:1,password:"",key:"",keyPassword:"",remark:""});oe(()=>e.ip,a=>{m||(e.remark=a)});const P={ip:{required:!0,message:u("Security.Conf.Index_28"),trigger:["blur","input"]},port:{required:!0,type:"number",message:u("Security.Conf.Index_28"),trigger:["blur","input"]},account:{required:!0,message:u("Security.Conf.Index_28"),trigger:["blur","input"]},password:{required:!0,message:u("Security.Conf.Index_28"),trigger:["blur","input"]},key:{required:!0,message:u("Security.Conf.Index_28"),trigger:["blur","input"]}},I=async()=>{try{f(!0),await O(y())}finally{f(!1)}},y=()=>({host:e.ip,port:e.port,username:e.account,password:e.type===1?e.password:"",pkey:e.type===2?e.key:"",pkey_passwd:e.type===2?e.keyPassword:"",ps:e.remark}),q=async({hide:a})=>{var n;await((n=c.value)==null?void 0:n.validate()),await Z(y()),x.setRefresh(!0),a(),d==null||d()};return(async()=>{if(S){e.ip="127.0.0.1",e.port=22,e.account="root",e.type=1,e.password="",e.key="",e.keyPassword="",e.remark="127.0.0.1";return}if(m&&_){const{message:a}=await z({host:_.host});A(a)&&(e.ip=a.host,e.port=a.port,e.account=a.username,e.type=a.password?1:2,e.password=a.password,e.key=a.pkey,e.keyPassword=a.pkey_passwd,e.remark=a.ps)}})(),h({onConfirm:q}),(a,n)=>{const B=G,p=K,s=J,D=M,R=H,k=W,E=Q,N=X,V=j;return i(),w("div",re,[o(C)?(i(),b(B,{key:0,class:"mb-16px",type:"warning"},{default:l(()=>[g(v(a.$t("Unable to authenticate automatically, please fill in the login information of the local server!")),1)]),_:1})):ne("",!0),t(V,{ref_key:"formRef",ref:c,model:o(e),rules:P},{default:l(()=>[t(R,null,{default:l(()=>[t(s,{label:a.$t("Term.index_8"),path:"ip"},{default:l(()=>[t(p,{class:"w-190px!",value:o(e).ip,"onUpdate:value":n[0]||(n[0]=r=>o(e).ip=r),placeholder:a.$t("Term.index_9")},null,8,["value","placeholder"])]),_:1},8,["label"]),t(s,{path:"port"},{default:l(()=>[t(D,{"show-button":!1,class:"w-80px!",value:o(e).port,"onUpdate:value":n[1]||(n[1]=r=>o(e).port=r),placeholder:a.$t("Docker.Container.create.index_7")},null,8,["value","placeholder"])]),_:1})]),_:1}),t(s,{label:a.$t("Term.index_10"),path:"account"},{default:l(()=>[t(p,{class:"w-280px!",value:o(e).account,"onUpdate:value":n[2]||(n[2]=r=>o(e).account=r),placeholder:a.$t("Term.index_11")},null,8,["value","placeholder"])]),_:1},8,["label"]),t(s,{label:a.$t("Term.index_12")},{default:l(()=>[t(E,{value:o(e).type,"onUpdate:value":n[3]||(n[3]=r=>o(e).type=r)},{default:l(()=>[t(k,{label:a.$t("Database.index_14"),value:1},null,8,["label"]),t(k,{label:a.$t("Term.index_13"),value:2},null,8,["label"])]),_:1},8,["value"])]),_:1},8,["label"]),o(e).type===1?(i(),b(s,{key:0,label:a.$t("Database.index_14"),path:"password"},{default:l(()=>[t(p,{class:"w-280px!",value:o(e).password,"onUpdate:value":n[4]||(n[4]=r=>o(e).password=r),placeholder:a.$t("Term.index_14")},null,8,["value","placeholder"])]),_:1},8,["label"])):(i(),w("div",le,[t(s,{label:a.$t("Term.index_13"),path:"key"},{default:l(()=>[t(p,{class:"w-280px!",type:"textarea",value:o(e).key,"onUpdate:value":n[5]||(n[5]=r=>o(e).key=r),placeholder:a.$t("Term.index_15")},null,8,["value","placeholder"])]),_:1},8,["label"]),t(s,{label:a.$t("Term.index_16")},{default:l(()=>[t(p,{class:"w-280px!",value:o(e).keyPassword,"onUpdate:value":n[6]||(n[6]=r=>o(e).keyPassword=r),placeholder:a.$t("Term.index_17")},null,8,["value","placeholder"])]),_:1},8,["label"])])),t(s,{label:"Remarks"},{default:l(()=>[t(p,{class:"w-280px!",value:o(e).remark,"onUpdate:value":n[7]||(n[7]=r=>o(e).remark=r),placeholder:a.$t("Term.index_18")},null,8,["value","placeholder"])]),_:1}),t(s,{label:" ","show-feedback":!1},{default:l(()=>[t(N,{onClick:I,loading:o(U)},{default:l(()=>[g(v(a.$t("Test connection")),1)]),_:1},8,["loading"])]),_:1})]),_:1},8,["model"])])}}});export{be as default};
