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.10.js";import{u as C,b as r}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as z}from"./SnackMsg.7BjcJK1j.js";import{S as A}from"./Steps.B84Ui3GU.js";import{I as E,g as L}from"./Integrations.BFhED4ck.js";import O from"./FlowluAuthorization.CfsuXXkZ.js";import{h as M,c as N}from"./FlowluCommonFunc.y89Y8zI_.js";import{F as B}from"./FlowluIntegLayout.BNkcGd8G.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.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};
