import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";

/**
 * HTML Element
 *
 */
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import E from './Element';

const P = (_ref) => {
  let {
    style_type,
    className
  } = _ref,
      p = _objectWithoutProperties(_ref, ["style_type", "className"]);

  if (style_type) {
    if (/ /.test(style_type)) {
      style_type = style_type.split(/ /g).reduce((acc, cur) => {
        return "".concat(acc, " dnb-p--").concat(cur);
      }, '');
      className = classnames(style_type, className);
    } else {
      className = classnames("dnb-p--".concat(style_type), className);
    }
  }

  return React.createElement(E, _extends({
    is: "p"
  }, p, {
    className: className
  }));
};

P.tagName = 'dnb-p';
P.propTypes = process.env.NODE_ENV !== "production" ? {
  className: PropTypes.string,
  style_type: PropTypes.string
} : {};
P.defaultProps = {
  className: null,
  style_type: null
};
export default P;