var I=Object.defineProperty;var v=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,L=Object.prototype.propertyIsEnumerable;var w=(s,t,e)=>t in s?I(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,N=(s,t)=>{for(var e in t||(t={}))F.call(t,e)&&w(s,e,t[e]);if(v)for(var e of v(t))L.call(t,e)&&w(s,e,t[e]);return s};import{j as a,_ as j,z as m}from"./main.2.8.1.js";import{u as z,d as i}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{S as E}from"./SnackMsg.S8DrwLlT.js";import{S as T}from"./Steps.1hz7v9Vj.js";import{I as M,g as P}from"./Integrations.D2bgBas2.js";import{s as A,c as S}from"./NewsletterCommonFunc.DTsaB5B-.js";import{N as B}from"./NewsletterIntegLayout.CWiO9JUA.js";import D from"./NewsletterAuthorization.EYP8HIvJ.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.js";import"./tutorialLinks.kMkIDzcD.js";import"./TutorialLink.BAFX--T3.js";function st({formFields:s,setFlow:t,flow:e,allIntegURL:p}){const d=z(),[C,f]=i.useState(!1),[g,u]=i.useState({auth:!1}),[r,x]=i.useState(1),[k,c]=i.useState({show:!1}),[o,l]=i.useState({name:"Newsletter",type:"Newsletter",field_map:[{formField:"",newsletterFormField:""}],staticFields:A,lists:[],selectedLists:"",groups:[],actions:{}}),y=()=>{f(!0),P(e,t,p,o,d,"","",f).then(n=>{var b;n.success?(m.success((b=n.data)==null?void 0:b.msg),d(p)):m.error(n.data||n)})},_=h=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!S(o)){m.error(j("Please map mandatory fields","bit-integrations"));return}o.field_map.length>0&&x(h)};return a.jsxs("div",{children:[a.jsx(E,{snack:k,setSnackbar:c}),a.jsx("div",{className:"txt-center mt-2",children:a.jsx(T,{step:3,active:r})}),a.jsx(D,{newsletterConf:o,setNewsletterConf:l,step:r,setStep:x,loading:g,setLoading:u,setSnackbar:c}),a.jsxs("div",{className:"btcd-stp-page",style:N({},r===2&&{width:900,height:"auto",overflow:"visible"}),children:[a.jsx(B,{formFields:s,newsletterConf:o,setNewsletterConf:l,loading:g,setLoading:u,setSnackbar:c}),a.jsxs("button",{onClick:()=>_(3),disabled:!S(o),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[j("Next","bit-integrations"),"  ",a.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),a.jsx(M,{step:r,saveConfig:()=>y(),isLoading:C,dataConf:o,setDataConf:l,formFields:s})]})}export{st as default};
