import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
import { jsx, ClassNames } from '@emotion/core';
import { forwardRef } from 'react';
import { BaseNavigation } from '../BaseNavigation/BaseNavigation.esm.js';
import { navigationBaseCss, dropdownToggleCss, hamburgerIconCss, navCss, listCss, itemCss, dropdownCss, dropdownListCss, dropdownItemCss, itemLinkCss, buttonItemCss } from './Navigation.styles.esm.js';

function Navigation(_ref) {
  var items = _ref.items,
      _ref$isInverted = _ref.isInverted,
      isInverted = _ref$isInverted === void 0 ? false : _ref$isInverted,
      _ref$mobileNavMediaQu = _ref.mobileNavMediaQuery,
      mobileNavMediaQuery = _ref$mobileNavMediaQu === void 0 ? "@media (max-width: 1065px)" : _ref$mobileNavMediaQu,
      delegated = _objectWithoutProperties(_ref, ["items", "isInverted", "mobileNavMediaQuery"]);

  return jsx(BaseNavigation, _extends({
    items: items,
    isInverted: isInverted,
    mobileNavMediaQuery: mobileNavMediaQuery // override base components
    ,
    Hamburger: Navigation.Hamburger,
    HamburgerIcon: Navigation.HamburgerIcon,
    Nav: Navigation.Nav,
    List: Navigation.List,
    Item: Navigation.Item,
    ItemLink: Navigation.ItemLink,
    Dropdown: Navigation.Dropdown,
    DropdownItem: Navigation.DropdownItem,
    DropdownToggle: Navigation.DropdownToggle,
    css: navigationBaseCss
  }, delegated));
}

function useNavigationContext() {
  return BaseNavigation.useNavigationContext();
}

Navigation.useNavigationContext = useNavigationContext;
var NavigationHamburger = forwardRef(function NavigationHamburger(delegated, ref) {
  return jsx(BaseNavigation.Hamburger, _extends({}, delegated, {
    ref: ref
  }));
});
Navigation.Hamburger = NavigationHamburger;

function NavigationHamburgerIcon(delegated) {
  var _Navigation$useNaviga = Navigation.useNavigationContext(),
      isMobileNavOpen = _Navigation$useNaviga.isMobileNavOpen;

  return jsx(BaseNavigation.HamburgerIcon, _extends({
    css: hamburgerIconCss,
    className: isMobileNavOpen ? "active" : ""
  }, delegated));
}

Navigation.HamburgerIcon = NavigationHamburgerIcon;

function NavigationNav(delegated) {
  var _Navigation$useNaviga2 = Navigation.useNavigationContext(),
      mobileNavMediaQuery = _Navigation$useNaviga2.mobileNavMediaQuery,
      isMobileNavOpen = _Navigation$useNaviga2.isMobileNavOpen;

  return jsx(BaseNavigation.Nav, _extends({
    css: navCss(mobileNavMediaQuery, isMobileNavOpen)
  }, delegated));
}

Navigation.Nav = NavigationNav;

function NavigationList(delegated) {
  var _Navigation$useNaviga3 = Navigation.useNavigationContext(),
      mobileNavMediaQuery = _Navigation$useNaviga3.mobileNavMediaQuery;

  return jsx(BaseNavigation.List, _extends({
    css: listCss(mobileNavMediaQuery)
  }, delegated));
}

Navigation.List = NavigationList;

function NavigationSpacer(delegated) {
  return jsx("li", _extends({
    css: {
      flex: 1
    }
  }, delegated, {
    role: "separator"
  }));
}

Navigation.Spacer = NavigationSpacer;

function NavigationItem(delegated) {
  var _Navigation$useNaviga4 = Navigation.useNavigationContext(),
      mobileNavMediaQuery = _Navigation$useNaviga4.mobileNavMediaQuery;

  return jsx(BaseNavigation.Item, _extends({
    css: itemCss(mobileNavMediaQuery)
  }, delegated));
}

Navigation.Item = NavigationItem;

