var g=Object.defineProperty;var x=Object.getOwnPropertySymbols;var f=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var j=(i,s,t)=>s in i?g(i,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[s]=t,c=(i,s)=>{for(var t in s||(s={}))f.call(s,t)&&j(i,t,s[t]);if(x)for(var t of x(s))N.call(s,t)&&j(i,t,s[t]);return i};import{k as F,f as v,j as e,_ as n,s as _}from"./main.2.8.10.js";import{g as w}from"./DropboxCommonFunc.Cgn_D7pU.js";import{aa as y}from"./Note.DalStCGz.js";import{a as k}from"./Integrations.BFhED4ck.js";import{b as $}from"./Table.DSsAy4VI.js";const u=(i,s,t)=>{const l=c({},s);l.field_map.splice(i,0,{}),t(c({},l))},D=(i,s,t)=>{const l=c({},s);l.field_map.length>1&&l.field_map.splice(i,1),t(c({},l))};function M({i,formFields:s,field:t,dropboxConf:l,setDropboxConf:r}){var h;const d=F(v),{isPro:m}=d,b=(a,o)=>{const p=c({},l);p.field_map[o][a.target.name]=a.target.value,r(c({},p))};return e.jsx("div",{className:"flx mt-2 mb-2 btcbi-field-map",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:t.formField||"",onChange:a=>b(a,i),children:[e.jsx("option",{value:"",children:n("Select Field","bit-integrations")}),e.jsx("optgroup",{label:n("Form Fields","bit-integrations"),children:s==null?void 0:s.filter(a=>a.type==="file").map(a=>e.jsx("option",{value:a.name,children:a.label},`ff-rm-${a.name}`))}),e.jsx("optgroup",{label:_(n("General Smart Codes %s","bit-integrations"),m?"":`(${n("Pro","bit-integrations")})`),children:m&&((h=k)==null?void 0:h.map(a=>e.jsx("option",{value:a.name,children:a.label},`ff-rm-${a.name}`)))})]}),e.jsxs("select",{className:"btcd-paper-inp",name:"dropboxFormField",value:t.dropboxFormField,onChange:a=>b(a,i),children:[e.jsx("option",{value:"",children:n("Select Folder","bit-integrations")}),y(l.foldersList,"lower_path").map(({name:a,lower_path:o})=>e.jsx("option",{value:o,children:o.substring(1).split("/").map(p=>p.replace("/",">")).join(" > ")},o))]})]}),e.jsx("button",{onClick:()=>u(i,l,r),className:"icn-btn sh-sm ml-2 mr-1",type:"button",children:"+"}),e.jsx("button",{onClick:()=>D(i,l,r),className:"icn-btn sh-sm ml-1",type:"button","aria-label":"btn",children:e.jsx("span",{className:"btcd-icn icn-trash-2"})})]})})}function S({dropboxConf:i,setDropboxConf:s}){var l;const t=(r,d)=>{const m=c({},i);r.target.checked?m.actions.delete_from_wp=!0:delete m.actions.delete_from_wp,s(c({},m))};return e.jsx("div",{className:"pos-rel d-flx w-8",children:e.jsx($,{checked:((l=i.actions)==null?void 0:l.delete_from_wp)||!1,onChange:r=>t(r),className:"mt-4 mr-2",value:"delete_from_wp",title:n("Delete File From Wordpress","bit-integrations"),subTitle:n("Delete file from Wordpress after upload in Dropbox","bit-integrations")})})}function R({flowID:i,formFields:s,dropboxConf:t,setDropboxConf:l}){return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"mt-5",children:[e.jsx("b",{className:"wdt-100",children:n("Field Map","bit-integrations")}),e.jsx("button",{onClick:()=>w(i,t,l),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${n("Fetch All Dropbox Folders","bit-integrations")}'`},type:"button",children:"↻"})]}),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:n("File Input","bit-integrations")})}),e.jsx("div",{className:"txt-dp",children:e.jsx("b",{children:n("Dropbox Folder","bit-integrations")})})]}),t==null?void 0:t.field_map.map((r,d)=>e.jsx(M,{i:d,field:r,formFields:s,dropboxConf:t,setDropboxConf:l},`rp-m-${d+9}`)),e.jsx("div",{className:"txt-center btcbi-field-map-button mt-2",children:e.jsx("button",{onClick:()=>u(t.field_map.length,t,l),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:n("Utilities","bit-integrations")})}),e.jsx("div",{className:"btcd-hr mt-1"}),e.jsx(S,{dropboxConf:t,setDropboxConf:l})]})}export{R as D};
