import{j as i,_ as m}from"./main.2.8.1.js";import{u as b,h as j,d as o}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{B as I}from"./BackIcn._kGL_vVw.js";import{S}from"./SnackMsg.S8DrwLlT.js";import{I as _,g as T}from"./Integrations.D2bgBas2.js";import k from"./NotificationXAuthorization.Da43qoyV.js";import{c as v}from"./NotificationXCommonFunc.CNvphlgG.js";import{N as y,a as A}from"./NotificationXIntegLayout.B9I6LIUA.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./tutorialLinks.kMkIDzcD.js";import"./TutorialLink.BAFX--T3.js";import"./ProUtilHelpers.fQlR3mWW.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.js";import"./GlobalIntegrationHelper.CgnhJgll.js";function K({formFields:f,setFlow:u,flow:g,allIntegURL:x}){const N=b(),{formID:c}=j(),[a,n]=o.useState(!1),[e,p]=o.useState(1),[h,s]=o.useState({show:!1}),[t,l]=o.useState({name:"NotificationX",type:"NotificationX",field_map:[{formField:"",notificationXField:""}],entry_map:[],actions:{},mainAction:"",selected_notification_id:"",notifications:[]}),d=r=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),r===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!==""&&p(r)}else p(r)};return i.jsxs("div",{children:[i.jsx(S,{snack:h,setSnackbar:s}),i.jsx("div",{className:"txt-center mt-2"}),i.jsx(k,{formID:c,notificationXConf:t,setNotificationXConf:l,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:c,formFields:f,notificationXConf:t,setNotificationXConf:l,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})]})}export{K as default};
