"use client";
import { jsx as _jsx } from "react/jsx-runtime";
import { createContext, useCallback, useContext, useMemo, useState, } from "react";
const BreadcrumbOverrideContext = createContext(null);
/**
 * Provides a breadcrumb label override for library detail pages.
 *
 * Wrap the library zone in this provider so that detail pages can push
 * a human-readable resource name into the breadcrumb via
 * `useBreadcrumbOverride().setLabel(name)`.
 */
export function LibraryBreadcrumbProvider({ children, }) {
    const [label, setLabelState] = useState(null);
    const setLabel = useCallback((next) => setLabelState(next), []);
    const value = useMemo(() => ({ label, setLabel }), [label, setLabel]);
    return (_jsx(BreadcrumbOverrideContext.Provider, { value: value, children: children }));
}
/**
 * Read the current breadcrumb override label.
 *
 * Used by breadcrumb UI components to display a resource display name
 * instead of the raw URL slug for the last segment.
 */
export function useBreadcrumbLabel() {
    return useContext(BreadcrumbOverrideContext)?.label ?? null;
}
/**
 * Set (or clear) the breadcrumb override label.
 *
 * Used by detail pages to push the resource display name up to the
 * breadcrumb after the resource data has loaded. Returns a stable
 * `setLabel` function safe for use as a `useEffect` dependency.
 */
export function useBreadcrumbOverride() {
    const ctx = useContext(BreadcrumbOverrideContext);
    const noop = useCallback((_label) => { }, []);
    return { setLabel: ctx?.setLabel ?? noop };
}
//# sourceMappingURL=LibraryBreadcrumbContext.js.map