"use strict";

import { Image, StyleSheet } from "react-native";
import { useIOThemeContext, useIOTheme } from "../../context";
import { IOListItemLogoMargin } from "../../core";
import { addCacheTimestampToUri } from "../../utils/image";
import { IOText } from "../typography";
import { PressableModuleBase } from "./PressableModuleBase";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
const styles = StyleSheet.create({
  idpLogo: {
    marginStart: IOListItemLogoMargin,
    width: 120,
    height: 30,
    resizeMode: "contain"
  }
});
const useIDPLogo = logo => {
  const {
    themeType
  } = useIOThemeContext();
  const logoIDPLightMode = addCacheTimestampToUri(logo.light);
  if (!logo.dark) {
    return logoIDPLightMode;
  }
  const logoIDPDarkMode = addCacheTimestampToUri(logo.dark);
  return themeType === "dark" ? logoIDPDarkMode : logoIDPLightMode;
};
export const ModuleIDP = ({
  name,
  logo,
  withLooseSpacing = false,
  onPress,
  testID,
  accessibilityLabel
}) => {
  const theme = useIOTheme();
  const IDPLogoSource = useIDPLogo(logo);
  return /*#__PURE__*/_jsxs(PressableModuleBase, {
    onPress: onPress,
    testID: testID,
    withLooseSpacing: withLooseSpacing,
    children: [/*#__PURE__*/_jsx(IOText, {
      weight: "Semibold",
      size: 12,
      lineHeight: 16,
      color: theme["textBody-tertiary"],
      textStyle: {
        alignSelf: "center",
        textTransform: "uppercase",
        letterSpacing: 0.5,
        flexShrink: 1
      },
      accessibilityLabel: accessibilityLabel ?? name,
      children: name
    }), /*#__PURE__*/_jsx(Image, {
      accessibilityIgnoresInvertColors: true,
      source: IDPLogoSource,
      style: styles.idpLogo
    })]
  });
};
//# sourceMappingURL=ModuleIDP.js.map