/** @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 const ICON_SIZE = 24;
const capitalizeFirstLetter = str => {
  return str.charAt(0).toUpperCase() + str.slice(1);
};
export const LozengeComponent = ({
  lozengeData,
  extensionName,
  title,
  params,
  renderImage,
  showMacroInteractionDesignUpdates,
  customContainerStyles,
  isNodeHovered,
  isNodeNested,
  setIsNodeHovered,
  isBodiedMacro
}) => {
  const capitalizedTitle = capitalizeFirstLetter(title);
  if (showMacroInteractionDesignUpdates) {
    return jsx(ExtensionLabel, {
      text: capitalizedTitle,
      extensionName: extensionName,
      isNodeHovered: isNodeHovered,
      isNodeNested: isNodeNested,
      customContainerStyles: customContainerStyles,
      setIsNodeHovered: setIsNodeHovered,
      isBodiedMacro: isBodiedMacro
    });
  }
  const isBlockExtension = extensionName === 'extension';
  return jsx("div", {
    "data-testid": "lozenge-fallback",
    css: placeholderFallback
  }, lozengeData && !isBlockExtension ? renderImage({
    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(key => key && ` | ${key} = ${params[key].value}`)));
};