var M=Object.defineProperty;var b=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var g=(a,i,s)=>i in a?M(a,i,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[i]=s,f=(a,i)=>{for(var s in i||(i={}))N.call(i,s)&&g(a,s,i[s]);if(b)for(var s of b(i))T.call(i,s)&&g(a,s,i[s]);return a};import{k as G,f as P,_ as t,j as r}from"./main.2.9.0.js";import{u as C,e as F,b as c}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{S as E}from"./SnackMsg.DYSD96P4.js";import{S as L}from"./Steps.BYe8zHkm.js";import U from"./GroundhoggAuthorization.DyOP6l_y.js";import{h as D,c as R,b as z}from"./GroundhoggCommonFunc.Db_ALPfi.js";import{G as B}from"./GroundhoggIntegLayout.RJOfTg8p.js";import{I as O,s as Z}from"./Integrations.DL8wqGct.js";import"./react-vendor.P7K3d6op.js";import"./BackIcn._8Wofmn2.js";import"./Note.NSUdvR3c.js";import"./TutorialLink.CFG7bS5c.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TitleModal.emRFbfw0.js";import"./EditIcn.ClgiZunh.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";function me({formFields:a,setFlow:i,flow:s,allIntegURL:h}){var u;const y=C(),{formID:k}=F(),_=G(P),{siteURL:x}=_,[o,m]=c.useState(!1),[l,p]=c.useState(1),[A,n]=c.useState({show:!1}),w=[{key:"email",label:t("Email","bit-integrations"),required:!0},{key:"first_name",label:t("First Name","bit-integrations"),required:!1},{key:"last_name",label:t("Last Name","bit-integrations"),required:!1},{key:"user_id",label:t("User Id","bit-integrations"),required:!1},{key:"owner_id",label:t("Owner Id","bit-integrations"),required:!1},{key:"note",label:t("Note","bit-integrations"),required:!1}],S=[{key:"primary_phone",label:t("Primary Phone","bit-integrations"),required:!1},{key:"street_address_1",label:t("Street Address 1","bit-integrations"),required:!1},{key:"street_address_2",label:t("Street Address 2","bit-integrations"),required:!1},{key:"postal_zip",label:t("Postal Zip","bit-integrations"),required:!1},{key:"city",label:t("City","bit-integrations"),required:!1},{key:"country",label:t("Country","bit-integrations"),required:!1}],j=[{key:"1",label:t("Create Contact","bit-integrations")},{key:"2",label:t("Add tag to user","bit-integrations")}],[e,d]=c.useState({name:"Groundhogg",type:"Groundhogg",domainName:x,token:"",public_key:"",id:"",mainAction:"",addTagToUser:"",emailAddress:"",showMeta:!1,optin_status:"1",field_map:[{formField:"",GroundhoggMapField:""}],field_map_meta:[{formField:"",GroundhoggMetaMapField:""}],contactsFields:w,contactMetaFields:S,allActions:j,address_field:[],actions:{}}),q=()=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),e.mainAction==="1"&&!R(e)){n({show:!0,msg:t("Please map fields to continue.","bit-integrations")});return}if(e.showMeta&&!z(e)){n({show:!0,msg:t("Please map fields to continue.","bit-integrations")});return}if(e.mainAction==="2"&&(e==null?void 0:e.emailAddress)===""){n({show:!0,msg:t("Please select Email field to continue.","bit-integrations")});return}if(e.mainAction==="2"&&(e==null?void 0:e.addTagToUser)===""){n({show:!0,msg:t("Please select All Tags field to continue.","bit-integrations")});return}e.listId!==""&&p(3)},v=!(e.mainAction==="2"&&e.addTagToUser!=="");return r.jsxs("div",{children:[r.jsx(E,{snack:A,setSnackbar:n}),r.jsx("div",{className:"txt-center mt-2",children:r.jsx(L,{step:3,active:l})}),r.jsx(U,{formID:k,groundhoggConf:e,setGroundhoggConf:d,step:l,setstep:p,isLoading:o,setIsLoading:m,setSnackbar:n}),r.jsxs("div",{className:"btcd-stp-page",style:f({},l===2&&{width:900,height:"auto",overflow:"visible"}),children:[r.jsx(B,{formFields:a,handleInput:I=>D(I,e,d),groundhoggConf:e,setGroundhoggConf:d,isLoading:o,setIsLoading:m,setSnackbar:n}),r.jsxs("button",{onClick:()=>q(),disabled:(e.mainAction==="2"?v:!(((u=e.field_map)==null?void 0:u.length)>=1))||o,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[t("Next","bit-integrations"),"  ",r.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),r.jsx(O,{step:l,saveConfig:()=>Z({flow:s,setFlow:i,allIntegURL:h,navigate:y,conf:e,setIsLoading:m,setSnackbar:n}),isLoading:o,dataConf:e,setDataConf:d,formFields:a})]})}export{me as default};
