import _defineProperty from "@babel/runtime/helpers/defineProperty";
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/** @jsx jsx */

import { jsx } from '@emotion/react';
import EditorFileIcon from '@atlaskit/icon/glyph/editor/file';
import { placeholderFallback, placeholderFallbackParams } from '../styles';
import { ExtensionLabel } from './ExtensionLabel';
export var ICON_SIZE = 24;
var capitalizeFirstLetter = function capitalizeFirstLetter(str) {
  return str.charAt(0).toUpperCase() + str.slice(1);
};
export var LozengeComponent = function LozengeComponent(_ref) {
  var lozengeData = _ref.lozengeData,
    extensionName = _ref.extensionName,
    title = _ref.title,
    params = _ref.params,
    renderImage = _ref.renderImage,
    showMacroInteractionDesignUpdates = _ref.showMacroInteractionDesignUpdates,
    customContainerStyles = _ref.customContainerStyles,
    isNodeHovered = _ref.isNodeHovered,
    isNodeNested = _ref.isNodeNested,
    setIsNodeHovered = _ref.setIsNodeHovered,
    isBodiedMacro = _ref.isBodiedMacro;
  var capitalizedTitle = capitalizeFirstLetter(title);
  if (showMacroInteractionDesignUpdates) {
    return jsx(ExtensionLabel, {
      text: capitalizedTitle,
      extensionName: extensionName,
      isNodeHovered: isNodeHovered,
      isNodeNested: isNodeNested,
      customContainerStyles: customContainerStyles,
      setIsNodeHovered: setIsNodeHovered,
      isBodiedMacro: isBodiedMacro
    });
  }
  var isBlockExtension = extensionName === 'extension';
  return jsx("div", {
    "data-testid": "lozenge-fallback",
    css: placeholderFallback
  }, lozengeData && !isBlockExtension ? renderImage(_objectSpread({
    height: ICON_SIZE,
    width: ICON_SIZE
  }, lozengeData)) : jsx(EditorFileIcon, {
    label: title
  }), jsx("span", {
    className: "extension-title"
  }, capitalizedTitle), params && !isBlockExtension && jsx("span", {
    css: placeholderFallbackParams
  }, Object.keys(params).map(function (key) {
    return key && " | ".concat(key, " = ").concat(params[key].value);
  })));
};