import{u as j,k as I,r as i,j as t}from"./main-406.js";import{Z as S,d as w,_ as p,I as D,s as Z}from"./bi.394.85.js";import{B as _}from"./bi.46.744.js";import{S as v}from"./bi.68.941.js";import N from"./bi.43.260.js";import{h as y,c as C,b as z}from"./bi.578.775.js";import{Z as F}from"./bi.328.776.js";import"./bi.150.760.js";import"./bi.704.707.js";import"./bi.701.708.js";function q({formFields:f,setFlow:h,flow:u,allIntegURL:g}){const k=j(),{formID:r}=I(),[d,o]=i.useState(!1),[n,m]=i.useState(1),[x,s]=i.useState({show:!1}),[e,c]=i.useState({name:"Zoho Desk",type:"Zoho Desk",clientId:"",clientSecret:"",orgId:"",department:"",field_map:[{formField:"",zohoFormField:""}],actions:{}});i.useEffect(()=>{window.opener&&S("zohoDesk")},[]);const b=a=>{var l;if(a===3){if(!C(e)){s({show:!0,msg:p("Please map mandatory fields","bit-integrations")});return}if(!((l=e.actions)!=null&&l.ticket_owner)){s({show:!0,msg:p("Please select a ticket owner","bit-integrations")});return}e.department!==""&&e.table!==""&&e.field_map.length>0&&m(a)}else m(a),a===2&&!e.department&&z(r,e,c,o,s)};return t.jsxs("div",{children:[t.jsx(w,{snack:x,setSnackbar:s}),t.jsx("div",{className:"txt-center mt-2",children:t.jsx(v,{step:3,active:n})}),t.jsx(N,{formID:r,deskConf:e,setDeskConf:c,step:n,setstep:m,isLoading:d,setIsLoading:o,setSnackbar:s}),t.jsxs("div",{className:"btcd-stp-page",style:{width:n===2&&900,height:n===2&&"auto"},children:[t.jsx(F,{formID:r,formFields:f,handleInput:a=>y(a,e,c,r,o,s),deskConf:e,setDeskConf:c,isLoading:d,setIsLoading:o,setSnackbar:s}),t.jsxs("button",{onClick:()=>b(3),disabled:e.department===""||e.table===""||e.field_map.length<1,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[p("Next","bit-integrations"),t.jsx(_,{className:"ml-1 rev-icn"})]})]}),t.jsx(D,{step:n,saveConfig:()=>Z({flow:u,setFlow:h,allIntegURL:g,navigate:k,conf:e,setIsLoading:o,setSnackbar:s})})]})}export{q as default};
