var T=Object.defineProperty;var N=Object.getOwnPropertySymbols;var S=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;var F=(e,a,t)=>a in e?T(e,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[a]=t,p=(e,a)=>{for(var t in a||(a={}))S.call(a,t)&&F(e,t,a[t]);if(N)for(var t of N(a))k.call(a,t)&&F(e,t,a[t]);return e};import{j as s,_ as c,L}from"./main.2.9.0.js";import{b as y}from"./react-router.DMwpH23k.js";import{a as R,u as U}from"./CopyIcn.CEA_lFLo.js";import{b as M}from"./Table.BfF8RYFZ.js";import{h as _,g as E,a as O}from"./OneDriveCommonFunc.BBNhC02r.js";function V({oneDriveConf:e,setOneDriveConf:a,formFields:t,formID:n,setSnackbar:x}){var w;e.folderMap?e.folderMap[0]:e.folder;const[o,h]=y.useState(!1),[b,i]=y.useState({show:!1}),d=(l,g,m)=>{const f=p({},e);l!==""?f.actions.attachments=l:(delete f.actions.attachments,delete f.actions.share.file),a(p({},f))},j=(l,g)=>{const m=p({},e);l.target.checked?m.actions.delete_from_wp=!0:delete m.actions.delete_from_wp,a(p({},m))},u=()=>{var l,g,m;(l=e.actions)!=null&&l.share||(e.actions.share={}),(m=(g=e.actions)==null?void 0:g.share)!=null&&m.file||(e.actions.share.file={permissions:[{email:"",access:"34",accessLabel:"View"},{email:"",access:"5",accessLabel:"Edit"},{email:"",access:"4",accessLabel:"Share"},{email:"",access:"6",accessLabel:"View and Comment"}],mail:"false"}),i({show:"attachments"})},r=()=>t.filter(l=>l.type==="file").map(l=>({label:l.label,value:l.name}));return s.jsxs("div",{className:"pos-rel d-flx w-5",children:[s.jsxs("div",{className:"pos-rel d-flx flx-col w-8",children:[s.jsx(M,{onChange:u,checked:"attachments"in e.actions,className:"wdt-200 mt-4 mr-2",value:"Attachment",title:c("Upload Files","bit-integration-pro"),subTitle:c("Add attachments from Bit-integration-pro to OneDrive folder.","bit-integration-pro")}),s.jsx("small",{style:{marginLeft:30,marginTop:10,color:"red",fontWeight:"bold"},children:c("This Required","bit-integrations")})]}),s.jsx(R,{className:"custom-conf-mdl",mainMdlCls:"o-v",btnClass:"purple",btnTxt:"Ok",show:b.show==="attachments",close:()=>i({show:!1}),action:()=>i({show:!1}),title:c("Select Attachment","bitform"),children:s.jsxs("div",{style:{height:"95%"},children:[s.jsx("div",{className:"mt-2",children:c("Select File Upload Fields","bitform")}),s.jsx(U,{defaultValue:e.actions.attachments,className:"mt-2 w-10 mb-25",options:r(),onChange:l=>d(l),height:300})]})}),s.jsx("div",{className:"pos-rel d-flx flx-col w-8",children:s.jsx(M,{checked:((w=e.actions)==null?void 0:w.delete_from_wp)||!1,onChange:l=>j(l),className:"mt-4 mr-2",value:"delete_from_wp",title:c("Delete File From Wordpress","bit-integrations"),subTitle:c("Delete file from Wordpress after upload in OneDrive","bit-integrations")})})]})}function z({formID:e,formFields:a,oneDriveConf:t,setOneDriveConf:n,isLoading:x,setIsLoading:o,setSnackbar:h}){var b;return s.jsxs(s.Fragment,{children:[s.jsx("br",{}),s.jsx("b",{className:"wdt-100 d-in-b",children:"Folder:"}),s.jsxs("select",{onChange:i=>_(i,t,n,e,o,h),name:"folder",value:t.folderMap[0]||t.folder,className:"btcd-paper-inp w-7",children:[s.jsx("option",{value:"",children:c("Select Folder","bit-integrations")}),((b=t==null?void 0:t.default)==null?void 0:b.rootFolders)&&t.default.rootFolders.map(i=>s.jsx("option",{value:i.id,children:i.name},i.id))]}),s.jsx("button",{onClick:()=>E(e,t,n,o),className:"icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${c("Refresh  Folders","bit-integrations")}'`},type:"button",disabled:x,children:"↻"}),s.jsx("br",{}),t.folderMap.map((i,d)=>{var j,u;return s.jsxs("div",{children:[s.jsx("br",{}),s.jsxs("div",{className:"flx",children:[s.jsx("b",{className:"wdt-100 d-in-b"}),s.jsx("div",{className:"d-in-b",style:{width:(d+1)*10,marginLeft:1,marginRight:2,height:58,marginTop:-60},children:s.jsx("div",{className:"sub-tree"})}),s.jsxs("div",{className:"flx sub-folder w-7",children:[s.jsxs("select",{onChange:r=>_(r,t,n,e,o,h,d+1),name:"folder",value:t.folderMap[d+1]||t.folder,className:"btcd-paper-inp",children:[s.jsx("option",{value:t.folderMap[d],children:"/ root"}),((u=(j=t==null?void 0:t.default)==null?void 0:j.folders)==null?void 0:u[i])&&t.default.folders[i].map(r=>s.jsx("option",{value:r.id,children:r.name},r.id))]}),s.jsx("button",{onClick:()=>O(e,t,n,o,h,d),className:"d-non icn-btn sh-sm ml-2 mr-2 tooltip",style:{"--tooltip-txt":`'${c("Refresh Sub Folders","bit-integrations")}'`},type:"button",disabled:x,children:"↻"})]})]})]},i)}),s.jsx("br",{}),s.jsx("br",{}),x&&s.jsx(L,{style:{display:"flex",justifyContent:"center",alignItems:"center",height:100,transform:"scale(0.7)"}}),t.folder&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mt-4",children:s.jsx("b",{className:"wdt-100",children:c("Utilities","bit-integrations")})}),s.jsx("div",{className:"btcd-hr mt-1"}),s.jsx(V,{oneDriveConf:t,setOneDriveConf:n,formFields:a,formID:e,setIsLoading:o,setSnackbar:h})]})]})}export{z as O};
