var M=Object.defineProperty;var q=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable;var x=(s,i,a)=>i in s?M(s,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[i]=a,C=(s,i)=>{for(var a in i||(i={}))P.call(i,a)&&x(s,a,i[a]);if(q)for(var a of q(i))w.call(i,a)&&x(s,a,i[a]);return s};import{_ as e,j as r,z as m}from"./main.2.8.10.js";import{u as R,b as n}from"./react-router.DMwpH23k.js";import"./CopyIcn.BnhKHfEP.js";import{S as T}from"./SnackMsg.7BjcJK1j.js";import{S as A}from"./Steps.B84Ui3GU.js";import{I as E,g as z}from"./Integrations.BFhED4ck.js";import D from"./NutshellCRMAuthorization.D5fiPs0z.js";import{h as B,c as S}from"./NutshellCRMCommonFunc.E3puGTel.js";import{N as G}from"./NutshellCRMIntegLayout.Cv12m672.js";import"./react-vendor.P7K3d6op.js";import"./Note.DalStCGz.js";import"./Table.DSsAy4VI.js";import"./index.DpWdl9V1.js";import"./TutorialLink.D6K_DiHL.js";function ae({formFields:s,setFlow:i,flow:a,allIntegURL:p}){const g=R(),[f,c]=n.useState(!1),[y,k]=n.useState({}),[o,h]=n.useState(1),[v,b]=n.useState({show:!1}),j=[{key:"first_name",label:e("First Name","bit-integrations"),required:!0},{key:"email",label:e("Email Address","bit-integrations"),required:!0},{key:"last_name",label:e("Last Name","bit-integrations"),required:!1},{key:"phone",label:e("Phone Number","bit-integrations"),required:!1},{key:"address_1",label:e("Address 1","bit-integrations"),required:!1},{key:"city",label:e("City","bit-integrations"),required:!1},{key:"state",label:e("State","bit-integrations"),required:!1},{key:"postalCode",label:e("Postal Code","bit-integrations"),required:!1},{key:"country",label:e("Country","bit-integrations"),required:!1}],_=[{key:"name",label:e("Name","bit-integrations"),required:!0},{key:"url",label:e("URL","bit-integrations"),required:!1},{key:"phone",label:e("Phone Number","bit-integrations"),required:!1},{key:"address_1",label:e("Address 1","bit-integrations"),required:!1},{key:"city",label:e("City","bit-integrations"),required:!1},{key:"state",label:e("State","bit-integrations"),required:!1},{key:"postalCode",label:e("Postal Code","bit-integrations"),required:!1},{key:"country",label:e("Country","bit-integrations"),required:!1}],I=[{key:"description",label:e("Lead Description","bit-integrations"),required:!0},{key:"dueTime",label:e("Due Time","bit-integrations"),required:!1},{key:"confidence",label:e("Confidence","bit-integrations"),required:!1}],[t,l]=n.useState({name:"NutshellCRM",type:"NutshellCRM",user_name:"",api_token:"",field_map:[{formField:"",nutshellCRMFormField:""}],actionName:"",actionId:"",peopleFields:j,companyFields:_,leadFields:I,actions:{}}),F=()=>{c(!0),z(a,i,p,t,g,"","",c).then(u=>{var N;u.success?(m.success((N=u.data)==null?void 0:N.msg),g(p)):m.error(u.data||u)})},L=d=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!S(t)){m.error(e("Please map mandatory fields","bit-integrations"));return}t.field_map.length>0&&h(d)};return r.jsxs("div",{children:[r.jsx(T,{snack:v,setSnackbar:b}),r.jsx("div",{className:"txt-center mt-2",children:r.jsx(A,{step:3,active:o})}),r.jsx(D,{nutshellCRMConf:t,setNutshellCRMConf:l,step:o,setStep:h,loading:y,setLoading:k,setSnackbar:b}),r.jsxs("div",{className:"btcd-stp-page",style:C({},o===2&&{width:900,height:"auto",overflow:"visible"}),children:[r.jsx(G,{formFields:s,handleInput:d=>B(d,t,l),nutshellCRMConf:t,setNutshellCRMConf:l,loading:y,setLoading:k,isLoading:f,setIsLoading:c,setSnackbar:b}),(t==null?void 0:t.actionName)&&r.jsxs("button",{onClick:()=>L(3),disabled:!S(t),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[e("Next","bit-integrations"),"  ",r.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(t==null?void 0:t.actionName)&&r.jsx(E,{step:o,saveConfig:()=>F(),isLoading:f,dataConf:t,setDataConf:l,formFields:s})]})}export{ae as default};
