var I=Object.defineProperty;var j=Object.getOwnPropertySymbols;var C=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var N=(a,e,s)=>e in a?I(a,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[e]=s,_=(a,e)=>{for(var s in e||(e={}))C.call(e,s)&&N(a,s,e[s]);if(j)for(var s of j(e))F.call(e,s)&&N(a,s,e[s]);return a};import{j as i,_ as l,z as c}from"./main.2.8.10.js";import{u as z,b as o}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as E}from"./SnackMsg.7BjcJK1j.js";import{S as L}from"./Steps.B84Ui3GU.js";import{I as P,g as T}from"./Integrations.BFhED4ck.js";import M from"./SuiteDashAuthorization.DiNT1OCX.js";import{c as k}from"./SuiteDashCommonFunc.rSOiNiz1.js";import{S as R}from"./SuiteDashIntegLayout.TTAOeS1X.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";function U({formFields:a,setFlow:e,flow:s,allIntegURL:u}){const g=z(),[f,m]=o.useState(!1),[h,S]=o.useState({}),[r,b]=o.useState(1),[y,p]=o.useState({show:!1}),[t,d]=o.useState({name:"SuiteDash",type:"SuiteDash",public_id:"",secret_key:"",field_map:[{formField:"",suiteDashFormField:""}],actionName:"",suiteDashFields:[],actions:{}}),D=()=>{m(!0),T(s,e,u,t,g,"","",m).then(n=>{var v;n.success?(c.success((v=n.data)==null?void 0:v.msg),g(u)):c.error(n.data||n)})},w=x=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!k(t)){c.error(l("Please map mandatory fields","bit-integrations"));return}if(!t.selectedRole){c.error(l("Please select a Role","bit-integrations"));return}t.field_map.length>0&&b(x)};return i.jsxs("div",{children:[i.jsx(E,{snack:y,setSnackbar:p}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(L,{step:3,active:r})}),i.jsx(M,{suiteDashConf:t,setSuiteDashConf:d,step:r,setStep:b,loading:h,setLoading:S,setSnackbar:p}),i.jsxs("div",{className:"btcd-stp-page",style:_({},r===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(R,{formFields:a,suiteDashConf:t,setSuiteDashConf:d,loading:h,setLoading:S,isLoading:f,setIsLoading:m,setSnackbar:p}),(t==null?void 0:t.actionName)&&i.jsxs("button",{onClick:()=>w(3),disabled:!k(t),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[l("Next","bit-integrations"),"  ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(t==null?void 0:t.actionName)&&i.jsx(P,{step:r,saveConfig:()=>D(),isLoading:f,dataConf:t,setDataConf:d,formFields:a})]})}export{U as default};
