var w=Object.defineProperty;var j=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var L=(a,e,s)=>e in a?w(a,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[e]=s,N=(a,e)=>{for(var s in e||(e={}))I.call(e,s)&&L(a,s,e[s]);if(j)for(var s of j(e))P.call(e,s)&&L(a,s,e[s]);return a};import{j as i,_ as m,z as o}from"./main.2.9.0.js";import{u as C,b as r}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{S as z}from"./SnackMsg.DYSD96P4.js";import{S as F}from"./Steps.BYe8zHkm.js";import{I as T,g as M}from"./Integrations.DL8wqGct.js";import A from"./LivestormAuthorization.7c2Bx7VW.js";import{c as k}from"./LivestormCommonFunc.DtgYJAOi.js";import{L as B}from"./LivestormIntegLayout.CCxNjhRi.js";import"./react-vendor.P7K3d6op.js";import"./Note.NSUdvR3c.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TutorialLink.CFG7bS5c.js";function U({formFields:a,setFlow:e,flow:s,allIntegURL:g}){const f=C(),[u,p]=r.useState(!1),[v,b]=r.useState({}),[n,x]=r.useState(1),[y,d]=r.useState({show:!1}),[t,l]=r.useState({name:"Livestorm",type:"Livestorm",api_key:"",field_map:[{formField:"",livestormFormField:""}],actionName:"addPeopletoEventSession",actions:{}}),_=()=>{p(!0),M(s,e,g,t,f,"","",p).then(c=>{var S;c.success?(o.success((S=c.data)==null?void 0:S.msg),f(g)):o.error(c.data||c)})},E=h=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!k(t)){o.error(m("Please map mandatory fields","bit-integrations"));return}if(!t.selectedEvent){o.error(m("Please select an Event","bit-integrations"));return}if(!t.selectedSession){o.error(m("Please select a Session","bit-integrations"));return}t.field_map.length>0&&x(h)};return i.jsxs("div",{children:[i.jsx(z,{snack:y,setSnackbar:d}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(F,{step:3,active:n})}),i.jsx(A,{livestormConf:t,setLivestormConf:l,step:n,setStep:x,loading:v,setLoading:b,setSnackbar:d}),i.jsxs("div",{className:"btcd-stp-page",style:N({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[i.jsx(B,{formFields:a,livestormConf:t,setLivestormConf:l,loading:v,setLoading:b,isLoading:u,setIsLoading:p,setSnackbar:d}),(t==null?void 0:t.actionName)&&i.jsxs("button",{onClick:()=>E(3),disabled:!k(t),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[m("Next","bit-integrations"),"  ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(t==null?void 0:t.actionName)&&i.jsx(T,{step:n,saveConfig:()=>_(),isLoading:u,dataConf:t,setDataConf:l,formFields:a})]})}export{U as default};
