function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure undefined"); }

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(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) 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';
import { getSvgStyles } from '../icon/styled-components';
import { KIND, PLACEMENT, TYPE } from './constants';

function getBackgroundColor(kind, type, theme) {
  var _KIND$info$KIND$posit;

  var isInline = type === TYPE.inline;
  return (_KIND$info$KIND$posit = {}, _defineProperty(_KIND$info$KIND$posit, KIND.info, isInline ? theme.colors.notificationInfoBackground : theme.colors.toastInfoBackground), _defineProperty(_KIND$info$KIND$posit, KIND.positive, isInline ? theme.colors.notificationPositiveBackground : theme.colors.toastPositiveBackground), _defineProperty(_KIND$info$KIND$posit, KIND.warning, isInline ? theme.colors.notificationWarningBackground : theme.colors.toastWarningBackground), _defineProperty(_KIND$info$KIND$posit, KIND.negative, isInline ? theme.colors.notificationNegativeBackground : theme.colors.toastNegativeBackground), _KIND$info$KIND$posit)[kind];
}

function getFontColor(kind, type, theme) {
  var _KIND$info$KIND$posit3;

  var isInline = type === TYPE.inline;

  if (isInline) {
    var _KIND$info$KIND$posit2;

    return (_KIND$info$KIND$posit2 = {}, _defineProperty(_KIND$info$KIND$posit2, KIND.info, theme.colors.notificationInfoText), _defineProperty(_KIND$info$KIND$posit2, KIND.positive, theme.colors.notificationPositiveText), _defineProperty(_KIND$info$KIND$posit2, KIND.warning, theme.colors.notificationWarningText), _defineProperty(_KIND$info$KIND$posit2, KIND.negative, theme.colors.notificationNegativeText), _KIND$info$KIND$posit2)[kind];
  }

  return (_KIND$info$KIND$posit3 = {}, _defineProperty(_KIND$info$KIND$posit3, KIND.info, theme.colors.toastInfoText), _defineProperty(_KIND$info$KIND$posit3, KIND.positive, theme.colors.toastPositiveText), _defineProperty(_KIND$info$KIND$posit3, KIND.warning, theme.colors.toastWarningText), _defineProperty(_KIND$info$KIND$posit3, KIND.negative, theme.colors.toastNegativeText), _KIND$info$KIND$posit3)[kind];
}

export function getPlacement(placement) {
  switch (placement) {
    case PLACEMENT.topLeft:
      return {
        top: 0,
        alignItems: 'flex-start',
        justifyContent: 'flex-start',
        flexDirection: 'column'
      };

    case PLACEMENT.top:
      return {
        top: 0,
        alignItems: 'center',
        justifyContent: 'flex-start',
        flexDirection: 'column'
      };

    case PLACEMENT.topRight:
      return {
        top: 0,
        alignItems: 'flex-end',
        justifyContent: 'flex-start',
        flexDirection: 'column'
      };

    case PLACEMENT.bottomRight:
      return {
        bottom: 0,
        alignItems: 'flex-end',
        justifyContent: 'flex-end',
        flexDirection: 'column-reverse'
      };

    case PLACEMENT.bottom:
      return {
        bottom: 0,
        alignItems: 'center',
        justifyContent: 'flex-end',
        flexDirection: 'column-reverse'
      };

    case PLACEMENT.bottomLeft:
      return {
        bottom: 0,
        alignItems: 'flex-start',
        justifyContent: 'flex-end',
        flexDirection: 'column-reverse'
      };
  }
}
export var Root = styled('div', function (_ref) {
  var $placement = _ref.$placement,
      $theme = _ref.$theme;
  return _objectSpread({
    pointerEvents: 'none',
    position: 'fixed',
    right: 0,
    left: 0,
    display: 'flex',
    marginTop: $theme.sizing.scale300,
    marginBottom: $theme.sizing.scale300,
    marginLeft: $theme.sizing.scale600,
    marginRight: $theme.sizing.scale600
  }, getPlacement($placement));
});
Root.displayName = "Root";
Root.displayName = 'Root';
export var InnerContainer = styled('div', // eslint-disable-next-line no-empty-pattern
function (_ref2) {
  _objectDestructuringEmpty(_ref2);

  return {};
});
InnerContainer.displayName = "InnerContainer";
InnerContainer.displayName = 'InnerContainer';
export var Body = styled('div', function (_ref3) {
  var $isVisible = _ref3.$isVisible,
      $kind = _ref3.$kind,
      $type = _ref3.$type,
      $theme = _ref3.$theme;
  var isInline = $type === TYPE.inline;
  return _objectSpread(_objectSpread({}, $theme.typography.font300), {}, {
    pointerEvents: 'auto',
    color: getFontColor($kind, $type, $theme),
    height: 'auto',
    width: '288px',
    paddingTop: $theme.sizing.scale600,
    paddingRight: $theme.sizing.scale600,
    paddingBottom: $theme.sizing.scale600,
    paddingLeft: $theme.sizing.scale600,
    marginTop: $theme.sizing.scale300,
    marginBottom: $theme.sizing.scale300,
    backgroundColor: getBackgroundColor($kind, $type, $theme) || $theme.colors.backgroundAccent,
    borderTopLeftRadius: $theme.borders.radius400,
    borderTopRightRadius: $theme.borders.radius400,
    borderBottomRightRadius: $theme.borders.radius400,
    borderBottomLeftRadius: $theme.borders.radius400,
    boxShadow: isInline ? 'none' : $theme.lighting.shadow600,
    opacity: $isVisible ? 1 : 0,
    transitionProperty: 'all',
    transitionDuration: $theme.animation.timing200,
    transitionTimingFunction: $theme.animation.easeInOutCurve,
    display: 'flex',
    justifyContent: 'space-between'
  });
});
Body.displayName = "Body";
Body.displayName = 'Body';
export var CloseIconSvg = styled('svg', function (_ref4) {
  var $theme = _ref4.$theme,
      $size = _ref4.$size,
      $color = _ref4.$color,
      $isFocusVisible = _ref4.$isFocusVisible;
  return _objectSpread(_objectSpread({}, getSvgStyles({
    $theme: $theme,
    $size: $size,
    $color: $color
  })), {}, {
    cursor: 'pointer',
    width: $size || '16px',
    flexShrink: 0,
    outline: $isFocusVisible ? "3px solid ".concat($theme.colors.borderAccent) : 'none'
  });
});
CloseIconSvg.displayName = "CloseIconSvg";
CloseIconSvg.displayName = 'CloseIconSvg';