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