import React from 'react';
import PropTypes from 'prop-types';
import { useParams } from 'react-router';
import { Link } from 'react-router-dom';
import { Menu } from 'antd';
import { useAppContext } from '../contexts/AppContext';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
const withRouter = Component => {
  function Wrapper(props) {
    const params = useParams();
    // eslint-disable-next-line react/jsx-props-no-spreading
    return /*#__PURE__*/_jsx(Component, {
      params: params,
      ...props
    });
  }
  return Wrapper;
};
function PageHeaderContent(props) {
  const {
    params
  } = props;
  const {
    dbs,
    getTablesByDbName
  } = useAppContext();
  if (!dbs) {
    return null;
  }
  return /*#__PURE__*/_jsxs("div", {
    className: "dbm-page-header",
    children: [/*#__PURE__*/_jsx("div", {
      className: "logo"
    }, 'logo'), /*#__PURE__*/_jsx(Menu, {
      theme: "dark",
      mode: "horizontal",
      className: "dbm-top-navbar-menu",
      defaultSelectedKeys: ['home'],
      selectedKeys: [params?.dbName || ''],
      items: [{
        key: 'home',
        label: /*#__PURE__*/_jsx(Link, {
          to: "/",
          children: "Home"
        })
      }, ...Object.keys(dbs || {}).sort((dbNameA, dbNameB) => dbNameA.localeCompare(dbNameB)).map(dbName => ({
        key: dbName,
        label: /*#__PURE__*/_jsxs(Link, {
          to: `/${dbName}`,
          children: [dbName, "(", getTablesByDbName(dbName).length, ")"]
        })
      })), {
        key: 'query',
        label: /*#__PURE__*/_jsx(Link, {
          to: "/query",
          children: "Query"
        })
      }, {
        key: 'settings',
        label: /*#__PURE__*/_jsx(Link, {
          to: "/settings",
          children: "Settings"
        })
      }]
    }, 'menu')]
  });
}
PageHeaderContent.propTypes = {
  params: PropTypes.shape({
    dbName: PropTypes.string
  })
};
PageHeaderContent.defaultProps = {
  params: {}
};
export default withRouter(PageHeaderContent);
//# sourceMappingURL=PageHeaderContent.js.map