"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UISwitch = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const material_1 = require("@mui/material");
const UIStyleConstants_1 = require("@appglue/common/dist/Common/UIStyleConstants");
const UILabel_1 = require("./UILabel");
const Check_1 = tslib_1.__importDefault(require("@mui/icons-material/Check"));
const Clear_1 = tslib_1.__importDefault(require("@mui/icons-material/Clear"));
function UISwitch(props) {
    let f = (0, jsx_runtime_1.jsx)(Clear_1.default, {});
    if (props.falseDisplay) {
        if (props.falseDisplay instanceof String) {
            f = (0, jsx_runtime_1.jsx)(UILabel_1.UILabel, { type: "small", children: props.falseDisplay });
        }
        else if (props.falseDisplay instanceof Function) {
            f = props.falseDisplay(props.checked);
        }
    }
    let t = (0, jsx_runtime_1.jsx)(Check_1.default, {});
    if (props.trueDisplay) {
        if (props.trueDisplay instanceof String) {
            f = (0, jsx_runtime_1.jsx)(UILabel_1.UILabel, { type: "small", children: props.trueDisplay });
        }
        else if (props.trueDisplay instanceof Function) {
            f = props.trueDisplay(props.checked);
        }
    }
    return ((0, jsx_runtime_1.jsx)(material_1.Box, { style: {
            margin: props.padding,
            marginLeft: props.paddingLeft,
            marginRight: props.paddingRight,
            marginBottom: props.paddingBottom,
            marginTop: props.paddingTop,
        }, border: "1px", borderRadius: "4px", borderColor: UIStyleConstants_1.UIStyleConstants.GRAY_COLOR, display: "flex", role: "checkbox", children: (0, jsx_runtime_1.jsxs)(material_1.ToggleButtonGroup, { style: {
                height: "29px",
            }, value: props.checked, onClick: () => {
                //                    props.checked = !props.checked;
                if (props.checked !== undefined)
                    props.onSet(!props.checked);
            }, children: [(0, jsx_runtime_1.jsx)(material_1.ToggleButton, { style: {
                        borderRight: "1px",
                        borderColor: UIStyleConstants_1.UIStyleConstants.GRAY_COLOR,
                        background: props.checked === false ? UIStyleConstants_1.UIStyleConstants.RED_LIGHT_COLOR : UIStyleConstants_1.UIStyleConstants.WHITE_COLOR,
                        paddingRight: "5px",
                        paddingLeft: "5px",
                    }, value: false, onClick: () => {
                        if (props.checked === undefined)
                            props.onSet(false);
                    }, children: f }), (0, jsx_runtime_1.jsx)(material_1.ToggleButton, { style: {
                        background: props.checked === true ? UIStyleConstants_1.UIStyleConstants.GREEN_LIGHT_COLOR : UIStyleConstants_1.UIStyleConstants.WHITE_COLOR,
                        borderColor: UIStyleConstants_1.UIStyleConstants.GRAY_COLOR,
                        paddingRight: "5px",
                        paddingLeft: "5px",
                    }, value: true, onClick: () => {
                        if (props.checked === undefined)
                            props.onSet(true);
                    }, children: t })] }) }));
}
exports.UISwitch = UISwitch;
//# sourceMappingURL=UISwitch.js.map