import{e,k as t,ay as s,aO as a}from"./vendor-element-plus.js?ver=3.1.10";import{aQ as i,W as n,Y as l,a5 as m,Z as _,aa as c,ab as d,a6 as o,a9 as r,a0 as p,X as f,a8 as h}from"./vendor.js?ver=3.1.10";import{_ as g,I as u}from"./fc-bits-ui.js?ver=3.1.10";const y=window.fcAdmin.auth.email,b={name:"SendTestEmail",components:{Icons:u},props:{campaign:{type:Object,default:()=>({})},btn_text:{type:String,default:()=>""},btn_type:{type:String,default:()=>"default"},placement:{type:String,default:()=>"top"},btn_class:{type:String,default:()=>""},showIcon:{type:Boolean,default:()=>!0}},data:()=>({sending_test:!1,test_email:y}),methods:{sendTestEmail(){if(!this.campaign.email_body)return this.$notify.error({title:this.$t("Oops!"),message:this.$t("Cam_Please_peb"),offset:19});const e=(this.test_email||"").trim();if(e&&!/^[^\s@,;<>]+@[^\s@,;<>]+\.[^\s@,;<>]+$/.test(e))return this.$notify.error({title:this.$t("Oops!"),message:this.$t("Please provide a single valid email address"),offset:19});this.test_email=e,window.last_fc_test_email=this.test_email,this.sending_test=!0,this.$post("campaigns/send-test-email",{campaign:{id:this.campaign.id,settings:this.campaign.settings,email_subject:this.campaign.email_subject,subjects:this.campaign.subjects||[],email_pre_header:this.campaign.email_pre_header,email_body:this.campaign.email_body,design_template:this.campaign.design_template},test_campaign:"yes",email:this.test_email}).then(e=>{this.$notify.success(e.message)}).catch(e=>{this.handleError(e)}).finally(()=>{this.sending_test=!1})}},mounted(){window.last_fc_test_email&&(this.test_email=window.last_fc_test_email)}},v={class:"fcrm_send_test_email_content"},$={class:"fcrm_send_test_email_content_header"},w={class:"fcrm_send_test_email_title"},S={class:"fcrm_send_test_email_description"},j={class:"fcrm_send_test_email_content_footer"},k={class:"fcrm_send_test_email_input_wrap"},E={class:"fcrm_input_hint"},I={class:"icon"},C={key:0,class:"icon"};const O=g(b,[["render",function(g,u,y,b,O,T){const x=e,A=t,P=i("Icons"),V=a,W=s;return n(),l(V,{placement:y.placement,width:"400","popper-class":"fcrm_send_test_email_popover",trigger:"click"},{reference:m(()=>[d(A,{type:y.btn_type,class:p(y.btn_class)},{default:m(()=>[y.showIcon?(n(),f("span",C,[d(P,{"icon-name":"paperPlane"})])):h("",!0),r(" "+c(y.btn_text||g.$t("Send a test email")),1)],void 0,!0),_:1},8,["type","class"])]),default:m(()=>[_("div",v,[_("div",$,[_("h3",w,c(g.$t("Send a test email")),1),_("p",S,c(g.$t("Cam_Type_cetstolbtsc")),1)]),_("div",j,[_("div",k,[d(x,{placeholder:g.$t("Email Address"),modelValue:O.test_email,"onUpdate:modelValue":u[0]||(u[0]=e=>O.test_email=e)},null,8,["placeholder","modelValue"]),o((n(),l(A,{disabled:O.sending_test,onClick:u[1]||(u[1]=e=>T.sendTestEmail()),type:"primary"},{default:m(()=>[r(c(g.$t("Send")),1)],void 0,!0),_:1},8,["disabled"])),[[W,O.sending_test]])]),_("p",E,[_("span",I,[d(P,{"icon-name":"el-icon-info"})]),r(" "+c(g.$t("Some_SmartCode_Not_Work_Alert")),1)])])])],void 0),_:1},8,["placement"])}]]);export{O as S};
