import { rpx2vw4style as __rpx2vw__ } from "babel-runtime-jsx-style-transform";

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

import { __rest } from "tslib";
import classNames from 'classnames';
import React, { createElement } from "react";
import { Icon as ReactIcon, Image } from "@alifd/meet-react-component-one";
var ImageComponent = Image;
var ICON_SIZE_MAP = {
  small: 's',
  medium: 'm',
  large: 'l'
};

var Icon = function Icon(props) {
  var _props$prefix = props.prefix,
      prefix = _props$prefix === void 0 ? 'mt-' : _props$prefix,
      uri = props.uri,
      className = props.className,
      name = props.name,
      type = props.type,
      _props$size = props.size,
      size = _props$size === void 0 ? 'm' : _props$size,
      style = props.style,
      others = __rest(props, ["prefix", "uri", "className", "name", "type", "size", "style"]);

  var _name = name || type;

  var iconSize = ICON_SIZE_MAP[size] || size;
  var newClassName = classNames("".concat(prefix, "icon"), "".concat(prefix, "icon--").concat(iconSize), className);

  if (uri && !_name) {
    return /*#__PURE__*/React.createElement(ImageComponent, {
      className: classNames("".concat(prefix, "icon-img--").concat(size), newClassName),
      style: __rpx2vw__(style),
      source: {
        uri: uri
      }
    });
  }

  return /*#__PURE__*/React.createElement(ReactIcon, _extends({
    className: classNames("".concat(prefix, "icon-").concat(_name), newClassName),
    style: __rpx2vw__(style)
  }, others));
};

export default Icon;