var A=Object.defineProperty;var h=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable;var v=(a,t,s)=>t in a?A(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,k=(a,t)=>{for(var s in t||(t={}))N.call(t,s)&&v(a,s,t[s]);if(h)for(var s of h(t))O.call(t,s)&&v(a,s,t[s]);return a};import{j as o,_ as r,z as i}from"./main.2.8.10.js";import{u as V,b as n}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as I}from"./SnackMsg.7BjcJK1j.js";import{S as w}from"./Steps.B84Ui3GU.js";import{I as L,g as D}from"./Integrations.BFhED4ck.js";import{c as _,T as p,P as z}from"./VoxelCommonFunctions.D0PdIG4v.js";import{V as F}from"./VoxelIntegLayout.Cd59BoJF.js";import K from"./VoxelAuthorization.OZCJGeII.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 ae({formFields:a,setFlow:t,flow:s,allIntegURL:f}){const u=V(),[j,g]=n.useState(!1),[T,x]=n.useState({auth:!1,postTypes:!1,postFields:!1,posts:!1}),[l,P]=n.useState(1),[y,d]=n.useState({show:!1}),[e,m]=n.useState({name:"Voxel",type:"Voxel",field_map:[],selectedTask:"",postTypes:[],selectedPostType:"",selectedPostStatus:"",voxelFields:[],actions:{},posts:[],selectedPost:""}),C=()=>{g(!0),D(s,t,f,e,u,"","",g).then(c=>{var b;c.success?(i.success((b=c.data)==null?void 0:b.msg),u(f)):i.error(c.data||c)})},E=S=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!e.selectedTask){i.error(r("Please select a task!","bit-integrations"));return}if((e.selectedTask===p.NEW_POST||e.selectedTask===p.UPDATE_POST)&&!e.selectedPostType){i.error(r("Please select a post type!","bit-integrations"));return}if(z.includes(e.selectedTask)&&!e.selectedPostStatus){i.error(r("Please select a post status!","bit-integrations"));return}if((e.selectedTask===p.UPDATE_POST||e.selectedTask===p.UPDATE_COLLECTION_POST)&&!e.selectedPost){i.error(r("Please select a post!","bit-integrations"));return}if(!_(e)){i.error(r("Please map mandatory fields!","bit-integrations"));return}e.field_map.length>0&&P(S)};return o.jsxs("div",{children:[o.jsx(I,{snack:y,setSnackbar:d}),o.jsx("div",{className:"txt-center mt-2",children:o.jsx(w,{step:3,active:l})}),o.jsx(K,{voxelConf:e,setVoxelConf:m,step:l,setStep:P,loading:T,setLoading:x,setSnackbar:d}),o.jsxs("div",{className:"btcd-stp-page",style:k({},l===2&&{width:900,height:"auto",overflow:"visible"}),children:[o.jsx(F,{formFields:a,voxelConf:e,setVoxelConf:m,loading:T,setLoading:x,setSnackbar:d}),o.jsxs("button",{onClick:()=>E(3),disabled:!_(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[r("Next","bit-integrations"),"  ",o.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),o.jsx(L,{step:l,saveConfig:()=>C(),isLoading:j,dataConf:e,setDataConf:m,formFields:a})]})}export{ae as default};
