var k=Object.defineProperty;var _=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,M=Object.prototype.propertyIsEnumerable;var $=(r,i,s)=>i in r?k(r,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[i]=s,j=(r,i)=>{for(var s in i||(i={}))w.call(i,s)&&$(r,s,i[s]);if(_)for(var s of _(i))M.call(i,s)&&$(r,s,i[s]);return r};import{u as V,j as e,_ as d,Q as R,$ as z,e as E}from"./main-634.js";import{r as S,a as Z}from"./bf-508-92.js";import{n as I}from"./bf-25-81.js";import{M as L}from"./bf-438-114.js";const f=(r,i,s)=>{const l=j({},i);l.field_map.splice(r,0,{}),s(l)};function O({i:r,formFields:i,field:s,campaignsConf:l,setCampaignsConf:o}){var a,x,v,y,N;const c=s.zohoFormField===""||((a=l.default.fields[l.list].required)==null?void 0:a.indexOf(s.zohoFormField))===-1,b=V(z),{isPro:u}=b,p=t=>{const m=j({},l);m.field_map.length>1&&m.field_map.splice(t,1),o(m)},h=(t,m)=>{const n=j({},l);n.field_map[m][t.target.name]=t.target.value,t.target.value==="custom"&&(n.field_map[m].customValue=""),o(n)},F=(t,m)=>{const n=j({},l);n.field_map[m].customValue=t.target.value,o(n)};return e.jsxs("div",{className:`flx flx-around mt-2 ${c&&"mr-1"}`,children:[e.jsxs("select",{className:"btcd-paper-inp mr-2",name:"formField",value:s.formField||"",onChange:t=>h(t,r),children:[e.jsx("option",{value:"",children:d("Select Field")}),e.jsx("optgroup",{label:"Form Fields",children:i.map(t=>t.type!=="file-up"&&e.jsx("option",{value:t.key,children:t.name},`ff-zhcrm-${t.key}`))}),e.jsx("option",{value:"custom",children:d("Custom...")}),e.jsx("optgroup",{label:`General Smart Codes ${u?"":"(PRO)"}`,children:u&&((x=I)==null?void 0:x.map(t=>e.jsx("option",{value:t.name,children:t.label},`ff-rm-${t.name}`)))})]}),s.formField==="custom"&&e.jsx(L,{onChange:t=>F(t,r),label:d("Custom Value"),className:"mr-2",type:"text",value:s.customValue,placeholder:d("Custom Value")}),e.jsxs("select",{className:"btcd-paper-inp",name:"zohoFormField",value:s.zohoFormField||"",disabled:!c,onChange:t=>h(t,r),children:[e.jsx("option",{value:"",children:d("Select Field")}),c?((N=(y=(v=l==null?void 0:l.default)==null?void 0:v.fields)==null?void 0:y[l.list])==null?void 0:N.fields)&&l.default.fields[l.list].fields.map(t=>t!=="Contact Email"&&e.jsx("option",{value:t,children:t},`${t}-1`)):e.jsx("option",{value:"Contact Email",children:d("Contact Email")},"contact_email")]}),e.jsx("button",{onClick:()=>f(r,l,o),className:`icn-btn sh-sm ml-2 ${!c&&"mr-8"}`,type:"button",children:"+"}),c&&e.jsx("button",{onClick:()=>p(r),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:e.jsx(R,{})})]})}function B({formID:r,formFields:i,handleInput:s,campaignsConf:l,setCampaignsConf:o,isLoading:c,setisLoading:b,setSnackbar:u}){var p,h,F;return e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("b",{className:"wdt-100 d-in-b",children:d("List:")}),e.jsxs("select",{onChange:a=>s(a),name:"list",value:l.list,className:"btcd-paper-inp w-7",children:[e.jsx("option",{value:"",children:d("Select List")}),((p=l==null?void 0:l.default)==null?void 0:p.lists)&&Object.values(l.default.lists).map(a=>e.jsx("option",{value:a.listkey,children:a.listname},a.listkey))]}),e.jsx("button",{onClick:()=>S(r,l,o,b,u),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${d("Refresh Campaigns Lists")}'`},type:"button",disabled:c,children:"↻"}),e.jsx("br",{}),e.jsx("br",{}),c&&e.jsx(E,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:100,transform:"scale(0.7)"}}),l.list&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-4",children:[e.jsx("b",{className:"wdt-100",children:d("Map Fields")}),e.jsx("button",{onClick:()=>Z(r,l,o,b,u),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${d("Refresh Campaigns Contact Fields")}'`},type:"button",disabled:c,children:"↻"})]}),e.jsx("div",{className:"btcd-hr mt-1"}),((F=(h=l.default)==null?void 0:h.fields)==null?void 0:F[l.list])&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flx flx-around mt-2 mb-1",children:[e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:d("Form Fields")})}),e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:d("Zoho Fields")})})]}),l.field_map.map((a,x)=>e.jsx(O,{i:x,field:a,campaignsConf:l,formFields:i,setCampaignsConf:o},`campaigns-m-${x+9}`)),e.jsx("div",{className:"txt-center  mt-2",style:{marginRight:85},children:e.jsx("button",{onClick:()=>f(l.field_map.length,l,o),className:"icn-btn sh-sm",type:"button",children:"+"})})]})]})]})}export{B as Z};
