"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
var _exportNames = {
  ICON_SIZE_12: true,
  ICON_SIZE_16: true,
  ICON_SIZE_24: true,
  ICON_SIZE_32: true,
  ICON_SIZE_48: true,
  ICON_SIZE_64: true,
  ICON_SIZE_96: true,
  ICON_SIZE_128: true,
  ICON_SIZE_192: true
};
exports.default = exports.ICON_SIZE_96 = exports.ICON_SIZE_64 = exports.ICON_SIZE_48 = exports.ICON_SIZE_32 = exports.ICON_SIZE_24 = exports.ICON_SIZE_192 = exports.ICON_SIZE_16 = exports.ICON_SIZE_128 = exports.ICON_SIZE_12 = void 0;
var _react = require("react");
var _classnames = _interopRequireDefault(require("classnames"));
var _constants = require("../../constants");
var _oldIconNames = _interopRequireDefault(require("./oldIconNames"));
var _symbols = _interopRequireDefault(require("./images/symbols.svg"));
var _constants2 = require("./constants");
Object.keys(_constants2).forEach(function (key) {
  if (key === "default" || key === "__esModule") return;
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  if (key in exports && exports[key] === _constants2[key]) return;
  Object.defineProperty(exports, key, {
    enumerable: true,
    get: function () {
      return _constants2[key];
    }
  });
});
var _utils = require("./utils");
var _OnDarkContext = _interopRequireDefault(require("../OnDarkContext"));
var _jsxRuntime = require("react/jsx-runtime");
// Copyright 1999-2023. Plesk International GmbH. All rights reserved.

const ICON_SIZE_12 = exports.ICON_SIZE_12 = '12';
const ICON_SIZE_16 = exports.ICON_SIZE_16 = '16';
const ICON_SIZE_24 = exports.ICON_SIZE_24 = '24';
const ICON_SIZE_32 = exports.ICON_SIZE_32 = '32';
const ICON_SIZE_48 = exports.ICON_SIZE_48 = '48';
const ICON_SIZE_64 = exports.ICON_SIZE_64 = '64';
const ICON_SIZE_96 = exports.ICON_SIZE_96 = '96';
const ICON_SIZE_128 = exports.ICON_SIZE_128 = '128';
const ICON_SIZE_192 = exports.ICON_SIZE_192 = '192';
const oldIconSizes = {
  sm: ICON_SIZE_16,
  md: ICON_SIZE_32,
  lg: ICON_SIZE_48,
  xl: ICON_SIZE_64,
  xxl: ICON_SIZE_96
};
const getHref = (name, size) => {
  let iconSize = '16';
  if ((size === '12' || size === '24') && _constants2.NAMES_12.indexOf(name) !== -1) {
    iconSize = '12';
  }
  return `${_symbols.default}#${name}:${iconSize}`;
};
/**
 * `Icons` are small symbolic images used for two things: to help quickly find the right control on the screen and to
 * bring user attention to something that requires consideration. In the former case, `Icon` typically acts as a part
 * of a [Button](#!/Button) and helps differentiate this particular [Button](#!/Button) from others. `Icons` come in several
 * standard sizes.
 * @since 0.0.35
 */

const Icon = _ref => {
  let {
    baseClassName = `${_constants.CLS_PREFIX}icon`,
    className,
    name,
    src,
    size,
    intent,
    animation,
    rotate,
    flipHorizontal = false,
    flipVertical = false,
    children,
    alt = '',
    ...props
  } = _ref;
  const newSize = size && oldIconSizes[size] || size;
  const newName = name ? _oldIconNames.default[name] || name : null;
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
    className: (0, _classnames.default)(baseClassName, {
      [`${baseClassName}--size-${newSize}`]: newSize,
      [`${baseClassName}--intent ${baseClassName}--${intent}`]: intent,
      [`${baseClassName}--animation-${animation}`]: animation,
      [`${baseClassName}--rotate-${rotate}`]: rotate,
      [`${baseClassName}--flip-horizontal`]: flipHorizontal,
      [`${baseClassName}--flip-vertical`]: flipVertical,
      [`${baseClassName}--on-dark`]: (0, _react.useContext)(_OnDarkContext.default)
    }, className),
    ...props,
    children: newName ? /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
      focusable: "false",
      children: /*#__PURE__*/(0, _jsxRuntime.jsx)("use", {
        href: getHref(newName, newSize)
      })
    }) : src && /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
      src: src,
      alt: alt
    }) || children
  });
};
Icon.create = _utils.create;
var _default = exports.default = Icon;