import{h as d,g as h,$ as I,k as E,i as C,j as s,_ as f,z as t}from"./main.2.9.0.js";import{u as j,e as b,b as n}from"./react-router.DMwpH23k.js";import{S as L}from"./SnackMsg.DYSD96P4.js";import{S as N,I as v,s as R}from"./Integrations.DL8wqGct.js";import{h as w,O,c as i,T as a}from"./HighLevelCommonFunc.d88tryba.js";import{H as D}from"./HighLevelIntegLayout.D3kcugUd.js";import"./Note.NSUdvR3c.js";import"./CopyIcn.CEA_lFLo.js";import"./react-vendor.P7K3d6op.js";import"./Table.BfF8RYFZ.js";import"./index.DpWdl9V1.js";import"./TagifyInput.KPPRQJ1B.js";import"./lodash.DCvQBX3r.js";function Q({allIntegURL:p}){const m=j(),{id:F,formID:u}=b(),[e,r]=d(h),[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}),A=()=>{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:S=>w(S,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:A,disabled:!e.selectedTask,isLoading:g,dataConf:e,setDataConf:r,formFields:c}),s.jsx("br",{})]})}export{Q as default};
