import{j as t,_ as m}from"./main.2.8.1.js";import{u as j,h as F,d as a}from"./react-router-dom.9mCuUg3q.js";import"./Note.BeM7sN-p.js";import{B as C}from"./BackIcn._kGL_vVw.js";import{S}from"./SnackMsg.S8DrwLlT.js";import{I,g as y}from"./Integrations.D2bgBas2.js";import _ from"./FluentCartAuthorization.JyNI_RV8.js";import{F as k,c as v}from"./FluentCartIntegLayout.CRvbHaiM.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:d,setFlow:g,flow:f,allIntegURL:x}){const h=j(),{formID:c}=F(),[n,o]=a.useState(!1),[s,p]=a.useState(1),[b,i]=a.useState({show:!1}),[e,l]=a.useState({name:"FluentCart",type:"FluentCart",field_map:[{formField:"",fluentCartField:""}],actions:{},mainAction:""}),u=r=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),r===3){if(e.mainAction==="create_coupon"&&!(e!=null&&e.discountType)){i({show:!0,msg:m("Please select discount Type to continue.","bit-integrations")});return}if(!v(e)){i({show:!0,msg:m("Please map all required fields to continue.","bit-integrations")});return}e.name!==""&&e.field_map.length>0&&p(r)}else p(r)};return t.jsxs("div",{children:[t.jsx(S,{snack:b,setSnackbar:i}),t.jsx("div",{className:"txt-center mt-2"}),t.jsx(_,{formID:c,fluentCartConf:e,setFluentCartConf:l,step:s,nextPage:u,isLoading:n,setIsLoading:o,setSnackbar:i}),t.jsxs("div",{className:"btcd-stp-page",style:{width:s===2&&900,height:s===2&&"auto",minHeight:s===2&&"200px"},children:[t.jsx(k,{formID:c,formFields:d,fluentCartConf:e,setFluentCartConf:l,setSnackbar:i,setIsLoading:o,isLoading:n}),t.jsx("br",{}),t.jsx("br",{}),t.jsx("br",{}),t.jsxs("button",{onClick:()=>u(3),disabled:e.field_map.length<1,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[m("Next","bit-integrations"),t.jsx(C,{className:"ml-1 rev-icn"})]})]}),t.jsx(I,{step:s,saveConfig:()=>y(f,g,x,e,h,"","",o),isLoading:n})]})}export{K as default};
