"use client";
'use strict';

var jsxRuntime = require('react/jsx-runtime');
var index$1 = require('../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.cjs');
var React = require('react');
var tooltip = require('../tooltip/tooltip.cjs');
var sidebar_module = require('./sidebar.module.css.cjs');
var index = require('../../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.cjs');

const SidebarContext = React.createContext({
    isCollapsed: false
});
const root = index$1.cva(sidebar_module.default.root);
const SidebarRoot = React.forwardRef(({ className, position = 'left', open: providedOpen, onOpenChange, hideCollapsedItemTooltip, collapsible = true, tooltipMessage, defaultOpen, children, ...props }, ref) => {
    const [internalOpen, setInternalOpen] = React.useState(defaultOpen);
    const open = providedOpen ?? internalOpen;
    const handleOpenChange = React.useCallback((value) => {
        setInternalOpen(value);
        onOpenChange?.(value);
    }, [onOpenChange]);
    return (jsxRuntime.jsx(SidebarContext.Provider, { value: { isCollapsed: !open, hideCollapsedItemTooltip }, children: jsxRuntime.jsx(tooltip.Tooltip.Provider, { children: jsxRuntime.jsx(index.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: jsxRuntime.jsxs("aside", { children: [collapsible && (jsxRuntime.jsx(tooltip.Tooltip, { message: tooltipMessage ??
                                (open ? 'Click to collapse' : 'Click to expand'), side: position === 'left' ? 'right' : 'left', asChild: true, followCursor: true, sideOffset: 10, children: jsxRuntime.jsx("div", { className: sidebar_module.default.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';

exports.SidebarContext = SidebarContext;
exports.SidebarRoot = SidebarRoot;
//# sourceMappingURL=sidebar-root.cjs.map
