"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
Object.defineProperty(exports, "ICON_COLOR", {
  enumerable: true,
  get: function get() {
    return _Icon.ICON_COLOR;
  }
});
exports.SIZE = void 0;
Object.defineProperty(exports, "TYPE", {
  enumerable: true,
  get: function get() {
    return _Icon.TYPE;
  }
});
exports.default = void 0;

var React = _interopRequireWildcard(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _Icon = _interopRequireWildcard(require("../icons/Icon"));

var _utils = require("../utils");

var _excluded = ["color", "size", "type", "children", "action", "transparent", "active", "border", "className", "title"];

var _ICON_SIZE;

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

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); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var SIZE = {
  SMALL: 'small',
  NORMAL: 'normal'
};
exports.SIZE = SIZE;
var ICON_SIZE = (_ICON_SIZE = {}, _defineProperty(_ICON_SIZE, SIZE.SMALL, 24), _defineProperty(_ICON_SIZE, SIZE.NORMAL, 24), _ICON_SIZE);

// This component is deprecated
var IconAsButton = function IconAsButton(_ref) {
  var _classNames;

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

  if (_utils.__DEV__) {
    (0, _utils.invariant)(!(color !== null && color !== void 0 && color.includes('60')), 'Shade 60 is not supported on this deprecated component. Please use <Button iconOnly...></Button> instead.');
  }

  var buttonClass = (0, _classnames.default)('sg-icon-as-button', (_classNames = {}, _defineProperty(_classNames, "sg-icon-as-button--".concat(String(color)), color), _defineProperty(_classNames, "sg-icon-as-button--".concat(size), size), _defineProperty(_classNames, 'sg-icon-as-button--with-border', border), _defineProperty(_classNames, 'sg-icon-as-button--action', action), _defineProperty(_classNames, 'sg-icon-as-button--action-active', action === true && active === true), _defineProperty(_classNames, 'sg-icon-as-button--transparent', transparent), _defineProperty(_classNames, 'sg-icon-as-button--transparent-active', transparent === true && active === true), _classNames), className);
  var content;

  if (type) {
    content = /*#__PURE__*/React.createElement(_Icon.default, {
      type: type,
      color: _Icon.ICON_COLOR.ADAPTIVE,
      size: ICON_SIZE[size],
      title: title
    });
  } else {
    content = children;
  }

  var RenderType = 'button';

  if (props.href !== undefined && props.href !== null && props.href !== '') {
    RenderType = 'a';
  }

  return /*#__PURE__*/React.createElement(RenderType, _extends({}, props, {
    role: "button",
    className: buttonClass
  }), /*#__PURE__*/React.createElement("div", {
    className: "sg-icon-as-button__hole"
  }, content || null));
};

var _default = IconAsButton;
exports.default = _default;