var I=Object.defineProperty;var y=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var S=(s,t,e)=>t in s?I(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,v=(s,t)=>{for(var e in t||(t={}))N.call(t,e)&&S(s,e,t[e]);if(y)for(var e of y(t))w.call(t,e)&&S(s,e,t[e]);return s};import{_ as d,j as a,z as f}from"./main.2.8.10.js";import{u as E,b as p}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as z}from"./SnackMsg.7BjcJK1j.js";import{S as F}from"./Steps.B84Ui3GU.js";import{I as T,g as q}from"./Integrations.BFhED4ck.js";import L from"./SendyAuthorization.BiZ1Q6CV.js";import{S as M,h as P,c as A}from"./SendyIntegLayout.B9u9VFPM.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./BackIcn.BFDZx8No.js";import"./TutorialLink.D6K_DiHL.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.js";import"./CustomFieldKey.DXUNVoDV.js";function st({formFields:s,setFlow:t,flow:e,allIntegURL:g}){const b=E(),[l,n]=p.useState(!1),[o,h]=p.useState(1),[j,u]=p.useState({show:!1}),k=[{key:"email",label:d("Email","bit-integrations"),required:!0},{key:"name",label:d("Name","bit-integrations"),required:!1}],[i,r]=p.useState({name:"Sendy",type:"Sendy",api_key:"",sendy_url:"",field_map:[{formField:"",sendyField:""}],subscriberFields:k,actions:{}}),C=()=>{n(!0),q(e,t,g,i,b,"","",n).then(m=>{var x;m.success?(f.success((x=m.data)==null?void 0:x.msg),b(g)):f.error(m.data||m)})},_=c=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!A(i)){f.error(d("Please map mandatory fields","bit-integrations"));return}i.field_map.length>0&&h(c)};return a.jsxs("div",{children:[a.jsx(z,{snack:j,setSnackbar:u}),a.jsx("div",{className:"txt-center mt-2",children:a.jsx(F,{step:3,active:o})}),a.jsx(L,{sendyConf:i,setSendyConf:r,step:o,setstep:h,isLoading:l,setIsLoading:n,setSnackbar:u}),a.jsxs("div",{className:"btcd-stp-page",style:v({},o===2&&{width:900,height:"auto",overflow:"visible"}),children:[a.jsx(M,{formFields:s,handleInput:c=>P(c,i,r),sendyConf:i,setSendyConf:r,isLoading:l,setIsLoading:n,setSnackbar:u}),a.jsxs("button",{onClick:()=>_(3),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[d("Next","bit-integrations"),"  ",a.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),a.jsx(T,{step:o,saveConfig:()=>C(),isLoading:l,dataConf:i,setDataConf:r,formFields:s})]})}export{st as default};
