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