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