import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Button } from "@material-ui/core";
import { UploadIcon } from "../Icon/UploadIcon";
export const PropertyEditorImage = ({ editObject, label, propertyName, updateCallback, }) => {
    const onChange = (event) => {
        const file = event.target.files ? event.target.files[0] : null;
        const reader = new FileReader();
        reader.onload = (event) => {
            var _a;
            Reflect.set(editObject, propertyName, (_a = event.target) === null || _a === void 0 ? void 0 : _a.result);
            updateCallback();
        };
        if (file) {
            reader.readAsDataURL(file);
        }
    };
    return (_jsxs(Button, Object.assign({ "data-testid": "property-editor-image", variant: "contained", color: "primary", component: "label", startIcon: _jsx(UploadIcon, {}, void 0) }, { children: [label, _jsx("input", { type: "file", hidden: true, onChange: onChange, accept: "image/*" }, void 0)] }), void 0));
};
//# sourceMappingURL=PropertyEditorImage.js.map