"use strict";

exports.__esModule = true;
exports.useCheckboxesList = void 0;
var _react = require("react");
var useCheckboxesList = exports.useCheckboxesList = function useCheckboxesList(values, handlers) {
  var checked = values.every(function (isChecked) {
    return isChecked;
  });
  var isIndeterminate = !checked && values.includes(false) && values.includes(true);
  var switchAllCheckboxes = (0, _react.useCallback)(function () {
    if (checked) {
      handlers.forEach(function (handler) {
        return handler(false);
      });
    } else {
      handlers.forEach(function (handler) {
        return handler(true);
      });
    }
  }, [checked, handlers]);
  return [checked, isIndeterminate, switchAllCheckboxes];
};