import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { useRef, useLayoutEffect } from 'react';
import classnames from 'classnames';
import { isNotEmpty, isPresent, noop } from '@bigbinary/neeto-cist';
import Typography from '@bigbinary/neetoui/Typography';
import Breadcrumbs from './Breadcrumbs.js';
import HelpPopover from './HelpPopover.js';
import MoreDropdown from './MoreDropdown.js';
import Search from './Search.js';
import { n } from './inject-css-C2dztUxs.js';
import { jsxs, jsx } from 'react/jsx-runtime';
import '@bigbinary/neeto-commons-frontend/utils/general';
import 'react-router-dom';
import '@bigbinary/neeto-icons/Help';
import '@bigbinary/neetoui/Button';
import '@bigbinary/neetoui/Popover';
import 'react-i18next';
import '@bigbinary/neeto-icons/MenuHorizontal';
import '@bigbinary/neeto-icons/MenuVertical';
import '@bigbinary/neetoui/Dropdown';
import '@bigbinary/neetoui/Tooltip';
import 'ramda';
import '@bigbinary/neeto-commons-frontend/react-utils';
import '@babel/runtime/helpers/slicedToArray';
import '@bigbinary/neeto-commons-frontend/react-utils/useFuncDebounce';
import '@bigbinary/neeto-commons-frontend/react-utils/useQueryParams';
import '@bigbinary/neeto-commons-frontend/react-utils/useUpdateEffect';
import '@bigbinary/neeto-icons/Search';
import '@bigbinary/neetoui/Input';
import '@bigbinary/neeto-commons-frontend/utils';

var SIZES = {
  nano: "nano",
  small: "small"
};
var DROPDOWN_BUTTON_SIZES = {
  nano: "small",
  small: "medium"
};

var css = ":root{--neeto-molecules-main-header-height:6.25rem;--neeto-molecules-main-header-with-breadcrumbs-height:8.25rem;--neeto-molecules-effective-header-height:0px}.neeto-molecules-header{align-items:flex-start;background:rgb(var(--neeto-ui-white));display:flex;flex-direction:row;flex-shrink:0;gap:1rem;justify-content:space-between;padding:2.5rem 0 1.5rem;width:100%}@media screen and (max-width:1024px){.neeto-molecules-header{flex-wrap:wrap}}.neeto-molecules-header .neeto-molecules-header__toggle-menubar-btn{margin-inline-end:.5rem}.neeto-molecules-header .neeto-molecules-header__left{align-items:flex-start;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start}.neeto-molecules-header .neeto-molecules-header__left-data-wrap{display:flex;flex-wrap:wrap}.neeto-molecules-header .neeto-molecules-header__page-title{align-items:center;display:flex;flex-direction:row;gap:.75rem;margin-top:-.25rem;width:100%}.neeto-molecules-header .neeto-molecules-header__page-title .neeto-molecule-help-popover-trigger,.neeto-molecules-header .neeto-molecules-header__page-title .neeto-molecule-moredropdown-btn{margin-inline-start:.5rem;vertical-align:middle}@media screen and (max-width:1024px){.neeto-molecules-header .neeto-molecules-header__page-title{margin-top:-.625rem}}@media screen and (max-width:768px){.neeto-molecules-header .neeto-molecules-header__page-title{margin-top:-.5rem}}@media screen and (max-width:576px){.neeto-molecules-header .neeto-molecules-header__page-title{margin-top:-.25rem}}.neeto-molecules-header .neeto-molecules-header__page-title h1{line-height:var(--neeto-ui-leading-tight)}.neeto-molecules-header .neeto-molecules-header__right{align-items:center;display:flex;gap:.75rem;justify-content:flex-end}.neeto-molecules-header .neeto-molecules-header__right:empty{display:none;visibility:hidden}@media screen and (max-width:768px){.neeto-molecules-header .neeto-molecules-header__right{flex-wrap:wrap;justify-content:flex-start}}.neeto-molecules-header .neeto-molecules-header__right .neeto-ui-btn{flex-shrink:0}.neeto-molecules-header .neeto-molecules-header__right .neeto-molecules-header__search-input{flex-grow:0;min-width:12.6rem}.neeto-molecules-header .neeto-molecules-header__right .neeto-molecules-header__action-block{align-items:center;display:flex;flex-shrink:0;gap:.75rem;justify-content:flex-end}@media screen and (max-width:360px){.neeto-molecules-header .neeto-molecules-header__right .neeto-molecules-header__action-block{flex-shrink:1;flex-wrap:wrap;justify-content:flex-start}}.neeto-molecules-header--has-breadcrumbs .neeto-molecules-breadcrumbs-wrap{margin:0 0 1rem}.neeto-molecules-header--has-breadcrumbs .neeto-molecules-header__page-title{margin-top:0}.neeto-molecules-header--nano,.neeto-molecules-header--small{flex-shrink:0;min-height:0}.neeto-molecules-header--nano .neeto-molecules-header__page-title{margin-top:0}";
n(css,{});

