import{j as e,_ as i}from"./main.2.8.10.js";import{u as _,e as j,b as r}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{B as I}from"./BackIcn.BFDZx8No.js";import{S}from"./SnackMsg.7BjcJK1j.js";import{S as v}from"./Steps.B84Ui3GU.js";import{I as w,g as k}from"./Integrations.BFhED4ck.js";import N from"./ConvertKitAuthorization.B15sjNg2.js";import{c as p}from"./ConvertKitCommonFunc.huu_uWh4.js";import{C as P}from"./ConvertKitIntegLayout.nPehWrKk.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";function O({formFields:l,setFlow:c,flow:g,allIntegURL:b}){const f=_(),{formID:u}=j(),[o,m]=r.useState(!1),[a,d]=r.useState(1),[h,s]=r.useState({show:!1}),[t,n]=r.useState({name:"Kit(ConvertKit)",type:"Kit(ConvertKit)",api_secret:"",field_map:[{formField:"",convertKitField:""}],actions:{},module:""}),x=y=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300);{if(!p(t)){s({show:!0,msg:i("Please map all required fields to continue.","bit-integrations")});return}if(!(t!=null&&t.module)){s({show:!0,msg:i("Please select module to continue.","bit-integrations")});return}if((t==null?void 0:t.module)==="add_subscriber_to_a_form"&&!(t!=null&&t.formId)){s({show:!0,msg:i("Please select form to continue.","bit-integrations")});return}if(((t==null?void 0:t.module)==="add_tags_to_a_subscriber"||(t==null?void 0:t.module)==="remove_tags_to_a_subscriber")&&!(t!=null&&t.tagIds)){s({show:!0,msg:i("Please select tag continue.","bit-integrations")});return}t.name!==""&&t.field_map.length>0&&d(3)}};return e.jsxs("div",{children:[e.jsx(S,{snack:h,setSnackbar:s}),e.jsx("div",{className:"txt-center mt-2",children:e.jsx(v,{step:3,active:a})}),e.jsx(N,{formID:u,convertKitConf:t,setConvertKitConf:n,step:a,setstep:d,isLoading:o,setIsLoading:m,setSnackbar:s}),e.jsxs("div",{className:"btcd-stp-page",style:{width:a===2&&900,height:a===2&&"auto"},children:[e.jsx(P,{formID:u,formFields:l,convertKitConf:t,setConvertKitConf:n,isLoading:o,setIsLoading:m,setSnackbar:s}),e.jsxs("button",{onClick:()=>x(),disabled:!p(t),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[i("Next","bit-integrations"),"  ",e.jsx(I,{className:"ml-1 rev-icn"})]})]}),e.jsx(w,{step:a,saveConfig:()=>k(g,c,b,t,f,"","",m),isLoading:o,dataConf:t,setDataConf:n,formFields:l})]})}export{O as default};
