import { jsx as _jsx } from "react/jsx-runtime";
import { Divider } from "../divider/Divider.js";
import { CollapsibleNavGroup } from "./CollapsibleNavGroup.js";
import { NavItemLink } from "./NavItemLink.js";
import { NavSubheader } from "./NavSubheader.js";
import { getHrefFromParents, getNavigationGroupId } from "./utils.js";
/**
 * **Client Component**
 *
 * The default behavior is attempt to render in order:
 * - `const { type, items, ...props } = item`
 * - `type === "divider"` - `<Divider {...props} />`
 * - `type === "subheader"` - `<NavSubheader {...props} />`
 * - `type === "group"` - `<><NavSubheader {...props} />{children}</>`
 * - `!!items` - `<CollapsibleNavGroup />`
 * - `<NavItemLink {...item} as={linkComponent} active={pathname === href} />`
 *
 * @see {@link https://react-md.dev/components/navigation | Navigation Demos}
 * @since 6.0.0
 */ export function DefaultNavigationRenderer(props) {
    const { item, data, children, parents } = props;
    switch(item.type){
        case "divider":
            {
                const { type: _type, items: _items, ...divider } = item;
                return /*#__PURE__*/ _jsx(Divider, {
                    ...divider
                });
            }
        case "subheader":
            {
                const { type: _type, items: _items, ...subheader } = item;
                return /*#__PURE__*/ _jsx(NavSubheader, {
                    ...subheader
                });
            }
    }
    if (item.items) {
        const nextParents = [
            item,
            ...parents
        ];
        const id = getNavigationGroupId(item, nextParents);
        return /*#__PURE__*/ _jsx(CollapsibleNavGroup, {
            depth: nextParents.length,
            collapsed: !data?.expandedItems.has(id),
            buttonChildren: item.children,
            toggleCollapsed: ()=>{
                data?.toggleExpandedItem(id);
            },
            children: children
        });
    }
    const href = `${getHrefFromParents(parents)}${item.href}`;
    return /*#__PURE__*/ _jsx(NavItemLink, {
        ...item,
        as: data?.linkComponent,
        active: "active" in item && !!item.active || data?.pathname === href,
        href: href
    });
}

//# sourceMappingURL=DefaultNavigationRenderer.js.map