Liferay.Loader.define("portal-workflow-metrics-web@2.0.46/js/shared/components/navbar-tabs/NavbarTabs.es", ['module', 'exports', 'require', '@frontend-taglib-clay$clayui/navigation-bar', 'frontend-js-react-web$react', 'portal-workflow-metrics-web$react-router-dom', '../../hooks/useRouter.es', '../router/routerUtil.es'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    function _typeof(obj) {
      "@babel/helpers - typeof";
      if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
        _typeof = function _typeof(obj) {
          return typeof obj;
        };
      } else {
        _typeof = function _typeof(obj) {
          return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
        };
      }return _typeof(obj);
    }

    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = void 0;

    var _navigationBar = _interopRequireDefault(require("@frontend-taglib-clay$clayui/navigation-bar"));

    var _react = _interopRequireWildcard(require("frontend-js-react-web$react"));

    var _reactRouterDom = require("portal-workflow-metrics-web$react-router-dom");

    var _useRouter3 = require("../../hooks/useRouter.es");

    var _routerUtil = require("../router/routerUtil.es");

    function _getRequireWildcardCache() {
      if (typeof WeakMap !== "function") return null;var cache = new WeakMap();_getRequireWildcardCache = function _getRequireWildcardCache() {
        return cache;
      };return cache;
    }

    function _interopRequireWildcard(obj) {
      if (obj && obj.__esModule) {
        return obj;
      }if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") {
        return { default: obj };
      }var cache = _getRequireWildcardCache();if (cache && cache.has(obj)) {
        return cache.get(obj);
      }var newObj = {};var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;for (var key in obj) {
        if (Object.prototype.hasOwnProperty.call(obj, key)) {
          var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;if (desc && (desc.get || desc.set)) {
            Object.defineProperty(newObj, key, desc);
          } else {
            newObj[key] = obj[key];
          }
        }
      }newObj.default = obj;if (cache) {
        cache.set(obj, newObj);
      }return newObj;
    }

    function _interopRequireDefault(obj) {
      return obj && obj.__esModule ? obj : { default: obj };
    }

    function _extends() {
      _extends = Object.assign || function (target) {
        for (var i = 1; i < arguments.length; i++) {
          var source = arguments[i];for (var key in source) {
            if (Object.prototype.hasOwnProperty.call(source, key)) {
              target[key] = source[key];
            }
          }
        }return target;
      };return _extends.apply(this, arguments);
    }

    var Item = function Item(_ref) {
      var active = _ref.active,
          name = _ref.name,
          params = _ref.params,
          path = _ref.path;

      var _useRouter = (0, _useRouter3.useRouter)(),
          search = _useRouter.location.search;

      return (/*#__PURE__*/_react.default.createElement(_navigationBar.default.Item, {
          active: active
        }, /*#__PURE__*/_react.default.createElement(_reactRouterDom.Link, {
          className: "nav-link",
          to: {
            pathname: (0, _routerUtil.getPathname)(params, path),
            search: search
          }
        }, name))
      );
    };

    var NavbarTabs = function NavbarTabs(_ref2) {
      var _ref2$tabs = _ref2.tabs,
          tabs = _ref2$tabs === void 0 ? [] : _ref2$tabs;

      var _useRouter2 = (0, _useRouter3.useRouter)(),
          pathname = _useRouter2.location.pathname;

      var isActive = (0, _react.useCallback)(function (tab) {
        return pathname.includes(tab.key);
      }, [pathname]);

      var _ref3 = tabs.filter(isActive)[0] || {},
          activeTabName = _ref3.name;

      return (/*#__PURE__*/_react.default.createElement(_navigationBar.default, {
          triggerLabel: activeTabName
        }, tabs.map(function (tab, index) {
          return (/*#__PURE__*/_react.default.createElement(NavbarTabs.Item, _extends({}, tab, {
              active: isActive(tab),
              key: index
            }))
          );
        }))
      );
    };

    NavbarTabs.Item = Item;
    var _default = NavbarTabs;
    exports.default = _default;
    //# sourceMappingURL=NavbarTabs.es.js.map
  }
});
//# sourceMappingURL=NavbarTabs.es.js.map