"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _novaIcons = require("@coorpacademy/nova-icons");
var _buttonLink = _interopRequireDefault(require("../../atom/button-link"));
var _provider = _interopRequireWildcard(require("../../atom/provider"));
var _tooltip = _interopRequireDefault(require("../../atom/tooltip"));
var _style = _interopRequireDefault(require("./style.css"));
var _propTypes = _interopRequireDefault(require("./prop-types"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const KlfButton = ({
  klf
}, legacyContext) => {
  const translate = (0, _provider.GetTranslateFromContext)(legacyContext);
  const klfButtonProps = (0, _react.useMemo)(() => ({
    ...klf,
    icon: {
      position: 'left',
      type: 'key'
    },
    type: 'primary'
  }), [klf]);
  const AnchorButton = (0, _react.useCallback)(({
    onKeyDown
  }) => /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.klfButtonContainer
  }, /*#__PURE__*/_react.default.createElement(_buttonLink.default, _extends({}, klfButtonProps, {
    className: _style.default.klfButton,
    onKeyDown: onKeyDown,
    useTitle: false
  }))), [klfButtonProps]);
  const TooltipContent = (0, _react.useCallback)(() => /*#__PURE__*/_react.default.createElement("span", {
    className: _style.default.tooltipText
    // eslint-disable-next-line react/no-danger
    ,
    dangerouslySetInnerHTML: {
      __html: klf.tooltip
    }
  }), [klf.tooltip]);
  const toolTipProps = (0, _react.useMemo)(() => ({
    closeToolTipInformationTextAriaLabel: translate('close_tooltip_information'),
    AnchorElement: AnchorButton,
    TooltipContent,
    'aria-label': translate('More details'),
    tooltipClassName: _style.default.toolTipCustomization
  }), [AnchorButton, TooltipContent, translate]);
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.klfContainer
  }, /*#__PURE__*/_react.default.createElement(_tooltip.default, toolTipProps));
};
KlfButton.propTypes = process.env.NODE_ENV !== "production" ? {
  klf: _propTypes.default.klf
} : {};
KlfButton.contextTypes = {
  translate: _provider.default.childContextTypes.translate
};
const ReviewCorrectionPopin = props => {
  const {
    information,
    resultLabel,
    type,
    klf,
    next
  } = props;
  const nextQuestionButtonProps = {
    ...next,
    type: 'primary'
  };
  const cta = type === 'wrong' ? /*#__PURE__*/_react.default.createElement(KlfButton, {
    klf: klf
  }) : null;
  const ICONS = {
    right: _novaIcons.NovaCompositionCoorpacademyCheck,
    wrong: _novaIcons.NovaSolidStatusClose
  };
  const Icon = ICONS[type];
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.wrapper,
    "data-testid": "review-correction-popin"
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _classnames.default)(_style.default.popin, type === 'right' ? _style.default.right : _style.default.wrong)
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.correctionSection
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.iconCircle
  }, /*#__PURE__*/_react.default.createElement(Icon, {
    className: type === 'right' ? _style.default.iconRight : _style.default.iconWrong
  })), /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.resultLabel
  }, /*#__PURE__*/_react.default.createElement("span", {
    "aria-label": resultLabel,
    role: "status"
  }, resultLabel))), /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.feedbackSection
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.information,
    "aria-label": "answer-information"
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.labelContainer
  }, /*#__PURE__*/_react.default.createElement("span", {
    className: _style.default.label,
    "aria-label": information.label
  }, information.label)), /*#__PURE__*/_react.default.createElement("span", {
    className: _style.default.message,
    "aria-label": information.message
    // eslint-disable-next-line react/no-danger
    ,
    dangerouslySetInnerHTML: {
      __html: information.message
    }
  }))), /*#__PURE__*/_react.default.createElement("div", {
    className: type === 'right' ? _style.default.actions : _style.default.actionsWrong
  }, cta, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.nextQuestionContainer,
    "data-testid": "next-question-button-container"
  }, /*#__PURE__*/_react.default.createElement(_buttonLink.default, _extends({}, nextQuestionButtonProps, {
    className: _style.default.nextQuestionButton
  }))))));
};
ReviewCorrectionPopin.propTypes = process.env.NODE_ENV !== "production" ? _propTypes.default : {};
var _default = exports.default = ReviewCorrectionPopin;
//# sourceMappingURL=index.js.map