"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _i18n = require("@wordpress/i18n");
var _components = require("@wordpress/components");
var _fontDemo = _interopRequireDefault(require("./font-demo"));
var _icons = require("@wordpress/icons");
var _jsxRuntime = require("react/jsx-runtime");
/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */

function FontCard({
  font,
  onClick,
  variantsText,
  navigatorPath
}) {
  const variantsCount = font.fontFace?.length || 1;
  const style = {
    cursor: !!onClick ? 'pointer' : 'default'
  };
  const navigator = (0, _components.useNavigator)();
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
    __next40pxDefaultSize: true,
    onClick: () => {
      onClick();
      if (navigatorPath) {
        navigator.goTo(navigatorPath);
      }
    },
    style: style,
    className: "font-library-modal__font-card",
    children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Flex, {
      justify: "space-between",
      wrap: false,
      children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_fontDemo.default, {
        font: font
      }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Flex, {
        justify: "flex-end",
        children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.FlexItem, {
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.__experimentalText, {
            className: "font-library-modal__font-card__count",
            children: variantsText || (0, _i18n.sprintf)(/* translators: %d: Number of font variants. */
            (0, _i18n._n)('%d variant', '%d variants', variantsCount), variantsCount)
          })
        }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.FlexItem, {
          children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Icon, {
            icon: (0, _i18n.isRTL)() ? _icons.chevronLeft : _icons.chevronRight
          })
        })]
      })]
    })
  });
}
var _default = exports.default = FontCard;
//# sourceMappingURL=font-card.js.map