import{j as e,_ as c}from"./main.2.9.0.js";import{u as j,e as S,b as a}from"./react-router.DMwpH23k.js";import"./CopyIcn.CEA_lFLo.js";import{B as I}from"./BackIcn._8Wofmn2.js";import{S as v}from"./SnackMsg.DYSD96P4.js";import{S as D}from"./Steps.BYe8zHkm.js";import{l as w,I as C,s as _}from"./Integrations.DL8wqGct.js";import N from"./ZohoDeskAuthorization.Ce7xG1JK.js";import{h as Z,c as y}from"./ZohoDeskCommonFunc.D793YqQj.js";import{Z as P}from"./ZohoDeskIntegLayout.BhigWi0r.js";import"./react-vendor.P7K3d6op.js";import"./Note.NSUdvR3c.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TutorialLink.CFG7bS5c.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";function V({formFields:l,setFlow:h,flow:u,allIntegURL:g}){const x=j(),{formID:r}=S(),[m,n]=a.useState(!1),[o,d]=a.useState(1),[k,s]=a.useState({show:!1}),[t,i]=a.useState({name:"Zoho Desk",type:"Zoho Desk",clientId:"",clientSecret:"",orgId:"",department:"",field_map:[{formField:"",zohoFormField:""}],actions:{}});a.useEffect(()=>{window.opener&&w("zohoDesk")},[]);const b=p=>{var f;{if(!y(t)){s({show:!0,msg:c("Please map mandatory fields","bit-integrations")});return}if(!((f=t.actions)!=null&&f.ticket_owner)){s({show:!0,msg:c("Please select a ticket owner","bit-integrations")});return}t.department!==""&&t.table!==""&&t.field_map.length>0&&d(p)}};return e.jsxs("div",{children:[e.jsx(v,{snack:k,setSnackbar:s}),e.jsx("div",{className:"txt-center mt-2",children:e.jsx(D,{step:3,active:o})}),e.jsx(N,{formID:r,deskConf:t,setDeskConf:i,step:o,setstep:d,isLoading:m,setIsLoading:n,setSnackbar:s}),e.jsxs("div",{className:"btcd-stp-page",style:{width:o===2&&900,height:o===2&&"auto"},children:[e.jsx(P,{formID:r,formFields:l,handleInput:p=>Z(p,t,i,r,n,s),deskConf:t,setDeskConf:i,isLoading:m,setIsLoading:n,setSnackbar:s}),e.jsxs("button",{onClick:()=>b(3),disabled:t.department===""||t.table===""||t.field_map.length<1,className:"btn f-right btcd-btn-lg purple sh-sm flx",type:"button",children:[c("Next","bit-integrations"),e.jsx(I,{className:"ml-1 rev-icn"})]})]}),e.jsx(C,{step:o,saveConfig:()=>_({flow:u,setFlow:h,allIntegURL:g,navigate:x,conf:t,setIsLoading:n,setSnackbar:s}),isLoading:m,dataConf:t,setDataConf:i,formFields:l})]})}export{V as default};
