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.1.js";import{u as F,d as o}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{S as R}from"./SnackMsg.S8DrwLlT.js";import{S as z}from"./Steps.1hz7v9Vj.js";import{I as E,g as L}from"./Integrations.D2bgBas2.js";import T from"./SalesmateAuthorization.CshePpHs.js";import{h as O,c as I}from"./SalesmateCommonFunc.B0_IVjr9.js";import{S as A}from"./SalesmateIntegLayout.BdkStcEg.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./tutorialLinks.kMkIDzcD.js";import"./TutorialLink.BAFX--T3.js";function ee({formFields:a,setFlow:t,flow:s,allIntegURL:u}){const f=F(),[S,p]=o.useState(!1),[b,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:b,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:b,setLoading:h,isLoading:S,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:S,dataConf:e,setDataConf:l,formFields:a})]})}export{ee as default};
