"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.CHART_LEGEND_ITEM_GLYPH_TYPES = void 0;
exports.ChartLegendItemGlyph = ChartLegendItemGlyph;
var _react = _interopRequireDefault(require("react"));
var _useTranslation = require("../hooks/use-translation");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const CHART_LEGEND_ITEM_GLYPH_TYPES = exports.CHART_LEGEND_ITEM_GLYPH_TYPES = {
  CROSS: 'CROSS',
  CIRCLE: 'CIRCLE',
  DISC: 'DISC',
  VERTICAL_LINE: 'VERTICAL_LINE',
  HORIZONTAL_LINE: 'HORIZONTAL_LINE',
  SQUARE: 'SQUARE'
};
function ChartLegendItemGlyph({
  glyphType,
  color,
  glyphAriaLabels
}) {
  const {
    t
  } = (0, _useTranslation.useTranslation)();
  const defaultAriaLabels = {
    [CHART_LEGEND_ITEM_GLYPH_TYPES.CROSS]: t('Cross'),
    [CHART_LEGEND_ITEM_GLYPH_TYPES.CIRCLE]: t('Circle'),
    [CHART_LEGEND_ITEM_GLYPH_TYPES.DISC]: t('Disc'),
    [CHART_LEGEND_ITEM_GLYPH_TYPES.VERTICAL_LINE]: t('Vertical line'),
    [CHART_LEGEND_ITEM_GLYPH_TYPES.HORIZONTAL_LINE]: t('Horizontal line'),
    [CHART_LEGEND_ITEM_GLYPH_TYPES.SQUARE]: t('Square')
  };
  const ariaLabel = glyphAriaLabels?.[glyphType] ?? defaultAriaLabels[glyphType];
  if (glyphType === CHART_LEGEND_ITEM_GLYPH_TYPES.CROSS) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
      width: "12",
      height: "12",
      "aria-label": ariaLabel,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("polygon", {
        "test-id": "chart-legend-item-glyph",
        className: "chart-legend-item-glyph",
        points: "12,5 7,5 7,0 5,0 5,5 0,5 0,7 5,7 5,12 7,12 7,7 12,7",
        fill: color,
        stroke: "transparent"
      })
    });
  }
  if (glyphType === CHART_LEGEND_ITEM_GLYPH_TYPES.CIRCLE) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
      width: "12",
      height: "12",
      "aria-label": ariaLabel,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("circle", {
        "test-id": "chart-legend-item-glyph",
        className: "chart-legend-item-glyph",
        cx: "6",
        cy: "6",
        r: "5",
        strokeWidth: "2",
        stroke: color,
        fill: "transparent"
      })
    });
  }
  if (glyphType === CHART_LEGEND_ITEM_GLYPH_TYPES.DISC) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
      width: "12",
      height: "12",
      "aria-label": ariaLabel,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("circle", {
        "test-id": "chart-legend-item-glyph",
        className: "chart-legend-item-glyph",
        cx: "6",
        cy: "6",
        r: "5",
        strokeWidth: "0",
        fill: color
      })
    });
  }
  if (glyphType === CHART_LEGEND_ITEM_GLYPH_TYPES.VERTICAL_LINE) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
      width: "12",
      height: "12",
      "aria-label": ariaLabel,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", {
        "test-id": "chart-legend-item-glyph",
        className: "chart-legend-item-glyph",
        x: "5",
        y: "0",
        width: "2",
        height: "12",
        strokeWidth: "0",
        fill: color
      })
    });
  }
  if (glyphType === CHART_LEGEND_ITEM_GLYPH_TYPES.HORIZONTAL_LINE) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
      width: "12",
      height: "12",
      "aria-label": ariaLabel,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", {
        "test-id": "chart-legend-item-glyph",
        className: "chart-legend-item-glyph",
        x: "0",
        y: "5",
        width: "12",
        height: "2",
        strokeWidth: "0",
        fill: color
      })
    });
  }
  if (glyphType === CHART_LEGEND_ITEM_GLYPH_TYPES.SQUARE) {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
      width: "12",
      height: "12",
      "aria-label": ariaLabel,
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("rect", {
        "test-id": "chart-legend-item-glyph",
        className: "chart-legend-item-glyph",
        width: "12",
        height: "12",
        fill: color
      })
    });
  }
  return null;
}