var P=Object.defineProperty;var D=Object.getOwnPropertySymbols;var V=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var S=(a,t,s)=>t in a?P(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,v=(a,t)=>{for(var s in t||(t={}))V.call(t,s)&&S(a,s,t[s]);if(D)for(var s of D(t))I.call(t,s)&&S(a,s,t[s]);return a};import{j as o,_ as i,z as r}from"./main.2.8.1.js";import{u as L,d as c}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{S as R}from"./SnackMsg.S8DrwLlT.js";import{S as A}from"./Steps.1hz7v9Vj.js";import{I as C,g as w}from"./Integrations.D2bgBas2.js";import{T as n,c as f}from"./dokanCommonFunctions.EK-osF5S.js";import{D as M}from"./DokanIntegLayout.BVuFODNV.js";import O from"./DokanAuthorization.VVQbL6KT.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.js";import"./tutorialLinks.kMkIDzcD.js";import"./TutorialLink.BAFX--T3.js";function se({formFields:a,setFlow:t,flow:s,allIntegURL:u}){const g=L(),[_,E]=c.useState(!1),[T,k]=c.useState({auth:!1,euFields:!1,vendors:!1}),[d,b]=c.useState(1),[j,m]=c.useState({show:!1}),[e,p]=c.useState({name:"Dokan",type:"Dokan",field_map:[],staticFields:[],selectedTask:"",vendors:[],selectedVendor:"",actions:{},deleteVendorFieldMap:!1,selectedPaymentMethod:""}),N=()=>{E(!0),w(s,t,u,e,g,"","",E).then(l=>{var x;l.success?(r.success((x=l.data)==null?void 0:x.msg),g(u)):r.error(l.data||l)})},y=h=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!e.selectedTask){r.error(i("Please select a task!","bit-integrations"));return}if((e.selectedTask===n.UPDATE_VENDOR||e.selectedTask===n.WITHDRAW_REQUEST)&&!e.selectedVendor){r.error(i("Please select a vendor!","bit-integrations"));return}if(e.selectedTask!==n.DELETE_VENDOR&&!f(e)){r.error(i("Please map mandatory fields!","bit-integrations"));return}if(e.selectedTask===n.DELETE_VENDOR&&!e.selectedVendor&&!f(e)){r.error(i("Please select a topic or map fields!","bit-integrations"));return}if(e.selectedTask===n.WITHDRAW_REQUEST&&!e.selectedPaymentMethod){r.error(i("Please select a payment method!","bit-integrations"));return}e.field_map.length>0&&b(h)};return o.jsxs("div",{children:[o.jsx(R,{snack:j,setSnackbar:m}),o.jsx("div",{className:"txt-center mt-2",children:o.jsx(A,{step:3,active:d})}),o.jsx(O,{dokanConf:e,setDokanConf:p,step:d,setStep:b,loading:T,setLoading:k,setSnackbar:m}),o.jsxs("div",{className:"btcd-stp-page",style:v({},d===2&&{width:900,height:"auto",overflow:"visible"}),children:[o.jsx(M,{formFields:a,dokanConf:e,setDokanConf:p,loading:T,setLoading:k,setSnackbar:m}),o.jsxs("button",{onClick:()=>y(3),disabled:(e==null?void 0:e.selectedTask)!==n.DELETE_VENDOR&&!f(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[i("Next","bit-integrations"),"  ",o.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),o.jsx(C,{step:d,saveConfig:()=>N(),isLoading:_,dataConf:e,setDataConf:p,formFields:a})]})}export{se as default};
