import{b as f,$ as O,h as A,k,i as b,j as a,_ as r,z as t}from"./main.2.8.1.js";import{u as C,d}from"./react-router-dom.9mCuUg3q.js";import{S as L}from"./SnackMsg.S8DrwLlT.js";import{S as y,I as N,s as j}from"./Integrations.D2bgBas2.js";import{J as h}from"./JetEngineIntegLayout.NgMWXN2d.js";import{h as p,D as I,c as i,T as s}from"./jetEngineCommonFunctions.DB_uIAts.js";import"./Note.BeM7sN-p.js";import"./CopyIcn.3gZpHton.js";import"./Table.DAL7rcPQ.js";import"./index.wO-AxluA.js";import"./TagifyInput.Cu0YIRbG.js";import"./tagify.YxUZd8Ix.js";function K({allIntegURL:E}){const m=C(),[l,S]=f(O),[e,o]=f(A),[u,D]=d.useState(!1),[g,P]=d.useState({auth:!1,menuPosition:!1,relationTypes:!1,cptList:!1,cctList:!1,relationList:!1}),[_,n]=d.useState({show:!1}),T=k(b),x=()=>{if(!e.selectedTask){t.error(r("Please select a task!","bit-integrations"));return}if(!I.includes(e.selectedTask)&&!i(e)){t.error(r("Please map mandatory fields!","bit-integrations"));return}if((e.selectedTask===s.CREATE_TAXONOMY||e.selectedTask===s.UPDATE_TAXONOMY)&&!e.selectedTaxPostTypes){t.error(r("Please select post type(s)!","bit-integrations"));return}if(e.selectedTask===s.CREATE_RELATION||e.selectedTask===s.UPDATE_RELATION){if(!e.relOptions.parentObject){t.error(r("Please select a parent object!","bit-integrations"));return}if(!e.relOptions.childObject){t.error(r("Please select a child object!","bit-integrations"));return}if(!e.relOptions.selectedRelationType){t.error(r("Please select a relation type!","bit-integrations"));return}}if(e.selectedTask===s.UPDATE_POST_TYPE&&!e.selectedCPT){t.error("Please select a custom post type!");return}if(e.selectedTask===s.UPDATE_CONTENT_TYPE&&!e.selectedCCT){t.error("Please select a custom content type!");return}if(e.selectedTask===s.UPDATE_TAXONOMY&&!e.selectedTaxForEdit){t.error("Please select a taxonomy!");return}if(e.selectedTask===s.UPDATE_RELATION&&!e.relOptions.selectedRelationForEdit){t.error("Please select a relation!");return}if(e.selectedTask===s.DELETE_POST_TYPE&&!e.selectedCPT&&!i(e)){t.error("Please select a custom post type or map fields!");return}if(e.selectedTask===s.DELETE_CONTENT_TYPE&&!e.selectedCCT&&!i(e)){t.error("Please select a custom content type or map fields!");return}if(e.selectedTask===s.DELETE_TAXONOMY&&!e.selectedTaxForEdit&&!i(e)){t.error("Please select a taxonomy or map fields!");return}if(e.selectedTask===s.DELETE_RELATION&&!e.relOptions.selectedRelationForEdit&&!i(e)){t.error("Please select a relation or map fields!");return}j({flow:l,allIntegURL:E,conf:e,navigate:m,edit:1,setSnackbar:n})};return a.jsxs("div",{style:{width:900},children:[a.jsx(L,{snack:_,setSnackbar:n}),a.jsxs("div",{className:"flx mt-3",children:[a.jsx("b",{className:"wdt-200 d-in-b",children:r("Integration Name:","bit-integrations")}),a.jsx("input",{className:"btcd-paper-inp w-5",onChange:c=>p(c,e,o),name:"name",defaultValue:e.name||"",type:"text",placeholder:r("Integration Name...","bit-integrations")})]}),a.jsx("br",{}),a.jsx(y,{entity:l.triggered_entity,setSnackbar:n}),a.jsx(h,{formID:l.triggered_entity_id,formFields:T,handleInput:c=>p(c,e,o),jetEngineConf:e,setJetEngineConf:o,loading:g,setLoading:P,setSnackbar:n}),a.jsx(N,{edit:!0,saveConfig:x,isLoading:u,dataConf:e,setDataConf:o,formFields:T}),a.jsx("br",{})]})}export{K as default};
