import { objectWithoutProperties as _objectWithoutProperties, extends as _extends } from '../../../_virtual/_rollupPluginBabelHelpers.js';
import { jsx } from '@emotion/core';
import { Fragment } from 'react';
import _pt from 'prop-types';
import { MdKeyboardArrowDown } from 'react-icons/md';
import { Heading } from '../Heading/Heading.esm.js';
import { forwardRefWithAs } from '../../../node_modules/@reach/utils/dist/utils.esm.esm.js';
import { DisableReachStyleCheck } from '../../utils/helpers/DisableReachStyleCheck.esm.js';
import { Menu, MenuButton, MenuList, MenuItems, MenuItem, MenuPopover, useMenuButtonContext, MenuLink } from '../../../node_modules/@reach/menu-button/dist/menu-button.esm.esm.js';
import { animated as extendedAnimated, useSpring } from '../../../node_modules/react-spring/web.esm.js';
import { dropdownButtonCss, dropdownButtonIconCss, menuItemCss, dropdownDividerCss, dropdownHeaderCss, dropdownCss, dropdownSizeCss } from './DropdownMenu.styles.esm.js';

var DropdownMenu = function DropdownMenu(props) {
  return jsx(Fragment, null, jsx(DisableReachStyleCheck, {
    reachComponent: "menu-button"
  }), jsx(Menu, props));
};
var DropdownMenuButton = function DropdownMenuButton(props) {
  return jsx(MenuButton, props);
};
var DropdownMenuButtonStyled = function DropdownMenuButtonStyled(_ref) {
  var children = _ref.children,
      props = _objectWithoutProperties(_ref, ["children"]);

  return jsx(DropdownMenuButton, _extends({}, props, {
    css: dropdownButtonCss
  }), children, jsx(MdKeyboardArrowDown, {
    css: dropdownButtonIconCss
  }));
};
var AnimatedMenuList = extendedAnimated(MenuList);
var DropdownMenuItems = function DropdownMenuItems(_ref2) {
  var _ref2$size = _ref2.size,
      size = _ref2$size === void 0 ? "LEGACY" : _ref2$size,
      rest = _objectWithoutProperties(_ref2, ["size"]);

  var styleProps = useAnimatedMenuItems();

  var finalCss = function finalCss(theme) {
    return [dropdownCss(theme), dropdownSizeCss[size](theme)];
  };

  return jsx(AnimatedMenuList, _extends({
    style: styleProps
  }, rest, {
    css: finalCss
  }));
};
DropdownMenuItems.propTypes = {
  size: _pt.oneOf(["AUTO", "MAX_CONTENT", "LEGACY"])
};
var AnimatedMenuItems = extendedAnimated(MenuItems);
var DropdownMenuItemsLowLevel = function DropdownMenuItemsLowLevel(_ref3) {
  var _ref3$size = _ref3.size,
      size = _ref3$size === void 0 ? "LEGACY" : _ref3$size,
      rest = _objectWithoutProperties(_ref3, ["size"]);

  var styleProps = useAnimatedMenuItems();

  var finalCss = function finalCss(theme) {
    return [dropdownCss(theme), dropdownSizeCss[size](theme)];
  };

  return jsx(AnimatedMenuItems, _extends({
    style: styleProps
  }, rest, {
    css: finalCss
  }));
};
DropdownMenuItemsLowLevel.propTypes = {
  size: _pt.oneOf(["AUTO", "MAX_CONTENT", "LEGACY"])
};
var DropdownMenuItem = function DropdownMenuItem(props) {
  return jsx(MenuItem, _extends({}, props, {
    css: menuItemCss
  }));
};
var DropdownMenuLink = forwardRefWithAs(function DropdownMenuLink(props, ref) {
  return jsx(MenuLink, _extends({
    ref: ref
  }, props, {
    css: menuItemCss
  }));
});
function DropdownMenuPopover(props) {
  return jsx(MenuPopover, props);
}
function useDropdownMenuContext() {
  return useMenuButtonContext();
}
function DropdownDivider(props) {
  return jsx("hr", _extends({}, props, {
    css: dropdownDividerCss
  }));
}
var DropdownHeader = function DropdownHeader(_ref4) {
  var children = _ref4.children,
      props = _objectWithoutProperties(_ref4, ["children"]);

  return jsx(Heading, _extends({}, props, {
    css: dropdownHeaderCss
  }), children);
};

function useAnimatedMenuItems() {
  var _useDropdownMenuConte = useDropdownMenuContext(),
      isExpanded = _useDropdownMenuConte.isExpanded;

  return useSpring({
    opacity: isExpanded ? 1 : 0,
    transform: isExpanded ? "scale(1)" : "scale(0.95)",
    config: {
      tension: 400
    }
  });
}

DropdownMenu.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "DropdownMenu"
};

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

DropdownMenuButton.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "DropdownMenuButton"
};

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

DropdownMenuButtonStyled.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "DropdownMenuButtonStyled"
};

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

DropdownMenuItems.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "DropdownMenuItems",
  "props": {
    "size": {
      "defaultValue": {
        "value": "`LEGACY`",
        "computed": false
      },
      "required": false
    }
  }
};

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

DropdownMenuItemsLowLevel.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "DropdownMenuItemsLowLevel",
  "props": {
    "size": {
      "defaultValue": {
        "value": "`LEGACY`",
        "computed": false
      },
      "required": false
    }
  }
};

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

DropdownMenuItem.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "DropdownMenuItem"
};

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

DropdownMenuPopover.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "DropdownMenuPopover"
};

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

DropdownDivider.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "DropdownDivider"
};

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

DropdownHeader.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "DropdownHeader"
};

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

export { DropdownDivider, DropdownHeader, DropdownMenu, DropdownMenuButton, DropdownMenuButtonStyled, DropdownMenuItem, DropdownMenuItems, DropdownMenuItemsLowLevel, DropdownMenuLink, DropdownMenuPopover, useDropdownMenuContext };
//# sourceMappingURL=DropdownMenu.esm.js.map
