"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _reactNativeLinearGradient = _interopRequireDefault(require("react-native-linear-gradient"));
var _novaIcons = require("@coorpacademy/nova-icons");
var _reactNativeAnimation = require("@coorpacademy/react-native-animation");
var _index = _interopRequireDefault(require("../../../hoc/touchable/index.native"));
var _templateContext = require("../../app-review/template-context");
var _index2 = _interopRequireDefault(require("../../../atom/text/index.native"));
var _colors = require("../../../variables/colors");
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 {
  cm_primary_blue
} = _colors.COLORS;
const createStyleSheet = theme => _reactNative.StyleSheet.create({
  wrapper: {
    top: 0,
    bottom: 0,
    left: 0,
    right: 0,
    flex: 1,
    justifyContent: 'space-around',
    alignItems: 'center',
    paddingHorizontal: 24
  },
  content: {
    width: '100%',
    alignItems: 'flex-start'
  },
  gradients: {
    position: 'absolute',
    top: 400,
    bottom: 400,
    left: 0,
    right: 0,
    flex: 1
  },
  gradient: {
    position: 'absolute',
    top: -730,
    bottom: 0,
    left: -380,
    right: -380,
    opacity: 1,
    transform: [{
      rotate: '35deg'
    }]
  },
  gradient2: {
    position: 'absolute',
    top: -630,
    bottom: -200,
    left: -300,
    right: -400,
    opacity: 0.6,
    transform: [{
      rotate: '-35deg'
    }]
  },
  animatedLogoWrapper: {
    alignItems: 'center'
  },
  animatedLogo: {
    position: 'absolute',
    width: 77,
    height: 100
  },
  logo: {
    padding: 100
  },
  logoBG: {
    backgroundColor: '#fff',
    top: 20,
    width: 60,
    height: 60
  },
  title: {
    color: '#1D1D2B',
    fontWeight: '600',
    fontSize: 28,
    lineHeight: 36,
    paddingVertical: 8
  },
  description: {
    color: '#1D1D2B',
    fontWeight: '400',
    fontSize: 17,
    lineHeight: 24,
    paddingVertical: 8
  },
  actions: {
    width: '100%'
  },
  buttons: {
    paddingVertical: 20,
    alignItems: 'center'
  },
  button: {
    paddingVertical: 12,
    marginVertical: 4,
    width: '100%',
    flexDirection: 'row',
    justifyContent: 'center',
    borderRadius: 12,
    alignItems: 'center',
    overflow: 'hidden'
  },
  ctaQrCode: {
    backgroundColor: theme.colors.cta
  },
  ctaQrCodeText: {
    marginLeft: 8,
    color: '#fff',
    fontWeight: '700',
    fontSize: 14,
    lineHeight: 24
  },
  qrCodeIcon: {
    fill: '#fff',
    height: 14,
    width: 14
  },
  ctaReceiveMail: {
    backgroundColor: '#eaeaeb'
  },
  ctaReceiveMailText: {
    marginLeft: 8,
    color: '#1D1D2B',
    fontWeight: '700',
    fontSize: 14,
    lineHeight: 24
  },
  mailIcon: {
    fill: '#1D1D2B',
    height: 12,
    width: 16
  },
  help: {
    flexDirection: 'row',
    justifyContent: 'center'
  },
  titleHelp: {
    color: '#9999A8'
  },
  ctaHelp: {
    marginLeft: 5,
    textDecorationLine: 'underline',
    color: '#9999A8'
  }
});
const Welcome = props => {
  const {
    locales,
    onDemoPress,
    onQRCodeButtonPress,
    onHelpPress,
    onReceiveEmailButtonPress
  } = props;
  const {
    theme
  } = (0, _templateContext.useTemplateContext)();
  const [styleSheet, setStylesheet] = (0, _react.useState)(null);
  const translateGradients = (0, _reactNativeAnimation.useTranslateY)({
    fromValue: 0,
    toValue: -200,
    duration: 300,
    delay: 750
  });
  const translateContent = (0, _reactNativeAnimation.useTranslateY)({
    fromValue: 170,
    toValue: 0,
    duration: 450,
    delay: 750
  });
  const fadeInContent = (0, _reactNativeAnimation.useAnimateProp)({
    property: 'opacity',
    fromValue: 0,
    toValue: 1,
    duration: 650,
    delay: 750
  });
  const fadeOutStartLogo = (0, _reactNativeAnimation.useAnimateProp)({
    property: 'opacity',
    fromValue: 1,
    toValue: 0,
    duration: 450,
    delay: 1000
  });
  const fadeInFinalLogo = (0, _reactNativeAnimation.useAnimateProp)({
    property: 'opacity',
    fromValue: 0,
    toValue: 1,
    duration: 250,
    delay: 900
  });
  const scaleAnim = (0, _react.useRef)(new _reactNative.Animated.Value(0)).current;
  const interpolateScale = scaleAnim.interpolate({
    inputRange: [0, 0.4, 0.5, 0.6, 1],
    outputRange: [1, 1.7, 1.7, 1.7, 1]
  });
  (0, _react.useEffect)(() => {
    const _stylesheet = createStyleSheet(theme);
    setStylesheet(_stylesheet);
  }, [theme]);
  (0, _react.useEffect)(() => {
    fadeInContent.start();
    fadeInFinalLogo.start();
    fadeOutStartLogo.start();
    translateContent.start();
    translateGradients.start();
    const animatedScale = _reactNative.Animated.timing(scaleAnim, {
      toValue: 1,
      duration: 1000,
      useNativeDriver: true
    });
    animatedScale.start();

    // on mount only
    // eslint-disable-next-line react-hooks/exhaustive-deps
  }, []);
  if (!styleSheet) {
    return null;
  }
  return /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
    style: [styleSheet.wrapper, translateContent.animatedStyle],
    testID: "welcome"
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
    style: [styleSheet.gradients, translateGradients.animatedStyle]
  }, /*#__PURE__*/_react.default.createElement(_reactNativeLinearGradient.default, {
    colors: [cm_primary_blue, '#fff'],
    locations: [0, 0.95],
    style: styleSheet.gradient
  }), /*#__PURE__*/_react.default.createElement(_reactNativeLinearGradient.default, {
    colors: ['#2199AB', '#fff'],
    locations: [0, 0.95],
    style: styleSheet.gradient2
  })), /*#__PURE__*/_react.default.createElement(_index.default, {
    onLongPress: onDemoPress,
    style: styleSheet.logo
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
    style: [styleSheet.animatedLogoWrapper, {
      transform: [{
        scale: interpolateScale
      }]
    }]
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
    style: [styleSheet.logoBG, fadeInFinalLogo.animatedStyle]
  }), /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
    style: [styleSheet.animatedLogo, fadeInFinalLogo.animatedStyle]
  }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademyLogoCoorp, {
    fill: "#0061FF"
  })), /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
    style: [styleSheet.animatedLogo, fadeOutStartLogo.animatedStyle]
  }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademyLogoCoorp, {
    fill: "#fff"
  })))), /*#__PURE__*/_react.default.createElement(_reactNative.Animated.View, {
    style: [styleSheet.content, fadeInContent.animatedStyle]
  }, /*#__PURE__*/_react.default.createElement(_index2.default, {
    style: styleSheet.title
  }, locales.title), /*#__PURE__*/_react.default.createElement(_index2.default, {
    style: styleSheet.description
  }, locales.description), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styleSheet.actions
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styleSheet.buttons
  }, /*#__PURE__*/_react.default.createElement(_index.default, {
    style: [styleSheet.button, styleSheet.ctaQrCode],
    onPress: onQRCodeButtonPress,
    testID: "qr-code-button"
  }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademyQrCode, {
    style: styleSheet.qrCodeIcon
  }), /*#__PURE__*/_react.default.createElement(_index2.default, {
    style: styleSheet.ctaQrCodeText
  }, locales.ctaQrCode)), /*#__PURE__*/_react.default.createElement(_index.default, {
    style: [styleSheet.button, styleSheet.ctaReceiveMail],
    onPress: onReceiveEmailButtonPress,
    testID: "receive-email-button"
  }, /*#__PURE__*/_react.default.createElement(_novaIcons.NovaCompositionCoorpacademyEmail, {
    style: styleSheet.mailIcon
  }), /*#__PURE__*/_react.default.createElement(_index2.default, {
    style: styleSheet.ctaReceiveMailText
  }, locales.ctaReceiveMail))), /*#__PURE__*/_react.default.createElement(_index.default, {
    onPress: onHelpPress,
    style: styleSheet.help
  }, /*#__PURE__*/_react.default.createElement(_index2.default, {
    style: styleSheet.titleHelp
  }, locales.titleHelp), /*#__PURE__*/_react.default.createElement(_index2.default, {
    style: styleSheet.ctaHelp
  }, locales.ctaHelp)))));
};
var _default = exports.default = Welcome;
//# sourceMappingURL=index.native.js.map