"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _reactI18next = require("react-i18next");
var _reactNative = require("react-native");
var _theme = require("../../contexts/theme");
var _bundleResolver = require("../../hooks/bundle-resolver");
var _credential = require("../../utils/credential");
var _helpers = require("../../utils/helpers");
var _ThemedText = require("../texts/ThemedText");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const ContactCredentialListItem = ({
  credential,
  onPress
}) => {
  var _overlay$metaOverlay, _overlay$metaOverlay2;
  const {
    Assets,
    ColorPalette
  } = (0, _theme.useTheme)();
  const {
    t,
    i18n
  } = (0, _reactI18next.useTranslation)();
  const credentialConnectionLabel = (0, _helpers.useCredentialConnectionLabel)(credential);
  const params = (0, _react.useMemo)(() => ({
    identifiers: (0, _credential.getCredentialIdentifiers)(credential),
    attributes: credential.credentialAttributes,
    meta: {
      credConnectionId: credential.connectionId,
      alias: credentialConnectionLabel
    },
    language: i18n.language
  }), [credential, credentialConnectionLabel, i18n.language]);
  const {
    overlay
  } = (0, _bundleResolver.useBranding)(params);
  const styles = _reactNative.StyleSheet.create({
    container: {
      flexDirection: 'row',
      alignItems: 'center',
      justifyContent: 'space-between'
    },
    credentialContainer: {
      flex: 9
    },
    credentialName: {
      color: ColorPalette.brand.primary,
      fontWeight: '600'
    },
    iconContainer: {
      flex: 1,
      padding: 8
    }
  });
  const icon = {
    color: ColorPalette.brand.primary,
    width: 48,
    height: 48
  };
  return /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
    onPress: onPress,
    style: styles.container,
    accessibilityHint: t('ContactDetails.GoToCredentialDetail'),
    accessibilityLabel: `${t('ContactDetails.CredentialName')}: ${overlay === null || overlay === void 0 || (_overlay$metaOverlay = overlay.metaOverlay) === null || _overlay$metaOverlay === void 0 ? void 0 : _overlay$metaOverlay.name}`,
    accessibilityRole: 'button'
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styles.credentialContainer
  }, /*#__PURE__*/_react.default.createElement(_ThemedText.ThemedText, {
    style: styles.credentialName
  }, overlay === null || overlay === void 0 || (_overlay$metaOverlay2 = overlay.metaOverlay) === null || _overlay$metaOverlay2 === void 0 ? void 0 : _overlay$metaOverlay2.name)), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
    style: styles.iconContainer
  }, /*#__PURE__*/_react.default.createElement(Assets.svg.iconChevronRight, icon)));
};
var _default = exports.default = ContactCredentialListItem;
//# sourceMappingURL=ContactCredentialListItem.js.map