import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["children", "className", "color", "element", "maxLines", "style", "tint"];

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

import cx from 'classnames';
import React, { forwardRef } from 'react';
import Box from '../box';
import theme from './theme.css';

var factory = function factory(baseType, type, defaultElement) {
  var Text = /*#__PURE__*/forwardRef(function (_ref, ref) {
    var _objectSpread2;

    var children = _ref.children,
        className = _ref.className,
        color = _ref.color,
        _ref$element = _ref.element,
        element = _ref$element === void 0 ? null : _ref$element,
        maxLines = _ref.maxLines,
        style = _ref.style,
        _ref$tint = _ref.tint,
        tint = _ref$tint === void 0 ? 'darkest' : _ref$tint,
        others = _objectWithoutProperties(_ref, _excluded);

    var classNames = cx(theme[baseType], theme[type], theme[tint], _objectSpread(_objectSpread({}, color && _defineProperty({}, theme[color], true)), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, theme['overflow-multiline'], maxLines && maxLines > 1), _defineProperty(_objectSpread2, theme['overflow-singleline'], maxLines && maxLines === 1), _objectSpread2)), className);

    var styles = _objectSpread(_objectSpread({}, maxLines && maxLines > 1 && {
      MozLineClamp: maxLines,
      WebkitLineClamp: maxLines
    }), style);

    var Element = element || defaultElement;
    return /*#__PURE__*/React.createElement(Box, _extends({
      className: classNames,
      "data-teamleader-ui": baseType,
      element: Element
    }, others, {
      style: styles,
      ref: ref
    }), children);
  });
  Text.displayName = 'Text';
  return Text;
};

export { factory as textFactory };