import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["overrideUrl"];
import React from 'react';
import { MediaType } from '../../../../../constants';
import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
import MediaElement from '../media-element';
var PreviewElement = function PreviewElement(props) {
  var _ref = props !== null && props !== void 0 ? props : {},
    overrideUrl = _ref.overrideUrl,
    rest = _objectWithoutProperties(_ref, _excluded);
  var context = useFlexibleUiContext();
  var data = overrideUrl ? {
    url: overrideUrl,
    type: MediaType.Image
  } : context === null || context === void 0 ? void 0 : context.preview;
  if (!data) {
    return null;
  }
  return /*#__PURE__*/React.createElement(MediaElement, _extends({}, rest, data));
};
export default PreviewElement;