var b=Object.defineProperty;var h=Object.getOwnPropertySymbols;var o=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable;var j=(s,l,a)=>l in s?b(s,l,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[l]=a,d=(s,l)=>{for(var a in l||(l={}))o.call(l,a)&&j(s,a,l[a]);if(h)for(var a of h(l))v.call(l,a)&&j(s,a,l[a]);return s};import{h as N,j as e,L as y}from"./main-333.js";import{j as _,_ as c,k as M,l as $,T as w,o as k}from"./bi.636.93.js";import{f as S}from"./bi.964.811.js";import{T}from"./bi.535.730.js";const V=(s,l,a)=>{const i=d({},l);i.field_map.splice(s,0,{}),a(d({},i))},I=(s,l,a)=>{const i=d({},l);i.field_map.length>1&&i.field_map.splice(s,1),a(d({},i))},g=(s,l,a,i)=>{const n=d({},a);n.field_map[l][s.target.name]=s.target.value,s.target.value==="custom"&&(n.field_map[l].customValue=""),i(d({},n))};function R({i:s,field:l,formFields:a,bitFormConf:i,setBitFormConf:n}){var p,m;const u=N(_),{isPro:x}=u;return e.jsxs("div",{className:"flx mt-2 mb-2 btcbi-field-map",children:[e.jsxs("div",{className:"flx integ-fld-wrp",children:[e.jsxs("select",{className:"btcd-paper-inp mr-2",name:"formField",value:l.formField||"",onChange:t=>g(t,s,i,n),children:[e.jsx("option",{value:"",children:c("Select Field","bit-integrations")}),e.jsx("optgroup",{label:"Form Fields",children:a.map(t=>t.type!=="file"&&e.jsx("option",{value:t.name,children:t.label},`ff-zhcrm-${t.name}`))}),e.jsx("option",{value:"custom",children:c("Custom...","bit-integrations")}),e.jsx("optgroup",{label:`General Smart Codes ${x?"":"(PRO)"}`,children:x&&((p=M)==null?void 0:p.map(t=>e.jsx("option",{value:t.name,children:t.label},`ff-rm-${t.name}`)))})]}),l.formField==="custom"&&e.jsx(T,{onChange:t=>$(t,s,i,n),label:c("Custom Value","bit-integrations"),className:"mr-2",type:"text",value:l.customValue,placeholder:c("Custom Value","bit-integrations"),formFields:a}),e.jsxs("select",{className:"btcd-paper-inp",name:"BitFormMapField",value:l.BitFormMapField||"",onChange:t=>g(t,s,i,n),children:[e.jsx("option",{value:"",children:c("Select Field","bit-integrations")}),((m=i==null?void 0:i.default)==null?void 0:m.fields)&&Object.entries(i.default.fields).map((t,r)=>t[1].typ!=="button"&&e.jsx("option",{value:t[0],children:t[1].lbl},`bitform-${r*2}`))]})]}),e.jsx("button",{onClick:()=>V(s,i,n),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),e.jsx("button",{onClick:()=>I(s,i,n),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:e.jsx(w,{})})]})}function z({formFields:s,handleInput:l,bitFormConf:a,setBitFormConf:i,isLoading:n,setIsLoading:u,setSnackbar:x}){var p,m;return e.jsxs(e.Fragment,{children:[e.jsx("br",{}),e.jsx("b",{className:"wdt-200 d-in-b",children:c("Forms:","bit-integrations")}),e.jsxs("select",{onChange:l,name:"id",value:a.id,className:"btcd-paper-inp w-5",children:[e.jsx("option",{value:"",children:c("Select Form","bit-integrations")}),((p=a==null?void 0:a.default)==null?void 0:p.forms)&&a.default.forms.map(({id:t,form_name:r})=>e.jsx("option",{value:t,children:r},t))]}),e.jsx("button",{onClick:()=>S(a,i,u),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${c("Fetch All Form","bit-integrations")}'`},type:"button",disabled:n,children:"↻"}),e.jsx("br",{}),n&&e.jsx(y,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:100,transform:"scale(0.7)"}}),(a==null?void 0:a.id)&&((m=a.default)==null?void 0:m.fields)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-4",children:e.jsx("b",{className:"wdt-100",children:c("Map Fields","bit-integrations")})}),e.jsx("div",{className:"btcd-hr mt-1"}),e.jsxs("div",{className:"flx flx-around mt-2 mb-2 btcbi-field-map-label",children:[e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:c("Form Fields","bit-integrations")})}),e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:c("Bit Form Fields","bit-integrations")})})]}),(a==null?void 0:a.id)&&(a==null?void 0:a.field_map.map((t,r)=>e.jsx(R,{i:r,field:t,formFields:s,bitFormConf:a,setBitFormConf:i},`sheet-m-${r+9}`))),e.jsx("div",{className:"txt-center btcbi-field-map-button mt-2",children:e.jsx("button",{onClick:()=>k(a.field_map.length,a,i),className:"icn-btn sh-sm",type:"button",children:"+"})}),e.jsx("br",{}),e.jsx("br",{})]}),e.jsx("br",{}),e.jsx("br",{})]})}export{z as B};
