import BadDataException from "../../../Types/Exception/BadDataException";
import React from "react";
export class ImageFunctions {
    static getImageURL(file) {
        const blob = new Blob([file.file.buffer], {
            type: file.fileType,
        });
        const url = URL.createObjectURL(blob);
        return url;
    }
}
const Image = (props) => {
    const getImageElement = (url) => {
        return (React.createElement("img", { onClick: () => {
                var _a;
                (_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props);
            }, "data-testid": props["data-testid"], alt: props.alt, src: url, height: props.height, className: props.className, style: props.style }));
    };
    if (props.imageUrl) {
        return getImageElement(props.imageUrl.toString());
    }
    if (props.file && props.file.file && props.file.fileType) {
        const url = ImageFunctions.getImageURL(props.file);
        return getImageElement(url);
    }
    throw new BadDataException("file or imageUrl required for <Image>");
};
export default Image;
//# sourceMappingURL=Image.js.map