var F=Object.defineProperty;var h=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var g=(t,s,a)=>s in t?F(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a,q=(t,s)=>{for(var a in s||(s={}))w.call(s,a)&&g(t,a,s[a]);if(h)for(var a of h(s))C.call(s,a)&&g(t,a,s[a]);return t};import{u as D,r as i,j as r}from"./main-333.js";import{d as E,_ as P,I as A,F as T,c as m}from"./bi.636.93.js";import{S as B}from"./bi.563.969.js";import M from"./bi.209.330.js";import{s as z,h as G,c as x}from"./bi.391.918.js";import{L as H}from"./bi.431.919.js";import"./bi.318.783.js";function X({formFields:t,setFlow:s,flow:a,allIntegURL:f}){const b=D(),[u,l]=i.useState(!1),[_,S]=i.useState({}),[n,y]=i.useState(1),[v,p]=i.useState({show:!1}),N=[{key:"name",label:"Name",required:!0}],j=[{key:"first_name",label:"First Name",required:!1},{key:"last_name",label:"Last Name",required:!1},{key:"email",label:"Email",required:!0},{key:"mobile_phone",label:"Mobile Phone",required:!1},{key:"home_phone",label:"Home Phone",required:!1},{key:"office_phone",label:"Office Phone",required:!1},{key:"fax",label:"Fax",required:!1},{key:"company",label:"Company",required:!1},{key:"birthday",label:"Birthday",required:!1},{key:"anniversary",label:"Anniversary",required:!1},{key:"spouse_name",label:"Spouse Name",required:!1},{key:"spouse_email",label:"Spouse Email",required:!1},{key:"spouse_phone",label:"Spouse Phone",required:!1},{key:"spouse_birthday",label:"Spouse Birthday",required:!1},{key:"type",label:"Address type",required:!1},{key:"street_address_1",label:"Street Address 1",required:!1},{key:"street_address_2",label:"Street Address 2",required:!1},{key:"zip",label:"Zip",required:!1},{key:"city",label:"City",required:!1},{key:"state",label:"State",required:!1}],[e,o]=i.useState({name:"LionDesk",type:"LionDesk",clientId:"",clientSecret:"",field_map:[{formField:"",lionDeskFormField:""}],actionName:"",actionId:"",campaignFields:N,contactFields:j,actions:{}});i.useEffect(()=>{window.opener&&z("lionDesk")},[]);const L=()=>{l(!0),T(a,s,f,e,b,"","",l).then(c=>{var k;c.success?(m.success((k=c.data)==null?void 0:k.msg),b(f)):m.error(c.data||c)})},I=d=>{if(setTimeout(()=>{document.getElementById("btcd-settings-wrp").scrollTop=0},300),!x(e)){m.error("Please map mandatory fields");return}e.field_map.length>0&&y(d)};return r.jsxs("div",{children:[r.jsx(E,{snack:v,setSnackbar:p}),r.jsx("div",{className:"txt-center mt-2",children:r.jsx(B,{step:3,active:n})}),r.jsx(M,{lionDeskConf:e,setLionDeskConf:o,step:n,setStep:y,setSnackbar:p,isLoading:u,setIsLoading:l}),r.jsxs("div",{className:"btcd-stp-page",style:q({},n===2&&{width:900,height:"auto",overflow:"visible"}),children:[r.jsx(H,{formFields:t,handleInput:d=>G(d,e,o),lionDeskConf:e,setLionDeskConf:o,loading:_,setLoading:S,isLoading:u,setIsLoading:l,setSnackbar:p}),(e==null?void 0:e.actionName)&&r.jsxs("button",{onClick:()=>I(3),disabled:!x(e),className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[P("Next","bit-integrations")," "," ",r.jsx("div",{className:"btcd-icn icn-arrow_back rev-icn d-in-b"})]})]}),(e==null?void 0:e.actionName)&&r.jsx(A,{step:n,saveConfig:()=>L(),isLoading:u,dataConf:e,setDataConf:o,formFields:t})]})}export{X as default};
