"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.ModuleIDP = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _context = require("../../context");
var _core = require("../../core");
var _image = require("../../utils/image");
var _typography = require("../typography");
var _PressableModuleBase = require("./PressableModuleBase");
var _jsxRuntime = require("react/jsx-runtime");
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 styles = _reactNative.StyleSheet.create({
  idpLogo: {
    marginStart: _core.IOListItemLogoMargin,
    width: 120,
    height: 30,
    resizeMode: "contain"
  }
});
const useIDPLogo = logo => {
  const {
    themeType
  } = (0, _context.useIOThemeContext)();
  const logoIDPLightMode = (0, _image.addCacheTimestampToUri)(logo.light);
  if (!logo.dark) {
    return logoIDPLightMode;
  }
  const logoIDPDarkMode = (0, _image.addCacheTimestampToUri)(logo.dark);
  return themeType === "dark" ? logoIDPDarkMode : logoIDPLightMode;
};
const ModuleIDP = ({
  name,
  logo,
  withLooseSpacing = false,
  onPress,
  testID,
  accessibilityLabel
}) => {
  const {
    newTypefaceEnabled
  } = (0, _context.useIONewTypeface)();
  const theme = (0, _context.useIOTheme)();
  const IDPLogoSource = useIDPLogo(logo);
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PressableModuleBase.PressableModuleBase, {
    onPress: onPress,
    testID: testID,
    withLooseSpacing: withLooseSpacing,
    children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_typography.IOText, {
      font: newTypefaceEnabled ? "Titillio" : "TitilliumSansPro",
      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__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
      accessibilityIgnoresInvertColors: true,
      source: IDPLogoSource,
      style: styles.idpLogo
    })]
  });
};
exports.ModuleIDP = ModuleIDP;
var _default = exports.default = ModuleIDP;
//# sourceMappingURL=ModuleIDP.js.map