import { __assign, __rest } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import * as ReactDOM from 'react-dom';
import createElement from '../utils/dom/createElement';
import Image from './Image';
export function previewImage(options) {
    if (options === void 0) { options = {}; }
    var parentComponent = options.parentComponent, rest = __rest(options, ["parentComponent"]);
    var container = createElement('div');
    var closePreviewMask = function () {
        if (!container) {
            return;
        }
        ReactDOM.unmountComponentAtNode(container);
        container = null;
    };
    var props = __assign(__assign({}, rest), { onClose: closePreviewMask });
    var render = parentComponent
        ? ReactDOM.unstable_renderSubtreeIntoContainer.bind(ReactDOM, parentComponent)
        : ReactDOM.render;
    render(_jsx(Image, __assign({}, props), void 0), container);
}
export default previewImage;
