import { _ as _extends } from '../extends-C4cduGrv.js';
import { _ as _objectWithoutProperties } from '../objectWithoutProperties-TXwlfNxG.js';
import React__default from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import library from './assets/icon-map/index.js';
import Icon, { lookupSocialIcon } from '../icon/index.js';
import '@fortawesome/react-fontawesome';
import '../icon/icons.js';
import '../icon/library.js';
import '@fortawesome/fontawesome-svg-core';
import '@fortawesome/pro-solid-svg-icons';
import '@fortawesome/pro-light-svg-icons';
import '@fortawesome/free-brands-svg-icons';

var _excluded = ["icon"],
    _excluded2 = ["name", "className", "size"];
var SIZES = {
  sm: "w-4 h-4",
  md: "w-6 h-6",
  lg: "w-8 h-8"
};

var lookupIcon = function lookupIcon(iconName) {
  return library.find(function (i) {
    if (i.name === iconName) {
      return i.component;
    }
  });
};

var FallbackIcon = function FallbackIcon(_ref) {
  var _icon$iconName;

  var icon = _ref.icon,
      props = _objectWithoutProperties(_ref, _excluded);

  var iconName = (_icon$iconName = icon.iconName) !== null && _icon$iconName !== void 0 ? _icon$iconName : "FontAwesome";
  console.warn("Use of ".concat(iconName, " icon is deprecated unless for social. Please use one of the icons from the CKIcon library."));
  return /*#__PURE__*/React__default.createElement(Icon, _extends({
    icon: icon
  }, props));
};

var CKIcon = function CKIcon(_ref2) {
  var name = _ref2.name,
      className = _ref2.className,
      _ref2$size = _ref2.size,
      size = _ref2$size === void 0 ? "md" : _ref2$size,
      props = _objectWithoutProperties(_ref2, _excluded2);

  className = cx("fill-current inline-block overflow-visible", SIZES[size], className);

  if (name && typeof name == 'string') {
    var icon = lookupIcon(name);

    if (!icon) {
      var socialIcon = lookupSocialIcon(name);

      if (!socialIcon) {
        return /*#__PURE__*/React__default.createElement("div", null, "Sorry looks like the icon you are looking for does not exist.");
      }

      return /*#__PURE__*/React__default.createElement(FallbackIcon, _extends({
        icon: socialIcon,
        className: className
      }, props));
    }

    var Icon = icon.component;
    return /*#__PURE__*/React__default.createElement(Icon, _extends({
      className: className,
      name: name,
      style: {
        fontSize: 'inherit'
      }
    }, props));
  }

  return /*#__PURE__*/React__default.createElement(FallbackIcon, _extends({
    icon: name,
    className: className
  }, props));
};

CKIcon.propTypes = {
  /** Matches name in Figma, using lowercase and hyphens instead of spaces. */
  name: PropTypes.string.isRequired,
  size: PropTypes.oneOf(["sm", "md", "lg"]),

  /** Customize the icon. E.g. text-gray-700 */
  className: PropTypes.string
};

export { CKIcon as default };
