'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { AlertCircle, CheckCircle2, Sparkles, Wand2 } from 'lucide-react';
export function SeoAnalysisList({ checks, onAiFixField, aiFixField, }) {
    const problems = checks.filter((c) => c.status === 'problem' || c.status === 'improvement');
    const good = checks.filter((c) => c.status === 'good');
    if (checks.length === 0) {
        return (_jsx("p", { className: "text-[12px] text-[var(--muted)]", children: "Add content and a focus keyphrase to run SEO checks." }));
    }
    return (_jsxs("div", { className: "space-y-4", children: [problems.length > 0 && (_jsxs("div", { children: [_jsxs("h4", { className: "mb-2 text-[11px] font-semibold tracking-wide text-[var(--sub)] uppercase", children: ["Problems (", problems.length, ")"] }), _jsx("ul", { className: "space-y-2", children: problems.map((check) => (_jsx(AnalysisRow, { check: check, onAiFix: onAiFixField, aiBusy: aiFixField }, check.id))) })] })), good.length > 0 && (_jsxs("div", { children: [_jsxs("h4", { className: "mb-2 text-[11px] font-semibold tracking-wide text-[var(--sub)] uppercase", children: ["Good results (", good.length, ")"] }), _jsx("ul", { className: "space-y-2", children: good.map((check) => (_jsx(AnalysisRow, { check: check }, check.id))) })] }))] }));
}
function AnalysisRow({ check, onAiFix, aiBusy, }) {
    const tone = check.status === 'good'
        ? 'text-[var(--suc)]'
        : check.status === 'improvement'
            ? 'text-[var(--warn)]'
            : 'text-[var(--err)]';
    const Icon = check.status === 'good' ? CheckCircle2 : AlertCircle;
    const aiField = aiFieldForCheck(check.id);
    return (_jsxs("li", { className: "flex items-start gap-2 rounded-[7px] border border-[var(--bdr)] bg-[var(--card)] px-2.5 py-2", children: [_jsx(Icon, { className: `mt-0.5 h-3.5 w-3.5 shrink-0 ${tone}`, "aria-hidden": true }), _jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("div", { className: "text-[12.5px] font-medium text-[var(--txt)]", children: check.title }), _jsx("p", { className: "text-[11.5px] text-[var(--sub)]", children: check.description })] }), onAiFix && aiField && check.status !== 'good' && (_jsxs("button", { type: "button", "aria-label": `AI help for ${check.title}`, disabled: Boolean(aiBusy), onClick: () => onAiFix(aiField), className: "inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-medium text-[var(--acc)] hover:bg-[var(--acc-l)] focus-visible:ring-2 focus-visible:ring-[var(--ring)] focus-visible:outline-none disabled:opacity-60", children: [aiBusy === aiField ? (_jsx(Sparkles, { className: "h-3 w-3 animate-pulse", "aria-hidden": true })) : (_jsx(Wand2, { className: "h-3 w-3", "aria-hidden": true })), "AI"] }))] }));
}
function aiFieldForCheck(checkId) {
    if (checkId.includes('meta-title') || checkId.includes('keyphrase-in-title'))
        return 'metaTitle';
    if (checkId.includes('meta-description') || checkId.includes('keyphrase-in-meta-description')) {
        return 'metaDescription';
    }
    if (checkId.includes('keyphrase'))
        return 'focusKeyword';
    return null;
}
//# sourceMappingURL=SeoAnalysisList.js.map