import _extends from "@babel/runtime/helpers/extends";
import React from 'react';
import { MediaType } from '../../../../../constants';
import { useFlexibleUiContext } from '../../../../../state/flexible-ui-context';
import MediaElement from '../media-element';
const PreviewElement = props => {
  const {
    overrideUrl,
    ...rest
  } = props !== null && props !== void 0 ? props : {};
  const context = useFlexibleUiContext();
  const 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;