var k=Object.defineProperty;var g=Object.getOwnPropertySymbols;var V=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var y=(e,a,s)=>a in e?k(e,a,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[a]=s,c=(e,a)=>{for(var s in a||(a={}))V.call(a,s)&&y(e,s,a[s]);if(g)for(var s of g(a))P.call(a,s)&&y(e,s,a[s]);return e};import{c as _,V as M,_ as m,u as $,j as n,bu as w,Q as S,$ as B}from"./main-634.js";import{n as O}from"./bf-25-81.js";import{M as q}from"./bf-438-114.js";import{B as A}from"./bf-913-201.js";const E=(e,a,s,o)=>{const t=c({},s);t[e].splice(a,0,{}),o(c({},t))},G=(e,a,s)=>{const o=_({post_type:e==null?void 0:e.post_type},"bitforms_get_metabox_fields").then(t=>{var i,p,r,u;return t!==void 0&&t.success&&((i=t==null?void 0:t.data)!=null&&i.metaboxFields&&a(t.data.metaboxFields),(p=t==null?void 0:t.data)!=null&&p.metaboxFile&&s(t.data.metaboxFile)),((r=t==null?void 0:t.data)==null?void 0:r.metaboxFields.length)!==0||((u=t==null?void 0:t.data)==null?void 0:u.metaboxFile.length)!==0?"Successfully refresh MetaBox Fields.":"MetaBox Fields not found"});M.promise(o,{success:t=>t,error:m("Error Occured"),loading:m("Loading MetaBox Fields...")})},I=(e,a,s,o)=>{const t=c({},s);t[e].length>1&&t[e].splice(a,1),o(c({},t))},j=(e,a,s,o,t)=>{const i=c({},o);i[e][s][a.target.name]=a.target.value,t(c({},i))},Q=e=>!((e!=null&&e.post_map?e.post_map.filter(s=>!s.formField&&s.postField&&s.required):[]).length>0),H=e=>!((e!=null&&e.metabox_map?e.metabox_map.filter(s=>!s.formField&&s.acfField&&s.required):[]).length>0),J=(e,a)=>{const s=_({},"bitforms_get_post_type").then(o=>{var t,i,p;if(o&&o.success){let r=c({},e);return(t=o==null?void 0:o.data)!=null&&t.post_types&&(r=Object.values((i=o==null?void 0:o.data)==null?void 0:i.post_types),a(r)),((p=o==null?void 0:o.data)==null?void 0:p.post_types.length)!==0?"Successfully refresh Post Types.":" Post Types not found"}});M.promise(s,{success:o=>o,error:m("Error Occured"),loading:m("Loading Post Types...")})};function K({i:e,type:a,formFields:s,field:o,dataConf:t,setDataConf:i,customFields:p,fieldType:r}){var f;const u=$(B),{isPro:h}=u,N={metabox:{propName:"metabox_map",fldName:"metaboxField"},post:{propName:"post_map",fldName:"postField"},metaboxFile:{propName:"metabox_file_map",fldName:"metaboxFileUpload"}},{propName:d,fldName:x}=N[a],v=(l,T)=>{const F=c({},t);F[d][T].customValue=l.target.value,i(F)},b=!!p.find(l=>l.key===o[x]&&l.required);return n.jsxs("div",{className:"flx mt-2 mr-1",children:[n.jsxs("div",{className:"flx integ-fld-wrp",children:[n.jsxs("select",{className:"btcd-paper-inp mr-2",name:"formField",value:o.formField||"",onChange:l=>j(d,l,e,t,i),children:[n.jsx("option",{value:"",children:m("Select Field")}),a!=="metaboxFile"?n.jsxs(n.Fragment,{children:[n.jsx(A,{formFields:s,notAllowFieldType:["file-up"]}),n.jsx("option",{value:"custom",children:m("Custom...")})]}):n.jsx("optgroup",{label:"Form Fields",children:s.map(l=>w.includes(l.type)&&n.jsx("option",{value:l.key,children:l.name},`ff-zhcrm-${l.key}`))}),r!=="file"&&n.jsx("optgroup",{label:`General Smart Codes ${h?"":"(PRO)"}`,children:h&&((f=O)==null?void 0:f.map(l=>n.jsx("option",{value:l.name,children:l.label},`ff-rm-${l.name}`)))})]}),o.formField==="custom"&&n.jsx(q,{onChange:l=>v(l,e),label:m("Custom Value"),className:"mr-2",type:"text",value:o.customValue,placeholder:m("Custom Value")}),n.jsxs("select",{className:"btcd-paper-inp",name:x,value:o[x]||"",onChange:l=>j(d,l,e,t,i),disabled:b,children:[n.jsx("option",{value:"",children:m("Select Field")}),p==null?void 0:p.map(l=>n.jsx("option",{value:l.key,children:`${l.name}`},`${l.name}-1`))]})]}),!b&&n.jsxs(n.Fragment,{children:[n.jsx("button",{onClick:()=>E(d,e,t,i),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),n.jsx("button",{onClick:()=>I(d,e,t,i),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:n.jsx(S,{size:"15"})})]})]})}export{K as F,E as a,G as b,Q as c,H as d,J as r};
