var A=Object.defineProperty,B=Object.defineProperties;var _=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var $=(t,s,l)=>s in t?A(t,s,{enumerable:!0,configurable:!0,writable:!0,value:l}):t[s]=l,d=(t,s)=>{for(var l in s||(s={}))I.call(s,l)&&$(t,l,s[l]);if(T)for(var l of T(s))P.call(s,l)&&$(t,l,s[l]);return t},c=(t,s)=>B(t,_(s));import{r,i as D,u as g,cg as H,g as R,D as G,a as J,j as e,M as L,_ as n,a1 as O,b as f,aQ as Q,J as U,$ as V,f as N}from"./main-634.js";import{m as W,n as q,d as z}from"./bf-25-81.js";function Z(){var y;const[t,s]=r.useState({title:"Untitled Template",sub:"Email Subject",body:"${bf_all_data}"}),[l,v]=D(Q),p=g(U),[u]=r.useState(()=>p.filter(a=>!H.includes(a.typ))),[w,F]=r.useState(!1),{formType:h,formID:m}=R(),S=G(),{css:b}=J(),M=g(V),{isPro:x}=M,C=a=>{s(i=>N(i,o=>{o.body=a}))},j=({target:{name:a,value:i}})=>{s(o=>c(d({},o),{[a]:i}))},E=()=>{const a=N(l,i=>{i.push(t),i.push({updateTem:1})});v(a),S(`/form/settings/${h}/${m}/email-templates`)},k=({target:{value:a}})=>{s(i=>c(d({},i),{sub:i.sub+a})),setTimeout(()=>{a=""},100)};return e.jsxs("div",{style:{width:900},children:[e.jsx(L,{show:w,setModal:F,title:n("Browse Template"),children:e.jsx("h4",{className:"txt-dp",children:n("Email Templates Coming soon")})}),e.jsxs(O,{to:`/form/settings/${h}/${m}/email-templates`,className:`${b(f.btn)} btcd-btn-o-gray`,children:[e.jsx(W,{className:"mr-1"}),n("Back")]}),e.jsx("button",{id:"secondary-update-btn",onClick:E,className:`${b(f.btn)} blue f-right`,type:"button",children:n("Save Template")}),e.jsxs("div",{className:"mt-3 flx",children:[e.jsxs("b",{style:{width:103},children:[n("Template Name:")," "]}),e.jsx("input",{onChange:j,name:"title",type:"text",className:"btcd-paper-inp w-9",placeholder:"Name",value:t.title})]}),e.jsxs("div",{className:"mt-3 flx",children:[e.jsx("b",{style:{width:100},children:"Subject:"}),e.jsx("input",{onChange:j,name:"sub",type:"text",className:"btcd-paper-inp w-7",placeholder:"Email Subject Here",value:t.sub}),e.jsxs("select",{onChange:k,className:"btcd-paper-inp ml-2",style:{width:150},children:[e.jsx("option",{value:"",children:n("Add field")}),e.jsx("optgroup",{label:"Form Fields",children:u!==null&&u.map(a=>!a.type.match(/^(file-up|recaptcha)$/)&&e.jsx("option",{value:`\${${a.key}}`,children:a.name},a.key))}),e.jsx("optgroup",{label:`General Smart Codes ${x?"":"(PRO)"}`,children:x&&((y=q)==null?void 0:y.map(a=>e.jsx("option",{value:`\${${a.name}}`,children:a.label},`ff-rm-${a.name}`)))})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("b",{children:n("Body:")}),e.jsx("label",{htmlFor:`mail-tem-${m}`,className:"mt-2 w-10",children:e.jsx(z,{id:`mail-tem-${m}`,formFields:p,value:t.body,onChangeHandler:C,width:"100%",mapAllFieldWithTable:!0,mapAllField:!0})})]})]})}export{Z as default};
