var y=Object.defineProperty;var v=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var j=(a,s,e)=>s in a?y(a,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[s]=e,S=(a,s)=>{for(var e in s||(s={}))L.call(s,e)&&j(a,e,s[e]);if(v)for(var e of v(s))N.call(s,e)&&j(a,e,s[e]);return a};import{j as i,_ as E,z as p}from"./main.2.8.1.js";import{u as w,d as o}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{S as C}from"./SnackMsg.S8DrwLlT.js";import{S as T}from"./Steps.1hz7v9Vj.js";import{I as z,g as M}from"./Integrations.D2bgBas2.js";import P from"./EmailOctopusAuthorization.BmHYxn5G.js";import{h as A,c as k}from"./EmailOctopusCommonFunc.8ffb1vKO.js";import{E as B}from"./EmailOctopusIntegLayout.DmNQvaCD.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";function et({formFields:a,setFlow:s,flow:e,allIntegURL:d}){const u=w(),[F,f]=o.useState(!1),[g,h]=o.useState({auth:!1,tags:!1,customFields:!1,lists:!1,emailOctopusFields:!1}),[n,x]=o.useState(1),[I,m]=o.useState({show:!1}),[t,r]=o.useState({name:"EmailOctopus",type:"EmailOctopus",auth_token:"",field_map:[{formField:"",emailOctopusFormField:""}],emailOctopusFields:[],lists:[],selectedList:"",status:"",tags:[],selectedTags:[],actions:{}}),O=()=>{f(!0),M(e,s,d,t,u,"","",f).then(l=>{var b;l.success?(p.success((b=l.data)==null?void 0:b.msg),u(d)):p.error(l.data||l)})},_=c=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!k(t)){p.error(E("Please map mandatory emailOctopusFields","bit-integrations"));return}t.field_map.length>0&&x(c)};return i.jsxs("div",{children:[i.jsx(C,{snack:I,setSnackbar:m}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(T,{step:3,active:n})}),i.jsx(P,{emailOctopusConf:t,setEmailOctopusConf:r,step:n,setStep:x,loading:g,setLoading:h,setSnackbar:m}),i.jsxs("div",{className:"btcd-stp-page",style:S({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(B,{formFields:a,handleInput:c=>A(c,t,r),emailOctopusConf:t,setEmailOctopusConf:r,loading:g,setLoading:h,setSnackbar:m}),(t==null?void 0:t.selectedList)&&i.jsxs("button",{onClick:()=>_(3),disabled:!k(t),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[E("Next","bit-integrations"),"  ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(t==null?void 0:t.selectedList)&&i.jsx(z,{step:n,saveConfig:()=>O(),isLoading:F,dataConf:t,setDataConf:r,formFields:a})]})}export{et as default};
