import{r as i,d as e,B as l,h as n}from"./p-9b6cc562.js";import{t as o}from"./p-07a452ee.js";const t=class{constructor(l){i(this,l),this.fireenjinTrigger=e(this,"fireenjinTrigger",7),this.to=[],this.attachments=[],this.users=[],this.hideTemplateSelect=!1,this.zoom=.45}onChange(i){var e;"templateId"===(null===(e=null==i?void 0:i.target)||void 0===e?void 0:e.name)&&(this.templateId=i.target.value)}async onSuccess(i){var e;if("sendTemplateEmail"===(null===(e=i.detail)||void 0===e?void 0:e.endpoint)){const i=document.querySelector("ion-modal.modal-send-email-wrapper");(null==i?void 0:i.dismiss)&&(await i.dismiss(),this.presentToast())}}async presentToast(){(await o.create({message:"Your emails are on their way.",duration:2e3})).present()}onBeforeSubmit(i){return{templateId:(null==i?void 0:i.templateId)?i.templateId:this.templateId?this.templateId:null,text:this.text,html:this.html,subject:this.subject,attachments:this.attachments,from:(null==i?void 0:i.from)||this.from,emails:(null==i?void 0:i.to)?i.to:this.to?this.to:[],filters:this.filters?this.filters:null}}componentWillLoad(){}render(){return[n("ion-header",null,n("ion-toolbar",null,n("ion-title",null,"Send Email"),n("ion-buttons",{slot:"end"},n("ion-button",{onClick:()=>this.formEl.submit()},n("ion-icon",{slot:"icon-only",name:"send"})),n("ion-button",{onClick:i=>this.fireenjinTrigger.emit({event:i,name:"closeModal"})},n("ion-icon",{slot:"icon-only",name:"close-circle-outline"}))))),n("ion-content",{style:{"--background":"var(--ion-color-base)"}},n("fireenjin-form",{ref:i=>this.formEl=i,endpoint:"sendTemplateEmail",disableEnterButton:!0,hideControls:!0,beforeSubmit:this.onBeforeSubmit.bind(this)},n("ion-grid",null,n("ion-row",null,n("ion-col",{size:"12",sizeMd:"7"},!this.hideTemplateSelect&&n("fireenjin-select",{ref:i=>this.templateSelectEl=i,name:"templateId",label:"Template",labelPosition:"stacked",placeholder:"Select Message Template",value:this.templateId,options:(this.templates||[]).filter((i=>!(null==i?void 0:i.partial)&&"email"===(null==i?void 0:i.type)&&(!this.templateFilter||this.templateFilter(i)))).map((i=>({label:null==i?void 0:i.subject,value:null==i?void 0:i.id}))),interface:"action-sheet"}),n("fireenjin-input",{name:"subject",label:"Subject",labelPosition:"stacked",placeholder:"Email Subject",value:this.subject}),n("fireenjin-select-tags",{name:"to",label:"Send To",labelPosition:"stacked",placeholder:"Add Emails",allowAdding:!0,value:this.to,options:(this.users||[]).map((i=>({label:(null==i?void 0:i.email)||`${null==i?void 0:i.firstName} ${null==i?void 0:i.lastName} has no Email on File.`,value:null==i?void 0:i.email,disabled:!(null==i?void 0:i.email)})))}),n("fireenjin-chip-bar",null,(this.attachments||[]).map((i=>{var e,l,o,t,a,s;return n("ion-chip",null,n("ion-icon",{name:"document",class:"ft-icon-style"}),n("ion-label",null,decodeURI((null===(s=null===(a=null===(t=null===(o=null===(l=null===(e=null==i?void 0:i.split)||void 0===e?void 0:e.call(i,"/"))||void 0===l?void 0:l.pop)||void 0===o?void 0:o.call(l))||void 0===t?void 0:t.split)||void 0===a?void 0:a.call(t,"?"))||void 0===s?void 0:s[0])||"No File Name")))})))),n("ion-col",{size:"12",sizeMd:"5",class:"ion-no-padding"},this.template&&n("fireenjin-render-template",{id:"email-preview",template:this.template,data:this.payload||{},helpers:this.helpers||{},partials:this.partials||[],zoom:this.zoom||.45})))),n("ion-accordion-group",null,n("ion-accordion",null,n("ion-item",{slot:"header",style:{"--background":"transparent"}},n("ion-label",null,"Advanced")),n("ion-grid",{slot:"content"},n("ion-row",null,n("ion-col",null,n("fireenjin-input",{name:"from",label:"Email From",labelPosition:"stacked",placeholder:"Email Address to Send From",value:this.from})),n("ion-col",null,n("fireenjin-input",{name:"replyTo",label:"Reply To",labelPosition:"stacked",placeholder:"Email Address to Reply",value:this.replyTo}))))))))]}};t.style=".fireenjin-mx-modal-send-email-wrapper{--min-width:300px}fireenjin-mx-modal-send-email ion-item-divider{--padding-start:0px}fireenjin-mx-modal-send-email fireenjin-avatar{margin-left:16px}fireenjin-mx-modal-send-email h5,fireenjin-mx-modal-send-email p{display:block;--ion-color-step-600:#666666;font-size:0.9em}fireenjin-mx-modal-send-email ion-button{display:table;margin-left:0px;margin:0 auto}fireenjin-mx-modal-send-email fireenjin-render-template#email-preview{color:#000000;display:block;margin:auto;border:1px solid var(--ion-color-light-shade);background-color:#ffffff;zoom:0.75;overflow:auto;width:100%;min-height:300px;max-height:300px}";export{t as fireenjin_mx_modal_send_email}