import{b as d,h as S,$ as I,k as E,i as C,j as s,_ as f,z as t}from"./main.2.8.1.js";import{u as j,h as b,d as n}from"./react-router-dom.9mCuUg3q.js";import{S as L}from"./SnackMsg.S8DrwLlT.js";import{S as N,I as v,s as R}from"./Integrations.D2bgBas2.js";import{h as w,O,c as i,T as a}from"./HighLevelCommonFunc.DjRv4nFN.js";import{H as D}from"./HighLevelIntegLayout.DQtbxHSD.js";import"./Note.BeM7sN-p.js";import"./Table.DAL7rcPQ.js";import"./CopyIcn.3gZpHton.js";import"./index.wO-AxluA.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.js";function J({allIntegURL:p}){const m=j(),{id:F,formID:u}=b(),[e,r]=d(S),[l,T]=d(I),c=E(C),[g,P]=n.useState(!1),[_,o]=n.useState({show:!1}),[k,x]=n.useState({auth:!1,customFields:!1,options:!1,contacts:!1,users:!1,hlTasks:!1,pipelines:!1,opportunities:!1}),h=()=>{if(!O.includes(e.selectedTask)&&!i(e)){t.error("Please map all required fields to continue!");return}if(!(e!=null&&e.selectedTask)){t.error("Please select task to continue!");return}if(e.selectedTask===a.UPDATE_CONTACT&&!e.selectedContact&&!i(e)){t.error("Please select a contact or map fields!");return}if((e.selectedTask===a.CREATE_TASK||e.selectedTask===a.UPDATE_TASK)&&!e.selectedContact&&!i(e)){t.error("Please select a contact or map fields!");return}if(e.selectedTask===a.UPDATE_TASK&&!e.updateTaskId&&!i(e)){t.error("Please select a task or map fields!");return}if(e.selectedTask===a.CREATE_OPPORTUNITY||e.selectedTask===a.UPDATE_OPPORTUNITY){if(!e.selectedPipeline){t.error("Please select a pipeline!");return}if(!e.selectedStage){t.error("Please select a stage!");return}if(!e.selectedTaskStatus){t.error("Please select a status!");return}}e.field_map.length>0&&R({flow:l,setFlow:T,allIntegURL:p,navigate:m,conf:e,edit:1,setIsLoading:P,setSnackbar:o})};return s.jsxs("div",{style:{width:900},children:[s.jsx(L,{snack:_,setSnackbar:o}),s.jsxs("div",{className:"flx mt-3",children:[s.jsx("b",{className:"wdt-200 d-in-b",children:f("Integration Name:","bit-integrations")}),s.jsx("input",{className:"btcd-paper-inp w-5",onChange:A=>w(A,e,r),name:"name",value:e.name,type:"text",placeholder:f("Integration Name...","bit-integrations")})]}),s.jsx("br",{}),s.jsx(N,{entity:l.triggered_entity,setSnackbar:o}),s.jsx(D,{formID:u,formFields:c,highLevelConf:e,setHighLevelConf:r,loading:k,setLoading:x}),s.jsx(v,{edit:!0,saveConfig:h,disabled:!e.selectedTask,isLoading:g,dataConf:e,setDataConf:r,formFields:c}),s.jsx("br",{})]})}export{J as default};
