var C=Object.defineProperty;var v=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,E=Object.prototype.propertyIsEnumerable;var j=(a,e,s)=>e in a?C(a,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[e]=s,S=(a,e)=>{for(var s in e||(e={}))z.call(e,s)&&j(a,s,e[s]);if(v)for(var s of v(e))E.call(e,s)&&j(a,s,e[s]);return a};import{j as i,_ as k,z as d}from"./main.2.8.1.js";import{u as F,d as o}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{S as L}from"./SnackMsg.S8DrwLlT.js";import{S as T}from"./Steps.1hz7v9Vj.js";import{I as M,g as P}from"./Integrations.D2bgBas2.js";import A from"./NimbleAuthorization.CdY0hweI.js";import{c as y}from"./NimbleCommonFunc.CVIjJfHy.js";import{N as B}from"./NimbleIntegLayout.Ui3ud2i-.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./tutorialLinks.kMkIDzcD.js";import"./TutorialLink.BAFX--T3.js";function U({formFields:a,setFlow:e,flow:s,allIntegURL:l}){const g=F(),[f,c]=o.useState(!1),[u,b]=o.useState({}),[n,x]=o.useState(1),[_,m]=o.useState({show:!1}),[t,p]=o.useState({name:"Nimble",type:"Nimble",api_key:"",field_map:[{formField:"",nimbleFormField:""}],actionName:"",actions:{}}),w=()=>{c(!0),P(s,e,l,t,g,"","",c).then(r=>{var h;r.success?(d.success((h=r.data)==null?void 0:h.msg),g(l)):d.error(r.data||r)})},I=N=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!y(t)){d.error(k("Please map mandatory fields","bit-integrations"));return}t.field_map.length>0&&x(N)};return i.jsxs("div",{children:[i.jsx(L,{snack:_,setSnackbar:m}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(T,{step:3,active:n})}),i.jsx(A,{nimbleConf:t,setNimbleConf:p,step:n,setStep:x,loading:u,setLoading:b,setSnackbar:m}),i.jsxs("div",{className:"btcd-stp-page",style:S({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(B,{formFields:a,nimbleConf:t,setNimbleConf:p,loading:u,setLoading:b,isLoading:f,setIsLoading:c,setSnackbar:m}),(t==null?void 0:t.actionName)&&i.jsxs("button",{onClick:()=>I(3),disabled:!y(t),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[k("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(M,{step:n,saveConfig:()=>w(),isLoading:f,dataConf:t,setDataConf:p,formFields:a})]})}export{U as default};
