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