'use client';
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { CheckCircle2, XCircle, AlertTriangle, HelpCircle, ExternalLink, Search, } from 'lucide-react';
import { SettingsCard } from './components.js';
const SEVERITY_STYLES = {
    success: {
        pill: 'bg-success/15 text-success border-success/30',
        icon: _jsx(CheckCircle2, { size: 14, "aria-hidden": "true" }),
    },
    warning: {
        pill: 'bg-warning/15 text-warning border-warning/30',
        icon: _jsx(AlertTriangle, { size: 14, "aria-hidden": "true" }),
    },
    danger: {
        pill: 'bg-destructive/10 text-destructive border-destructive/30',
        icon: _jsx(XCircle, { size: 14, "aria-hidden": "true" }),
    },
    neutral: {
        pill: 'bg-muted text-muted-foreground border-border',
        icon: _jsx(HelpCircle, { size: 14, "aria-hidden": "true" }),
    },
};
const CHECK_ICON = {
    pass: _jsx(CheckCircle2, { size: 14, className: "text-success", "aria-hidden": "true" }),
    warning: _jsx(AlertTriangle, { size: 14, className: "text-warning", "aria-hidden": "true" }),
    fail: _jsx(XCircle, { size: 14, className: "text-destructive", "aria-hidden": "true" }),
    unknown: _jsx(HelpCircle, { size: 14, className: "text-muted-foreground", "aria-hidden": "true" }),
};
const CHECK_SR = {
    pass: 'OK',
    warning: 'Warning',
    fail: 'Problem',
    unknown: 'Unknown',
};
export function SiteIndexStatusCard({ status, loading, onNavigate, onRunAudit, }) {
    return (_jsx(SettingsCard, { title: "Site Index Status", description: "Current effective crawl and indexing state.", actions: status ? (_jsxs("span", { className: `inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium ${SEVERITY_STYLES[status.severity].pill}`, children: [SEVERITY_STYLES[status.severity].icon, _jsx("span", { className: "sr-only", children: "Status: " }), status.label] })) : undefined, children: loading && !status ? (_jsxs("div", { className: "space-y-2", "aria-hidden": "true", children: [_jsx("div", { className: "bg-muted h-4 w-2/3 animate-pulse rounded" }), _jsx("div", { className: "bg-muted h-20 w-full animate-pulse rounded" })] })) : !status ? (_jsx("p", { className: "text-muted-foreground text-sm", children: "Index status is unavailable." })) : (_jsxs(_Fragment, { children: [_jsx("p", { className: "text-muted-foreground mb-3 text-sm", children: status.description }), _jsx("dl", { className: "border-border grid grid-cols-1 gap-x-6 gap-y-2 rounded-md border p-3 sm:grid-cols-2", children: status.checks.map((check) => (_jsxs("div", { className: "flex items-center justify-between gap-2 text-sm", children: [_jsx("dt", { className: "text-muted-foreground", children: check.label }), _jsxs("dd", { className: "text-foreground flex items-center gap-1.5 font-medium", children: [_jsxs("span", { className: "sr-only", children: [CHECK_SR[check.status], ": "] }), CHECK_ICON[check.status], check.value] })] }, check.key))) }), status.actions.length > 0 && (_jsx("div", { className: "mt-3 flex flex-wrap gap-2", children: status.actions.map((action) => (_jsx(SiteIndexAction, { label: action.label, href: action.href, action: action.action, onNavigate: onNavigate, onRunAudit: onRunAudit }, action.label))) }))] })) }));
}
function SiteIndexAction({ label, href, action, onNavigate, onRunAudit, }) {
    const className = 'border-border text-foreground hover:bg-accent inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1.5 text-sm transition-colors';
    // The audit action stays in-app; robots/sitemap are real public URLs.
    const isAudit = action === 'run_seo_audit';
    const isAdminRoute = href?.startsWith('/seo');
    const icon = isAudit ? (_jsx(Search, { size: 14, "aria-hidden": "true" })) : (_jsx(ExternalLink, { size: 14, "aria-hidden": "true" }));
    if (isAudit && onRunAudit) {
        return (_jsxs("button", { type: "button", onClick: onRunAudit, className: className, children: [icon, label] }));
    }
    if (isAdminRoute && onNavigate) {
        return (_jsxs("button", { type: "button", onClick: () => onNavigate(href), className: className, children: [icon, label] }));
    }
    return (_jsxs("a", { href: href, target: "_blank", rel: "noopener noreferrer", className: className, children: [icon, label] }));
}
//# sourceMappingURL=SiteIndexStatusCard.js.map