"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.CloudDefendRoute = void 0; var _react = _interopRequireDefault(require("react")); var _sharedUxRouter = require("@kbn/shared-ux-router"); var _public = require("@kbn/usage-collection-plugin/public"); var _constants = require("../common/navigation/constants"); var _security_solution_context = require("./security_solution_context"); /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ // Security SpyRoute can be automatically rendered for pages with static paths, Security will manage everything using the `links` object. // Pages with dynamic paths are not in the Security `links` object, they must render SpyRoute with the parameters values, if needed. const STATIC_PATH_PAGE_IDS = Object.fromEntries(Object.values(_constants.cloudDefendPages).map(({ id }) => [id, true])); const CloudDefendRoute = ({ id, children, component: Component, disabled = false, ...cloudDefendRouteProps }) => { var _useSecuritySolutionC; const SpyRoute = (_useSecuritySolutionC = (0, _security_solution_context.useSecuritySolutionContext)()) === null || _useSecuritySolutionC === void 0 ? void 0 : _useSecuritySolutionC.getSpyRouteComponent(); if (disabled) { return null; } const routeProps = { ...cloudDefendRouteProps, ...(Component && { render: renderProps => /*#__PURE__*/_react.default.createElement(_public.TrackApplicationView, { viewId: id }, STATIC_PATH_PAGE_IDS[id] && SpyRoute && /*#__PURE__*/_react.default.createElement(SpyRoute, { pageName: id }), /*#__PURE__*/_react.default.createElement(Component, renderProps)) }) }; return /*#__PURE__*/_react.default.createElement(_sharedUxRouter.Route, routeProps, children); }; exports.CloudDefendRoute = CloudDefendRoute;