import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["onRender", "textPrefix"];
import React, { useEffect } from 'react';
import { ElementName } from '../../../../../constants';
import { messages } from '../../../../../messages';
import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
import { BaseTextElement, toFormattedTextProps } from '../common';
var OwnedByElement = function OwnedByElement(props) {
  var context = useFlexibleUiContext();
  var _ref = props || {},
    onRender = _ref.onRender,
    _ref$textPrefix = _ref.textPrefix,
    textPrefix = _ref$textPrefix === void 0 ? 'owned_by' : _ref$textPrefix,
    restProps = _objectWithoutProperties(_ref, _excluded);
  var data = context ? toFormattedTextProps(messages[textPrefix], context === null || context === void 0 ? void 0 : context.ownedBy) : null;
  useEffect(function () {
    onRender === null || onRender === void 0 || onRender(!!data);
  }, [data, onRender]);
  return data ? /*#__PURE__*/React.createElement(BaseTextElement, _extends({}, data, restProps, {
    name: ElementName.OwnedBy
  })) : null;
};
export default OwnedByElement;