"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.LogoPaymentWithFallback = void 0;
var _accessibility = require("../../utils/accessibility");
var _object = require("../../utils/object");
var _icons = require("../icons");
var _logos = require("../logos");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * This component renders either
 * - a LogoPayment/LogoPaymentExt component
 * - a default credit card icon
 * @param cardIcon: IOLogoPaymentType icon
 * @param size: the size of the icon (standard is 24/48)
 * @param fallbackIconColor: default icon color (standard is grey-700)
 * @param isExtended: if true, renders a LogoPaymentExt component
 * @returns a LogoPayment/LogopaymentExt component if the cardIcon is supported, a default credit card icon otherwise
 */
const LogoPaymentWithFallback = ({
  brand,
  fallbackIconColor = "grey-700",
  isExtended = false,
  size = isExtended ? 48 : 24
}) => {
  const {
    dynamicFontScale
  } = (0, _accessibility.useIOFontDynamicScale)();
  const logos = isExtended ? _logos.IOPaymentExtLogos : _logos.IOPaymentLogos;
  if (!brand) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
      allowFontScaling: true,
      name: "creditCard",
      size: size,
      color: fallbackIconColor
    });
  }
  const findCase = (0, _object.findFirstCaseInsensitive)(logos, brand);
  if (!findCase) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.Icon, {
      allowFontScaling: true,
      name: "creditCard",
      size: size,
      color: fallbackIconColor
    });
  }
  return isExtended ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_logos.LogoPaymentExt, {
    name: findCase,
    size: size * dynamicFontScale
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_logos.LogoPayment, {
    name: findCase,
    size: size * dynamicFontScale
  });
};
exports.LogoPaymentWithFallback = LogoPaymentWithFallback;
//# sourceMappingURL=LogoPaymentWithFallback.js.map