var C=Object.defineProperty;var D=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var I=(a,t,s)=>t in a?C(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,k=(a,t)=>{for(var s in t||(t={}))E.call(t,s)&&I(a,s,t[s]);if(D)for(var s of D(t))F.call(t,s)&&I(a,s,t[s]);return a};import{D as L,g as T,r,f as y,j as i,M as z,cj as $,S as J}from"./main-634.js";import"./bf-25-81.js";import{S as P}from"./bf-54-258.js";import{ac as B,s as G,a7 as H}from"./bf-746-82.js";import{C as q}from"./bf-4-87.js";import{I as K}from"./bf-942-184.js";import{N as Q}from"./bf-123-109.js";import{g as R,O as N}from"./bf-611-89.js";import{O as V}from"./bf-987-221.js";import"./bf-275-83.js";import"./bf-822-108.js";function re({formFields:a,setIntegration:t,integrations:s,allIntegURL:x}){const v=L(),{formID:d}=T(),[A,f]=r.useState(!1),[n,m]=r.useState(1),[O,h]=r.useState(!1),[M,u]=r.useState({show:!1}),[e,c]=r.useState({name:"OneDrive",type:"OneDrive",clientId:"",clientSecret:"",field_map:[{formField:"",OneDriveFormField:""}],folder:"",folderMap:[],foldersList:[],actions:{}}),j=B([e.type]),w=()=>{setTimeout(()=>{v(`${x}/new/${e.type}`)},1e3),h(!1)},_=(p,g)=>{if(p.integration_type===e.type){const l=JSON.parse(p.integration_details);c(o=>y(o,S=>{S.parentAppId=p.id,S.clientId=l.clientId,S.clientSecret=l.clientSecret,S.tokenDetails=l.tokenDetails})),m(2)}};r.useEffect(()=>{c(p=>y(p,g=>{const l=j.find(o=>o.id===e.parentAppId);if(l){const o=JSON.parse(l.integration_details);g.clientId=o.clientId,g.clientSecret=o.clientSecret,g.tokenDetails=o.tokenDetails}})),e!=null&&e.parentAppId&&R(d,e,c,f)},[e.parentAppId]),r.useEffect(()=>{window.opener&&G("oneDrive")},[]);const b=()=>{H(s,t,x,e,v)};return i.jsxs("div",{children:[i.jsx(z,{title:$("Authorize New One Drive App"),show:O,setModal:()=>h(!1),children:i.jsx(N,{formID:d,oneDriveConf:e,setOneDriveConf:c,step:n,setStep:m,isLoading:A,setIsLoading:f,setSnackbar:u,authorizedAction:w})}),i.jsx(J,{snack:M,setSnackbar:u}),i.jsx("div",{className:"txt-center w-9 mt-2 cal-width",children:i.jsx(P,{step:3,active:n})}),j.length>0&&n===1&&i.jsx(q,{allIntegURL:x,specificTypes:[e.type],onClickAction:_,allowAddNew:!0,addNewAction:()=>h(!0)}),n===1&&j.length===0&&i.jsx(N,{formID:d,oneDriveConf:e,setOneDriveConf:c,step:n,setStep:m,isLoading:A,setIsLoading:f,setSnackbar:u,authorizedAction:w}),i.jsxs("div",{className:"btcd-stp-page",style:k({},n===2&&{width:900,height:"100%",overflow:"visible"}),children:[i.jsx(V,{formID:d,formFields:a,oneDriveConf:e,setOneDriveConf:c,isLoading:A,setIsLoading:f,setSnackbar:u,setShowMdl:h}),i.jsx(Q,{nextPageHandler:()=>m(3),disabled:!e.actions.attachments||!e.folder})]}),i.jsx(K,{step:n,saveConfig:()=>b()})]})}export{re as default};
