var w=Object.defineProperty;var I=Object.getOwnPropertySymbols;var F=Object.prototype.hasOwnProperty,z=Object.prototype.propertyIsEnumerable;var j=(a,t,s)=>t in a?w(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s,v=(a,t)=>{for(var s in t||(t={}))F.call(t,s)&&j(a,s,t[s]);if(I)for(var s of I(t))z.call(t,s)&&j(a,s,t[s]);return a};import{j as n,_ as S,z as f}from"./main.2.9.0.js";import{u as E,b as o}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{S as L}from"./SnackMsg.DYSD96P4.js";import{S as T}from"./Steps.BYe8zHkm.js";import{I as M,g as P}from"./Integrations.DL8wqGct.js";import A from"./InstasentAuthorization.i3MZpWbq.js";import{h as B,c as k}from"./InstasentCommonFunc.CY5oGi9Y.js";import{I as D}from"./InstasentIntegLayout.Bv1IrSXi.js";import"./react-vendor.P7K3d6op.js";import"./Note.NSUdvR3c.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TutorialLink.CFG7bS5c.js";import"./ProUtilHelpers.CHf_DzPf.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";function at({formFields:a,setFlow:t,flow:s,allIntegURL:u}){const g=E(),[_,h]=o.useState(!1),[d,m]=o.useState({list:!1,field:!1,auth:!1,datasource:!1}),[i,x]=o.useState(1),[y,l]=o.useState({show:!1}),[e,r]=o.useState({name:"Instasent",type:"Instasent",auth_token:"",action:"",projectId:"",datasourceId:"",instasentFields:[],field_map:[{formField:"",instasentFormField:""}],actions:{},default:{datasources:[]}}),C=()=>{h(!0),P(s,t,u,e,g,"","",h).then(p=>{var b;p.success?(f.success((b=p.data)==null?void 0:b.msg),g(u)):f.error(p.data||p)})},N=c=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!k(e)){f.error(S("Please map mandatory fields","bit-integrations"));return}e.field_map.length>0&&x(c)};return n.jsxs("div",{children:[n.jsx(L,{snack:y,setSnackbar:l}),n.jsx("div",{className:"txt-center mt-2",children:n.jsx(T,{step:3,active:i})}),n.jsx(A,{instasentConf:e,setInstasentConf:r,step:i,setstep:x,loading:d,setLoading:m,setSnackbar:l}),n.jsxs("div",{className:"btcd-stp-page",style:v({},i===2&&{width:900,minHeight:"500px",overflow:"visible"}),children:[n.jsx(D,{formFields:a,handleInput:c=>B(c,e,r,d,m),instasentConf:e,setInstasentConf:r,loading:d,setLoading:m,setSnackbar:l}),(e==null?void 0:e.action)&&n.jsxs("button",{onClick:()=>N(3),disabled:!k(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[S("Next","bit-integrations"),"  ",n.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),n.jsx(M,{step:i,saveConfig:()=>C(),isLoading:_,dataConf:e,setDataConf:r,formFields:a})]})}export{at as default};
