import{r as i,a as b,j as e,_ as u,L as v,bs as N,W as I,h as C,c as y,H as k,D as W,g as L,S as _}from"./main-634.js";import"./bf-25-81.js";import{S as z}from"./bf-54-258.js";import{a5 as F,a7 as T}from"./bf-746-82.js";import{I as A}from"./bf-942-184.js";import{N as S}from"./bf-123-109.js";import{t as w}from"./bf-275-83.js";import{W as B,h as H}from"./bf-762-214.js";import"./bf-822-108.js";import"./bf-438-114.js";function P({wcConf:m,setWcConf:g,step:l,setStep:f,setSnackbar:x}){const[o,d]=i.useState(!1),[n,s]=i.useState(!1),[h,j]=i.useState(!1),{css:r}=b(),t=()=>{s("auth"),y({},"bitforms_wc_authorize").then(a=>{a!=null&&a.success&&(d(!0),x({show:!0,msg:u("Connected with WooCommerce Successfully")})),s(!1),j(!0)})},c=a=>{const p=k(m);p[a.target.name]=a.target.value,g(p)};return e.jsxs(e.Fragment,{children:[e.jsx(F,{title:w.wooCommerce.title,youTubeLink:w.wooCommerce.link}),e.jsxs("div",{className:"btcd-stp-page",style:{width:l===1&&900,height:l===1&&"100%"},children:[e.jsx("div",{className:"mt-3",children:e.jsx("b",{children:u("Integration Name:")})}),e.jsx("input",{className:"btcd-paper-inp w-6 mt-1",onChange:c,name:"name",value:m.name,type:"text",placeholder:u("Integration Name...")}),n==="auth"&&e.jsxs("div",{className:"flx mt-5",children:[e.jsx(v,{size:25,clr:"#022217",className:"mr-2"}),"Checking if WooCommerce is active!!!"]}),h&&!o&&!n&&e.jsxs("div",{className:"flx mt-5",style:{color:"red"},children:[e.jsx("span",{className:"mr-2",style:{fontSize:30,marginTop:-5},children:e.jsx(N,{size:"15"})}),"WooCommerce plugin must be activated to integrate with Bit Form."]}),!o&&e.jsx(I,{variant:o?"disabled":"success",onClick:t,className:r(C.mt3,C.mb3,{ml:3}),children:u("Connect")}),o&&e.jsx(S,{nextPageHandler:()=>f(2),disabled:!o})]})]})}function Q({formFields:m,setIntegration:g,integrations:l,allIntegURL:f}){const x=W(),{formID:o}=L(),[d,n]=i.useState(!1),[s,h]=i.useState(1),[j,r]=i.useState({show:!1}),[t,c]=i.useState({name:"WooCommerce Integration",type:"WooCommerce",field_map:[{formField:"",wcField:""}],upload_field_map:[{formField:"",wcField:""}],actions:{}}),a=()=>{setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),t.workspace!==""&&t.table!==""&&t.field_map.length>0&&h(3)};return e.jsxs("div",{children:[e.jsx(_,{snack:j,setSnackbar:r}),e.jsx("div",{className:"txt-center w-9 mt-2 cal-width",children:e.jsx(z,{step:3,active:s})}),e.jsx(P,{formID:o,wcConf:t,setWcConf:c,step:s,setStep:h,isLoading:d,setisLoading:n,setSnackbar:r}),e.jsxs("div",{className:"btcd-stp-page",style:{width:s===2&&900,height:s===2&&"100%"},children:[e.jsx(B,{wcConf:t,setWcConf:c,formFields:m,handleInput:p=>H(p,t,c,n,r),isLoading:d,setisLoading:n}),e.jsx(S,{nextPageHandler:()=>a(),disabled:t.workspace===""||t.table===""||t.field_map.length<1})]}),e.jsx(A,{step:s,saveConfig:()=>T(l,g,f,t,x)})]})}export{Q as default};
