import { jsx as _jsx } from "react/jsx-runtime";
import { createContext, createRef, useRef, useState, } from 'react';
import { LOCAL_STORAGE_KEY } from './constants';
import { useSidebar } from './hooks';
export const DashboardSidebarContext = createContext({
    collapsedIn: false,
    onToggleSidebar: () => undefined,
    isPinned: true,
    onTogglePin: () => undefined,
    isPopupOpen: false,
    setIsPopupOpen: () => undefined,
    popoverAnchorRef: createRef(),
});
/**
 * Провайдер предназначен для проброса состояния боковой панел, а так же управления этим состоянием.
 * В данный провайдер обернут компонент DashboardLayout.
 */
export const DashboardSidebarProvider = ({ children, localStorageKey = LOCAL_STORAGE_KEY, isFocusedMode = false, }) => {
    const sidebar = useSidebar(localStorageKey, isFocusedMode);
    const [isPopupOpen, setIsPopupOpen] = useState(false);
    const popoverAnchorRef = useRef(null);
    const value = {
        ...sidebar,
        isPopupOpen,
        setIsPopupOpen,
        popoverAnchorRef,
    };
    return (_jsx(DashboardSidebarContext.Provider, { value: value, children: children }));
};
