var _=Object.defineProperty;var j=Object.getOwnPropertySymbols;var q=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var k=(a,t,s)=>t in a?_(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,S=(a,t)=>{for(var s in t||(t={}))q.call(t,s)&&k(a,s,t[s]);if(j)for(var s of j(t))w.call(t,s)&&k(a,s,t[s]);return a};import{_ as r,j as i,z as p}from"./main.2.8.10.js";import{u as z,b as o}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as T}from"./SnackMsg.7BjcJK1j.js";import{S as E}from"./Steps.B84Ui3GU.js";import{I as L,g as A}from"./Integrations.BFhED4ck.js";import B from"./MailBlusterAuthorization.Cucr6Dpe.js";import{h as P,c as C}from"./MailBlusterCommonFunc.CDuwzmFK.js";import{M as D}from"./MailBlusterIntegLayout.Dvvfpopa.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.js";function ae({formFields:a,setFlow:t,flow:s,allIntegURL:u}){const b=z(),[y,g]=o.useState(!1),[f,h]=o.useState({auth:!1,customFields:!1}),[n,x]=o.useState(1),[N,m]=o.useState({show:!1}),M=[{key:"email",label:r("Email","bit-integrations"),required:!0},{key:"firstName",label:r("First Name","bit-integrations"),required:!1},{key:"lastName",label:r("Last Name","bit-integrations"),required:!1},{key:"timezone",label:r("Timezone","bit-integrations"),required:!1},{key:"ipAddress",label:r("IP Address","bit-integrations"),required:!1}],[e,l]=o.useState({name:"MailBluster",type:"MailBluster",auth_token:"",field_map:[{formField:"",mailBlusterFormField:""}],staticFields:M,subscribed:"",customFields:[],selectedTags:[],actions:{}}),I=()=>{g(!0),A(s,t,u,e,b,"","",g).then(d=>{var v;d.success?(p.success((v=d.data)==null?void 0:v.msg),b(u)):p.error(d.data||d)})},F=c=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!C(e)){p.error(r("Please map mandatory fields","bit-integrations"));return}e.field_map.length>0&&x(c)};return i.jsxs("div",{children:[i.jsx(T,{snack:N,setSnackbar:m}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(E,{step:3,active:n})}),i.jsx(B,{mailBlusterConf:e,setMailBlusterConf:l,step:n,setStep:x,loading:f,setLoading:h,setSnackbar:m}),i.jsxs("div",{className:"btcd-stp-page",style:S({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(D,{formFields:a,handleInput:c=>P(c,e,l),mailBlusterConf:e,setMailBlusterConf:l,loading:f,setLoading:h,setSnackbar:m}),(e==null?void 0:e.subscribed)&&i.jsxs("button",{onClick:()=>F(3),disabled:!(e!=null&&e.subscribed),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[r("Next","bit-integrations"),"  ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(e==null?void 0:e.subscribed)&&i.jsx(L,{step:n,saveConfig:()=>I(),isLoading:y,dataConf:e,setDataConf:l,formFields:a})]})}export{ae as default};
