import{r as i,e,B as l,h as o}from"./p-a89095f5.js";import{t as n}from"./p-ef1929d5.js";const t=class{constructor(l){i(this,l),this.fireenjinTrigger=e(this,"fireenjinTrigger",7),this.to=[],this.text=void 0,this.html=void 0,this.template=void 0,this.subject=void 0,this.replyTo=void 0,this.from=void 0,this.attachments=[],this.templateId=void 0,this.partials=void 0,this.frames=void 0,this.templates=void 0,this.users=[],this.templateFilter=void 0,this.hideTemplateSelect=!1,this.filters=void 0,this.helpers=void 0,this.payload=void 0,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 n.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[o("ion-header",null,o("ion-toolbar",null,o("ion-title",null,"Send Email"),o("ion-buttons",{slot:"end"},o("ion-button",{onClick:()=>this.formEl.submit()},o("ion-icon",{slot:"icon-only",name:"send"})),o("ion-button",{onClick:i=>this.fireenjinTrigger.emit({event:i,name:"closeModal"})},o("ion-icon",{slot:"icon-only",name:"close-circle-outline"}))))),o("ion-content",{style:{"--background":"var(--ion-color-base)"}},o("fireenjin-form",{ref:i=>this.formEl=i,endpoint:"sendTemplateEmail",disableEnterButton:!0,hideControls:!0,beforeSubmit:this.onBeforeSubmit.bind(this)},o("ion-grid",null,o("ion-row",null,o("ion-col",{size:"12",sizeMd:"7"},!this.hideTemplateSelect&&o("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"}),o("fireenjin-input",{name:"subject",label:"Subject",labelPosition:"stacked",placeholder:"Email Subject",value:this.subject}),o("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)})))}),o("fireenjin-chip-bar",null,(this.attachments||[]).map((i=>{var e,l,n,t,a,s;return o("ion-chip",null,o("ion-icon",{name:"document",class:"ft-icon-style"}),o("ion-label",null,decodeURI((null===(s=null===(a=null===(t=null===(n=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===n?void 0:n.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")))})))),o("ion-col",{size:"12",sizeMd:"5",class:"ion-no-padding"},this.template&&o("fireenjin-render-template",{id:"email-preview",template:this.template,data:this.payload||{},helpers:this.helpers||{},partials:this.partials||[],zoom:this.zoom||.45})))),o("ion-accordion-group",null,o("ion-accordion",null,o("ion-item",{slot:"header",style:{"--background":"transparent"}},o("ion-label",null,"Advanced")),o("ion-grid",{slot:"content"},o("ion-row",null,o("ion-col",null,o("fireenjin-input",{name:"from",label:"Email From",labelPosition:"stacked",placeholder:"Email Address to Send From",value:this.from})),o("ion-col",null,o("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}