"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useDataGridSettings = useDataGridSettings;
const react_1 = require("react");
const data_grid_settings_1 = require("../../data-grid-preferences/helpers/data-grid-settings");
const hooks_1 = require("../../utils/hooks");
function useDataGridSettings(args) {
    const { settings: userSettings, defaultSettings, onSettingsChange } = args;
    const [settings, setSettings] = (0, hooks_1.useControllableState)({
        defaultValue: defaultSettings !== null && defaultSettings !== void 0 ? defaultSettings : {},
        value: userSettings,
        onChange: onSettingsChange,
    });
    const resolvedSettings = (0, react_1.useMemo)(() => (0, data_grid_settings_1.resolveDataGridSettings)(settings), [settings]);
    const updateSettings = (0, react_1.useCallback)((newSettings) => {
        setSettings((prevSettings) => (Object.assign(Object.assign({}, prevSettings), newSettings)));
    }, [setSettings]);
    return {
        settings: resolvedSettings,
        updateSettings,
    };
}
//# sourceMappingURL=useDataGridSettings.js.map