import _extends from "@babel/runtime/helpers/extends";
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 const 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 const renderIconPerSize = (ObjectIcon, ObjectTileIcon) => {
  return ({
    size,
    ...props
  }) => {
    if (isIconSizeLarge(size)) {
      return /*#__PURE__*/React.createElement(ObjectTileIcon, _extends({}, props, {
        size: "small"
      }));
    }
    return /*#__PURE__*/React.createElement(ObjectIcon, props);
  };
};
export const renderIconTile = (Icon, appearance) => {
  return ({
    size,
    ...props
  }) => {
    return /*#__PURE__*/React.createElement(IconTile, _extends({
      appearance: appearance,
      icon: Icon,
      size: transformSmartLinkSizeToIconTileSize(size)
    }, props));
  };
};