"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _novaIcons = require("@coorpacademy/nova-icons");
var _reactNativeAnimation = require("@coorpacademy/react-native-animation");
var _index = _interopRequireDefault(require("../../atom/html/index.native"));
var _index2 = _interopRequireDefault(require("../../atom/text/index.native"));
var _index3 = _interopRequireDefault(require("../../hoc/touchable/index.native"));
var _templateContext = require("../../template/app-review/template-context");
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; }
const createStyleSheet = (theme, type) => _reactNative.StyleSheet.create({
  wrapper: {
    backgroundColor: '#00000000',
    height: 2000,
    display: 'flex',
    justifyContent: 'flex-end'
  },
  popin: {
    padding: theme.spacing.medium,
    borderRadius: 16,
    display: 'flex',
    flexDirection: 'column',
    alignItems: 'flex-start',
    backgroundColor: type === 'wrong' ? theme.colors.negative : theme.colors.positive,
    shadowColor: type === 'wrong' ? theme.colors.negative : theme.colors.positive,
    shadowOpacity: 0.5,
    shadowOffset: {
      width: 0,
      height: 0
    },
    shadowRadius: 15,
    elevation: 4
  },
  correctionSection: {
    flexDirection: 'row',
    alignItems: 'center',
    width: '80%'
  },
  iconCircle: {
    width: 60,
    height: 60,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: theme.colors.white,
    opacity: 0.7,
    borderRadius: 50
  },
  icon: {
    height: 30,
    width: 30
  },
  resultLabel: {
    color: theme.colors.white,
    fontSize: 24,
    fontWeight: '600',
    lineHeight: 24,
    marginLeft: 12,
    textTransform: 'uppercase'
  },
  feedbackSection: {
    marginVertical: theme.spacing.medium
  },
  labelContainer: {
    alignSelf: 'flex-start',
    backgroundColor: 'rgba(255, 255, 255, 0.3)',
    borderRadius: 56,
    paddingHorizontal: theme.spacing.tiny,
    paddingVertical: theme.spacing.micro,
    marginBottom: 8
  },
  label: {
    color: theme.colors.white,
    fontSize: 14,
    fontWeight: theme.fontWeight.extraBold,
    lineHeight: 17
  },
  htmlInfoMessage: {
    color: theme.colors.white,
    fontSize: 16,
    fontWeight: '600',
    lineHeight: 19
  },
  button: {
    alignSelf: 'stretch',
    backgroundColor: theme.colors.white,
    borderRadius: 7,
    paddingHorizontal: theme.spacing.base,
    paddingVertical: theme.spacing.small
  },
  buttonText: {
    color: theme.colors.cta,
    fontSize: 14,
    fontWeight: theme.fontWeight.bold,
    lineHeight: 20,
    textAlign: 'center'
  },
  containerButtonKlf: {
    width: '100%'
  },
  buttonKlf: {
    flexDirection: 'row',
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: 'rgba(255, 255, 255, 0.1)',
    borderRadius: 7,
    paddingHorizontal: theme.spacing.base,
    paddingVertical: theme.spacing.small,
    marginBottom: theme.spacing.tiny
  },
  buttonKlfActive: {
    backgroundColor: 'linear-gradient(0deg, rgba(0, 0, 0, 0.25), rgba(0, 0, 0, 0.25)), rgba(255, 255, 255, 0.1)'
  },
  buttonKlfText: {
    color: 'white',
    fontSize: 14,
    fontWeight: theme.fontWeight.bold,
    lineHeight: 20,
    textAlign: 'center'
  },
  iconKey: {
    width: 12,
    height: 12,
    marginRight: theme.spacing.tiny
  },
  containerTooltip: {
    zIndex: 30,
    position: 'relative',
    shadowColor: theme.colors.black,
    shadowOpacity: 0.3,
    shadowOffset: {
      width: 0,
      height: 0
    },
    shadowRadius: 8
  },
  buttonTooltip: {
    zIndex: 20,
    flexDirection: 'column',
    justifyContent: 'center',
    backgroundColor: theme.colors.white,
    borderRadius: 15,
    padding: theme.spacing.small,
    width: '112%',
    position: 'absolute',
    bottom: 4,
    right: -15,
    shadowColor: theme.colors.black,
    shadowOpacity: 0.3,
    shadowOffset: {
      width: 0,
      height: 0
    },
    shadowRadius: 8,
    elevation: 6
  },
  htmlTooltipText: {
    color: theme.colors.text.primary,
    fontSize: 16,
    fontWeight: '600',
    lineHeight: 22,
    textAlign: 'center'
  },
  triangleTooltip: {
    zIndex: 31,
    width: 0,
    height: 0,
    backgroundColor: 'transparent',
    borderStyle: 'solid',
    borderLeftWidth: 13,
    borderRightWidth: 13,
    borderBottomWidth: 13,
    borderTopWidth: 13,
    borderLeftColor: 'transparent',
    borderTopColor: 'transparent',
    borderRightColor: theme.colors.white,
    borderBottomColor: theme.colors.white,
    transform: [{
      rotate: '45deg'
    }],
    position: 'absolute',
    left: 110,
    top: -20,
    borderRadius: 4
  }
});
const KlfButton = ({
  klf,
  styleSheet
}) => {
  const [displayTooltip, setDisplayTooltip] = (0, _react.useState)(false);
  const fadeIn = (0, _reactNativeAnimation.useAnimateProp)({
    property: 'opacity',
    fromValue: 0,
    toValue: 1,
    duration: 250,
    easing: _reactNative.Easing.bezier(0.25, 1, 0.5, 1)
  });
  const handlePressKey = (0, _react.useCallback)(() => {
    setDisplayTooltip(!displayTooltip);
    !displayTooltip ? fadeIn.start() : fadeIn.reset();
  }, [displayTooltip, fadeIn]);
  const {
    buttonKlf,
    buttonKlfActive,
    buttonKlfText,
    containerButtonKlf,
    containerTooltip,
    buttonTooltip,
    htmlTooltipText,
    iconKey,
    triangleTooltip
  } = styleSheet;
  const {
    label,
    tooltip
  } = klf;
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: containerButtonKlf
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
    style: [containerTooltip, fadeIn.animatedStyle]
  }, /*#__PURE__*/_react.default.createElement(_index3.default, {
    style: buttonTooltip,
    accessibilityLabel: `aria-label-tooltip`,
    isHighlight: true,
    onPress: handlePressKey,
    testID: "button-tooltip"
  }, /*#__PURE__*/_react.default.createElement(_index.default, {
    style: htmlTooltipText
  }, tooltip)), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: triangleTooltip
  })), /*#__PURE__*/_react.default.createElement(_index3.default, {
    style: displayTooltip ? {
      ...buttonKlf,
      ...buttonKlfActive
    } : buttonKlf,
    accessibilityLabel: `aria-label-${label}`,
    onPress: handlePressKey,
    testID: "button-klf"
  }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaLineLoginKey1, {
    style: iconKey,
    color: "white"
  }), /*#__PURE__*/_react.default.createElement(_index2.default, {
    style: buttonKlfText
  }, label)));
};
const ICONS = {
  right: _novaIcons.NovaCompositionCoorpacademyCheck,
  wrong: _novaIcons.NovaSolidStatusClose
};
const ReviewCorrectionPopin = ({
  information,
  klf,
  next,
  type,
  resultLabel
}) => {
  const templateContext = (0, _templateContext.useTemplateContext)();
  const [styleSheet, setStylesheet] = (0, _react.useState)(null);
  const {
    theme
  } = templateContext;
  const handlePressNext = next.onClick;
  const Icon = ICONS[type];
  (0, _react.useEffect)(() => {
    const _stylesheet = createStyleSheet(theme, type);
    setStylesheet(_stylesheet);
  }, [theme, type]);
  if (!styleSheet) {
    return null;
  }
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styleSheet.wrapper
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styleSheet.popin
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styleSheet.correctionSection
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styleSheet.iconCircle
  }, /*#__PURE__*/_react.default.createElement(Icon, {
    style: styleSheet.icon,
    color: type === 'wrong' ? theme.colors.negative : theme.colors.positive
  })), /*#__PURE__*/_react.default.createElement(_index2.default, {
    style: styleSheet.resultLabel
  }, resultLabel)), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styleSheet.feedbackSection,
    accessibilityLabel: "answer-information"
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styleSheet.labelContainer,
    needsOffscreenAlphaCompositing: true
  }, /*#__PURE__*/_react.default.createElement(_index2.default, {
    accessibilityLabel: information.label,
    style: styleSheet.label
  }, information.label)), /*#__PURE__*/_react.default.createElement(_index.default, {
    style: styleSheet.htmlInfoMessage
  }, information.message)), klf && type === 'wrong' ? /*#__PURE__*/_react.default.createElement(KlfButton, {
    styleSheet: styleSheet,
    klf: klf
  }) : null, /*#__PURE__*/_react.default.createElement(_index3.default, {
    style: styleSheet.button,
    onPress: handlePressNext,
    accessibilityLabel: next['aria-label'],
    testID: next['data-name']
  }, /*#__PURE__*/_react.default.createElement(_index2.default, {
    style: styleSheet.buttonText
  }, next.label))));
};
var _default = exports.default = ReviewCorrectionPopin;
//# sourceMappingURL=index.native.js.map