function NavigationItemLink(delegated) {
  var _Navigation$useNaviga5 = Navigation.useNavigationContext(),
      isInverted = _Navigation$useNaviga5.isInverted,
      mobileNavMediaQuery = _Navigation$useNaviga5.mobileNavMediaQuery;

  var commonCss = itemLinkCss(mobileNavMediaQuery, isInverted);

  if (isExternalLinkItem(delegated)) {
    return jsx(BaseNavigation.ItemAnchor, _extends({
      css: commonCss
    }, delegated));
  }

  return jsx(BaseNavigation.ItemLink, _extends({
    css: commonCss
  }, delegated));
}

Navigation.ItemLink = NavigationItemLink;

function isExternalLinkItem(props) {
  return isExternalLink(props.item.linkTo);
}

function NavigationDropdown(delegated) {
  var _Navigation$useNaviga6 = Navigation.useNavigationContext(),
      mobileNavMediaQuery = _Navigation$useNaviga6.mobileNavMediaQuery,
      dropdownOffsets = _Navigation$useNaviga6.dropdownOffsets;

  var itemOffset = dropdownOffsets[delegated.item.name];
  var offset = itemOffset ? "".concat(itemOffset, "px") : "0px";
  return jsx(ClassNames, null, function (_ref2) {
    var css = _ref2.css,
        theme = _ref2.theme;
    return jsx(BaseNavigation.Dropdown, _extends({
      css: dropdownCss(mobileNavMediaQuery, offset),
      dropdownListClassName: css(dropdownListCss(theme, mobileNavMediaQuery))
    }, delegated));
  });
}

Navigation.Dropdown = NavigationDropdown;
var NavigationDropdownToggle = forwardRef(function NavigationDropdownToggle(delegated, ref) {
  var _Navigation$useNaviga7 = Navigation.useNavigationContext(),
      mobileNavMediaQuery = _Navigation$useNaviga7.mobileNavMediaQuery;

  return jsx(BaseNavigation.DropdownToggle, _extends({
    css: dropdownToggleCss(mobileNavMediaQuery)
  }, delegated, {
    ref: ref
  }));
});
Navigation.DropdownToggle = NavigationDropdownToggle;

function NavigationDropdownItem(delegated) {
  var _Navigation$useNaviga8 = Navigation.useNavigationContext(),
      mobileNavMediaQuery = _Navigation$useNaviga8.mobileNavMediaQuery;

  return jsx(BaseNavigation.DropdownItem, _extends({
    css: dropdownItemCss(mobileNavMediaQuery)
  }, delegated));
}

Navigation.DropdownItem = NavigationDropdownItem;

function NavigationButton(_ref3) {
  var linkTo = _ref3.linkTo,
      delegated = _objectWithoutProperties(_ref3, ["linkTo"]);

  var _Navigation$useNaviga9 = Navigation.useNavigationContext(),
      mobileNavMediaQuery = _Navigation$useNaviga9.mobileNavMediaQuery;

  var commonCss = buttonItemCss(mobileNavMediaQuery);

  if (isExternalButtonLink(linkTo)) {
    return jsx("li", {
      css: commonCss
    }, jsx(BaseNavigation.AnchorButton, _extends({
      href: linkTo
    }, delegated)));
  }

  return jsx("li", {
    css: commonCss
  }, jsx(BaseNavigation.LinkButton, _extends({
    linkTo: linkTo
  }, delegated)));
}

Navigation.Button = NavigationButton;

function isExternalButtonLink(linkTo, _props) {
  return !linkTo || isExternalLink(linkTo);
}

var isExternalLink = function isExternalLink(linkTo) {
  return Boolean(linkTo.match(/(^http|^mailto)/i));
};

