var k=Object.defineProperty;var v=Object.getOwnPropertySymbols;var y=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var j=(s,e,t)=>e in s?k(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,L=(s,e)=>{for(var t in e||(e={}))y.call(e,t)&&j(s,t,e[t]);if(v)for(var t of v(e))I.call(e,t)&&j(s,t,e[t]);return s};import{u as N,r as o,j as a}from"./main-406.js";import{d as w,_ as F,I as E,G as T,c as d}from"./bi.394.85.js";import{S as P}from"./bi.68.941.js";import z from"./bi.817.271.js";import{h as A,c as B}from"./bi.662.796.js";import{M as D}from"./bi.641.797.js";import"./bi.150.760.js";import"./bi.704.707.js";import"./bi.701.708.js";function X({formFields:s,setFlow:e,flow:t,allIntegURL:m}){const f=N(),[_,u]=o.useState(!1),[g,h]=o.useState({list:!1,field:!1,auth:!1,group:!1}),[n,x]=o.useState(1),[S,p]=o.useState({show:!1}),[i,r]=o.useState({name:"MailerLite",type:"MailerLite",auth_token:"",field_map:[{formField:"",mailerLiteFormField:"email"}],mailer_lite_type:"",mailerLiteFields:[],groups:[],group_ids:[],actions:{}}),M=()=>{u(!0),T(t,e,m,i,f,"","",u).then(c=>{var b;c.success?(d.success((b=c.data)==null?void 0:b.msg),f(m)):d.error(c.data||c)})},C=l=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!B(i)){d.error("Please map mandatory fields");return}i.field_map.length>0&&x(l)};return a.jsxs("div",{children:[a.jsx(w,{snack:S,setSnackbar:p}),a.jsx("div",{className:"txt-center mt-2",children:a.jsx(P,{step:3,active:n})}),a.jsx(z,{mailerLiteConf:i,setMailerLiteConf:r,step:n,setstep:x,loading:g,setLoading:h,setSnackbar:p}),a.jsxs("div",{className:"btcd-stp-page",style:L({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[a.jsx(D,{formFields:s,handleInput:l=>A(l,i,r),mailerLiteConf:i,setMailerLiteConf:r,loading:g,setLoading:h,setSnackbar:p}),a.jsxs("button",{onClick:()=>C(3),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[F("Next","bit-integrations")," "," ",a.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),a.jsx(E,{step:n,saveConfig:()=>M(),isLoading:_,dataConf:i,setDataConf:r,formFields:s})]})}export{X as default};
