var N=Object.defineProperty;var x=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var S=(i,s,a)=>s in i?N(i,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[s]=a,v=(i,s)=>{for(var a in s||(s={}))w.call(s,a)&&S(i,a,s[a]);if(x)for(var a of x(s))F.call(s,a)&&S(i,a,s[a]);return i};import{_ as t,j as r,z as m}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 C}from"./SnackMsg.7BjcJK1j.js";import{S as E}from"./Steps.B84Ui3GU.js";import{I as L,g as T}from"./Integrations.BFhED4ck.js";import P from"./MailRelayAuthorization.BdTzRxsD.js";import{h as A,c as B}from"./MailRelayCommonFunc.Bi9qhtj1.js";import{M as R}from"./MailRelayIntegLayout.CdSr4m_G.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:i,setFlow:s,flow:a,allIntegURL:p}){const b=z(),[j,g]=o.useState(!1),[f,y]=o.useState({auth:!1,groups:!1,customFields:!1}),[n,h]=o.useState(1),[q,u]=o.useState({show:!1}),M=[{key:"email",label:t("Email","bit-integrations"),required:!0},{key:"name",label:t("Name","bit-integrations"),required:!1},{key:"sms_phone",label:t("SMS Phone","bit-integrations"),required:!1},{key:"address",label:t("Address","bit-integrations"),required:!1},{key:"city",label:t("City","bit-integrations"),required:!1},{key:"state",label:t("State","bit-integrations"),required:!1},{key:"country",label:t("Country","bit-integrations"),required:!1},{key:"birthday",label:t("Birthday","bit-integrations"),required:!1},{key:"website",label:t("Website","bit-integrations"),required:!1},{key:"locale",label:t("Locale","bit-integrations"),required:!1},{key:"time_zone",label:t("Time Zone","bit-integrations"),required:!1}],[e,l]=o.useState({name:"MailRelay",type:"MailRelay",auth_token:"",domain:"",field_map:[{formField:"",mailRelayFormField:""}],staticFields:M,status:"",customFields:[],groups:[],selectedGroups:[],actions:{}}),_=()=>{g(!0),T(a,s,p,e,b,"","",g).then(c=>{var k;c.success?(m.success((k=c.data)==null?void 0:k.msg),b(p)):m.error(c.data||c)})},I=d=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!B(e)){m.error(t("Please map mandatory fields","bit-integrations"));return}e.field_map.length>0&&h(d)};return r.jsxs("div",{children:[r.jsx(C,{snack:q,setSnackbar:u}),r.jsx("div",{className:"txt-center mt-2",children:r.jsx(E,{step:3,active:n})}),r.jsx(P,{mailRelayConf:e,setMailRelayConf:l,step:n,setStep:h,loading:f,setLoading:y,setSnackbar:u}),r.jsxs("div",{className:"btcd-stp-page",style:v({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[r.jsx(R,{formFields:i,handleInput:d=>A(d,e,l),mailRelayConf:e,setMailRelayConf:l,loading:f,setLoading:y,setSnackbar:u}),(e==null?void 0:e.status)&&r.jsxs("button",{onClick:()=>I(3),disabled:!(e!=null&&e.status),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[t("Next","bit-integrations"),"  ",r.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(e==null?void 0:e.status)&&r.jsx(L,{step:n,saveConfig:()=>_(),isLoading:j,dataConf:e,setDataConf:l,formFields:i})]})}export{ae as default};
