'use client';
import { jsx as _jsx } from "react/jsx-runtime";
import { isCrudModuleAvailable, CrudCard as BaseCrudCard, } from '../crudImports';
import { Link } from '../../routing';
/**
 * CrudCard with Link wrapping for web navigation.
 * When detailHref is provided, wraps the card in a Link for a11y/SEO.
 */
export function CrudCard({ detailHref, onClick, ...rest }) {
    // Safe guard: isCrudModuleAvailable is a module-level constant (immutable after load).
    // eslint-disable-next-line react-hooks/rules-of-hooks
    if (!isCrudModuleAvailable)
        return null;
    // When detailHref is set, Link handles navigation — don't pass onClick to inner card
    const card = (_jsx(BaseCrudCard, { ...rest, onClick: detailHref ? undefined : onClick }));
    if (detailHref) {
        return (_jsx(Link, { path: detailHref, "aria-label": rest.item?.id ? `View ${rest.item.id}` : undefined, children: card }));
    }
    return card;
}
export default CrudCard;
