import{b as E}from"./useflows-BpG3C9m1.js";import{e}from"./main-few-lands-burn.js";import{s as b}from"./machine.-BRuqPpdF.js";import"./mutative-C6xjlr6O.js";import"./lodash-YpNkAOPN.js";const o=t=>({$:a,e:n})=>{a.setThisComponent(m=>{m.value=n}),a.setDb(m=>{m[t]=n})},C=E(({helpers:t})=>({states:{components:[{componentName:t.componentName.mixInput,helperText:e("Email address that will be used to send the email."),id:"from-email",label:e("From Email"),onChange:"HANDLE_FROM_EMAIL",path:"fromEmail",render:!0,required:!0,value:void 0},{componentName:t.componentName.mixInput,helperText:e("Name that will be used to send the email."),id:"from-name",label:e("From Name"),onChange:"HANDLE_FROM_NAME",path:"fromName",render:!0,required:!0,value:void 0},{componentName:t.componentName.mixInput,helperText:e("Email address to which the email will be sent. You can use multiple emails separated by commas."),id:"to-email",label:e("To"),onChange:"HANDLE_TO_EMAIL",path:"toEmail",render:!0,required:!0,value:void 0},{componentName:t.componentName.mixInput,helperText:e("Email address to which a copy of the email will be sent. You can use multiple emails separated by commas."),id:"cc-email",label:e("CC"),onChange:"HANDLE_CC_EMAIL",path:"ccEmail",render:!0,value:void 0},{componentName:t.componentName.mixInput,helperText:e("Email address to which a blind copy of the email will be sent. You can use multiple emails separated by commas."),id:"bcc-email",label:e("BCC"),onChange:"HANDLE_BCC_EMAIL",path:"bccEmail",render:!0,value:void 0},{componentName:t.componentName.mixInput,helperText:e("Email address to which replies will be sent. Make sure it is not same as the from email. If it is same, skip this field."),id:"reply-to-email",label:e("Reply To"),onChange:"HANDLE_REPLY_TO_EMAIL",path:"replyToEmail",render:!0,value:void 0},{componentName:t.componentName.mixInput,helperText:e("Subject of the email."),id:"subject",label:e("Subject"),onChange:"HANDLE_SUBJECT",path:"subject",render:!0,required:!0,value:void 0},{componentName:t.componentName.mixInput,helperText:e('Content of the email. You can map an HTML field here. If you map an HTML field, you must set the "Is this email in HTML format?" option to true.'),id:"body",label:e("Body"),onChange:"HANDLE_BODY",path:"body",render:!0,required:!0,value:void 0},{componentName:t.componentName.mixInput,helperText:e("Enter file URLs or paths separated by commas, or use the button below to pick files directly from the WordPress media library."),id:"attachments",label:e("Attachments"),onChange:"HANDLE_ATTACHMENTS",path:"attachments",render:!0,value:void 0},{componentName:t.componentName.button,fieldType:"config",id:"attachments-picker",onClick:"OPEN_MEDIA_PICKER",render:!0,text:e("Select from Media Library"),tooltip:e("Pick one or more files from the WordPress media library and append their URLs to the field above.")},{componentName:t.componentName.switch,fieldType:"config",id:"mail-format",label:e("Is this email in HTML format?"),onChange:"HANDLE_MAIL_FORMAT",path:"mailFormat",render:!0,value:!1}]},actions:{ON_MACHINE_LOAD:({$:a})=>{b(a,[{db:"fromEmail",id:"from-email"},{db:"fromName",id:"from-name"},{db:"toEmail",id:"to-email"},{db:"ccEmail",id:"cc-email"},{db:"bccEmail",id:"bcc-email"},{db:"replyToEmail",id:"reply-to-email"},{db:"subject",id:"subject"},{db:"body",id:"body"},{db:"attachments",id:"attachments"},{db:"mailFormat",id:"mail-format"}])},HANDLE_ATTACHMENTS:o("attachments"),HANDLE_BCC_EMAIL:o("bccEmail"),HANDLE_BODY:o("body"),HANDLE_CC_EMAIL:o("ccEmail"),HANDLE_FROM_EMAIL:o("fromEmail"),HANDLE_FROM_NAME:o("fromName"),HANDLE_MAIL_FORMAT:o("mailFormat"),HANDLE_REPLY_TO_EMAIL:o("replyToEmail"),HANDLE_SUBJECT:o("subject"),HANDLE_TO_EMAIL:o("toEmail"),OPEN_MEDIA_PICKER:({$:a})=>{if(typeof wp>"u"||!wp.media)return;const n=wp.media({button:{text:e("Select Files")},multiple:!0,title:e("Select Attachments")});n.on("select",()=>{const m=n.state().get("selection").toJSON(),s=a.getComponent("attachments"),r=a.util.isMixInputComponent(s)&&Array.isArray(s.value)?s.value:[],l=[];if(m.length>0){const i=r.at(-1),p=i?.type==="string"&&i.value.trim().endsWith(",");r.length>0&&!p&&l.push({type:"string",value:","}),m.forEach((u,d)=>{const h=l.length>0||r.length>0||d>0?" ":"";l.push({type:"string",value:`${h}${u.url}`}),d<m.length-1&&l.push({type:"string",value:","})})}const c=[...r,...l];a.setComponent("attachments",i=>{a.util.isMixInputComponent(i)&&(i.value=c)}),a.setDb(i=>{i.attachments=c})}),n.open()}}}));export{C as default};
