'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
 * Shared status / type / SEO indicators for the Posts admin area.
 *
 * Colors are restricted to the theme tokens already used elsewhere in
 * the admin (`success`, `warning`, `destructive`, `primary`, `muted`)
 * plus a small named-color palette (`purple`, `green`, `orange`, ...)
 * that maps to fixed Tailwind utilities. This keeps the badges working
 * in both light and dark mode and avoids leaking `bg-[#...]` arbitrary
 * values into components.
 */
// ─── Named color palette ─────────────────────────────────────────────
const PALETTE = {
    purple: {
        bg: 'bg-violet-50 dark:bg-violet-950/40',
        text: 'text-violet-700 dark:text-violet-300',
        ring: 'ring-violet-200 dark:ring-violet-900',
        border: 'border-violet-500',
    },
    green: {
        bg: 'bg-emerald-50 dark:bg-emerald-950/40',
        text: 'text-emerald-700 dark:text-emerald-300',
        ring: 'ring-emerald-200 dark:ring-emerald-900',
        border: 'border-emerald-500',
    },
    orange: {
        bg: 'bg-amber-50 dark:bg-amber-950/40',
        text: 'text-amber-700 dark:text-amber-300',
        ring: 'ring-amber-200 dark:ring-amber-900',
        border: 'border-amber-500',
    },
    red: {
        bg: 'bg-red-50 dark:bg-red-950/40',
        text: 'text-red-700 dark:text-red-300',
        ring: 'ring-red-200 dark:ring-red-900',
        border: 'border-red-500',
    },
    blue: {
        bg: 'bg-blue-50 dark:bg-blue-950/40',
        text: 'text-blue-700 dark:text-blue-300',
        ring: 'ring-blue-200 dark:ring-blue-900',
        border: 'border-blue-500',
    },
    pink: {
        bg: 'bg-pink-50 dark:bg-pink-950/40',
        text: 'text-pink-700 dark:text-pink-300',
        ring: 'ring-pink-200 dark:ring-pink-900',
        border: 'border-pink-500',
    },
    gray: {
        bg: 'bg-muted',
        text: 'text-muted-foreground',
        ring: 'ring-border',
        border: 'border-border',
    },
};
export function paletteFor(color) {
    if (!color)
        return PALETTE.gray;
    return PALETTE[color] ?? PALETTE.gray;
}
// ─── PostStatusBadge ─────────────────────────────────────────────────
const STATUS_LABEL = {
    PUBLISHED: 'Published',
    DRAFT: 'Draft',
    SCHEDULED: 'Scheduled',
    ARCHIVED: 'Archived',
};
const STATUS_PALETTE = {
    PUBLISHED: 'green',
    DRAFT: 'gray',
    SCHEDULED: 'orange',
    ARCHIVED: 'gray',
};
const STATUS_GLYPH = {
    PUBLISHED: '●',
    DRAFT: '○',
    SCHEDULED: '◐',
    ARCHIVED: '◌',
};
export function PostStatusBadge({ status }) {
    const p = paletteFor(STATUS_PALETTE[status]);
    return (_jsxs("span", { className: `inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium ${p.bg} ${p.text}`, "aria-label": `Status: ${STATUS_LABEL[status]}`, children: [_jsx("span", { "aria-hidden": true, className: "text-[10px] leading-none", children: STATUS_GLYPH[status] }), STATUS_LABEL[status]] }));
}
// ─── PostTypeBadge ───────────────────────────────────────────────────
export function PostTypeBadge({ label, color, onClick, }) {
    const p = paletteFor(color);
    const className = `inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium ${p.bg} ${p.text}`;
    if (onClick) {
        return (_jsx("button", { type: "button", onClick: onClick, className: `${className} hover:opacity-80`, children: label }));
    }
    return _jsx("span", { className: className, children: label });
}
// ─── SeoScoreIndicator ───────────────────────────────────────────────
/**
 * Returns the palette key for an SEO score so callers can match the
 * colored dot. 80+ green, 60–79 orange, 1–59 red, missing = gray.
 */
export function seoScorePalette(score) {
    if (score === null || Number.isNaN(score))
        return 'gray';
    if (score >= 80)
        return 'green';
    if (score >= 60)
        return 'orange';
    if (score >= 1)
        return 'red';
    return 'gray';
}
export function SeoScoreIndicator({ score }) {
    const colorKey = seoScorePalette(score);
    const p = paletteFor(colorKey);
    if (score === null) {
        return (_jsxs("span", { className: "text-muted-foreground inline-flex items-center gap-1.5 text-xs", children: [_jsx("span", { "aria-hidden": true, className: `h-2 w-2 rounded-full ${p.bg.split(' ')[0]}` }), _jsx("span", { className: "tabular-nums", children: "\u2014" })] }));
    }
    return (_jsxs("span", { className: "text-foreground inline-flex items-center gap-1.5 text-xs", children: [_jsx("span", { "aria-hidden": true, className: `h-2 w-2 rounded-full ${colorKey === 'green'
                    ? 'bg-emerald-500'
                    : colorKey === 'orange'
                        ? 'bg-amber-500'
                        : 'bg-red-500'}` }), _jsx("span", { className: "tabular-nums", children: score })] }));
}
//# sourceMappingURL=badges.js.map