/**
 * Copyright IBM Corp. 2020, 2026
 *
 * This source code is licensed under the Apache-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

const require_runtime = require('../../../../../../_virtual/_rolldown/runtime.js');
const require_deepCompareObject = require('../../../../../../global/js/utils/deepCompareObject.js');
let react = require("react");

//#region src/components/Datagrid/Datagrid/addons/Filtering/hooks/useShouldDisableButtons.js
/**
* Copyright IBM Corp. 2023, 2025
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Keeps track of the button disabled state
* @param  {string} initialValue - the initial value if the buttons should be enabled or disabled
* @param  {object} filtersState - the filter state from the filter panel or flyout
* @param  {object} prevFiltersRef - reference of the prev filterState
* @returns {Array} returns a tuple of the state and setter function
*/
const useShouldDisableButtons = ({ initialValue, filtersState, prevFiltersRef, open }) => {
	const [shouldDisableButtons, setShouldDisableButtons] = (0, react.useState)(initialValue);
	(0, react.useEffect)(function updateDisabledButtonsState() {
		if (!open) return;
		setShouldDisableButtons(require_deepCompareObject.deepCompareObject(filtersState, JSON.parse(prevFiltersRef.current)));
	}, [filtersState, prevFiltersRef]);
	return [shouldDisableButtons, setShouldDisableButtons];
};

//#endregion
exports.default = useShouldDisableButtons;