import{r as i,a as b,j as e,_ as u,L as v,aL as N,B as I,x as w,c as y,q as k,v as L,w as W,S as _}from"./main-40.js";/* empty css          */import{T as z,S as F}from"./bf-679-136.js";import{b as T}from"./bf-132-75.js";import{I as A}from"./bf-94-335.js";import{N as S}from"./bf-504-404.js";import{t as C}from"./bf-892-199.js";import{W as B,h as P}from"./bf-229-381.js";import"./bf-860-126.js";import"./bf-141-80.js";import"./bf-586-70.js";import"./bf-200-122.js";import"./bf-689-131.js";function E({wcConf:m,setWcConf:g,step:l,setStep:f,setSnackbar:x}){const[o,d]=i.useState(!1),[n,s]=i.useState(!1),[p,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 h=k(m);h[a.target.name]=a.target.value,g(h)};return e.jsxs(e.Fragment,{children:[e.jsx(z,{title:C.wooCommerce.title,youTubeLink:C.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!!!"]}),p&&!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(w.mt3,w.mb3,{ml:3}),children:u("Connect")}),o&&e.jsx(S,{nextPageHandler:()=>f(2),disabled:!o})]})]})}function X({formFields:m,setIntegration:g,integrations:l,allIntegURL:f}){const x=L(),{formID:o}=W(),[d,n]=i.useState(!1),[s,p]=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&&p(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(F,{step:3,active:s})}),e.jsx(E,{formID:o,wcConf:t,setWcConf:c,step:s,setStep:p,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:h=>P(h,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{X as default};
