"use client";
import { jsx, jsxs } from 'react/jsx-runtime';
import { cva } from '../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.js';
import { createContext, forwardRef, useState, useCallback } from 'react';
import { Tooltip } from '../tooltip/tooltip.js';
import styles from './sidebar.module.css.js';
import { Root } from '../../node_modules/.pnpm/@radix-ui_react-collapsible@1.1.11_@types_react-dom@19.1.7_@types_react@19.1.9__@types_react@_a35yqe6vcc2vmteafw4xyimtca/node_modules/@radix-ui/react-collapsible/dist/index.js';

const SidebarContext = createContext({
    isCollapsed: false
});
const root = cva(styles.root);
const SidebarRoot = forwardRef(({ className, position = 'left', open: providedOpen, onOpenChange, hideCollapsedItemTooltip, collapsible = true, tooltipMessage, defaultOpen, children, ...props }, ref) => {
    const [internalOpen, setInternalOpen] = useState(defaultOpen);
    const open = providedOpen ?? internalOpen;
    const handleOpenChange = useCallback((value) => {
        setInternalOpen(value);
        onOpenChange?.(value);
    }, [onOpenChange]);
    return (jsx(SidebarContext.Provider, { value: { isCollapsed: !open, hideCollapsedItemTooltip }, children: jsx(Tooltip.Provider, { children: jsx(Root, { ref: ref, className: root({ className }), "data-position": position, "data-state": open ? 'expanded' : 'collapsed', "data-collapse-disabled": !collapsible, open: open, onOpenChange: collapsible ? handleOpenChange : undefined, "aria-label": 'Navigation Sidebar', "aria-expanded": open, role: 'navigation', ...props, asChild: true, children: jsxs("aside", { children: [collapsible && (jsx(Tooltip, { message: tooltipMessage ??
                                (open ? 'Click to collapse' : 'Click to expand'), side: position === 'left' ? 'right' : 'left', asChild: true, followCursor: true, sideOffset: 10, children: jsx("div", { className: styles.resizeHandle, onClick: () => handleOpenChange(!open), role: 'button', tabIndex: 0, "aria-label": open ? 'Collapse sidebar' : 'Expand sidebar', onKeyDown: e => {
                                    if (e.key === 'Enter' || e.key === ' ') {
                                        e.preventDefault();
                                        handleOpenChange(!open);
                                    }
                                } }) })), children] }) }) }) }));
});
SidebarRoot.displayName = 'Sidebar';

export { SidebarContext, SidebarRoot };
//# sourceMappingURL=sidebar-root.js.map
