import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["size"],
  _excluded2 = ["size"];
import React from 'react';
import { IconTile } from '@atlaskit/icon';
import { fg } from '@atlaskit/platform-feature-flags';
import { SmartLinkSize } from '../../../constants';
import { isIconSizeLarge } from '../../../utils';
export var transformSmartLinkSizeToIconTileSize = function transformSmartLinkSizeToIconTileSize(size) {
  if (fg('platform_sl_icons_refactor')) {
    switch (size) {
      case SmartLinkSize.Small:
      case SmartLinkSize.Medium:
        return '16';
      case SmartLinkSize.XLarge:
      case SmartLinkSize.Large:
        return '24';
      default:
        return '16';
    }
  }
  switch (size) {
    case SmartLinkSize.XLarge:
    case SmartLinkSize.Large:
      return '24';
    default:
      return '16';
  }
};

/**
 * For large/xlarge smart-link icon size, renders an `@atlaskit/object/tile/*` component; otherwise a standard `@atlaskit/object` glyph.
 */
export var renderIconPerSize = function renderIconPerSize(ObjectIcon, ObjectTileIcon) {
  return function (_ref) {
    var size = _ref.size,
      props = _objectWithoutProperties(_ref, _excluded);
    if (isIconSizeLarge(size)) {
      return /*#__PURE__*/React.createElement(ObjectTileIcon, _extends({}, props, {
        size: "small"
      }));
    }
    return /*#__PURE__*/React.createElement(ObjectIcon, props);
  };
};
export var renderIconTile = function renderIconTile(Icon, appearance) {
  return function (_ref2) {
    var size = _ref2.size,
      props = _objectWithoutProperties(_ref2, _excluded2);
    return /*#__PURE__*/React.createElement(IconTile, _extends({
      appearance: appearance,
      icon: Icon,
      size: transformSmartLinkSizeToIconTileSize(size)
    }, props));
  };
};