"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _novaIcons = require("@coorpacademy/nova-icons");
var _cta = _interopRequireDefault(require("../../atom/cta"));
var _loader = _interopRequireDefault(require("../../atom/loader"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const ICONS = {
  login: _novaIcons.NovaCompositionCoorpacademySchoolGraduation,
  loginFailed: _novaIcons.NovaCompositionCoorpacademyLoginFailed,
  addressError: _novaIcons.NovaCompositionCoorpacademyAddressError,
  reload: _novaIcons.NovaCompositionCoorpacademyReload,
  wrong: _novaIcons.NovaCompositionCoorpacademyReload
};
const TeamsPopin = props => {
  const {
    header,
    content,
    buttonLabel,
    aboutLabel,
    onButtonClick,
    type,
    isLoading = false,
    backgroundImageUrl
  } = props;
  const IconType = ICONS[type];
  const iconContainerStyle = type === 'login' ? _style.default.iconContainer : _style.default.errorIconContainer;
  const Icon = IconType ? /*#__PURE__*/_react.default.createElement("div", {
    className: iconContainerStyle
  }, /*#__PURE__*/_react.default.createElement(IconType, {
    className: _style.default.icon
  })) : null;
  const backgroundImageStyle = backgroundImageUrl ? {
    backgroundImage: `url(${backgroundImageUrl})`,
    backgroundSize: 'cover'
  } : {};
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.background,
    style: backgroundImageStyle
  }, isLoading ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.loader
  }, /*#__PURE__*/_react.default.createElement(_loader.default, {
    "data-name": "teams-popin-loader"
  })) : /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.popin
  }, Icon, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.header,
    "data-name": `popin-header-${type}` // eslint-disable-next-line react/no-danger
    ,
    dangerouslySetInnerHTML: {
      __html: header
    }
  }), /*#__PURE__*/_react.default.createElement("p", {
    className: _style.default.content,
    "data-name": `popin-content-${type}` // eslint-disable-next-line react/no-danger
    ,
    dangerouslySetInnerHTML: {
      __html: content
    }
  }), buttonLabel && onButtonClick ? /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.buttonContainer
  }, /*#__PURE__*/_react.default.createElement(_cta.default, {
    submitValue: buttonLabel,
    onClick: onButtonClick,
    name: `popin-cta-${type}`
  })) : null, aboutLabel ? /*#__PURE__*/_react.default.createElement("p", {
    className: _style.default.about,
    "data-name": `popin-about-label-${type}` // eslint-disable-next-line react/no-danger
    ,
    dangerouslySetInnerHTML: {
      __html: aboutLabel
    }
  }) : null));
};
TeamsPopin.propTypes = process.env.NODE_ENV !== "production" ? {
  header: _propTypes.default.string,
  content: _propTypes.default.string,
  buttonLabel: _propTypes.default.string,
  aboutLabel: _propTypes.default.string,
  onButtonClick: _propTypes.default.func,
  type: _propTypes.default.oneOf(['login', 'reload', 'loginFailed', 'addressError', 'wrong']),
  isLoading: _propTypes.default.bool,
  backgroundImageUrl: _propTypes.default.string
} : {};
var _default = exports.default = TeamsPopin;
//# sourceMappingURL=index.js.map