"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Root = exports.InnerContainer = exports.CloseIconSvg = exports.Body = void 0;
exports.getPlacement = getPlacement;

var _styles = require("../styles");

var _styledComponents = require("../icon/styled-components");

var _constants = require("./constants");

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

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

  var isInline = type === _constants.TYPE.inline;
  return (_KIND$info$KIND$posit = {}, _defineProperty(_KIND$info$KIND$posit, _constants.KIND.info, isInline ? theme.colors.notificationInfoBackground : theme.colors.toastInfoBackground), _defineProperty(_KIND$info$KIND$posit, _constants.KIND.positive, isInline ? theme.colors.notificationPositiveBackground : theme.colors.toastPositiveBackground), _defineProperty(_KIND$info$KIND$posit, _constants.KIND.warning, isInline ? theme.colors.notificationWarningBackground : theme.colors.toastWarningBackground), _defineProperty(_KIND$info$KIND$posit, _constants.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 === _constants.TYPE.inline;

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

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

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

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

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

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

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

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

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

var Root = (0, _styles.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));
});
exports.Root = Root;
Root.displayName = "Root";
Root.displayName = 'Root';
var InnerContainer = (0, _styles.styled)('div', // eslint-disable-next-line no-empty-pattern
function (_ref2) {
  _objectDestructuringEmpty(_ref2);

  return {};
});
exports.InnerContainer = InnerContainer;
InnerContainer.displayName = "InnerContainer";
InnerContainer.displayName = 'InnerContainer';
var Body = (0, _styles.styled)('div', function (_ref3) {
  var $isVisible = _ref3.$isVisible,
      $kind = _ref3.$kind,
      $type = _ref3.$type,
      $theme = _ref3.$theme;
  var isInline = $type === _constants.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'
  });
});
exports.Body = Body;
Body.displayName = "Body";
Body.displayName = 'Body';
var CloseIconSvg = (0, _styles.styled)('svg', function (_ref4) {
  var $theme = _ref4.$theme,
      $size = _ref4.$size,
      $color = _ref4.$color,
      $isFocusVisible = _ref4.$isFocusVisible;
  return _objectSpread(_objectSpread({}, (0, _styledComponents.getSvgStyles)({
    $theme: $theme,
    $size: $size,
    $color: $color
  })), {}, {
    cursor: 'pointer',
    width: $size || '16px',
    flexShrink: 0,
    outline: $isFocusVisible ? "3px solid ".concat($theme.colors.borderAccent) : 'none'
  });
});
exports.CloseIconSvg = CloseIconSvg;
CloseIconSvg.displayName = "CloseIconSvg";
CloseIconSvg.displayName = 'CloseIconSvg';