var _tests$HEADER_NAVIGAT;

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _typeof(obj) { 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); }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a 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); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }

function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }

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

function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }

function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }

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; }

/*
Copyright (c) 2018 Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/

/* eslint-disable react/display-name*/
import * as React from 'react';
import { withProps } from '../helpers/index.js';
import { Button } from '../button/index.js';
import { StatefulMenu as Menu, KEY_STRINGS } from '../menu/index.js';
import { StatefulSelect as Search } from '../select/index.js';
import { styled } from '../styles/index.js';
import COLORS from '../select/examples-colors.json';
import { HamburgerIcon } from './examples-icons.js';
import { HeaderNavigation, ALIGN, StyledNavigationItem as NavigationItem, StyledNavigationList as NavigationList } from './index.js';
import tests from './examples-list.js';
import { TYPE } from '../select/index.js';
var Link = withProps(styled('a', function (props) {
  return {
    ':hover': {
      color: props.$theme.colors.primary400
    }
  };
}), {
  tabIndex: '0'
}); // $FlowFixMe

Link.displayName = 'Link';
var Hamburger = styled('div', function (props) {
  return {
    lineHeight: 'initial'
  };
});
Hamburger.displayName = "Hamburger";
Hamburger.displayName = 'Hamburger';
var StyledHamburgerIcon = styled('span', function (props) {
  return {
    ':after': {
      content: "url('data:image/svg+xml;utf8,".concat(HamburgerIcon(props.$theme.colors.foreground), "');")
    }
  };
});
StyledHamburgerIcon.displayName = "StyledHamburgerIcon";
var ExtraStyledNavigationList = styled(NavigationList, function (props) {
  return {
    backgroundColor: 'red'
  };
});
ExtraStyledNavigationList.displayName = "ExtraStyledNavigationList";
var ITEMS = [];

for (var i = 0; i < 100; i++) {
  ITEMS.push({
    label: "Item ".concat(i)
  });
}

var options = {
  options: COLORS,
  labelKey: 'id',
  valueKey: 'color',
  placeholder: 'Choose a color',
  maxDropdownHeight: '300px'
};

var MenuContainer =
/*#__PURE__*/
function (_React$Component) {
  _inherits(MenuContainer, _React$Component);

  function MenuContainer() {
    var _getPrototypeOf2;

    var _this;

    _classCallCheck(this, MenuContainer);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(MenuContainer)).call.apply(_getPrototypeOf2, [this].concat(args)));

    _defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "state", {
      isOpen: _this.props.isOpen
    });

    return _this;
  }

  _createClass(MenuContainer, [{
    key: "toggleMenu",
    value: function toggleMenu() {
      this.setState({
        isOpen: !this.state.isOpen
      });
    }
  }, {
    key: "render",
    value: function render() {
      var _this2 = this;

      return React.createElement(React.Fragment, null, React.createElement(Hamburger, {
        tabIndex: "0",
        "aria-label": "Navigation menu",
        onKeyDown: function onKeyDown(e) {
          switch (e.key) {
            case KEY_STRINGS.ArrowDown:
            case KEY_STRINGS.Space:
            case KEY_STRINGS.Enter:
              _this2.toggleMenu();

              return;
          }
        },
        onClick: function onClick() {
          return _this2.toggleMenu();
        }
      }, React.createElement(StyledHamburgerIcon, null)), this.state.isOpen && React.createElement(Menu, {
        items: ITEMS,
        overrides: {
          List: {
            style: {
              cursor: 'pointer',
              position: 'absolute',
              height: '90vh',
              right: this.props.align === ALIGN.right ? '0' : 'initial'
            }
          }
        }
      }));
    }
  }]);

  return MenuContainer;
}(React.Component);

_defineProperty(MenuContainer, "defaultProps", {
  isOpen: false,
  align: ''
});

