function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, 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; }

/*
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.
*/
import { styled } from '../styles/index.js';
import { ARROW_WIDTH } from './constants.js';
import { getPopoverMarginStyles, getArrowPositionStyles, getStartPosition, getEndPosition } from './utils.js';

/**
 * Main popover container element that gets positioned next to the anchor
 */
export function getBodyStyles(props) {
  var $isOpen = props.$isOpen,
      $isAnimating = props.$isAnimating,
      $placement = props.$placement,
      $popoverOffset = props.$popoverOffset,
      $showArrow = props.$showArrow,
      $theme = props.$theme;
  return _objectSpread({
    position: 'absolute',
    top: 0,
    left: 0,
    zIndex: 1050,
    backgroundColor: $theme.colors.background,
    borderRadius: $theme.borders.useRoundedCorners ? $theme.borders.radius300 : '0px',
    boxShadow: $theme.lighting.shadow600,
    transitionProperty: 'opacity,transform',
    transitionDuration: $isAnimating ? '0.1s' : '0s',
    transitionTimingFunction: $isOpen ? $theme.animation.easeOutCurve : $theme.animation.easeInCurve,
    opacity: $isAnimating && $isOpen ? 1 : 0,
    transform: $isAnimating && $isOpen ? getEndPosition($popoverOffset) : getStartPosition($popoverOffset, $placement, $showArrow)
  }, getPopoverMarginStyles($showArrow, $placement));
}
export var Body = styled('div', getBodyStyles);
/**
 * Arrow shown between the popover and the anchor element
 */

Body.displayName = "Body";
export function getArrowStyles(props) {
  var $arrowOffset = props.$arrowOffset,
      $placement = props.$placement,
      $theme = props.$theme;
  return _objectSpread({
    backgroundColor: $theme.colors.backgroundAlt,
    boxShadow: $theme.lighting.shadow600,
    width: "".concat(ARROW_WIDTH, "px"),
    height: "".concat(ARROW_WIDTH, "px"),
    transform: 'rotate(45deg)',
    position: 'absolute',
    zIndex: 1
  }, getArrowPositionStyles($arrowOffset, $placement));
}
export var Arrow = styled('div', getArrowStyles);
/**
 * Extra div that holds the popover content. This extra element
 * is needed for the arrow–the arrow is just a 45deg rotated div,
 * and rendering this extra element on top with a solid background
 * clips the part of the arrow that extends into the popover.
 */

Arrow.displayName = "Arrow";
export function getInnerStyles(_ref) {
  var $theme = _ref.$theme;
  return {
    backgroundColor: $theme.colors.backgroundAlt,
    color: $theme.colors.foreground,
    borderRadius: $theme.borders.useRoundedCorners ? $theme.borders.radius300 : '0px',
    position: 'relative',
    zIndex: 2 // Above "Arrow"

  };
}
export var Inner = styled('div', getInnerStyles);
/**
 * A drop-in component that provides the recommended padding
 * for popovers. Mostly a convenience for users so they don't
 * have to define this themselves.
 */

Inner.displayName = "Inner";
export var Padding = styled('div', {
  padding: '12px'
});
Padding.displayName = "Padding";