import{t as e}from"./XinForm-DX04WSwD.js";import{t}from"./card-BDbI8Gdq.js";import{Ca as n,Ct as r,Dt as i,Ea as a,Jt as o,Pt as s,T as c,c as l,gn as u,qt as d,rt as f,s as p,ya as m,yt as h}from"./index-DThTpSPU.js";var g=a(n(),1);async function _(){return m({url:`/system/mail/config`,method:`get`})}async function v(e){return m({url:`/system/mail/save`,method:`post`,data:e})}async function y(e){return m({url:`/system/mail/test`,method:`post`,data:{to:e}})}var b=p(),{Text:x,Title:S}=f,C=()=>{let{t:n}=l(),a=(0,g.useRef)(null),[f]=s.useForm(),[p]=s.useForm(),[m,C]=(0,g.useState)(!1),w=[{label:n(`system.mail.driver.smtp`),value:`smtp`},{label:n(`system.mail.driver.ses`),value:`ses`},{label:n(`system.mail.driver.mailgun`),value:`mailgun`},{label:n(`system.mail.driver.postmark`),value:`postmark`},{label:n(`system.mail.driver.resend`),value:`resend`},{label:n(`system.mail.driver.log`),value:`log`},{label:n(`system.mail.driver.array`),value:`array`}],T=[{dataIndex:[`other`,`mode`],valueType:`radio`,title:n(`system.mail.mode`),fieldProps:{options:[{label:n(`system.mail.mode.single`),value:`single`},{label:n(`system.mail.mode.failover`),value:`failover`},{label:n(`system.mail.mode.roundrobin`),value:`roundrobin`}]},required:!0,colProps:{span:24}},{dataIndex:[`mail`,`default`],valueType:`radioButton`,title:n(`system.mail.driver`),fieldProps:{options:w},required:!0,colProps:{span:24},dependency:{dependencies:[`other`],visible:e=>e.other?.mode===`single`}},{dataIndex:[`other`,`mailers`],valueType:`checkbox`,title:n(`system.mail.driver`),fieldProps:{options:w},colProps:{span:24},dependency:{dependencies:[`other`],visible:e=>e.other?.mode!==`single`}},{dataIndex:[`mail`,`from`,`address`],valueType:`text`,title:n(`system.mail.from_address`),fieldProps:{placeholder:n(`system.mail.from_address.placeholder`)},required:!0,colProps:{span:12}},{dataIndex:[`mail`,`from`,`name`],valueType:`text`,title:n(`system.mail.from_name`),fieldProps:{placeholder:n(`system.mail.from_name.placeholder`)},required:!0,colProps:{span:12}},{fieldRender:()=>(0,b.jsx)(d,{children:n(`system.mail.smtp.title`)}),dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`smtp`||!!e.other?.mailers?.includes(`smtp`)},colProps:{span:24},noStyle:!0},{dataIndex:[`mail`,`mailers`,`smtp`,`host`],valueType:`text`,title:n(`system.mail.host`),fieldProps:{placeholder:n(`system.mail.host.placeholder`)},required:!0,colProps:{span:16},dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`smtp`||!!e.other?.mailers?.includes(`smtp`)}},{dataIndex:[`mail`,`mailers`,`smtp`,`port`],valueType:`digit`,title:n(`system.mail.port`),fieldProps:{placeholder:n(`system.mail.port.placeholder`)},required:!0,colProps:{span:8},dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`smtp`||!!e.other?.mailers?.includes(`smtp`)}},{dataIndex:[`mail`,`mailers`,`smtp`,`username`],valueType:`text`,title:n(`system.mail.username`),fieldProps:{placeholder:n(`system.mail.username.placeholder`)},required:!0,colProps:{span:12},dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`smtp`||!!e.other?.mailers?.includes(`smtp`)}},{dataIndex:[`mail`,`mailers`,`smtp`,`password`],valueType:`password`,title:n(`system.mail.password`),fieldProps:{placeholder:n(`system.mail.password.placeholder`)},required:!0,colProps:{span:12},dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`smtp`||!!e.other?.mailers?.includes(`smtp`)}},{fieldRender:()=>(0,b.jsx)(d,{children:n(`system.mail.log.title`)}),dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`log`||!!e.other?.mailers?.includes(`log`)},colProps:{span:24},noStyle:!0},{dataIndex:[`mail`,`mailers`,`log`,`channel`],valueType:`text`,title:n(`system.mail.log.channel`),fieldProps:{placeholder:n(`system.mail.log.channel.placeholder`)},required:!0,colProps:{span:24},dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`log`||!!e.other?.mailers?.includes(`log`)}},{fieldRender:()=>(0,b.jsx)(d,{children:n(`system.mail.postmark.title`)}),dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`postmark`||!!e.other?.mailers?.includes(`postmark`)},colProps:{span:24},noStyle:!0},{dataIndex:[`services`,`postmark`,`token`],valueType:`text`,title:n(`system.mail.postmark.token`),fieldProps:{placeholder:n(`system.mail.postmark.token.placeholder`)},required:!0,colProps:{span:24},dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`postmark`||!!e.other?.mailers?.includes(`postmark`)}},{fieldRender:()=>(0,b.jsx)(d,{children:n(`system.mail.resend.title`)}),dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`resend`||!!e.other?.mailers?.includes(`resend`)},colProps:{span:24},noStyle:!0},{dataIndex:[`services`,`resend`,`key`],valueType:`text`,title:n(`system.mail.resend.key`),fieldProps:{placeholder:n(`system.mail.resend.key.placeholder`)},required:!0,colProps:{span:24},dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`resend`||!!e.other?.mailers?.includes(`resend`)}},{fieldRender:()=>(0,b.jsx)(d,{children:n(`system.mail.mailgun.title`)}),dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`mailgun`||!!e.other?.mailers?.includes(`mailgun`)},colProps:{span:24},noStyle:!0},{dataIndex:[`services`,`mailgun`,`domain`],valueType:`text`,title:n(`system.mail.mailgun.domain`),fieldProps:{placeholder:n(`system.mail.mailgun.domain.placeholder`)},required:!0,colProps:{span:12},dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`mailgun`||!!e.other?.mailers?.includes(`mailgun`)}},{dataIndex:[`services`,`mailgun`,`secret`],valueType:`text`,title:n(`system.mail.mailgun.secret`),fieldProps:{placeholder:n(`system.mail.mailgun.secret.placeholder`)},required:!0,colProps:{span:12},dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`mailgun`||!!e.other?.mailers?.includes(`mailgun`)}},{dataIndex:[`services`,`mailgun`,`endpoint`],valueType:`text`,title:n(`system.mail.mailgun.endpoint`),fieldProps:{placeholder:n(`system.mail.mailgun.endpoint.placeholder`)},required:!0,colProps:{span:12},dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`mailgun`||!!e.other?.mailers?.includes(`mailgun`)}},{fieldRender:()=>(0,b.jsx)(d,{children:n(`system.mail.ses.title`)}),dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`ses`||!!e.other?.mailers?.includes(`ses`)},colProps:{span:24},noStyle:!0},{dataIndex:[`services`,`ses`,`key`],valueType:`text`,title:n(`system.mail.ses.key`),fieldProps:{placeholder:n(`system.mail.ses.key.placeholder`)},required:!0,colProps:{span:12},dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`ses`||!!e.other?.mailers?.includes(`ses`)}},{dataIndex:[`services`,`ses`,`secret`],valueType:`text`,title:n(`system.mail.ses.secret`),fieldProps:{placeholder:n(`system.mail.ses.secret.placeholder`)},required:!0,colProps:{span:12},dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`ses`||!!e.other?.mailers?.includes(`ses`)}},{dataIndex:[`services`,`ses`,`region`],valueType:`text`,title:n(`system.mail.ses.region`),fieldProps:{placeholder:n(`system.mail.ses.region.placeholder`)},required:!0,colProps:{span:12},dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`ses`||!!e.other?.mailers?.includes(`ses`)}},{dataIndex:[`services`,`ses`,`token`],valueType:`text`,title:n(`system.mail.ses.token`),fieldProps:{placeholder:n(`system.mail.ses.token.placeholder`)},required:!0,colProps:{span:12},dependency:{dependencies:[`mail`,`other`],visible:e=>e.mail?.default===`ses`||!!e.other?.mailers?.includes(`ses`)}}];(0,g.useEffect)(()=>{E()},[]);let E=async()=>{let{data:e}=await _();e.success&&f.setFieldsValue(e.data)};return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`mb-5`,children:[(0,b.jsx)(S,{level:3,children:n(`system.mail.page.title`)}),(0,b.jsx)(x,{type:`secondary`,children:n(`system.mail.page.description`)})]}),(0,b.jsxs)(h,{gutter:24,children:[(0,b.jsx)(o,{span:16,children:(0,b.jsx)(t,{variant:`borderless`,children:(0,b.jsx)(e,{columns:T,layout:`vertical`,formRef:a,form:f,grid:!0,onFinish:async e=>{await v(e),r.success(n(`system.mail.save.success`))},rowProps:{gutter:[10,0]}})})}),(0,b.jsx)(o,{span:8,children:(0,b.jsx)(t,{title:n(`system.mail.test.title`),children:(0,b.jsxs)(s,{form:p,layout:`vertical`,onFinish:async e=>{try{C(!0),await y(e.to),r.success(n(`system.mail.test.success`))}finally{C(!1)}},children:[(0,b.jsx)(s.Item,{name:`to`,label:n(`system.mail.test.to`),rules:[{required:!0,type:`email`}],children:(0,b.jsx)(i,{placeholder:n(`system.mail.test.to.placeholder`)})}),(0,b.jsx)(u,{type:`primary`,htmlType:`submit`,block:!0,icon:(0,b.jsx)(c,{}),loading:m,children:n(`system.mail.test.send`)})]})})})]})]})};export{C as default};