var I=Object.defineProperty;var h=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable;var k=(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={}))O.call(t,s)&&k(a,s,t[s]);if(h)for(var s of h(t))R.call(t,s)&&k(a,s,t[s]);return a};import{j as r,_ as i,z as o}from"./main.2.8.10.js";import{u as L,b as c}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as N}from"./SnackMsg.7BjcJK1j.js";import{S as W}from"./Steps.B84Ui3GU.js";import{I as y,g as A}from"./Integrations.BFhED4ck.js";import{T as n,c as m}from"./WPForoCommonFunc.DC3wfkgi.js";import{W as D}from"./WPForoIntegLayout.CIzT0COb.js";import G from"./WPForoAuthorization.CH2AEQrL.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.js";import"./TutorialLink.D6K_DiHL.js";function se({formFields:a,setFlow:t,flow:s,allIntegURL:f}){const g=L(),[v,T]=c.useState(!1),[b,P]=c.useState({auth:!1,reputation:!1,groups:!1,forums:!1,topics:!1}),[l,E]=c.useState(1),[j,d]=c.useState({show:!1}),[e,u]=c.useState({name:"WPForo",type:"WPForo",field_map:[],staticFields:[],selectedTask:"",groups:[],selectedGroup:"",reputations:[],selectedReputation:"",forums:[],selectedForum:"",selectedTags:"",actions:{},selectedTopic:"",topics:[],deleteTopicFieldMap:!1}),C=()=>{T(!0),A(s,t,f,e,g,"","",T).then(p=>{var _;p.success?(o.success((_=p.data)==null?void 0:_.msg),g(f)):o.error(p.data||p)})},F=x=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!e.selectedTask){o.error(i("Please select a task!","bit-integrations"));return}if(e.selectedTask!==n.DELETE_TOPIC&&!m(e)){o.error(i("Please map mandatory fields!","bit-integrations"));return}if(e.selectedTask===n.USER_REPUTATION&&!e.selectedReputation){o.error(i("Please select a reputation!","bit-integrations"));return}if(e.selectedTask===n.ADD_TO_GROUP&&!e.selectedGroup){o.error(i("Please select a group!","bit-integrations"));return}if(e.selectedTask===n.REMOVE_FROM_GROUP&&!e.selectedGroup){o.error(i("Please select a group!","bit-integrations"));return}if(e.selectedTask===n.CREATE_TOPIC&&!e.selectedForum){o.error(i("Please select a forum!","bit-integrations"));return}if(e.selectedTask===n.DELETE_TOPIC&&!e.selectedTopic&&!m(e)){o.error(i("Please select a topic or map fields!","bit-integrations"));return}e.field_map.length>0&&E(x)};return r.jsxs("div",{children:[r.jsx(N,{snack:j,setSnackbar:d}),r.jsx("div",{className:"txt-center mt-2",children:r.jsx(W,{step:3,active:l})}),r.jsx(G,{wpforoConf:e,setWPForoConf:u,step:l,setStep:E,loading:b,setLoading:P,setSnackbar:d}),r.jsxs("div",{className:"btcd-stp-page",style:S({},l===2&&{width:900,height:"auto",overflow:"visible"}),children:[r.jsx(D,{formFields:a,wpforoConf:e,setWPForoConf:u,loading:b,setLoading:P,setSnackbar:d}),r.jsxs("button",{onClick:()=>F(3),disabled:(e==null?void 0:e.selectedTask)!==n.DELETE_TOPIC&&!m(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[i("Next","bit-integrations"),"  ",r.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),r.jsx(y,{step:l,saveConfig:()=>C(),isLoading:v,dataConf:e,setDataConf:u,formFields:a})]})}export{se as default};
