"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _core = require("@aries-framework/core");
var _reactHooks = require("@aries-framework/react-hooks");
var _react = _interopRequireDefault(require("react"));
var _reactI18next = require("react-i18next");
var _reactNative = require("react-native");
var _theme = require("../../contexts/theme");
var _notifications = require("../../hooks/notifications");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const offset = 25;
const HomeFooterView = _ref => {
  let {
    children
  } = _ref;
  const credentials = [...(0, _reactHooks.useCredentialByState)(_core.CredentialState.CredentialReceived), ...(0, _reactHooks.useCredentialByState)(_core.CredentialState.Done)];
  const notifications = (0, _notifications.useNotifications)();
  const {
    HomeTheme
  } = (0, _theme.useTheme)();
  const {
    t
  } = (0, _reactI18next.useTranslation)();
  const styles = _reactNative.StyleSheet.create({
    container: {
      paddingHorizontal: offset,
      paddingBottom: offset * 3
    },
    messageContainer: {
      alignItems: 'center',
      justifyContent: 'center',
      marginTop: 35,
      marginHorizontal: offset
    }
  });
  const displayMessage = credentialCount => {
    if (typeof credentialCount === 'undefined' && credentialCount >= 0) {
      throw new Error('Credential count cannot be undefined');
    }
    let credentialMsg;
    if (credentialCount === 1) {
      credentialMsg = /*#__PURE__*/_react.default.createElement(_reactNative.Text, null, t('Home.YouHave'), " ", /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          fontWeight: 'bold'
        }
      }, credentialCount), " ", t('Home.Credential'), ' ', t('Home.InYourWallet'));
    } else if (credentialCount > 1) {
      credentialMsg = /*#__PURE__*/_react.default.createElement(_reactNative.Text, null, t('Home.YouHave'), " ", /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
        style: {
          fontWeight: 'bold'
        }
      }, credentialCount), " ", t('Home.Credentials'), ' ', t('Home.InYourWallet'));
    } else {
      credentialMsg = t('Home.NoCredentials');
    }
    return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, notifications.total === 0 && /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: [styles.messageContainer]
    }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
      adjustsFontSizeToFit: true,
      style: [HomeTheme.welcomeHeader, {
        marginTop: offset,
        marginBottom: 20
      }]
    }, t('Home.Welcome'))), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
      style: [styles.messageContainer]
    }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
      style: [HomeTheme.credentialMsg, {
        marginTop: offset,
        textAlign: 'center'
      }]
    }, credentialMsg)));
  };
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styles.container
  }, displayMessage(credentials.length)), children);
};
var _default = HomeFooterView;
exports.default = _default;
//# sourceMappingURL=HomeFooterView.js.map