"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
var _react = _interopRequireDefault(require("react"));
var _constants = require("../../constants");
const _excluded = ["text"];
const renderText = (props, editor) => {
  const {
    attributes,
    children,
    leaf
  } = props;
  const {
      text
    } = leaf,
    rest = (0, _objectWithoutProperties2.default)(leaf, _excluded);
  let markedChildren = /*#__PURE__*/_react.default.cloneElement(children);
  if (leaf[_constants.TEXT_STYLE_MAP.BOLD]) {
    markedChildren = /*#__PURE__*/_react.default.createElement("strong", null, markedChildren);
  }
  if (leaf[_constants.TEXT_STYLE_MAP.ITALIC]) {
    markedChildren = /*#__PURE__*/_react.default.createElement("i", null, markedChildren);
  }
  if (leaf[_constants.TEXT_STYLE_MAP.UNDERLINE]) {
    markedChildren = /*#__PURE__*/_react.default.createElement("span", {
      style: {
        textDecoration: 'underline'
      }
    }, markedChildren);
  }
  if (leaf[_constants.TEXT_STYLE_MAP.CODE]) {
    markedChildren = /*#__PURE__*/_react.default.createElement("code", null, markedChildren);
  }
  if (leaf[_constants.TEXT_STYLE_MAP.DELETE]) {
    markedChildren = /*#__PURE__*/_react.default.createElement("del", null, markedChildren);
  }
  if (leaf[_constants.TEXT_STYLE_MAP.ADD]) {
    markedChildren = /*#__PURE__*/_react.default.createElement("span", null, markedChildren);
  }
  if (leaf.decoration) {
    markedChildren = /*#__PURE__*/_react.default.createElement("span", {
      className: "token ".concat(leaf.type)
    }, markedChildren);
  }
  return /*#__PURE__*/_react.default.createElement("span", Object.assign({
    "data-id": leaf.id
  }, attributes, {
    className: Object.keys(rest).join(' ')
  }), markedChildren);
};
var _default = exports.default = renderText;