var T=Object.defineProperty;var j=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var y=(a,e,s)=>e in a?T(a,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[e]=s,S=(a,e)=>{for(var s in e||(e={}))k.call(e,s)&&y(a,s,e[s]);if(j)for(var s of j(e))C.call(e,s)&&y(a,s,e[s]);return a};import{j as i,_ as l,z as o}from"./main.2.8.1.js";import{u as I,d as r}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{S as L}from"./SnackMsg.S8DrwLlT.js";import{S as N}from"./Steps.1hz7v9Vj.js";import{I as z,g as E}from"./Integrations.D2bgBas2.js";import M from"./ACPTAuthorization.B7dlb6DS.js";import{c as F}from"./ACPTCommonFunc.Bw3Hgvq6.js";import{m as B,o as D,t as H,a as q,c as G,b as J,A as K}from"./ACPTIntegLayout.BxTzVKoE.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./tutorialLinks.kMkIDzcD.js";import"./ProUtilHelpers.fQlR3mWW.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.js";function nt({formFields:a,setFlow:e,flow:s,allIntegURL:d}){const u=I(),[g,c]=r.useState(!1),[b,f]=r.useState({}),[n,x]=r.useState(1),[P,_]=r.useState({show:!1}),[t,m]=r.useState({name:"ACPT",type:"ACPT",base_url:window.location.origin,api_key:"",field_map:[{formField:"",acptFormField:""}],label_field_map:[{formField:"",acptFormField:""}],acptFields:[],acptLabels:[],utilities:{},icon:"wordpress",capability:"manage_options",module:"",cptFields:J,cptLabels:G,taxonomyLabels:q,taxonomyFields:H,optionPageFields:D,modules:B}),w=()=>{c(!0),E(s,e,d,t,u,"","",c).then(p=>{var v;p.success?(o.success((v=p.data)==null?void 0:v.msg),u(d)):o.error(p.data||p)})},A=h=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!F(t)){o.error(l("Please map mandatory fields","bit-integrations"));return}if(["create_cpt","update_cpt","create_option_page","update_option_page"].includes(t.module)&&!(t!=null&&t.icon)){o.error(l("Please select Icon","bit-integrations"));return}if(["create_option_page","update_option_page"].includes(t.module)&&!(t!=null&&t.capability)){o.error(l("Please select Capability","bit-integrations"));return}t.field_map.length>0&&x(h)};return i.jsxs("div",{children:[i.jsx(L,{snack:P,setSnackbar:_}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(N,{step:3,active:n})}),i.jsx(M,{acptConf:t,setAcptConf:m,step:n,setStep:x,loading:b,setLoading:f}),i.jsxs("div",{className:"btcd-stp-page",style:S({},n===2&&{width:900,minHeight:"400px",height:"auto",overflow:"visible"}),children:[i.jsx(K,{formFields:a,acptConf:t,setAcptConf:m,loading:b,setLoading:f,isLoading:g,setIsLoading:c,setSnackbar:_}),(t==null?void 0:t.module)&&i.jsxs("button",{onClick:()=>A(3),disabled:!F(t),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[l("Next","bit-integrations"),"  ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(t==null?void 0:t.module)&&i.jsx(z,{step:n,saveConfig:()=>w(),isLoading:g,dataConf:t,setDataConf:m,formFields:a})]})}export{nt as default};