Navigation.__docgenInfo = {
  "description": "",
  "methods": [{
    "name": "useNavigationContext",
    "docblock": null,
    "modifiers": ["static"],
    "params": [],
    "returns": {
      "type": {
        "name": "BaseNavigationContextValue"
      }
    }
  }, {
    "name": "HamburgerIcon",
    "docblock": null,
    "modifiers": ["static"],
    "params": [{
      "name": "delegated",
      "type": {
        "name": "BaseNavigationHamburgerIconProps",
        "alias": "NavigationHamburgerIconProps"
      }
    }],
    "returns": null
  }, {
    "name": "Nav",
    "docblock": null,
    "modifiers": ["static"],
    "params": [{
      "name": "delegated",
      "type": {
        "name": "BaseNavigationNavProps",
        "alias": "NavigationNavProps"
      }
    }],
    "returns": null
  }, {
    "name": "List",
    "docblock": null,
    "modifiers": ["static"],
    "params": [{
      "name": "delegated",
      "type": {
        "name": "BaseNavigationListProps",
        "alias": "NavigationListProps"
      }
    }],
    "returns": null
  }, {
    "name": "Spacer",
    "docblock": null,
    "modifiers": ["static"],
    "params": [{
      "name": "delegated",
      "type": {
        "name": "Omit",
        "elements": [{
          "name": "JSX.IntrinsicElements[\"li\"]",
          "raw": "JSX.IntrinsicElements[\"li\"]"
        }, {
          "name": "union",
          "raw": "\"ref\" | \"role\"",
          "elements": [{
            "name": "literal",
            "value": "\"ref\""
          }, {
            "name": "literal",
            "value": "\"role\""
          }]
        }],
        "raw": "Omit<\n  JSX.IntrinsicElements[\"li\"],\n  \"ref\" | \"role\"\n>",
        "alias": "NavigationSpacerProps"
      }
    }],
    "returns": null
  }, {
    "name": "Item",
    "docblock": null,
    "modifiers": ["static"],
    "params": [{
      "name": "delegated",
      "type": {
        "name": "BaseNavigationListItemProps",
        "alias": "NavigationItemProps"
      }
    }],
    "returns": null
  }, {
    "name": "ItemLink",
    "docblock": null,
    "modifiers": ["static"],
    "params": [{
      "name": "delegated",
      "type": {
        "name": "union",
        "raw": "BaseNavigationItemAnchorProps\n| BaseNavigationItemLinkProps",
        "elements": [{
          "name": "BaseNavigationItemAnchorProps"
        }, {
          "name": "BaseNavigationItemLinkProps"
        }],
        "alias": "NavigationItemLinkProps"
      }
    }],
    "returns": null
  }, {
    "name": "Dropdown",
    "docblock": null,
    "modifiers": ["static"],
    "params": [{
      "name": "delegated",
      "type": {
        "name": "BaseNavigationDropdownProps",
        "alias": "NavigationDropdownProps"
      }
    }],
    "returns": null
  }, {
    "name": "DropdownItem",
    "docblock": null,
    "modifiers": ["static"],
    "params": [{
      "name": "delegated",
      "type": {
        "name": "BaseNavigationDropdownItemProps",
        "alias": "NavigationDropdownItemProps"
      }
    }],
    "returns": null
  }, {
    "name": "Button",
    "docblock": null,
    "modifiers": ["static"],
    "params": [{
      "name": "{ linkTo, ...delegated }: NavigationButtonProps",
      "type": {
        "name": "union",
        "raw": "BaseNavigationAnchorButtonProps\n| BaseNavigationLinkButtonProps",
        "elements": [{
          "name": "BaseNavigationAnchorButtonProps"
        }, {
          "name": "BaseNavigationLinkButtonProps"
        }],
        "alias": "NavigationButtonProps"
      }
    }],
    "returns": null
  }],
  "displayName": "Navigation",
  "props": {
    "isInverted": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "required": false
    },
    "mobileNavMediaQuery": {
      "defaultValue": {
        "value": "`@media (max-width: 1065px)`",
        "computed": false
      },
      "required": false
    }
  }
};

if (typeof STORYBOOK_REACT_CLASSES !== "undefined") {
  STORYBOOK_REACT_CLASSES["src/components/Navigation/Navigation.tsx"] = {
    name: "Navigation",
    docgenInfo: Navigation.__docgenInfo,
    path: "src/components/Navigation/Navigation.tsx"
  };
}

export { Navigation };
//# sourceMappingURL=Navigation.esm.js.map
