"use strict";
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TableCheckbox = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const Box_1 = require("../Box");
const Checkbox = (props) => (0, jsx_runtime_1.jsx)("input", Object.assign({ type: "checkbox" }, props), void 0);
const TableCheckbox = (_a) => {
    var { onChange, setShowBatchActions, indeterminate, checked } = _a, rest = __rest(_a, ["onChange", "setShowBatchActions", "indeterminate", "checked"]);
    (0, react_1.useEffect)(() => {
        if (setShowBatchActions) {
            setShowBatchActions(indeterminate || checked);
        }
    }, [setShowBatchActions, indeterminate, checked]);
    const handleChange = (state) => {
        const event = { target: { value: state } };
        onChange(event);
    };
    return ((0, jsx_runtime_1.jsx)(Box_1.Box, Object.assign({ variant: "raw", margin: "s 0 0 0" }, { children: (0, jsx_runtime_1.jsx)(Checkbox, Object.assign({ onChange: handleChange, indeterminate: indeterminate, checked: checked }, rest), void 0) }), void 0));
};
exports.TableCheckbox = TableCheckbox;
//# sourceMappingURL=TableCheckbox.js.map