var F=Object.defineProperty;var q=Object.getOwnPropertySymbols;var P=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var h=(s,a,t)=>a in s?F(s,a,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[a]=t,x=(s,a)=>{for(var t in a||(a={}))P.call(a,t)&&h(s,t,a[t]);if(q)for(var t of q(a))T.call(a,t)&&h(s,t,a[t]);return s};import{u as I,r as i,j as l}from"./main-406.js";import{d as L,_ as M,I as E,G as D,c as r}from"./bi.394.85.js";import{S as R}from"./bi.68.941.js";import z from"./bi.920.297.js";import{h as B,c as N}from"./bi.926.853.js";import{A as G}from"./bi.249.854.js";import"./bi.150.760.js";function Y({formFields:s,setFlow:a,flow:t,allIntegURL:b}){const f=I(),[_,m]=i.useState(!1),[k,p]=i.useState({}),[n,y]=i.useState(1),[S,u]=i.useState({show:!1}),j=[{key:"name",label:"Name",required:!0},{key:"description",label:"Description",required:!1},{key:"size",label:"Size",required:!1},{key:"email",label:"Email",required:!1},{key:"phone",label:"Phone",required:!1},{key:"website",label:"Website",required:!1},{key:"facebook",label:"Facebook",required:!1},{key:"linkedin",label:"Linkedin",required:!1},{key:"twitter",label:"Twitter",required:!1},{key:"skype",label:"Skype",required:!1},{key:"note",label:"Note",required:!1},{key:"tax_no",label:"Tax No",required:!1}],v=[{key:"first_name",label:"First Name",required:!0},{key:"email",label:"Email",required:!0},{key:"last_name",label:"Last Name",required:!1},{key:"phone",label:"Phone",required:!1},{key:"job_title",label:"Job Title",required:!1},{key:"facebook",label:"Facebook",required:!1},{key:"linkedin",label:"Linkedin",required:!1},{key:"twitter",label:"Twitter",required:!1},{key:"skype",label:"Skype",required:!1},{key:"note",label:"Note",required:!1},{key:"tax_no",label:"Tax No",required:!1},{key:"last_contacted",label:"Last Contacted",required:!1}],w=[{key:"deal_name",label:"Deal Name",required:!0},{key:"amount",label:"Amount",required:!1},{key:"close_date",label:"Close Date",required:!1}],[e,o]=i.useState({name:"Agiled CRM",type:"Agiled CRM",auth_token:"",brand:"",field_map:[{formField:"",agiledFormField:""}],actionName:"",accountFields:j,contactFields:v,dealFields:w,actions:{}}),C=()=>{m(!0),D(t,a,b,e,f,"","",m).then(c=>{var g;c.success?(r.success((g=c.data)==null?void 0:g.msg),f(b)):r.error(c.data||c)})},A=d=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!N(e)){r.error("Please map mandatory fields");return}if(e.actionName==="deal"){if(!e.selectedCRMPipeline){r.error("Please select a pipeline");return}if(!e.selectedCRMPipelineStages){r.error("Please select a pipeline stage");return}}e.field_map.length>0&&y(d)};return l.jsxs("div",{children:[l.jsx(L,{snack:S,setSnackbar:u}),l.jsx("div",{className:"txt-center mt-2",children:l.jsx(R,{step:3,active:n})}),l.jsx(z,{agiledConf:e,setAgiledConf:o,step:n,setStep:y,loading:k,setLoading:p,setSnackbar:u}),l.jsxs("div",{className:"btcd-stp-page",style:x({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[l.jsx(G,{formFields:s,handleInput:d=>B(d,e,o),agiledConf:e,setAgiledConf:o,loading:k,setLoading:p,setSnackbar:u}),(e==null?void 0:e.actionName)&&l.jsxs("button",{onClick:()=>A(3),disabled:!N(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[M("Next","bit-integrations")," "," ",l.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(e==null?void 0:e.actionName)&&l.jsx(E,{step:n,saveConfig:()=>C(),isLoading:_,dataConf:e,setDataConf:o,formFields:s})]})}export{Y as default};
