"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = NavigationItemBase;
var _clsx = _interopRequireDefault(require("clsx"));
var _element = require("@wordpress/element");
var _context = require("../context");
var _useNavigationTreeItem = require("./use-navigation-tree-item");
var _navigationStyles = require("../styles/navigation-styles");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * External dependencies
 */

/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

let uniqueId = 0;
function NavigationItemBase(props) {
  // Also avoid to pass the `title` and `href` props to the ItemBaseUI styled component.
  const {
    children,
    className,
    title,
    href,
    ...restProps
  } = props;
  const [itemId] = (0, _element.useState)(`item-${++uniqueId}`);
  (0, _useNavigationTreeItem.useNavigationTreeItem)(itemId, props);
  const {
    navigationTree
  } = (0, _context.useNavigationContext)();
  if (!navigationTree.getItem(itemId)?._isVisible) {
    return null;
  }
  const classes = (0, _clsx.default)('components-navigation__item', className);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_navigationStyles.ItemBaseUI, {
    className: classes,
    ...restProps,
    children: children
  });
}
//# sourceMappingURL=base.js.map