import{_ as e}from"./index.vue_vue_type_script_setup_true_lang.js?v=1764830988434";import{t as a,f as l,h as t}from"./terminal2.js?v=1764830988434";import{da as r,d as s}from"./page_layout.js?v=1764830988434";import{d as o}from"./public.js?v=1764830988434";import{dk as p,da as d,dR as n,au as u,df as i,dT as c,e1 as m,aC as _}from"./naive.js?v=1764830988434";import{k as y,P as f,r as v,e as k,w,R as x,V as h,a2 as b,an as g,W as $,U as T,a3 as j,j as U,a4 as C}from"./vue.js?v=1764830988434";import"./xterm.js?v=1764830988434";import"./xterm-addon-canvas.js?v=1764830988434";import"./common.js?v=1764830988434";import"./__commonjsHelpers__.js?v=1764830988434";const P={class:"p-20px"},R={key:1},q=y({__name:"form",props:{data:{}},setup(y,{expose:q}){const I=r(),{t:S}=f(),D=y,{isEdit:E,row:H,tips:L,localhost:V,onRefresh:W}=D.data,z=v(null),{loading:A,setLoading:B}=o(),F=k({ip:"",port:22,account:"root",type:1,password:"",key:"",keyPassword:"",remark:""});w(()=>F.ip,e=>{E||(F.remark=e)});const G={ip:{required:!0,message:S("Security.Conf.Index_28"),trigger:["blur","input"]},port:{required:!0,type:"number",message:S("Security.Conf.Index_28"),trigger:["blur","input"]},account:{required:!0,message:S("Security.Conf.Index_28"),trigger:["blur","input"]},password:{required:!0,message:S("Security.Conf.Index_28"),trigger:["blur","input"]},key:{required:!0,message:S("Security.Conf.Index_28"),trigger:["blur","input"]}},J=async()=>{try{B(!0),await a(K())}finally{B(!1)}},K=()=>({host:F.ip,port:F.port,username:F.account,password:1===F.type?F.password:"",pkey:2===F.type?F.key:"",pkey_passwd:2===F.type?F.keyPassword:"",ps:F.remark});return(async()=>{if(V)return F.ip="127.0.0.1",F.port=22,F.account="root",F.type=1,F.password="",F.key="",F.keyPassword="",void(F.remark="127.0.0.1");if(E&&H){const{message:e}=await t({host:H.host});s(e)&&(F.ip=e.host,F.port=e.port,F.account=e.username,F.type=e.password?1:2,F.password=e.password,F.key=e.pkey,F.keyPassword=e.pkey_passwd,F.remark=e.ps)}})(),q({onConfirm:async({hide:e})=>{var a;await(null==(a=z.value)?void 0:a.validate()),await l(K()),I.setRefresh(!0),e(),null==W||W()}}),(a,l)=>{const t=p,r=u,s=n,o=i,y=d,f=m,v=c,k=_,w=e;return h(),x("div",P,[T(L)?(h(),b(t,{key:0,class:"mb-16px",type:"warning"},{default:j(()=>[U(C(a.$t("Unable to authenticate automatically, please fill in the login information of the local server!")),1)]),_:1})):g("",!0),$(w,{ref_key:"formRef",ref:z,model:T(F),rules:G},{default:j(()=>[$(y,null,{default:j(()=>[$(s,{label:a.$t("Term.index_8"),path:"ip"},{default:j(()=>[$(r,{class:"w-190px!",value:T(F).ip,"onUpdate:value":l[0]||(l[0]=e=>T(F).ip=e),placeholder:a.$t("Term.index_9")},null,8,["value","placeholder"])]),_:1},8,["label"]),$(s,{path:"port"},{default:j(()=>[$(o,{"show-button":!1,class:"w-80px!",value:T(F).port,"onUpdate:value":l[1]||(l[1]=e=>T(F).port=e),placeholder:a.$t("Docker.Container.create.index_7")},null,8,["value","placeholder"])]),_:1})]),_:1}),$(s,{label:a.$t("Term.index_10"),path:"account"},{default:j(()=>[$(r,{class:"w-280px!",value:T(F).account,"onUpdate:value":l[2]||(l[2]=e=>T(F).account=e),placeholder:a.$t("Term.index_11")},null,8,["value","placeholder"])]),_:1},8,["label"]),$(s,{label:a.$t("Term.index_12")},{default:j(()=>[$(v,{value:T(F).type,"onUpdate:value":l[3]||(l[3]=e=>T(F).type=e)},{default:j(()=>[$(f,{label:a.$t("Database.index_14"),value:1},null,8,["label"]),$(f,{label:a.$t("Term.index_13"),value:2},null,8,["label"])]),_:1},8,["value"])]),_:1},8,["label"]),1===T(F).type?(h(),b(s,{key:0,label:a.$t("Database.index_14"),path:"password"},{default:j(()=>[$(r,{class:"w-280px!",value:T(F).password,"onUpdate:value":l[4]||(l[4]=e=>T(F).password=e),placeholder:a.$t("Term.index_14")},null,8,["value","placeholder"])]),_:1},8,["label"])):(h(),x("div",R,[$(s,{label:a.$t("Term.index_13"),path:"key"},{default:j(()=>[$(r,{class:"w-280px!",type:"textarea",value:T(F).key,"onUpdate:value":l[5]||(l[5]=e=>T(F).key=e),placeholder:a.$t("Term.index_15")},null,8,["value","placeholder"])]),_:1},8,["label"]),$(s,{label:a.$t("Term.index_16")},{default:j(()=>[$(r,{class:"w-280px!",value:T(F).keyPassword,"onUpdate:value":l[6]||(l[6]=e=>T(F).keyPassword=e),placeholder:a.$t("Term.index_17")},null,8,["value","placeholder"])]),_:1},8,["label"])])),$(s,{label:"Remarks"},{default:j(()=>[$(r,{class:"w-280px!",value:T(F).remark,"onUpdate:value":l[7]||(l[7]=e=>T(F).remark=e),placeholder:a.$t("Term.index_18")},null,8,["value","placeholder"])]),_:1}),$(s,{label:" ","show-feedback":!1},{default:j(()=>[$(k,{onClick:J,loading:T(A)},{default:j(()=>[U(C(a.$t("Test connection")),1)]),_:1},8,["loading"])]),_:1})]),_:1},8,["model"])])}}});export{q as default};
