"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.InfoBar = void 0;
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireDefault(require("styled-components"));
var _ = require("../..");
var _PageWrapper = _interopRequireDefault(require("../PageWrapper"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var bgFn = function bgFn(_ref) {
  var variant = _ref.variant,
    theme = _ref.theme;
  switch (variant) {
    case 'success':
      return theme.color.infoBarBackgroundSuccess;
    case 'error':
      return theme.color.infoBarBackgroundError;
    case 'warning':
      return theme.color.infoBarBackgroundWarning;
    case 'general':
      return theme.color.infoBarBackgroundInfo;
    default:
      return theme.color.infoBarBackgroundInfo;
  }
};
var textLinkFn = function textLinkFn(_ref2) {
  var variant = _ref2.variant,
    theme = _ref2.theme;
  switch (variant) {
    case 'success':
      return theme.color.text;
    case 'error':
      return theme.color.text;
    case 'warning':
      return theme.color.text;
    case 'general':
      return theme.color.link;
    default:
      return theme.color.link;
  }
};
var InfoBarPageWrapper = (0, _styledComponents.default)(_PageWrapper.default).withConfig({
  displayName: "InfoBar__InfoBarPageWrapper",
  componentId: "sc-1xd3qwc-0"
})(["background:", ";color:", ";& span{color:inherit;}& a{font-weight:bold;color:", ";}button{display:block;padding:0;background:none;border-width:0;cursor:pointer;}"], bgFn, function (_ref3) {
  var theme = _ref3.theme;
  return theme.color.text;
}, textLinkFn);
var InfoBarIcon = function InfoBarIcon(_ref4) {
  var variant = _ref4.variant;
  switch (variant) {
    case 'success':
      return _react.default.createElement(_.Icon.CheckCircleFill16, {
        color: function color(theme) {
          return theme.color.infoBarSuccess;
        }
      });
    case 'error':
      return _react.default.createElement(_.Icon.ErrorFill16, {
        color: function color(theme) {
          return theme.color.infoBarError;
        }
      });
    case 'warning':
      return _react.default.createElement(_.Icon.WarningFill16, {
        color: function color(theme) {
          return theme.color.infoBarWarning;
        }
      });
    case 'general':
      return _react.default.createElement(_.Icon.InformationFill16, {
        color: function color(theme) {
          return theme.color.infoBarInfo;
        }
      });
    default:
      return _react.default.createElement(_.Icon.InformationFill16, {
        color: function color(theme) {
          return theme.color.infoBarInfo;
        }
      });
  }
};
var InfoBar = exports.InfoBar = function InfoBar(_ref5) {
  var variant = _ref5.variant,
    onClose = _ref5.onClose,
    className = _ref5.className,
    children = _ref5.children,
    _ref5$closeButtonText = _ref5.closeButtonText,
    closeButtonText = _ref5$closeButtonText === void 0 ? 'Close' : _ref5$closeButtonText;
  return _react.default.createElement(InfoBarPageWrapper, {
    className: className,
    variant: variant
  }, _react.default.createElement(_.Box, {
    py: 1,
    px: 3,
    sm: {
      px: 0
    }
  }, _react.default.createElement(_.Flexbox, {
    container: true,
    alignItems: "center"
  }, _react.default.createElement(_.Flexbox, {
    item: true
  }, _react.default.createElement(_.Box, {
    pr: 2
  }, _react.default.createElement(InfoBarIcon, {
    variant: variant
  }))), _react.default.createElement(_.Flexbox, {
    item: true,
    grow: 2
  }, _react.default.createElement(_.Typography, {
    type: "secondary"
  }, children)), typeof onClose === 'function' ? _react.default.createElement(_.Flexbox, {
    item: true
  }, _react.default.createElement(_.Box, {
    pl: 2
  }, _react.default.createElement("button", {
    type: "button",
    onClick: onClose
  }, _react.default.createElement(_.Icon.Cross16, {
    color: function color(theme) {
      return theme.color.text;
    }
  }), _react.default.createElement(_.VisuallyHidden, null, closeButtonText)))) : _react.default.createElement(_react.default.Fragment, null))));
};