var w=Object.defineProperty;var S=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var M=(a,e,s)=>e in a?w(a,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[e]=s,k=(a,e)=>{for(var s in e||(e={}))A.call(e,s)&&M(a,s,e[s]);if(S)for(var s of S(e))P.call(e,s)&&M(a,s,e[s]);return a};import{j as i,_ as r,z as n}from"./main.2.8.10.js";import{u as T,b as c}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as L}from"./SnackMsg.7BjcJK1j.js";import{S as z}from"./Steps.B84Ui3GU.js";import{I as B,g as E}from"./Integrations.BFhED4ck.js";import F from"./MondayComAuthorization.B4FfDmtZ.js";import{k as D,i as H,c as C,n as q,a as G}from"./MondayComCommonFunc.BjAE-bJU.js";import{M as J}from"./MondayComIntegLayout.l94q_7Pl.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";import"./FieldMapHelper.DGWtlkLN.js";import"./TagifyInput.C4ilRm4k.js";import"./lodash.DCvQBX3r.js";import"./ProUtilHelpers.CtRYkgop.js";function ct({formFields:a,setFlow:e,flow:s,allIntegURL:p}){const l=T(),[u,g]=c.useState(!1),[f,b]=c.useState({}),[m,x]=c.useState(1),[I,h]=c.useState({show:!1}),v=[],[t,d]=c.useState({name:"Monday.Com",type:"Monday.Com",apiToken:"",field_map:H(v),mainAction:"",mondayComFields:v,actionLists:D}),N=()=>{g(!0),E(s,e,p,t,l,"","",g).then(o=>{var y;o.success?(n.success((y=o.data)==null?void 0:y.msg),l(p)):n.error(o.data||o)})},_=j=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!C(t)){n.error(r("Please map mandatory fields","bit-integrations"));return}const o=t.mainAction;if(q.includes(o)&&!t.selectedBoard){n.error(r("Please select a board","bit-integrations"));return}if(G.includes(o)&&!t.selectedItem){n.error(r("Please select an item","bit-integrations"));return}if(o==="create_column"&&!t.columnType){n.error(r("Please select a column type","bit-integrations"));return}x(j)};return i.jsxs("div",{children:[i.jsx(L,{snack:I,setSnackbar:h}),i.jsx("div",{className:"txt-center mt-2",children:i.jsx(z,{step:3,active:m})}),i.jsx(F,{mondayComConf:t,setMondayComConf:d,step:m,setStep:x,loading:f,setLoading:b,setSnackbar:h}),i.jsxs("div",{className:"btcd-stp-page",style:k({},m===2&&{width:900,minHeight:500,overflow:"visible"}),children:[i.jsx(J,{formFields:a,mondayComConf:t,setMondayComConf:d,loading:f,setLoading:b,isLoading:u}),(t==null?void 0:t.mainAction)&&i.jsxs("button",{onClick:()=>_(3),disabled:!C(t),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[r("Next","bit-integrations"),"  ",i.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(t==null?void 0:t.mainAction)&&i.jsx(B,{step:m,saveConfig:()=>N(),isLoading:u,dataConf:t,setDataConf:d,formFields:a})]})}export{ct as default};
