import{g as w,D as C,i as S,u as b,r as k,cg as A,a as E,j as e,em as B,a1 as M,b as x,_ as i,aQ as H,J as P,$ as _,H as c,f as j}from"./main-634.js";import{m as D,n as I,d as R}from"./bf-25-81.js";function L(){var h;const{formType:d,formID:n,id:s}=w(),g=C(),[l,m]=S(H),r=b(P),[o]=k.useState(()=>r.filter(a=>!A.includes(a.typ))),{css:p}=E(),$=b(_),{isPro:u}=$,y=a=>{const t=c(l);t[s].title=a.target.value,m(t)},v=a=>{const t=c(l);t[s].sub=a.target.value,m(t)},T=a=>{m(t=>j(t,F=>{F[s].body=a}))},f=a=>{const t=c(l);t[s].sub+=a.target.value,m(t)},N=()=>{const a=j(l,t=>{t.push({updateTem:1})});m(a),g(`/form/settings/${d}/${n}/email-templates`)};return l.length<1?e.jsx(B,{to:`/form/settings/edit/${n}/email-templates`,replace:!0}):e.jsxs("div",{style:{width:900},children:[e.jsxs(M,{to:`/form/settings/${d}/${n}/email-templates`,className:`${p(x.btn)} btcd-btn-o-gray`,children:[e.jsx(D,{className:"mr-1"}),i("Back")]}),e.jsx("button",{id:"secondary-update-btn",onClick:N,className:`${p(x.btn)} blue f-right`,type:"button",children:i("Update Template")}),e.jsxs("div",{className:"mt-3 flx",children:[e.jsx("b",{style:{width:102},children:i("Template Name:")}),e.jsx("input",{onChange:y,type:"text",className:"btcd-paper-inp w-9",placeholder:"Name",value:l[s].title})]}),e.jsxs("div",{className:"mt-3 flx",children:[e.jsx("b",{style:{width:100},children:i("Subject:")}),e.jsx("input",{onChange:v,type:"text",className:"btcd-paper-inp w-7",placeholder:i("Email Subject Here"),value:l[s].sub}),e.jsxs("select",{onChange:f,className:"btcd-paper-inp ml-2",style:{width:150},children:[e.jsx("option",{value:"",children:i("Add field")}),e.jsx("optgroup",{label:"Form Fields",children:o!==null&&o.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 ${u?"":"(PRO)"}`,children:u&&((h=I)==null?void 0:h.map(a=>e.jsx("option",{value:`\${${a.name}}`,children:a.label},`ff-rm-${a.name}`)))})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("div",{children:e.jsx("b",{children:i("Body:")})}),e.jsx("label",{htmlFor:`t-m-e-${s}-${n}`,className:"mt-2 w-10",children:e.jsx(R,{id:`mail-tem-${n}`,formFields:r,value:l[s].body,onChangeHandler:T,width:"100%",mapAllFieldWithTable:!0,mapAllField:!0,height:"400"})})]})]})}export{L as default};
