/**
 * amis-ui v6.14.0-beta.1
 * Copyright 2018-2025 fex
 */

import { __read, __assign } from 'tslib';
import { useState, useCallback } from 'react';
import isFunction from 'lodash/isFunction';

var useSetState = function (initialState) {
    if (initialState === void 0) { initialState = {}; }
    var _a = __read(useState(initialState), 2), state = _a[0], setState = _a[1];
    var setMergeState = useCallback(function (patch) {
        setState(function (prevState) { return (__assign(__assign({}, prevState), (isFunction(patch) ? patch(prevState) : patch))); });
    }, []);
    return [state, setMergeState];
};

export { useSetState as default };
