import{$ as e,C as t,G as n,S as r,Wt as i,_ as a,dt as o,g as s,h as c,u as l,ut as u,v as d,vt as f,z as p,zt as m}from"./vue.runtime.esm-bundler-DAWRyTnP.js";import{t as h}from"./company-CN0LeovV.js";import{n as g}from"./vue-i18n-C4HYJWrq.js";import{K as _,W as v,Z as y,jn as b}from"./main-Gn9UsJwa.js";var x={class:`grid-cols-2 col-span-1 mt-14`},S={class:`divide-y divide-gray-200`},C={__name:`NotificationsSetting`,setup(C){let w=h(),T=o(!1),{t:E}=g(),D=u({notify_invoice_viewed:w.selectedCompanySettings.notify_invoice_viewed,notify_estimate_viewed:w.selectedCompanySettings.notify_estimate_viewed,notification_email:w.selectedCompanySettings.notification_email}),O=b(c(()=>({notification_email:{required:v.withMessage(E(`validation.required`),y),email:v.withMessage(E(`validation.email_incorrect`),_)}})),c(()=>D)),k=c({get:()=>D.notify_invoice_viewed===`YES`,set:async e=>{let t=e?`YES`:`NO`,n={settings:{notify_invoice_viewed:t}};D.notify_invoice_viewed=t,await w.updateCompanySettings({data:n,message:`general.setting_updated`})}}),A=c({get:()=>D.notify_estimate_viewed===`YES`,set:async e=>{let t=e?`YES`:`NO`,n={settings:{notify_estimate_viewed:t}};D.notify_estimate_viewed=t,await w.updateCompanySettings({data:n,message:`general.setting_updated`})}});async function j(){if(O.value.$touch(),O.value.$invalid)return!0;T.value=!0;let e={settings:{notification_email:D.notification_email}};await w.updateCompanySettings({data:e,message:`settings.notification.email_save_message`}),T.value=!1}return(o,c)=>{let u=n(`BaseInput`),h=n(`BaseInputGroup`),g=n(`BaseIcon`),_=n(`BaseButton`),v=n(`BaseDivider`),y=n(`BaseSwitchSection`),b=n(`BaseSettingCard`);return p(),a(b,{title:o.$t(`settings.notification.title`),description:o.$t(`settings.notification.description`)},{default:e(()=>[s(`form`,{action:``,onSubmit:l(j,[`prevent`])},[s(`div`,x,[t(h,{error:f(O).notification_email.$error&&f(O).notification_email.$errors[0].$message,label:o.$t(`settings.notification.email`),class:`my-2`,required:``},{default:e(()=>[t(u,{modelValue:D.notification_email,"onUpdate:modelValue":c[0]||=e=>D.notification_email=e,modelModifiers:{trim:!0},invalid:f(O).notification_email.$error,type:`email`,onInput:c[1]||=e=>f(O).notification_email.$touch()},null,8,[`modelValue`,`invalid`])]),_:1},8,[`error`,`label`]),t(_,{disabled:f(T),loading:f(T),variant:`primary`,type:`submit`,class:`mt-6`},{left:e(e=>[f(T)?d(``,!0):(p(),a(g,{key:0,class:m(e.class),name:`ArrowDownOnSquareIcon`},null,8,[`class`]))]),default:e(()=>[r(` `+i(o.$t(`settings.notification.save`)),1)]),_:1},8,[`disabled`,`loading`])])],32),t(v,{class:`mt-6 mb-2`}),s(`ul`,S,[t(y,{modelValue:k.value,"onUpdate:modelValue":c[2]||=e=>k.value=e,title:o.$t(`settings.notification.invoice_viewed`),description:o.$t(`settings.notification.invoice_viewed_desc`)},null,8,[`modelValue`,`title`,`description`]),t(y,{modelValue:A.value,"onUpdate:modelValue":c[3]||=e=>A.value=e,title:o.$t(`settings.notification.estimate_viewed`),description:o.$t(`settings.notification.estimate_viewed_desc`)},null,8,[`modelValue`,`title`,`description`])])]),_:1},8,[`title`,`description`])}}};export{C as default};