'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _styledComponents = require('styled-components');

var _styledComponents2 = _interopRequireDefault(_styledComponents);

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

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var Item = _styledComponents2.default.li.withConfig({
  displayName: 'MenuItem__Item'
})(['&:nth-of-type(1){order:1}&:nth-of-type(2){order:2}&:nth-of-type(3){order:3}&:nth-of-type(4){order:4}&:nth-of-type(5){order:5}&:nth-of-type(6){order:6}&:nth-of-type(7){order:7}&:nth-of-type(8){order:8}@media screen and (max-width:1024px){&:nth-of-type(1){order:1}&:nth-of-type(2){order:3}&:nth-of-type(3){order:4}&:nth-of-type(4){order:5}&:nth-of-type(5){order:6}&:nth-of-type(6){order:7}&:nth-of-type(7){order:2}&:nth-of-type(8){order:8}}&:first-of-type{margin-right:30px;opacity:1 !important;}&:last-of-type{margin-left:25px;@media screen and (max-width:1024px){bottom:0;margin:0;opacity:0;padding:10px;position:absolute;transition:opacity 500ms ease-in;visibility:collapse;width:100%;}}& > a,& > a:hover,& > a:visited{color:', ';position:relative;text-decoration:none;text-transform:uppercase;z-index:1;}&.with-children{border-radius:2px 2px 0 0 !important;padding:0 40px 0 20px;position:relative;@media screen and (height:480px) and (orientation:portrait){margin-top:0;padding:0 0 0 30px;}@media screen and (max-height:667px) and (max-width:1024px) and (orientation:landscape){padding:0 0 0 30px;width:25%;}@media screen and (height:568px) and (orientation:portrait){padding:0 0 0 30px;}@media screen and (min-width:667px) and (max-width:1024px){width:25%;}@media screen and (min-width:1024px) and (max-width:1155px){padding-right:20px;}@media screen and (max-width:1024px){margin:0;min-height:170px;opacity:0;padding-left:40px;width:50%;}}&.with-children:hover ul{background:rgba(255,255,255,.08);list-style:none;transition:background .4s ease-in;}&.with-children > a{font-size:13px;@media screen and (height:480px) and (orientation:portrait){font-size:14px;}@media screen and (width:480px) and (orientation:landscape){font-size:14px;}@media screen and (max-height:568px) and (max-width:1024px){font-size:16px;}}&.with-children:hover ul li{height:18px;transition:height .25s ease-in;@media screen and (max-height:568px) and (max-width:1024px){margin:10px 0;}}&.with-children:hover ul li a{opacity:.6;transition:opacity .2s ease-in;transition-delay:.1s;@media screen and (height:480px) and (orientation:portrait){font-size:14px;}}& ul{background:rgba(255,255,255,0);height:150px;left:0;list-style:none;padding:0;position:absolute;top:-10px;min-width:90px;padding-top:40px;& li{margin:6px 0;height:0;transition:height .25s ease-out;&:first-of-type{margin-top:0;}&:hover{& a,& a:active,& a:visited{text-decoration:none;}& a:focus{outline:none !important;}& a{opacity:1 !important;transition:opacity .2s ease-in;}}& a{color:', ';display:block;font-size:12px;font-weight:300;opacity:0;padding-left:20px;}}@media screen and (height:480px) and (orientation:portrait){left:30px;padding-top:30px;}@media screen and (max-height:667px) and (max-width:1024px) and (orientation:landscape){left:30px;padding-top:30px;}@media screen and (height:568px) and (orientation:portrait){left:30px;padding-top:30px;}}'], function (props) {
  return props.theme['white'];
}, function (props) {
  return props.theme['white'];
});

var MenuItem = function (_Component) {
  _inherits(MenuItem, _Component);

  function MenuItem() {
    _classCallCheck(this, MenuItem);

    return _possibleConstructorReturn(this, (MenuItem.__proto__ || Object.getPrototypeOf(MenuItem)).apply(this, arguments));
  }

  _createClass(MenuItem, [{
    key: 'render',
    value: function render() {
      var _props = this.props,
          children = _props.children,
          hasMenu = _props.hasMenu,
          onChange = _props.onChange,
          flexibleSpace = _props.flexibleSpace;

      return flexibleSpace ? _react2.default.createElement(Item, { style: { flexGrow: 1 } }) : _react2.default.createElement(
        Item,
        { className: hasMenu ? 'with-children' : null, onMouseEnter: hasMenu ? function () {
            return onChange(true);
          } : null, onMouseLeave: hasMenu ? function () {
            return onChange(false);
          } : null },
        ' ',
        children,
        ' '
      );
    }
  }]);

  return MenuItem;
}(_react.Component);

exports.default = MenuItem;