import{r as l,d as i,B as o,h as e}from"./p-f8363b1b.js";import{t as n}from"./p-510e3bc9.js";import{s as t}from"./p-c78d1e1b.js";import"./p-d2ac57a0.js";import"./p-f44f0a67.js";import"./p-3775d1fc.js";import"./p-80de33dc.js";import"./p-c2fbed0d.js";import"./p-5717491f.js";import"./p-de14d315.js";const a=class{constructor(o){l(this,o),this.floodteamCloseModal=i(this,"floodteamCloseModal",7),this.to=[],this.from="info@thefloodteam.com",this.attachments=[],this.users=[],this.hideTemplateSelect=!1}onChange(l){var i;"templateId"===(null===(i=null==l?void 0:l.target)||void 0===i?void 0:i.name)&&(this.templateId=l.target.value)}async onSuccess(l){var i;if("sendTemplateEmail"===(null===(i=l.detail)||void 0===i?void 0:i.endpoint)){const l=document.querySelector("ion-modal.modal-send-email-wrapper");(null==l?void 0:l.dismiss)&&(await l.dismiss(),this.presentToast())}}async presentToast(){(await n.create({message:"Your emails are on their way.",duration:2e3})).present()}onBeforeSubmit(l){return{templateId:(null==l?void 0:l.templateId)?l.templateId:this.templateId?this.templateId:null,attachments:this.attachments,from:(null==l?void 0:l.from)?l.from:this.from?this.from:"info@thefloodteam.com",emails:(null==l?void 0:l.to)?l.to:this.to?this.to:[],filters:this.filters?this.filters:null}}componentWillLoad(){}render(){return[e("ion-header",null,e("ion-toolbar",null,e("ion-title",null,"Send Email"),e("ion-buttons",{slot:"end"},e("ion-button",{onClick:()=>this.formEl.submit(),color:"primary",fill:"solid"},"Send"),e("ion-button",{onClick:()=>this.floodteamCloseModal.emit(),style:{"--color":"var(--ion-text-color)","--color-hover":"var(--ion-color-danger"}},e("ion-icon",{slot:"icon-only",name:"close-circle-outline"}))))),e("ion-content",{style:{"--background":"var(--ion-color-base)"}},e("fireenjin-form",{ref:l=>this.formEl=l,endpoint:"sendTemplateEmail",disableEnterButton:!0,hideControls:!0,beforeSubmit:this.onBeforeSubmit.bind(this)},e("ion-grid",null,e("ion-row",null,e("ion-col",{size:"12",sizeMd:"7"},!this.hideTemplateSelect&&e("fireenjin-select",{ref:l=>this.templateSelectEl=l,name:"templateId",label:"Template",labelPosition:"stacked",placeholder:"Select Message Template",value:this.templateId,options:(t.templates||[]).filter((l=>!(null==l?void 0:l.partial)&&"email"===(null==l?void 0:l.type)&&(!this.templateFilter||this.templateFilter(l)))).map((l=>({label:null==l?void 0:l.subject,value:null==l?void 0:l.id})))}),e("fireenjin-select-tags",{name:"to",label:"Send To",labelPosition:"stacked",placeholder:"Add Emails",allowAdding:!0,value:this.to,options:(this.users||[]).map((l=>({label:(null==l?void 0:l.email)||`${null==l?void 0:l.firstName} ${null==l?void 0:l.lastName} has no Email on File.`,value:null==l?void 0:l.email,disabled:!(null==l?void 0:l.email)})))})),e("ion-col",{size:"12",sizeMd:"5"},this.templateId&&e("floodteam-template",{id:"email-preview",zoom:.3,templateId:this.templateId,data:this.payload||{job:this.job||null}}))),e("ion-row",null,e("ion-col",null,e("fireenjin-chip-bar",null,(this.attachments||[]).map((l=>{var i,o,n,t,a,s;return e("ion-chip",null,e("ion-icon",{name:"document",class:"ft-icon-style"}),e("ion-label",null,decodeURI((null===(s=null===(a=null===(t=null===(n=null===(o=null===(i=null==l?void 0:l.split)||void 0===i?void 0:i.call(l,"/"))||void 0===o?void 0:o.pop)||void 0===n?void 0:n.call(o))||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")))})))))),e("ion-accordion-group",null,e("ion-accordion",null,e("ion-item",{slot:"header"},e("ion-label",null,"Advanced")),e("ion-grid",{slot:"content"},e("ion-row",null,e("ion-col",null,e("fireenjin-input",{name:"subject",label:"Subject",labelPosition:"stacked",placeholder:"Email Subject",value:this.subject}))),e("ion-row",null,e("ion-col",null,e("fireenjin-input",{name:"from",label:"Email From",labelPosition:"stacked",placeholder:"Email Address to Send From",value:this.from})),e("ion-col",null,e("fireenjin-input",{name:"replyTo",label:"Reply To",labelPosition:"stacked",placeholder:"Email Address to Reply",value:this.replyTo}))))))))]}};a.style=".modal-send-email-wrapper{--min-width:300px}modal-send-email ion-item-divider{--padding-start:0px}modal-send-email fireenjin-avatar{margin-left:16px}modal-send-email h5,modal-send-email p{display:block;--ion-color-step-600:#666666;font-size:0.9em}modal-send-email ion-button{display:table;margin-left:0px;margin:0 auto}";export{a as modal_send_email}