var w=Object.defineProperty;var b=Object.getOwnPropertySymbols;var f=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var v=(n,t,l)=>t in n?w(n,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[t]=l,r=(n,t)=>{for(var l in t||(t={}))f.call(t,l)&&v(n,l,t[l]);if(b)for(var l of b(t))N.call(t,l)&&v(n,l,t[l]);return n};import{r as g,j as e,T as A,_ as a,d as C,bp as T,u as y,$ as M,K as S,f as E}from"./main-343.js";import{u as p,d as V}from"./bf-649-79.js";function $({formFields:n,mailConf:t,setMailConf:l}){const[o,h]=g.useState({show:!1}),m=(c,x)=>{const u=r({},t);x==="attachments"&&(c!==""?u.actions.attachments=c:delete u.actions.attachments),l(r({},u))};return e.jsxs("div",{className:"pos-rel",children:[e.jsx("div",{className:"d-flx flx-wrp",children:e.jsx(A,{onChange:()=>h({show:"attachments"}),checked:"attachments"in t.actions,className:"wdt-200 mt-4 mr-2",value:"Attachment",title:a("Attachments"),subTitle:a("Add attachments from BitForm to mail pushed to Zoho Mail.")})}),e.jsxs(C,{className:"custom-conf-mdl",mainMdlCls:"o-v",btnClass:"blue",btnTxt:"Ok",show:o.show==="attachments",close:()=>h({show:!1}),action:()=>h({show:!1}),title:a("Select Attachment"),children:[e.jsx("div",{className:"btcd-hr mt-2"}),e.jsx("div",{className:"mt-2",children:a("Select file upload fields")}),e.jsx(p,{defaultValue:t.actions.attachments,className:"mt-2 w-9",onChange:c=>m(c,"attachments"),options:n.filter(c=>T.includes(c.type)).map(c=>({label:c.name,value:c.key}))})]})]})}function F({formFields:n,mailConf:t,setMailConf:l}){const o=y(M),h=y(S),m=()=>{const s=[];o.userMail&&Array.isArray(o.userMail)&&s.push(...o.userMail);const d=[];return n.map(i=>{i.type==="email"&&d.push({label:i.name,value:`\${${i.key}}`})}),s.push({title:"Form Fields",type:"group",childs:d}),s},c=(s,d)=>{l(i=>{const j=r({},i);return j[d]=s,j})},x=s=>{l(d=>E(d,i=>{i.body=s}))},u=s=>{const d=r({},t);d.subject+=s.target.value,l(r({},d)),s.target.value=""};return e.jsxs("div",{style:{width:875},children:[e.jsxs("div",{className:"flx",children:[e.jsx("b",{style:{width:100},children:a("Type:")}),e.jsxs("select",{onChange:s=>c(s.target.value,"mailType"),className:"btcd-paper-inp",style:{width:150},value:t.mailType,children:[e.jsx("option",{value:"",children:a("Select type")}),e.jsx("option",{value:"send",children:a("Send Email")}),e.jsx("option",{value:"draft",children:a("Save as Draft")})]})]}),e.jsxs("div",{className:"flx",children:[e.jsx("b",{style:{width:100},children:"To:"}),e.jsx(p,{className:"w-7 mt-2 btcd-paper-drpdwn",defaultValue:t.to,placeholder:a("Add Email Receiver"),onChange:s=>c(s,"to"),options:m(),customValue:!0})]}),e.jsxs("div",{className:"flx",children:[e.jsx("b",{style:{width:100},children:a("CC:")}),e.jsx(p,{className:"w-7 mt-2 btcd-paper-drpdwn",defaultValue:t.cc,placeholder:a("Add Email CC"),onChange:s=>c(s,"cc"),options:m(),customValue:!0})]}),e.jsxs("div",{className:"flx",children:[e.jsx("b",{style:{width:100},children:a("BCC:")}),e.jsx(p,{className:"w-7 mt-2 btcd-paper-drpdwn",defaultValue:t.bcc,placeholder:a("Add Email BCC"),onChange:s=>c(s,"bcc"),options:m(),customValue:!0})]}),e.jsxs("div",{className:"mt-2 flx",children:[e.jsx("b",{style:{width:100},children:a("Subject:")}),e.jsx("input",{type:"text",onChange:s=>c(s.target.value,"subject"),className:"btcd-paper-inp w-7",placeholder:a("Email Subject Here"),value:t.subject||""}),e.jsxs("select",{onChange:u,className:"btcd-paper-inp ml-2",style:{width:150},children:[e.jsx("option",{value:"",children:a("Add form field")}),n!==null&&n.map(s=>!s.type.match(/^(file-up|recaptcha)$/)&&e.jsx("option",{value:`\${${s.key}}`,children:s.name},s.key))]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{className:"flx flx-between",children:e.jsx("b",{children:a("Body:")})}),e.jsx(V,{id:"body-content",formFields:h,value:t.body||"",onChangeHandler:x})]}),e.jsx("br",{}),e.jsx("br",{}),e.jsx("div",{className:"mt-4",children:e.jsx("b",{className:"wdt-100",children:a("Actions")})}),e.jsx("div",{className:"btcd-hr mt-1"}),e.jsx($,{mailConf:t,setMailConf:l,formFields:n})]})}export{F as Z};
