"use strict";

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.TopNav = void 0;

var _react = _interopRequireWildcard(require("react"));

var _TopNavDesktop = require("./TopNavDesktop/TopNavDesktop");

var _TopNavMobile = require("./TopNavMobile/TopNavMobile");

var _jsxRuntime = require("@emotion/react/jsx-runtime");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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 ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var TopNav = function TopNav(_ref) {
  var documentWidth = _ref.documentWidth,
      items = _ref.items;

  var _useMemo = (0, _react.useMemo)(function () {
    var desktopLeftItems = [];
    var desktopRightItems = [];
    var mobileMenuItems = [];
    var mobileAboveMenuItems = [];
    var mobileBelowMenuItems = [];
    items.forEach(function (_ref2) {
      var position = _ref2.position,
          element = _ref2.element;

      switch (position.desktop) {
        case 'left':
          desktopLeftItems.push(element);
          break;

        case 'right':
          desktopRightItems.push(element);
      }

      switch (position.mobile) {
        case 'above':
          mobileAboveMenuItems.push(element);
          break;

        case 'below':
          mobileBelowMenuItems.push(element);
          break;

        default:
          mobileMenuItems.push(element);
      }
    });
    return {
      desktop: {
        leftItems: desktopLeftItems,
        rightItems: desktopRightItems
      },
      mobile: {
        menuItems: mobileMenuItems,
        aboveMenuItems: mobileAboveMenuItems,
        belowMenuItems: mobileBelowMenuItems
      }
    };
  }, []),
      navDesktopProps = _useMemo.desktop,
      navMobileProps = _useMemo.mobile;

  return documentWidth >= 768 ? (0, _jsxRuntime.jsx)(_TopNavDesktop.TopNavDesktop, _objectSpread({}, navDesktopProps)) : (0, _jsxRuntime.jsx)(_TopNavMobile.TopNavMobile, _objectSpread({}, navMobileProps));
};

exports.TopNav = TopNav;