import { _ as _extends } from '../extends-C4cduGrv.js';
import { _ as _defineProperty } from '../defineProperty-CEd-kZQW.js';
import { _ as _objectWithoutProperties } from '../objectWithoutProperties-TXwlfNxG.js';
import cx from 'classnames';
import PropTypes from 'prop-types';
import React__default from 'react';

var _excluded = ["as", "className", "children", "size", "weight", "color"];
var SIZES = {
  xs: {
    className: "text-xs leading-4"
  },
  sm: {
    className: "text-sm leading-6"
  },
  md: {
    className: "text-base leading-5"
  },
  lg: {
    className: "text-lg leading-8"
  },
  xl: {
    className: "text-2xl leading-8"
  },
  "2xl": {
    className: "leading-10",
    style: {
      fontSize: "2rem"
    }
  }
};

var hasCSSUnit = function hasCSSUnit(size) {
  return size.match(/px|r?em|%$/);
};

var getSize = function getSize(size) {
  if (hasCSSUnit(size)) return {
    style: {
      fontSize: size
    }
  };
  return SIZES[size];
};

function Text(_ref) {
  var _classNames;

  var _ref$as = _ref.as,
      Component = _ref$as === void 0 ? "div" : _ref$as,
      className = _ref.className,
      children = _ref.children,
      _ref$size = _ref.size,
      size = _ref$size === void 0 ? "md" : _ref$size,
      weight = _ref.weight,
      color = _ref.color,
      props = _objectWithoutProperties(_ref, _excluded);

  className = cx(className, getSize(size).className, (_classNames = {}, _defineProperty(_classNames, "font-".concat(weight), weight), _defineProperty(_classNames, "text-".concat(color), color), _classNames));
  var style = SIZES[size].style || {};
  return /*#__PURE__*/React__default.createElement(Component, _extends({
    className: className,
    style: style
  }, props), children);
}
Text.propTypes = {
  /** An HTML tag in which the text will be rendered. */
  as: PropTypes.string,
  className: PropTypes.string,
  children: PropTypes.node,
  size: PropTypes.oneOf(Object.keys(SIZES)),
  weight: PropTypes.oneOf(["light", "normal", "semibold"]),

  /** A Tailwind-style text color such as `red-400`. */
  color: PropTypes.string
};

export { Text as default };
