var C=Object.defineProperty;var v=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var j=(a,t,e)=>t in a?C(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,S=(a,t)=>{for(var e in t||(t={}))N.call(t,e)&&j(a,e,t[e]);if(v)for(var e of v(t))w.call(t,e)&&j(a,e,t[e]);return a};import{j as i,_ as L,z as f}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 z}from"./SnackMsg.S8DrwLlT.js";import{S as E}from"./Steps.1hz7v9Vj.js";import{I as T,g as P}from"./Integrations.D2bgBas2.js";import A from"./MailerLiteAuthorization.BwBEpYWK.js";import{h as B,c as _}from"./MailerLiteCommonFunc.C7trWZsR.js";import{M as D}from"./MailerLiteIntegLayout.DSkspxld.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./tutorialLinks.kMkIDzcD.js";import"./TutorialLink.BAFX--T3.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.js";import"./ProUtilHelpers.fQlR3mWW.js";function at({formFields:a,setFlow:t,flow:e,allIntegURL:u}){const g=F(),[M,h]=o.useState(!1),[c,m]=o.useState({list:!1,field:!1,auth:!1,group:!1}),[r,x]=o.useState(1),[k,d]=o.useState({show:!1}),[s,n]=o.useState({name:"MailerLite",type:"MailerLite",auth_token:"",field_map:[{formField:"",mailerLiteFormField:"email"}],mailer_lite_type:"",mailerLiteFields:[],groups:[],group_ids:[],actions:{},action:""}),y=()=>{h(!0),P(e,t,u,s,g,"","",h).then(p=>{var b;p.success?(f.success((b=p.data)==null?void 0:b.msg),g(u)):f.error(p.data||p)})},I=l=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!_(s)){f.error(L("Please map mandatory fields","bit-integrations"));return}s.field_map.length>0&&x(l)};return i.jsxs("div",{children:[i.jsx(z,{snack:k,setSnackbar:d}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(E,{step:3,active:r})}),i.jsx(A,{mailerLiteConf:s,setMailerLiteConf:n,step:r,setstep:x,loading:c,setLoading:m,setSnackbar:d}),i.jsxs("div",{className:"btcd-stp-page",style:S({},r===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(D,{formFields:a,handleInput:l=>B(l,s,n,c,m),mailerLiteConf:s,setMailerLiteConf:n,loading:c,setLoading:m,setSnackbar:d}),(s==null?void 0:s.action)&&i.jsxs("button",{onClick:()=>I(3),disabled:!_(s),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[L("Next","bit-integrations"),"  ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),i.jsx(T,{step:r,saveConfig:()=>y(),isLoading:M,dataConf:s,setDataConf:n,formFields:a})]})}export{at as default};
