"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.BodyTextDecorator = exports.BodyTextBase = exports.BodyText = exports["default"] = void 0;

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

var _kind = _interopRequireDefault(require("@enact/core/kind"));

var _BodyText = _interopRequireDefault(require("@enact/ui/BodyText"));

var _Pure = _interopRequireDefault(require("@enact/ui/internal/Pure"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _compose = _interopRequireDefault(require("ramda/src/compose"));

var _Marquee = require("@enact/ui/Marquee");

var _Skinnable = _interopRequireDefault(require("../Skinnable"));

var _BodyTextModule = _interopRequireDefault(require("./BodyText.module.css"));

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

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (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 = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return 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; }

// Create a Marquee using BodyText as the base
var MarqueeBodyText = (0, _Marquee.MarqueeDecorator)(_BodyText["default"]);
/**
 * A simple text block component.
 *
 * This component is most often not used directly but may be composed within another component as it
 * is within [BodyText]{@link agate/BodyText.BodyText}.
 *
 * @class BodyTextBase
 * @memberof agate/BodyText
 * @extends ui/BodyText.BodyText
 * @ui
 * @public
 */

var BodyTextBase = (0, _kind["default"])({
  name: 'BodyText',
  propTypes:
  /** @lends agate/BodyText.BodyTextBase.prototype */
  {
    /**
     * Centers the contents.
     *
     * Applies the `centered` CSS class which can be customized by
     * [theming]{@link /docs/developer-guide/theming/}.
     *
     * @type {Boolean}
     * @default false
     * @public
     */
    centered: _propTypes["default"].bool,

    /**
     * Customizes the component by mapping the supplied collection of CSS class names to the
     * corresponding internal elements and states of this component.
     *
     * The following classes are supported:
     *
     * * `bodyText` - The root class name
     *
     * @type {Object}
     * @public
     */
    css: _propTypes["default"].object,

    /**
     * Toggles multi-line (`false`) vs single-line (`true`) behavior. `noWrap` mode
     * automatically enables {@link ui/Marquee} so long text isn't permanently occluded.
     *
     * @type {Boolean}
     * @default false
     * @public
     */
    noWrap: _propTypes["default"].bool,

    /**
     * Sets the text size to one of the preset sizes.
     * Available sizes: 'large' (default) and 'small'.
     *
     * @type {('small'|'large')}
     * @default 'large'
     * @public
     */
    size: _propTypes["default"].oneOf(['small', 'large'])
  },
  defaultProps: {
    centered: false,
    noWrap: false,
    size: 'large'
  },
  styles: {
    css: _BodyTextModule["default"],
    publicClassNames: 'bodyText'
  },
  computed: {
    className: function className(_ref) {
      var noWrap = _ref.noWrap,
          size = _ref.size,
          styler = _ref.styler;
      return styler.append(size, {
        noWrap: noWrap
      });
    }
  },
  render: function render(_ref2) {
    var centered = _ref2.centered,
        css = _ref2.css,
        noWrap = _ref2.noWrap,
        rest = _objectWithoutProperties(_ref2, ["centered", "css", "noWrap"]);

    delete rest.size;

    if (noWrap) {
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(MarqueeBodyText, _objectSpread(_objectSpread({
        component: "div" // Assign a new component to BodyText, since DIV is not allowed inside a P tag (the default for BodyText)
        ,
        marqueeOn: "render"
      }, rest), {}, {
        alignment: centered ? 'center' : null // Centering Marquee
        ,
        centered: centered // Centering UiBodyText
        ,
        css: css
      }));
    }

    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_BodyText["default"], _objectSpread(_objectSpread({}, rest), {}, {
      centered: centered,
      css: css
    }));
  }
});
/**
 * Applies Agate specific behaviors to [BodyTextBase]{@link agate/BodyText.BodyTextBase}.
 *
 * @hoc
 * @memberof agate/BodyText
 * @mixes agate/Skinnable.Skinnable
 * @public
 */

exports.BodyTextBase = BodyTextBase;
var BodyTextDecorator = (0, _compose["default"])(_Pure["default"], _Skinnable["default"]);
/**
 * A simple text block component, ready to use in Agate applications.
 *
 * `BodyText` may be used to display a block of text and is sized and spaced appropriately for a
 * Agate application.
 *
 * Usage:
 * ```
 * <BodyText>
 *   I have a Ham radio. There are many like it, but this one is mine.
 * </BodyText>
 * ```
 *
 * @class BodyText
 * @memberof agate/BodyText
 * @extends agate/BodyText.BodyTextBase
 * @mixes agate/BodyText.BodyTextDecorator
 * @ui
 * @public
 */

exports.BodyTextDecorator = BodyTextDecorator;
var BodyText = BodyTextDecorator(BodyTextBase);
exports.BodyText = BodyText;
var _default = BodyText;
exports["default"] = _default;