import{C as e,E as t,Ht as n,Q as r,R as i,W as a,b as o,f as s,ut as c,w as l,y as u}from"./vue.runtime.esm-bundler-56z_v_HH.js";import{t as d}from"./notification.store-EczSZ_VB.js";import{n as f,r as p}from"./error-handling-S7N4FACK.js";import{n as m}from"./vue-i18n-DhldrKy8.js";import{I as h}from"./main-CkEZzrzw.js";import{n as g,t as _}from"./MailTestModal-qxcF9_aw.js";import{t as v}from"./MailConfigurationForm-B2XI8M18.js";var y={key:0,class:`mt-14`},b=t({__name:`AdminMailConfigView`,setup(t){let{t:b}=m(),x=h(),S=d(),C=c(!1),w=c(!1),T=c(null),E=c([]);D();async function D(){w.value=!0;try{let[e,t]=await Promise.all([g.getDrivers(),g.getConfig()]);E.value=e,T.value=t}catch(e){let t=p(e);S.showNotification({type:`error`,message:f(t.message)??t.message})}finally{w.value=!1}}async function O(e){C.value=!0;try{(await g.saveConfig(e)).success&&(S.showNotification({type:`success`,message:`settings.mail.mail_config_updated`}),T.value&&={...T.value,...e})}catch(e){let t=p(e);S.showNotification({type:`error`,message:f(t.message)??t.message})}finally{C.value=!1}}function k(){x.openModal({title:b(`general.test_mail_conf`),componentName:`MailTestModal`,size:`sm`})}return(t,c)=>{let d=a(`BaseButton`),f=a(`BaseSettingCard`);return i(),o(s,null,[l(_,{"store-type":`global`}),l(f,{title:t.$t(`settings.mail.mail_config`),description:t.$t(`settings.mail.mail_config_desc`)},{default:r(()=>[T.value?(i(),o(`div`,y,[l(v,{"config-data":T.value,"is-saving":C.value,"mail-drivers":E.value,"is-fetching-initial-data":w.value,onSubmitData:O},{default:r(()=>[l(d,{variant:`primary-outline`,type:`button`,class:`ml-2`,"content-loading":w.value,onClick:k},{default:r(()=>[e(n(t.$t(`general.test_mail_conf`)),1)]),_:1},8,[`content-loading`])]),_:1},8,[`config-data`,`is-saving`,`mail-drivers`,`is-fetching-initial-data`])])):u(``,!0)]),_:1},8,[`title`,`description`])],64)}}});export{b as default};