export default (_tests$HEADER_NAVIGAT = {}, _defineProperty(_tests$HEADER_NAVIGAT, tests.HEADER_NAVIGATION_WITH_MENU_ELEMENT, function () {
  return React.createElement(React.Fragment, null, React.createElement("div", {
    style: {
      marginTop: '50px'
    }
  }), React.createElement(HeaderNavigation, null, React.createElement(NavigationList, {
    align: ALIGN.left
  }, React.createElement(NavigationItem, null, React.createElement(MenuContainer, null)), React.createElement(NavigationItem, null, "Uber")), React.createElement(NavigationList, {
    align: ALIGN.center
  }), React.createElement(NavigationList, {
    align: ALIGN.right
  }, React.createElement(NavigationItem, null, React.createElement(Link, null, "Tab Link One")), React.createElement(NavigationItem, null, React.createElement(Link, null, "Tab Link Two")), React.createElement(NavigationItem, null, React.createElement(Link, null, "Tab Link Three"))), React.createElement(NavigationList, {
    align: ALIGN.right
  }, React.createElement(NavigationItem, null, React.createElement(Button, null, "Get started")))));
}), _defineProperty(_tests$HEADER_NAVIGAT, tests.HEADER_NAVIGATION_WITH_RIGHT_MENU, function () {
  return React.createElement(React.Fragment, null, React.createElement("div", {
    style: {
      marginTop: '50px'
    }
  }), React.createElement(HeaderNavigation, null, React.createElement(NavigationList, {
    align: ALIGN.center
  }, React.createElement(NavigationItem, null, React.createElement(Link, null, "Tab Link One")), React.createElement(NavigationItem, null, React.createElement(Link, null, "Tab Link Two")), React.createElement(NavigationItem, null, React.createElement(Link, null, "Tab Link Three"))), React.createElement(NavigationList, {
    align: ALIGN.right
  }, React.createElement(NavigationItem, null, "Uber"), React.createElement(NavigationItem, null, React.createElement(MenuContainer, {
    align: ALIGN.right
  })))));
}), _defineProperty(_tests$HEADER_NAVIGAT, tests.HEADER_NAVIGATION_WITH_OVERRIDES, function () {
  return React.createElement(React.Fragment, null, React.createElement("div", {
    style: {
      marginTop: '50px'
    }
  }), React.createElement(HeaderNavigation, {
    overrides: {
      Root: {
        style: {
          backgroundColor: 'lightblue'
        }
      }
    }
  }, React.createElement(NavigationList, {
    align: ALIGN.left
  }, React.createElement(NavigationItem, null, React.createElement(MenuContainer, null)), React.createElement(NavigationItem, null, "Uber")), React.createElement(NavigationList, {
    align: ALIGN.right
  }, React.createElement(NavigationItem, null, React.createElement(Link, null, "Tab Link One")), React.createElement(NavigationItem, null, React.createElement(Link, null, "Tab Link Two")), React.createElement(NavigationItem, null, React.createElement(Link, null, "Tab Link Three"))), React.createElement(NavigationList, {
    align: ALIGN.right
  }, React.createElement(NavigationItem, null, React.createElement(Button, null, "Get started")))));
}), _defineProperty(_tests$HEADER_NAVIGAT, tests.HEADER_NAVIGATION_SEARCH_BAR, function () {
  return React.createElement(React.Fragment, null, React.createElement("div", {
    style: {
      marginTop: '50px'
    }
  }), React.createElement(HeaderNavigation, null, React.createElement(NavigationList, {
    align: ALIGN.left
  }, React.createElement(NavigationItem, null, React.createElement(MenuContainer, null)), React.createElement(NavigationItem, null, "Uber")), React.createElement(NavigationList, {
    align: ALIGN.center
  }, React.createElement(NavigationItem, null, React.createElement(Link, null, "Tab Link One")), React.createElement(NavigationItem, null, React.createElement(Link, null, "Tab Link Two")), React.createElement(NavigationItem, null, React.createElement(Link, null, "Tab Link Three"))), React.createElement(NavigationList, {
    align: ALIGN.right
  }, React.createElement(NavigationItem, {
    style: {
      width: '300px'
    }
  }, React.createElement(Search, _extends({}, options, {
    type: TYPE.search,
    getOptionLabel: function getOptionLabel(props) {
      return props.option.id || null;
    },
    onChange: function onChange() {},
    rows: 8,
    multi: true
  }))))));
}), _defineProperty(_tests$HEADER_NAVIGAT, tests.HEADER_NAVIGATION_DIFFERENT_ALIGNMENTS, function () {
  return React.createElement(React.Fragment, null, React.createElement("div", {
    style: {
      marginTop: '50px'
    }
  }), React.createElement(HeaderNavigation, null, React.createElement(NavigationList, {
    align: ALIGN.left
  }, React.createElement(NavigationItem, null, "Uber")), React.createElement(NavigationList, {
    align: ALIGN.center
  }, React.createElement(NavigationItem, null, React.createElement(Link, null, "Centered Tab Link One")), React.createElement(NavigationItem, null, React.createElement(Link, null, "Centered Tab Link Two")), React.createElement(NavigationItem, null, React.createElement(Link, null, "Centered Tab Link Three"))), React.createElement(NavigationList, {
    align: ALIGN.right
  }, React.createElement(NavigationItem, null, React.createElement(Link, null, "Right Aligned Link"))), React.createElement(NavigationList, {
    align: ALIGN.right
  }, React.createElement(NavigationItem, null, React.createElement(Button, null, "Get started")))));
}), _defineProperty(_tests$HEADER_NAVIGAT, tests.HEADER_NAVIGATION_STYLED_NAV_LIST, function () {
  return React.createElement(React.Fragment, null, React.createElement("div", {
    style: {
      marginTop: '50px'
    }
  }), React.createElement(HeaderNavigation, null, React.createElement(ExtraStyledNavigationList, {
    align: ALIGN.left
  }, React.createElement(NavigationItem, null, "Uber")), React.createElement(ExtraStyledNavigationList, {
    align: ALIGN.center
  }, React.createElement(NavigationItem, null, React.createElement(Link, null, "Centered Tab Link One")), React.createElement(NavigationItem, null, React.createElement(Link, null, "Centered Tab Link Two")), React.createElement(NavigationItem, null, React.createElement(Link, null, "Centered Tab Link Three"))), React.createElement(NavigationList, {
    align: ALIGN.right
  }, React.createElement(NavigationItem, null, React.createElement(Link, null, "Right Aligned Link"))), React.createElement(NavigationList, {
    align: ALIGN.right
  }, React.createElement(NavigationItem, null, React.createElement(Button, null, "Get started")))));
}), _tests$HEADER_NAVIGAT);