import{_ as R}from"./index.vue_vue_type_script_setup_true_lang-D8O2mMsP.js?v=1773287522785";import{_ as k,fc as y,m as C}from"./index-BTglIPU2.js?v=1773287522785";import{_ as N}from"./index.vue_vue_type_script_setup_true_lang-DG86e1NA.js?v=1773287522785";import{k as U,R as S,a6 as q,r as B,e as V,c as E,$ as T,a8 as j,a9 as l,a0 as o,_ as u,S as t,j as I,aa as L,N as O}from"./vue-core-DJjvd5ZC.js?v=1773287522785";import{u as P}from"./index-B5d4M70B.js?v=1773287522785";import{g as z}from"./index-wgWqrNqx.js?v=1773287522785";import{a1 as A,b as F,a6 as G}from"./naive-ui--dJnpVcV.js?v=1773287522785";import"./prismjs-BZPoR7_J.js?v=1773287522785";import"./index-K4YGya6V.js?v=1773287522785";import"./index-COOnaZWq.js?v=1773287522785";const H={class:"w-240px"},J={class:"w-240px"},K={class:"w-240px"},M={class:"w-240px"},Q={class:"ml-8px"},ue=U({__name:"index",setup(W,{expose:c}){const{t:r}=S(),p=P(),{remoteList:m}=q(p),d=B(null),s=V({sid:m.value.length>0?m.value[0].id:null,name:"",db_user:"",password:"",active:!1,ssl:""}),f=E(()=>m.value.map(e=>({label:"".concat(e.ps," (").concat(e.db_host,")"),value:e.id}))),b={name:{required:!0,message:r("Database.form.index_15"),trigger:["blur","change"]},db_user:{required:!0,message:r("Database.form.index_16"),trigger:["blur","change"]},password:{required:!0,message:r("Database.form.index_17"),trigger:["blur","change"]},sid:{trigger:"change",validator:(e,a)=>a===null?new Error(r("Database.form.index_18")):!0}},v=e=>{s.db_user=e},g=()=>{z()},w=()=>{const e=O(s),{sid:a}=e;if(a===null)throw C.error(r("Database.form.index_18")),new Error(r("Database.form.index_18"));return{...e,sid:a,ps:e.name}};return c({onConfirm:async()=>{var e;try{await((e=d.value)==null?void 0:e.validate());const a=w();await y(p.type,a),p.setRefresh(!0)}catch(a){console.warn(a)}}}),(e,a)=>{const _=F,i=A,x=N,D=G,h=k,$=R;return T(),j($,{ref_key:"formRef",ref:d,model:t(s),rules:b,class:"p-20px"},{default:l(()=>[o(i,{label:e.$t("Database.index_12"),path:"name"},{default:l(()=>[u("div",H,[o(_,{value:t(s).name,"onUpdate:value":[a[0]||(a[0]=n=>t(s).name=n),v],placeholder:e.$t("Database.form.index_2"),"input-props":{name:"name"}},null,8,["value","placeholder"])])]),_:1},8,["label"]),o(i,{label:e.$t("Database.index_13"),path:"db_user"},{default:l(()=>[u("div",J,[o(_,{value:t(s).db_user,"onUpdate:value":a[1]||(a[1]=n=>t(s).db_user=n),placeholder:"Database user","input-props":{name:"user"}},null,8,["value"])])]),_:1},8,["label"]),o(i,{label:e.$t("Database.index_14"),path:"password"},{default:l(()=>[u("div",K,[o(x,{value:t(s).password,"onUpdate:value":a[2]||(a[2]=n=>t(s).password=n),"input-props":{name:"password"}},null,8,["value"])])]),_:1},8,["label"]),o(i,{label:e.$t("Database.form.index_9"),path:"sid"},{default:l(()=>[u("div",M,[o(D,{value:t(s).sid,"onUpdate:value":a[3]||(a[3]=n=>t(s).sid=n),class:"server-select",options:t(f)},null,8,["value","options"])]),u("div",Q,[o(h,{onClick:g},{default:l(()=>[I(L(e.$t("Database.form.index_10")),1)]),_:1})])]),_:1},8,["label"])]),_:1},8,["model"])}}});export{ue as default};
