var N=Object.defineProperty;var S=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var k=(s,e,t)=>e in s?N(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,x=(s,e)=>{for(var t in e||(e={}))I.call(e,t)&&k(s,t,e[t]);if(S)for(var t of S(e))O.call(e,t)&&k(s,t,e[t]);return s};import{u as F,r as i,j as a}from"./main-333.js";import{d as w,_ as E,I as L,F as P,c}from"./bi.636.93.js";import{S as T}from"./bi.563.969.js";import A from"./bi.944.291.js";import{h as B,c as D}from"./bi.327.728.js";import{O as M}from"./bi.8.729.js";import"./bi.318.783.js";import"./bi.535.730.js";import"./bi.286.731.js";function Y({formFields:s,setFlow:e,flow:t,allIntegURL:u}){const f=F(),[C,p]=i.useState(!1),[b,h]=i.useState({channel:!1,field:!1,auth:!1}),[r,y]=i.useState(1),[v,m]=i.useState({show:!1}),_=[{key:"email",label:"Email",required:!1},{key:"phone_number",label:"Phone Number",required:!1},{key:"firstName",label:"First Name",required:!1},{key:"lastName",label:"Last Name",required:!1},{key:"country",label:"Country",required:!1},{key:"countryCode",label:"Country Code",required:!1},{key:"state",label:"State",required:!1},{key:"city",label:"City",required:!1},{key:"address",label:"Address",required:!1},{key:"postalCode",label:"Postal Code",required:!1},{key:"gender",label:"Gender",required:!1},{key:"birthdate",label:"Birth Date",required:!1}],[n,l]=i.useState({name:"OmniSend",type:"OmniSend",api_key:"",field_map:[{formField:"",omniSendFormField:""}],channels:"",channel_types:[],email_status:"",sms_status:"",omniSend_fields:_,actions:{}}),j=()=>{p(!0),P(t,e,u,n,f,"","",p).then(d=>{var g;d.success?(c.success((g=d.data)==null?void 0:g.msg),f(u)):c.error(d.data||d)})},q=o=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!D(n)){c.error("Please map mandatory fields");return}n.field_map.length>0&&y(o)};return a.jsxs("div",{children:[a.jsx(w,{snack:v,setSnackbar:m}),a.jsx("div",{className:"txt-center mt-2",children:a.jsx(T,{step:3,active:r})}),a.jsx(A,{omniSendConf:n,setOmniSendConf:l,step:r,setstep:y,loading:b,setLoading:h,setSnackbar:m}),a.jsxs("div",{className:"btcd-stp-page",style:x({},r===2&&{width:900,height:"auto",overflow:"visible"}),children:[a.jsx(M,{formFields:s,handleInput:o=>B(o,n,l),omniSendConf:n,setOmniSendConf:l,loading:b,setLoading:h,setSnackbar:m}),a.jsxs("button",{onClick:()=>q(3),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[E("Next","bit-integrations")," "," ",a.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),a.jsx(L,{step:r,saveConfig:()=>j(),isLoading:C,dataConf:n,setDataConf:l,formFields:s})]})}export{Y as default};
