import{u as x,k as I,r as a,j as t}from"./main-406.js";import{d as j,_ as k,I as b,s as w}from"./bi.394.85.js";import{B as v}from"./bi.46.744.js";import{S as N}from"./bi.68.941.js";import{s as C}from"./bi.93.731.js";import G from"./bi.557.242.js";import{h as _,d as y}from"./bi.170.729.js";import{G as E}from"./bi.65.730.js";import"./bi.150.760.js";import"./bi.704.707.js";import"./bi.701.708.js";function W({formFields:l,setFlow:d,flow:p,allIntegURL:h}){const f=x(),{formID:i}=I(),[c,n]=a.useState(!1),[o,m]=a.useState(1),[g,s]=a.useState({show:!1}),[e,r]=a.useState({name:"Google Sheet",type:"Google Sheet",clientId:"",clientSecret:"",spreadsheetId:"",worksheetName:"",field_map:[{formField:"",googleSheetField:""}],header:"ROWS",headerRow:"A1",actions:{}});a.useEffect(()=>{window.opener&&C("googleSheet")},[]);const u=()=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!y(e)){s({show:!0,msg:"Please map fields to continue."});return}e.spreadsheetId!==""&&e.worksheetName!==""&&e.field_map.length>0&&m(3)};return t.jsxs("div",{children:[t.jsx(j,{snack:g,setSnackbar:s}),t.jsx("div",{className:"txt-center mt-2",children:t.jsx(N,{step:3,active:o})}),t.jsx(G,{formID:i,sheetConf:e,setSheetConf:r,step:o,setstep:m,setSnackbar:s,isLoading:c,setIsLoading:n}),t.jsxs("div",{className:"btcd-stp-page",style:{width:o===2&&900,height:o===2&&"auto"},children:[t.jsx(E,{formID:i,formFields:l,handleInput:S=>_(S,e,r,i,n,s),sheetConf:e,setSheetConf:r,isLoading:c,setIsLoading:n,setSnackbar:s}),t.jsxs("button",{onClick:()=>u(),disabled:!e.spreadsheetId||!e.worksheetName||e.field_map.length<1,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[k("Next","bit-integrations"),t.jsx(v,{className:"ml-1 rev-icn"})]})]}),t.jsx(b,{step:o,saveConfig:()=>w({flow:p,setFlow:d,allIntegURL:h,conf:e,navigate:f,setIsLoading:n,setSnackbar:s}),isLoading:c,dataConf:e,setDataConf:r,formFields:l})]})}export{W as default};
