"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Icon = Icon;
exports.Avatar = Avatar;

var _react = _interopRequireDefault(require("react"));

var _icons = require("../../icons");

var _jsxRuntime = require("react/jsx-runtime");

var _excluded = ["size", "name", "className", "alt"];

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

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 Icon(_ref) {
  var _ref$size = _ref.size,
      size = _ref$size === void 0 ? "sm" : _ref$size,
      name = _ref.name,
      className = _ref.className,
      _ref$alt = _ref.alt,
      alt = _ref$alt === void 0 ? "" : _ref$alt,
      props = _objectWithoutProperties(_ref, _excluded);

  var iconClassName;

  switch (size) {
    case "2xs":
      iconClassName = "h-3 w-3";
      break;

    case "2xsi":
      iconClassName = "h-3.5 w-3.5";
      break;

    case "xs":
      iconClassName = "h-3 w-3";
      break;

    case "sm":
      iconClassName = "h-4 w-4";
      break;

    case "md":
      iconClassName = "h-5 w-5";
      break;

    case "lg":
      iconClassName = "h-5 w-5";
      break;

    case "xl":
      iconClassName = "h-6 w-6";
      break;

    case "2xl":
      iconClassName = "h-8 w-8";
      break;

    default:
      iconClassName = "h-4 w-4";
  }

  if (name != null && (name.startsWith("http:") || name.startsWith("https://"))) {
    props.icon = name;
  } else if (name !== "") {
    props.icon = _icons.Icons[name];
  }

  if (typeof props.icon === "string") {
    return /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
      alt: alt,
      src: props.icon,
      className: "".concat(iconClassName, " ").concat(className)
    });
  }

  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
    children: props.icon ? /*#__PURE__*/(0, _jsxRuntime.jsx)(props.icon, {
      className: iconClassName
    }) : null
  });
}

function Avatar(_ref2) {
  var url = _ref2.url,
      _ref2$alt = _ref2.alt,
      alt = _ref2$alt === void 0 ? "" : _ref2$alt;
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
    className: "h-10 w-10 rounded-full bg-gray-400 flex items-center justify-center ring-8 ring-white",
    src: url,
    alt: alt
  });
}