var S=Object.defineProperty;var g=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;var h=(i,e,t)=>e in i?S(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,b=(i,e)=>{for(var t in e||(e={}))F.call(e,t)&&h(i,t,e[t]);if(g)for(var t of g(e))k.call(e,t)&&h(i,t,e[t]);return i};import{j as a,_ as p}from"./main.2.8.10.js";import{u as A,e as C,b as o}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as I}from"./SnackMsg.7BjcJK1j.js";import{S as _}from"./Steps.B84Ui3GU.js";import{I as w,s as y}from"./Integrations.BFhED4ck.js";import L from"./PipeDriveAuthorization.DB6s7xL5.js";import{h as z,c as E,a as T}from"./PipeDriveCommonFunc.Bgp8U4Wc.js";import{P as M}from"./PipeDriveIntegLayout.Cc3IJ9ew.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";import"./ActionProFeatureComponent.ByowZIj8.js";function ie({formFields:i,setFlow:e,flow:t,allIntegURL:x}){const D=A(),{formID:l}=C(),[u,n]=o.useState(!1),[d,f]=o.useState(1),[P,r]=o.useState({show:!1}),[v,q]=o.useState(0),[s,m]=o.useState({name:"PipeDrive",type:"PipeDrive",api_key:"",default:{modules:{Leads:{required:!0,requiredFields:["title"],relatedlists:[{name:"Notes"},{name:"Activities"}]},Deals:{required:!0,requiredFields:["title"],relatedlists:[{name:"Notes"},{name:"Activities"}]},Activities:{required:!0},Organizations:{required:!0,requiredFields:["name"],relatedlists:[{name:"Activities"},{name:"Deals"},{name:"Leads"},{name:"Notes"},{name:"Persons"}]},Persons:{required:!0,requiredFields:["name"],relatedlists:[{name:"Activities"},{name:"Deals"},{name:"Leads"},{name:"Notes"}]},Products:{requiredFields:["name"]},Notes:{required:!0,requiredFields:["content"]}}},moduleData:{module:""},field_map:[{formField:"",pipeDriveFormField:""}],relatedlists:[],actions:{}}),j=()=>{y({flow:t,setFlow:e,allIntegURL:x,conf:s,navigate:D,setIsLoading:n,setSnackbar:r})},N=c=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!E(s)){r({show:!0,msg:p("Please map mandatory fields","bit-integrations")});return}if(!T(s)){["Leads","Deals","Activities","Notes"].includes(s.moduleData.module)&&r({show:!0,msg:p("Please select a organization or a person","bit-integrations")});return}s.moduleData.module&&s.field_map.length>0&&f(c)};return a.jsxs("div",{children:[a.jsx(I,{snack:P,setSnackbar:r}),a.jsx("div",{className:"txt-center mt-2",children:a.jsx(_,{step:3,active:d})}),a.jsx(L,{formID:l,pipeDriveConf:s,setPipeDriveConf:m,step:d,setstep:f,isLoading:u,setIsLoading:n,setSnackbar:r}),a.jsxs("div",{className:"btcd-stp-page",style:b({},d===2&&{width:900,height:"auto",overflow:"visible"}),children:[a.jsx(M,{tab:v,settab:q,formID:l,formFields:i,handleInput:c=>z(c,v,s,m,l,n,r),pipeDriveConf:s,setPipeDriveConf:m,isLoading:u,setIsLoading:n,setSnackbar:r}),a.jsxs("button",{onClick:()=>N(3),disabled:s.moduleData.module===""||s.field_map.length<1,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[p("Next","bit-integrations"),"  ",a.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),a.jsx(w,{step:d,saveConfig:()=>j(),isLoading:u,dataConf:s,setDataConf:m,formFields:i})]})}export{ie as default};
