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