import{k as v,f as x,j as t,_ as A,z as s}from"./main.2.8.10.js";import{u as I,e as E,b as r}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{B as L}from"./BackIcn.BFDZx8No.js";import{S as b}from"./Steps.B84Ui3GU.js";import{I as j,g as C}from"./Integrations.BFhED4ck.js";import N from"./HighLevelAuthorization.BjQGWw9p.js";import{O,c as o,T as a}from"./HighLevelCommonFunc.d8C7ayTH.js";import{H as R}from"./HighLevelIntegLayout.BAAuy458.js";import"./react-vendor.P7K3d6op.js";import"./SnackMsg.7BjcJK1j.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";import"./ProUtilHelpers.CtRYkgop.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.js";function Z({formFields:c,setFlow:f,flow:u,allIntegURL:T}){const g=v(x),{isPro:k}=g,P=I(),{formID:n}=E(),[h,S]=r.useState(!1),[i,p]=r.useState(1),[d,m]=r.useState({auth:!1,customFields:!1,options:!1,contacts:!1,users:!1,hlTasks:!1,pipelines:!1,opportunities:!1}),[e,l]=r.useState({name:"GoHighLevel",type:"GoHighLevel",api_key:"",field_map:[{formField:"",highLevelField:""}],actions:{},tags:[],version:k?"v2":"v1",highLevelFields:[],selectedTags:"",selectedTask:"",contacts:[],selectedContact:"",selectedTaskStatus:"",users:[],selectedUser:"",hlTasks:[],updateTaskId:"",pipelines:[],selectedPipeline:"",stages:[],currentStages:[],selectedStage:"",opportunities:[],selectedOpportunity:""}),_=U=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300);{if(!O.includes(e.selectedTask)&&!o(e)){s.error("Please map all required fields to continue!");return}if(!(e!=null&&e.selectedTask)){s.error("Please select task to continue!");return}if(e.selectedTask===a.UPDATE_CONTACT&&!e.selectedContact&&!o(e)){s.error("Please select a contact or map fields!");return}if((e.selectedTask===a.CREATE_TASK||e.selectedTask===a.UPDATE_TASK)&&!e.selectedContact&&!o(e)){s.error("Please select a contact or map fields!");return}if(e.selectedTask===a.UPDATE_TASK&&!e.updateTaskId&&!o(e)){s.error("Please select a task or map fields!");return}if(e.selectedTask===a.CREATE_OPPORTUNITY||e.selectedTask===a.UPDATE_OPPORTUNITY){if(!e.selectedPipeline){s.error("Please select a pipeline!");return}if(!e.selectedStage){s.error("Please select a stage!");return}if(!e.selectedTaskStatus){s.error("Please select a status!");return}}e.name!==""&&e.field_map.length>0&&p(3)}};return t.jsxs("div",{children:[t.jsx("div",{className:"txt-center mt-2",children:t.jsx(b,{step:3,active:i})}),t.jsx(N,{formID:n,highLevelConf:e,setHighLevelConf:l,step:i,setstep:p,loading:d,setLoading:m}),t.jsxs("div",{className:"btcd-stp-page",style:{width:i===2&&900,height:i===2&&"auto"},children:[t.jsx(R,{formID:n,formFields:c,highLevelConf:e,setHighLevelConf:l,loading:d,setLoading:m}),t.jsxs("button",{onClick:()=>_(),disabled:!(e!=null&&e.selectedTask),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[A("Next","bit-integrations"),"  ",t.jsx(L,{className:"ml-1 rev-icn"})]})]}),t.jsx(j,{step:i,saveConfig:()=>C(u,f,T,e,P,"","",S),isLoading:h,dataConf:e,setDataConf:l,formFields:c})]})}export{Z as default};
