var C=Object.defineProperty;var I=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var D=(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)&&D(a,s,t[s]);if(I)for(var s of I(t))F.call(t,s)&&D(a,s,t[s]);return a};import{G as L,g as T,r,f as y,j as i,M as z,ce as $,S as G}from"./main-343.js";import"./bf-649-79.js";import{S as J}from"./bf-149-261.js";import{ac as P,s as B,a7 as H}from"./bf-659-81.js";import{C as q}from"./bf-559-89.js";import{I as K}from"./bf-58-184.js";import{N as Q}from"./bf-713-109.js";import{g as R,O as N}from"./bf-88-91.js";import{O as V}from"./bf-72-221.js";import"./bf-974-82.js";function oe({formFields:a,setIntegration:t,integrations:s,allIntegURL:x}){const w=L(),{formID:p}=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:{}}),v=P([e.type]),j=()=>{setTimeout(()=>{w(`${x}/new/${e.type}`)},1e3),h(!1)},_=(d,g)=>{if(d.integration_type===e.type){const l=JSON.parse(d.integration_details);c(o=>y(o,S=>{S.parentAppId=d.id,S.clientId=l.clientId,S.clientSecret=l.clientSecret,S.tokenDetails=l.tokenDetails})),m(2)}};r.useEffect(()=>{c(d=>y(d,g=>{const l=v.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(p,e,c,f)},[e.parentAppId]),r.useEffect(()=>{window.opener&&B("oneDrive")},[]);const b=()=>{H(s,t,x,e,w)};return i.jsxs("div",{children:[i.jsx(z,{title:$("Authorize New One Drive App"),show:O,setModal:()=>h(!1),children:i.jsx(N,{formID:p,oneDriveConf:e,setOneDriveConf:c,step:n,setStep:m,isLoading:A,setIsLoading:f,setSnackbar:u,authorizedAction:j})}),i.jsx(G,{snack:M,setSnackbar:u}),i.jsx("div",{className:"txt-center w-9 mt-2 cal-width",children:i.jsx(J,{step:3,active:n})}),v.length>0&&n===1&&i.jsx(q,{allIntegURL:x,specificTypes:[e.type],onClickAction:_,allowAddNew:!0,addNewAction:()=>h(!0)}),n===1&&v.length===0&&i.jsx(N,{formID:p,oneDriveConf:e,setOneDriveConf:c,step:n,setStep:m,isLoading:A,setIsLoading:f,setSnackbar:u,authorizedAction:j}),i.jsxs("div",{className:"btcd-stp-page",style:k({},n===2&&{width:900,height:"100%",overflow:"visible"}),children:[i.jsx(V,{formID:p,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{oe as default};
