var L=Object.defineProperty;var j=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var k=(i,e,s)=>e in i?L(i,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[e]=s,y=(i,e)=>{for(var s in e||(e={}))z.call(e,s)&&k(i,s,e[s]);if(j)for(var s of j(e))B.call(e,s)&&k(i,s,e[s]);return i};import{D as J,g as O,r as l,f as _,j as a,S as $,M as q,_ as H}from"./main-634.js";import"./bf-25-81.js";import{S as G}from"./bf-54-258.js";import{C as K}from"./bf-4-87.js";import{ac as Q,a7 as V}from"./bf-746-82.js";import{I as W}from"./bf-942-184.js";import{N as X}from"./bf-123-109.js";import v from"./bf-118-123.js";import{f as Y,a as Z,c as C}from"./bf-709-177.js";import{A as R}from"./bf-137-222.js";import"./bf-275-83.js";import"./bf-822-108.js";import"./bf-438-114.js";import"./bf-186-202.js";function ft({formFields:i,setIntegration:e,integrations:s,allIntegURL:A}){const x=J(),{formID:h}=O(),[N,m]=l.useState(!1),[g,d]=l.useState(!1),[o,u]=l.useState(1),[M,c]=l.useState({show:!1}),P=[{key:"1",label:"Add/Update Subscriber"},{key:"2",label:"Delete Subscriber"}],D=[{key:"email",label:"Email",required:!0}],[t,n]=l.useState({name:"Acumbamail",type:"Acumbamail",mainAction:"",listId:"",auth_token:"",field_map:[{formField:"",acumbamailFormField:"email"}],addSubsCriberFields:D,allActions:P,address_field:[],actions:{}}),b=Q([t.type]),E=()=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!C(t)){c({show:!0,msg:"Please map fields to continue."});return}t.listId!==""&&u(3)},F=()=>{V(s,e,A,t,x)},T=(r,w)=>{if(r.integration_type===t.type){const f=JSON.parse(r.integration_details);n(p=>_(p,I=>{I.parentAppId=r.id,I.auth_token=f.auth_token})),u(2)}},S=()=>{setTimeout(()=>{x(`${A}/new/${t.type}`)},1e3),m(!1)};return l.useEffect(()=>{n(r=>_(r,w=>{const f=b.find(p=>p.id===t.parentAppId);if(f){const p=JSON.parse(f.integration_details);w.auth_token=p.auth_token}})),t!=null&&t.parentAppId&&Y(t,n,d)},[t.parentAppId]),a.jsxs("div",{children:[a.jsx($,{snack:M,setSnackbar:c}),a.jsx("div",{className:"txt-center w-9 mt-2 cal-width",children:a.jsx(G,{step:3,active:o})}),a.jsx(q,{title:H("Connect New Active Campaing API"),show:N,setModal:()=>m(!1),children:a.jsx(v,{formID:h,acumbamailConf:t,setAcumbamailConf:n,step:o,setstep:u,isLoading:g,setIsLoading:d,setSnackbar:c,authorizedAction:S})}),b.length>0&&o===1&&a.jsx(K,{allIntegURL:A,specificTypes:[t.type],onClickAction:T,allowAddNew:!0,addNewAction:()=>m(!0)}),o===1&&b.length===0&&a.jsx(v,{formID:h,acumbamailConf:t,setAcumbamailConf:n,step:o,setstep:u,isLoading:g,setIsLoading:d,setSnackbar:c,authorizedAction:S}),a.jsxs("div",{className:"btcd-stp-page",style:y({},o===2&&{width:900,height:"auto",overflow:"visible"}),children:[a.jsx(R,{formFields:i,handleInput:r=>Z(r,t,n,d,c,h),acumbamailConf:t,setAcumbamailConf:n,isLoading:g,setIsLoading:d,setSnackbar:c,setShowMdl:m}),a.jsx(X,{nextPageHandler:()=>E(),disabled:!t.mainAction||!C(t)})]}),a.jsx(W,{step:o,saveConfig:()=>F()})]})}export{ft as default};
