import { Image, StyleSheet, Text, View } from 'react-native';
import { BrandingOverlayType } from '@hyperledger/aries-oca/build/legacy';
import { useTheme } from '../../contexts/theme';
import { toImageSource } from '../../utils/credential';
import { useMemo } from 'react';
const CredentialCardLogo = ({
  overlay,
  brandingOverlayType = BrandingOverlayType.Branding10
}) => {
  var _overlay$brandingOver, _overlay$brandingOver2;
  const {
    TextTheme,
    CredentialCardShadowTheme
  } = useTheme();
  const logoHeight = brandingOverlayType === BrandingOverlayType.Branding10 ? 80 : 48;
  const paddingHorizontal = 24;
  const logoText = useMemo(() => {
    var _overlay$metaOverlay2, _overlay$metaOverlay3;
    if (brandingOverlayType === BrandingOverlayType.Branding11) {
      var _overlay$metaOverlay;
      return (((_overlay$metaOverlay = overlay.metaOverlay) === null || _overlay$metaOverlay === void 0 ? void 0 : _overlay$metaOverlay.issuer) ?? 'I').charAt(0).toUpperCase();
    }
    return (((_overlay$metaOverlay2 = overlay.metaOverlay) === null || _overlay$metaOverlay2 === void 0 ? void 0 : _overlay$metaOverlay2.name) ?? ((_overlay$metaOverlay3 = overlay.metaOverlay) === null || _overlay$metaOverlay3 === void 0 ? void 0 : _overlay$metaOverlay3.issuer) ?? 'C').charAt(0).toUpperCase();
  }, [brandingOverlayType, overlay]);
  const styles = StyleSheet.create({
    logoContainer: {
      width: logoHeight,
      height: logoHeight,
      backgroundColor: '#ffffff',
      borderRadius: 8,
      justifyContent: 'center',
      alignItems: 'center',
      ...(brandingOverlayType === BrandingOverlayType.Branding10 && {
        top: -0.5 * logoHeight,
        left: paddingHorizontal,
        marginBottom: -1 * logoHeight,
        ...CredentialCardShadowTheme
      })
    }
  });
  return /*#__PURE__*/React.createElement(View, {
    style: styles.logoContainer
  }, (_overlay$brandingOver = overlay.brandingOverlay) !== null && _overlay$brandingOver !== void 0 && _overlay$brandingOver.logo ? /*#__PURE__*/React.createElement(Image, {
    source: toImageSource((_overlay$brandingOver2 = overlay.brandingOverlay) === null || _overlay$brandingOver2 === void 0 ? void 0 : _overlay$brandingOver2.logo),
    style: {
      resizeMode: 'cover',
      width: logoHeight,
      height: logoHeight,
      borderRadius: 8
    }
  }) : /*#__PURE__*/React.createElement(Text, {
    style: [TextTheme.title, {
      fontSize: 0.5 * logoHeight,
      color: '#000'
    }],
    accessible: false
  }, logoText));
};
export default CredentialCardLogo;
//# sourceMappingURL=CredentialCardLogo.js.map