var P=Object.defineProperty;var h=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var x=(s,i,a)=>i in s?P(s,i,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[i]=a,N=(s,i)=>{for(var a in i||(i={}))T.call(i,a)&&x(s,a,i[a]);if(h)for(var a of h(i))I.call(i,a)&&x(s,a,i[a]);return s};import{_ as e,j as r,z as n}from"./main.2.9.0.js";import{u as L,b as l}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{S as M}from"./SnackMsg.DYSD96P4.js";import{S as z}from"./Steps.BYe8zHkm.js";import{I as E,g as D}from"./Integrations.DL8wqGct.js";import R from"./AgiledAuthorization.DymS_X6E.js";import{h as B,c as S}from"./AgiledCommonFunc.YZJKfApy.js";import{A as J}from"./AgiledIntegLayout.DwzleubN.js";import"./react-vendor.P7K3d6op.js";import"./Note.NSUdvR3c.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TutorialLink.CFG7bS5c.js";function ae({formFields:s,setFlow:i,flow:a,allIntegURL:g}){const m=L(),[_,p]=l.useState(!1),[f,k]=l.useState({}),[o,y]=l.useState(1),[j,u]=l.useState({show:!1}),v=[{key:"name",label:e("Name","bit-integrations"),required:!0},{key:"description",label:e("Description","bit-integrations"),required:!1},{key:"size",label:e("Size","bit-integrations"),required:!1},{key:"email",label:e("Email","bit-integrations"),required:!1},{key:"phone",label:e("Phone","bit-integrations"),required:!1},{key:"website",label:e("Website","bit-integrations"),required:!1},{key:"facebook",label:e("Facebook","bit-integrations"),required:!1},{key:"linkedin",label:e("Linkedin","bit-integrations"),required:!1},{key:"twitter",label:e("Twitter","bit-integrations"),required:!1},{key:"skype",label:e("Skype","bit-integrations"),required:!1},{key:"note",label:e("Note","bit-integrations"),required:!1},{key:"tax_no",label:e("Tax No","bit-integrations"),required:!1}],w=[{key:"first_name",label:e("First Name","bit-integrations"),required:!0},{key:"email",label:e("Email","bit-integrations"),required:!0},{key:"last_name",label:e("Last Name","bit-integrations"),required:!1},{key:"phone",label:e("Phone","bit-integrations"),required:!1},{key:"job_title",label:e("Job Title","bit-integrations"),required:!1},{key:"facebook",label:e("Facebook","bit-integrations"),required:!1},{key:"linkedin",label:e("Linkedin","bit-integrations"),required:!1},{key:"twitter",label:e("Twitter","bit-integrations"),required:!1},{key:"skype",label:e("Skype","bit-integrations"),required:!1},{key:"note",label:e("Note","bit-integrations"),required:!1},{key:"tax_no",label:e("Tax No","bit-integrations"),required:!1},{key:"last_contacted",label:e("Last Contacted","bit-integrations"),required:!1}],C=[{key:"deal_name",label:e("Deal Name","bit-integrations"),required:!0},{key:"amount",label:e("Amount","bit-integrations"),required:!1},{key:"close_date",label:e("Close Date","bit-integrations"),required:!1}],[t,d]=l.useState({name:"Agiled CRM",type:"Agiled CRM",auth_token:"",brand:"",field_map:[{formField:"",agiledFormField:""}],actionName:"",accountFields:v,contactFields:w,dealFields:C,actions:{}}),A=()=>{p(!0),D(a,i,g,t,m,"","",p).then(c=>{var q;c.success?(n.success((q=c.data)==null?void 0:q.msg),m(g)):n.error(c.data||c)})},F=b=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!S(t)){n.error(e("Please map mandatory fields","bit-integrations"));return}if(t.actionName==="deal"){if(!t.selectedCRMPipeline){n.error(e("Please select a pipeline","bit-integrations"));return}if(!t.selectedCRMPipelineStages){n.error(e("Please select a pipeline stage","bit-integrations"));return}}t.field_map.length>0&&y(b)};return r.jsxs("div",{children:[r.jsx(M,{snack:j,setSnackbar:u}),r.jsx("div",{className:"txt-center mt-2",children:r.jsx(z,{step:3,active:o})}),r.jsx(R,{agiledConf:t,setAgiledConf:d,step:o,setStep:y,loading:f,setLoading:k,setSnackbar:u}),r.jsxs("div",{className:"btcd-stp-page",style:N({},o===2&&{width:900,height:"auto",overflow:"visible"}),children:[r.jsx(J,{formFields:s,handleInput:b=>B(b,t,d),agiledConf:t,setAgiledConf:d,loading:f,setLoading:k,setSnackbar:u}),(t==null?void 0:t.actionName)&&r.jsxs("button",{onClick:()=>F(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:()=>A(),isLoading:_,dataConf:t,setDataConf:d,formFields:s})]})}export{ae as default};
