"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PropertyEditorImage = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const core_1 = require("@material-ui/core");
const UploadIcon_1 = require("../Icon/UploadIcon");
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) => {
            Reflect.set(editObject, propertyName, event.target?.result);
            updateCallback();
        };
        if (file) {
            reader.readAsDataURL(file);
        }
    };
    return ((0, jsx_runtime_1.jsxs)(core_1.Button, { "data-testid": "property-editor-image", variant: "contained", color: "primary", component: "label", startIcon: (0, jsx_runtime_1.jsx)(UploadIcon_1.UploadIcon, {}), children: [label, (0, jsx_runtime_1.jsx)("input", { type: "file", hidden: true, onChange: onChange, accept: "image/*" })] }));
};
exports.PropertyEditorImage = PropertyEditorImage;
//# sourceMappingURL=PropertyEditorImage.js.map