import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2021-2025 GoodData Corporation
import { createContext, useCallback, useContext, useMemo, useState } from "react";
const ExportXlsxDialogContext = createContext({
    isOpen: false,
    dialogConfig: {},
    closeDialog: () => { },
    openDialog: () => { },
});
/**
 * @internal
 */
export const useExportXlsxDialogContext = () => {
    return useContext(ExportXlsxDialogContext);
};
/**
 * @internal
 */
export function ExportXlsxDialogContextProvider({ children }) {
    const [isOpen, setIsOpen] = useState(false);
    const [dialogConfig, setDialogConfig] = useState({});
    const openDialog = useCallback((config = {}) => {
        setIsOpen(true);
        setDialogConfig(config);
    }, []);
    const closeDialog = useCallback(() => {
        setIsOpen(false);
    }, []);
    const contextValue = useMemo(() => ({ isOpen, dialogConfig, openDialog, closeDialog }), [isOpen, dialogConfig, openDialog, closeDialog]);
    return (_jsx(ExportXlsxDialogContext.Provider, { value: contextValue, children: children }));
}
