import _extends from "@babel/runtime/helpers/extends";
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';
const OwnedByElement = props => {
  const context = useFlexibleUiContext();
  const {
    onRender,
    textPrefix = 'owned_by',
    ...restProps
  } = props || {};
  const data = context ? toFormattedTextProps(messages[textPrefix], context === null || context === void 0 ? void 0 : context.ownedBy) : null;
  useEffect(() => {
    onRender === null || onRender === void 0 ? void 0 : onRender(!!data);
  }, [data, onRender]);
  return data ? /*#__PURE__*/React.createElement(BaseTextElement, _extends({}, data, restProps, {
    name: ElementName.OwnedBy
  })) : null;
};
export default OwnedByElement;