"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

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

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

var _richEditor = _interopRequireDefault(require("@titaui/rich-editor"));

var _getLocale = require("../../../../utils/getLocale");

var _header = _interopRequireDefault(require("../components/header"));

var _interviewContent = _interopRequireDefault(require("./interview-content"));

require("./index.css");

var _openData = require("../../../../utils/open-data");

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; }

var preCls = "titaui-dynamic-interview-share";

function DynamicInterviewShare(_ref) {
  var _window$BSGlobal$logi;

  var data = _ref.data,
      onDeleteFeed = _ref.onDeleteFeed,
      _ref$hasDynamicOperea = _ref.hasDynamicOpereateAuth,
      hasDynamicOpereateAuth = _ref$hasDynamicOperea === void 0 ? false : _ref$hasDynamicOperea;
  var publishUser = data.publishUser,
      content = data.content,
      shareFeedSource = data.shareFeedSource,
      version = data.version;
  var isPublisher = publishUser.userId === ((_window$BSGlobal$logi = window.BSGlobal.loginUserInfo) === null || _window$BSGlobal$logi === void 0 ? void 0 : _window$BSGlobal$logi.Id);
  var renderDesc = (0, _react.useMemo)(function () {
    return /*#__PURE__*/_react["default"].createElement("span", {
      className: "".concat(preCls, "__operate-desc")
    }, (0, _getLocale.getLocale)("Ooo_Mo_Sharedconver"));
  }, []);
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: preCls
  }, /*#__PURE__*/_react["default"].createElement(_header["default"], {
    data: data,
    onDeleteFeed: onDeleteFeed,
    desc: renderDesc,
    user: publishUser,
    showDelete: hasDynamicOpereateAuth || isPublisher,
    showTopping: hasDynamicOpereateAuth
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(preCls, "__text")
  }, [undefined, 0].includes(version) && (0, _openData.parseTag)(content.trim()), version === 1 && /*#__PURE__*/_react["default"].createElement(_richEditor["default"], {
    className: "".concat(preCls, "__editor-preview"),
    placeholder: "",
    editable: false,
    showToolbar: false,
    initialState: content
  })), /*#__PURE__*/_react["default"].createElement(_interviewContent["default"], {
    data: shareFeedSource
  }));
}

var _default = DynamicInterviewShare;
exports["default"] = _default;