import _extends from "@babel/runtime/helpers/esm/extends";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["type", "size", "color", "className", "title"];
import * as React from 'react';
import classNames from 'classnames';
import { ICON_COLOR } from '../icons/Icon';
export var MATH_SYMBOL_TYPE = {
  SQUERE_ROOT: 'squere-root',
  NTH_ROOT: 'nth-root',
  POWER: 'power',
  SUBSCRIPT: 'subscript',
  LESSEQUAL: 'less-then-or-equal',
  GREATEREQUAL: 'greater-then-or-equal',
  INEQUALITY: 'inequality',
  DIVISION: 'division',
  PI: 'pi',
  ALPHA: 'alpha',
  BETA: 'beta',
  LINE: 'line',
  LIMIT: 'limit',
  MATRIX: 'matrix',
  INTEGRAL: 'integral',
  EQUATION_SYSTEM: 'equation-system'
};
var WIDE = [MATH_SYMBOL_TYPE.LIMIT, MATH_SYMBOL_TYPE.MATRIX, MATH_SYMBOL_TYPE.INTEGRAL, MATH_SYMBOL_TYPE.EQUATION_SYSTEM];
export var SIZE = {
  SMALL: 'small',
  MEDIUM: 'medium',
  NORMAL: 'normal'
};

var MathSymbol = function MathSymbol(_ref) {
  var _classNames;

  var type = _ref.type,
      _ref$size = _ref.size,
      size = _ref$size === void 0 ? SIZE.NORMAL : _ref$size,
      color = _ref.color,
      className = _ref.className,
      title = _ref.title,
      props = _objectWithoutProperties(_ref, _excluded);

  var isWide = WIDE.indexOf(type) !== -1;
  var iconClass = classNames('sg-math-symbol-icon', (_classNames = {}, _defineProperty(_classNames, "sg-math-symbol-icon--".concat(size), !isWide && size !== SIZE.NORMAL), _defineProperty(_classNames, "sg-math-symbol-icon--wide-".concat(size), isWide && size !== SIZE.NORMAL), _defineProperty(_classNames, 'sg-math-symbol-icon--wide', isWide && size === SIZE.NORMAL), _defineProperty(_classNames, "sg-math-symbol-icon--".concat(String(color)), color), _classNames), className);
  var iconType = "#sg-math-symbol-icon-".concat(type);
  var titleId = "sg-math-symbol-icon-".concat(type, "-title");
  var defaultTitle = type.replace(/-/g, ' ');
  return (
    /*#__PURE__*/
    // @ts-expect-error ts migration
    React.createElement("svg", _extends({}, props, {
      className: iconClass,
      "aria-labelledby": titleId,
      role: "img"
    }), /*#__PURE__*/React.createElement("text", {
      id: titleId,
      hidden: true
    }, title || defaultTitle), /*#__PURE__*/React.createElement("use", {
      xlinkHref: iconType,
      "aria-hidden": "true"
    }))
  );
};

export default MathSymbol;
export { ICON_COLOR };