var o=Object.defineProperty;var h=Object.getOwnPropertySymbols;var u=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var x=(t,l,s)=>l in t?o(t,l,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[l]=s,c=(t,l)=>{for(var s in l||(l={}))u.call(l,s)&&x(t,s,l[s]);if(h)for(var s of h(l))b.call(l,s)&&x(t,s,l[s]);return t};import{j as e,T as F,_ as d,bp as N,cf as g,W as v}from"./main-343.js";import{af as f}from"./bf-659-81.js";function y({dropboxConf:t,setDropboxConf:l}){var a;const s=(m,r)=>{const i=c({},t);r==="deleteFile"&&(m.target.checked?i.actions.delete_from_wp=!0:delete i.actions.delete_from_wp),l(c({},i))};return e.jsx("div",{className:"pos-rel d-flx w-8",children:e.jsx(F,{checked:((a=t.actions)==null?void 0:a.delete_from_wp)||!1,onChange:m=>s(m,"deleteFile"),className:"mt-4 mr-2",value:"delete_from_wp",title:d("Delete File From Wordpress"),subTitle:d("Delete file from Wordpress after upload in Dropbox")})})}const j=(t,l,s)=>{const a=c({},l);a.field_map.splice(t,0,{}),s(c({},a))},_=(t,l,s)=>{const a=c({},l);a.field_map.length>1&&a.field_map.splice(t,1),s(c({},a))};function k({i:t,formFields:l,field:s,dropboxConf:a,setDropboxConf:m}){const r=(i,n)=>{const p=c({},a);p.field_map[n][i.target.name]=i.target.value,m(c({},p))};return e.jsx("div",{className:"flx mt-2 mr-1",children:e.jsxs("div",{className:"pos-rel flx",children:[e.jsxs("div",{className:"flx integ-fld-wrp",children:[e.jsxs("select",{className:"btcd-paper-inp mr-2",name:"formField",value:s.formField||"",onChange:i=>r(i,t),children:[e.jsx("option",{value:"",children:d("Select Field")}),l==null?void 0:l.filter(i=>N.includes(i.type)).map(i=>e.jsx("option",{value:i.key,children:i.name},`ff-rm-${i.key}`))]}),e.jsxs("select",{className:"btcd-paper-inp",name:"dropboxFormField",value:s.dropboxFormField,onChange:i=>r(i,t),children:[e.jsx("option",{value:"",children:d("Select Folder")}),g(a.foldersList,"lower_path","ASC").map(({name:i,lower_path:n})=>e.jsx("option",{value:n,children:n==null?void 0:n.substring(1).split("/").map(p=>p.replace("/",">")).join(" > ")},n))]})]}),e.jsx("button",{onClick:()=>j(t,a,m),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),e.jsx("button",{onClick:()=>_(t,a,m),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:e.jsx(v,{})})]})})}function D({formID:t,formFields:l,dropboxConf:s,setDropboxConf:a,isLoading:m,setIsLoading:r}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-5",children:[e.jsx("b",{className:"wdt-100",children:d("Field Map")}),e.jsx("button",{onClick:()=>f(t,s,a),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${d("Fetch All Dropbox Folders")}'`},type:"button",children:"↻"})]}),e.jsx("div",{className:"btcd-hr mt-1"}),e.jsxs("div",{className:"flx flx-around mt-2 mb-1",children:[e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:d("File Input")})}),e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:d("Dropbox Folder")})})]}),s==null?void 0:s.field_map.map((i,n)=>e.jsx(k,{i:n,field:i,formFields:l,dropboxConf:s,setDropboxConf:a},`rp-m-${n+9}`)),e.jsx("div",{className:"txt-center  mt-2",style:{marginRight:85},children:e.jsx("button",{onClick:()=>j(s.field_map.length,s,a),className:"icn-btn sh-sm",type:"button",children:"+"})}),e.jsx("br",{}),e.jsx("br",{}),e.jsx("div",{className:"mt-4",children:e.jsx("b",{className:"wdt-100",children:d("Actions")})}),e.jsx("div",{className:"btcd-hr mt-1"}),e.jsx(y,{dropboxConf:s,setDropboxConf:a})]})}export{D};
