'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { ChevronRight, Home } from 'lucide-react';
const LABEL_MAP = {
    posts: 'Posts',
    pages: 'Pages',
    media: 'Media Library',
    forms: 'Forms',
    seo: 'SEO',
    redirects: 'Redirects',
    canonicals: 'Canonicalization',
    links: 'Link Health',
    users: 'Users',
    'script-tags': 'Script Tags',
    settings: 'Settings',
    profile: 'Your Profile',
    collections: 'Collections',
    submissions: 'Submissions',
    new: 'New',
    edit: 'Edit',
};
function labelFor(segment) {
    return (LABEL_MAP[segment] ?? segment.replace(/[-_]/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase()));
}
export function isId(segment) {
    return (
    // numeric id
    /^\d+$/.test(segment) ||
        // hex id (e.g. ObjectId / md5-style)
        /^[0-9a-f]{8,}$/i.test(segment) ||
        // cuid (Prisma's @default(cuid())): leading "c" + base36, ~25 chars
        /^c[a-z0-9]{20,}$/i.test(segment) ||
        // cuid2 / other long base36 token ids (24+ chars, no separators)
        /^[a-z0-9]{24,}$/i.test(segment));
}
export function Breadcrumbs({ currentPath, onNavigate }) {
    // Strip query string + hash so tab-driven routes (e.g. `/settings?tab=users`,
    // `/seo?tab=audit`) don't leak the raw query into a crumb label.
    const cleanPath = currentPath.split('?')[0].split('#')[0];
    const segments = cleanPath.split('/').filter(Boolean);
    if (segments.length === 0)
        return null;
    const crumbs = [];
    let accumulated = '';
    for (let i = 0; i < segments.length; i++) {
        const seg = segments[i];
        accumulated += `/${seg}`;
        let label;
        if (isId(seg)) {
            const parentLabel = i > 0 ? labelFor(segments[i - 1]) : '';
            label = parentLabel ? `Edit ${parentLabel.replace(/s$/, '')}` : `#${seg}`;
        }
        else {
            label = labelFor(seg);
        }
        crumbs.push({ label, path: accumulated });
    }
    return (_jsxs("nav", { "aria-label": "Breadcrumb", className: "border-border bg-card flex items-center gap-1 overflow-x-auto border-b px-4 py-2.5 text-sm", children: [_jsxs("button", { type: "button", onClick: () => onNavigate('/'), className: "text-muted-foreground hover:text-primary/80 flex shrink-0 items-center gap-1 transition-colors", children: [_jsx(Home, { className: "h-3.5 w-3.5" }), _jsx("span", { className: "hidden sm:inline", children: "Dashboard" })] }), crumbs.map((crumb, i) => {
                const isLast = i === crumbs.length - 1;
                return (_jsxs("span", { className: "flex shrink-0 items-center gap-1", children: [_jsx(ChevronRight, { className: "text-muted-foreground h-3.5 w-3.5" }), isLast ? (_jsx("span", { className: "text-foreground font-medium", children: crumb.label })) : (_jsx("button", { type: "button", onClick: () => onNavigate(crumb.path), className: "text-muted-foreground hover:text-primary/80 transition-colors", children: crumb.label }))] }, crumb.path));
            })] }));
}
//# sourceMappingURL=Breadcrumbs.js.map