var _excluded = ["dropdownButtonProps"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var Header = function Header(_ref) {
  var title = _ref.title,
    _ref$titleHelpPopover = _ref.titleHelpPopoverProps,
    titleHelpPopoverProps = _ref$titleHelpPopover === void 0 ? {} : _ref$titleHelpPopover,
    searchProps = _ref.searchProps,
    _ref$className = _ref.className,
    className = _ref$className === void 0 ? "" : _ref$className,
    actionBlock = _ref.actionBlock,
    _ref$breadcrumbs = _ref.breadcrumbs,
    breadcrumbs = _ref$breadcrumbs === void 0 ? [] : _ref$breadcrumbs,
    _ref$renderDropdown = _ref.renderDropdown,
    renderDropdown = _ref$renderDropdown === void 0 ? noop : _ref$renderDropdown,
    _ref$size = _ref.size,
    size = _ref$size === void 0 ? "small" : _ref$size,
    _ref$dataTestid = _ref["data-testid"],
    dataTestId = _ref$dataTestid === void 0 ? "neeto-molecules-header" : _ref$dataTestid;
  var headerRef = useRef(null);
  useLayoutEffect(function () {
    var updateHeaderHeight = function updateHeaderHeight() {
      if (!headerRef.current) return;
      var height = headerRef.current.offsetHeight;
      document.body.style.setProperty("--neeto-molecules-effective-header-height", "".concat(height, "px"));
    };
    updateHeaderHeight();
    window.addEventListener("resize", updateHeaderHeight);
    return function () {
      return window.removeEventListener("resize", updateHeaderHeight);
    };
  }, []);
  return /*#__PURE__*/jsxs("div", {
    "data-cy": "neeto-molecules-header",
    "data-testid": dataTestId,
    ref: headerRef,
    className: classnames(["neeto-molecules-header", {
      "neeto-molecules-header--has-breadcrumbs": isNotEmpty(breadcrumbs),
      "neeto-molecules-header--small": size === SIZES.small,
      "neeto-molecules-header--nano": size === SIZES.nano
    }, className]),
    children: [/*#__PURE__*/jsx("div", {
      className: "neeto-molecules-header__left",
      children: /*#__PURE__*/jsxs("div", {
        className: "neeto-molecules-header__left-data-wrap",
        children: [isNotEmpty(breadcrumbs) && /*#__PURE__*/jsx(Breadcrumbs, {
          breadcrumbs: breadcrumbs
        }), /*#__PURE__*/jsx("div", {
          className: "neeto-molecules-header__page-title",
          children: /*#__PURE__*/jsxs(Typography, {
            "data-cy": "main-header",
            "data-test-id": "main-header",
            lineHeight: "tight",
            style: size === SIZES.nano ? "h3" : "h1",
            weight: "semibold",
            children: [title, isPresent(titleHelpPopoverProps) && /*#__PURE__*/jsx(HelpPopover, _objectSpread({}, titleHelpPopoverProps)), renderDropdown(function (_ref2) {
              var _ref2$dropdownButtonP = _ref2.dropdownButtonProps,
                dropdownButtonProps = _ref2$dropdownButtonP === void 0 ? {} : _ref2$dropdownButtonP,
                dropdownProps = _objectWithoutProperties(_ref2, _excluded);
              return /*#__PURE__*/jsx(MoreDropdown, _objectSpread({
                dropdownButtonProps: _objectSpread({
                  size: DROPDOWN_BUTTON_SIZES[size]
                }, dropdownButtonProps)
              }, dropdownProps));
            })]
          })
        })]
      })
    }), /*#__PURE__*/jsxs("div", {
      className: "neeto-molecules-header__right",
      children: [searchProps && /*#__PURE__*/jsx(Search, _objectSpread({
        enableUrlSync: true,
        className: classnames(["neeto-molecules-header__search-input", searchProps.className])
      }, searchProps)), actionBlock && /*#__PURE__*/jsx("div", {
        className: "neeto-molecules-header__action-block",
        children: actionBlock
      })]
    })]
  });
};

export { Header as default };
//# sourceMappingURL=Header.js.map
