var y=Object.defineProperty;var b=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,f=Object.prototype.propertyIsEnumerable;var v=(n,t,l)=>t in n?y(n,t,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[t]=l,r=(n,t)=>{for(var l in t||(t={}))w.call(t,l)&&v(n,l,t[l]);if(b)for(var l of b(t))f.call(t,l)&&v(n,l,t[l]);return n};import{r as N,j as e,T as g,_ as a,d as A,bu as C,u as T,J as S,f as E}from"./main-634.js";import{j as u,l as M,d as V}from"./bf-25-81.js";function k({formFields:n,mailConf:t,setMailConf:l}){const[p,i]=N.useState({show:!1}),h=(c,x)=>{const m=r({},t);x==="attachments"&&(c!==""?m.actions.attachments=c:delete m.actions.attachments),l(r({},m))};return e.jsxs("div",{className:"pos-rel",children:[e.jsx("div",{className:"d-flx flx-wrp",children:e.jsx(g,{onChange:()=>i({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(A,{className:"custom-conf-mdl",mainMdlCls:"o-v",btnClass:"blue",btnTxt:"Ok",show:p.show==="attachments",close:()=>i({show:!1}),action:()=>i({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(u,{defaultValue:t.actions.attachments,className:"mt-2 w-9",onChange:c=>h(c,"attachments"),options:n.filter(c=>C.includes(c.type)).map(c=>({label:c.name,value:c.key}))})]})]})}function F({formFields:n,mailConf:t,setMailConf:l}){const p=T(S),{userMail:i}=M(),h=()=>{const s=[];i&&Array.isArray(i)&&s.push(...i);const d=[];return n.map(o=>{o.type==="email"&&d.push({label:o.name,value:`\${${o.key}}`})}),s.push({title:"Form Fields",type:"group",childs:d}),s},c=(s,d)=>{l(o=>{const j=r({},o);return j[d]=s,j})},x=s=>{l(d=>E(d,o=>{o.body=s}))},m=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(u,{className:"w-7 mt-2 btcd-paper-drpdwn",defaultValue:t.to,placeholder:a("Add Email Receiver"),onChange:s=>c(s,"to"),options:h(),customValue:!0})]}),e.jsxs("div",{className:"flx",children:[e.jsx("b",{style:{width:100},children:a("CC:")}),e.jsx(u,{className:"w-7 mt-2 btcd-paper-drpdwn",defaultValue:t.cc,placeholder:a("Add Email CC"),onChange:s=>c(s,"cc"),options:h(),customValue:!0})]}),e.jsxs("div",{className:"flx",children:[e.jsx("b",{style:{width:100},children:a("BCC:")}),e.jsx(u,{className:"w-7 mt-2 btcd-paper-drpdwn",defaultValue:t.bcc,placeholder:a("Add Email BCC"),onChange:s=>c(s,"bcc"),options:h(),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:m,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:p,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(k,{mailConf:t,setMailConf:l,formFields:n})]})}export{F as Z};
