import{j as i,_ as m}from"./main.2.9.0.js";import{u as h,e as j,b as o}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{B as I}from"./BackIcn._8Wofmn2.js";import{S}from"./SnackMsg.DYSD96P4.js";import{I as _,g as T}from"./Integrations.DL8wqGct.js";import k from"./NotificationXAuthorization.oTGuTFHC.js";import{c as v}from"./NotificationXCommonFunc.4OCf43HL.js";import{N as y,a as A}from"./NotificationXIntegLayout.BUXsZovN.js";import"./react-vendor.P7K3d6op.js";import"./Note.NSUdvR3c.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TutorialLink.CFG7bS5c.js";import"./ProUtilHelpers.CHf_DzPf.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";import"./GlobalIntegrationHelper.B6YI8w_n.js";function K({formFields:p,setFlow:u,flow:g,allIntegURL:x}){const N=h(),{formID:f}=j(),[a,n]=o.useState(!1),[e,l]=o.useState(1),[b,s]=o.useState({show:!1}),[t,r]=o.useState({name:"NotificationX",type:"NotificationX",field_map:[{formField:"",notificationXField:""}],entry_map:[],actions:{},mainAction:"",selected_notification_id:"",notifications:[]}),d=c=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),c===3){if(A.includes(t==null?void 0:t.mainAction)&&!(t!=null&&t.selected_notification_id)){s({show:!0,msg:m("Please select a notification to continue.","bit-integrations")});return}if(!v(t)){s({show:!0,msg:m("Please map all required fields to continue.","bit-integrations")});return}t.name!==""&&l(c)}else l(c)};return i.jsxs("div",{children:[i.jsx(S,{snack:b,setSnackbar:s}),i.jsx("div",{className:"txt-center mt-2"}),i.jsx(k,{formID:f,notificationXConf:t,setNotificationXConf:r,step:e,nextPage:d,isLoading:a,setIsLoading:n,setSnackbar:s}),i.jsxs("div",{className:"btcd-stp-page",style:{width:e===2&&900,height:e===2&&"auto",minHeight:e===2&&"500px"},children:[i.jsx(y,{formID:f,formFields:p,notificationXConf:t,setNotificationXConf:r,setSnackbar:s,setIsLoading:n,isLoading:a}),i.jsx("br",{}),i.jsx("br",{}),i.jsx("br",{}),i.jsxs("button",{onClick:()=>d(3),disabled:!t.mainAction,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[m("Next","bit-integrations"),i.jsx(I,{className:"ml-1 rev-icn"})]})]}),i.jsx(_,{step:e,saveConfig:()=>T(g,u,x,t,N,"","",n),isLoading:a,dataConf:t,setDataConf:r,formFields:p})]})}export{K as default};
