import{u as I,k as j,r as a,j as t}from"./main-333.js";import{d as b,_ as d,I as k,s as w}from"./bi.636.93.js";import{B as v}from"./bi.429.767.js";import{S as N}from"./bi.563.969.js";import{s as C}from"./bi.864.754.js";import G from"./bi.401.253.js";import{h as _,d as y}from"./bi.576.752.js";import{G as E}from"./bi.872.753.js";import"./bi.318.783.js";import"./bi.535.730.js";import"./bi.286.731.js";function W({formFields:l,setFlow:p,flow:h,allIntegURL:f}){const g=I(),{formID:r}=j(),[c,n]=a.useState(!1),[o,m]=a.useState(1),[u,s]=a.useState({show:!1}),[e,i]=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 S=()=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!y(e)){s({show:!0,msg:d("Please map fields to continue.","bit-integrations")});return}e.spreadsheetId!==""&&e.worksheetName!==""&&e.field_map.length>0&&m(3)};return t.jsxs("div",{children:[t.jsx(b,{snack:u,setSnackbar:s}),t.jsx("div",{className:"txt-center mt-2",children:t.jsx(N,{step:3,active:o})}),t.jsx(G,{formID:r,sheetConf:e,setSheetConf:i,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:r,formFields:l,handleInput:x=>_(x,e,i,r,n,s),sheetConf:e,setSheetConf:i,isLoading:c,setIsLoading:n,setSnackbar:s}),t.jsxs("button",{onClick:()=>S(),disabled:!e.spreadsheetId||!e.worksheetName||e.field_map.length<1,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[d("Next","bit-integrations"),t.jsx(v,{className:"ml-1 rev-icn"})]})]}),t.jsx(k,{step:o,saveConfig:()=>w({flow:h,setFlow:p,allIntegURL:f,conf:e,navigate:g,setIsLoading:n,setSnackbar:s}),isLoading:c,dataConf:e,setDataConf:i,formFields:l})]})}export{W as default};
