"use strict";

exports.__esModule = true;
exports["default"] = _default;

var _react = _interopRequireWildcard(require("react"));

var _htmlReactParser = _interopRequireDefault(require("html-react-parser"));

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

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

/**
 * remark替换, 主要为了支持reactDOM和html
 * @param {String|Node} remark 格式: <>内容<span>标签</span>内容</>或者'内容<span>标签</span>内容'
 * @param {boolean} dangerouslyHTML 是否需要html转换成reactDOM, 格式: true | false
 * @return {Object} 内容<span>标签</span>内容
 */
function _default(remark, dangerouslyHTML) {
  if (!remark || !dangerouslyHTML) {
    return remark;
  }

  var child = remark; // 如果需要转换html, 则把变量html字符串转换字符为reactDOM

  if (dangerouslyHTML && typeof remark === 'string') {
    child = (0, _htmlReactParser["default"])(remark);
  } // reactDOM渲染


  var childrenArrary = _react["default"].Children.map([child], function (child) {
    return child;
  });

  return _react["default"].createElement(_react.Fragment, null, childrenArrary);
}

module.exports = exports.default;