'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { AlertTriangle, Info } from 'lucide-react';
import { useGeneralSettings } from './useGeneralSettings.js';
import { SettingsSaveBar, SettingsValidationSummary } from './components.js';
import { SiteIndexStatusCard } from './SiteIndexStatusCard.js';
import { SiteInformationCard } from './SiteInformationCard.js';
import { LanguageRegionCard } from './LanguageRegionCard.js';
import { SeoRobotsDefaultsCard } from './SeoRobotsDefaultsCard.js';
export function GeneralSettingsTab({ onNavigate, role }) {
    const canEdit = role === 'ADMIN';
    const settings = useGeneralSettings(canEdit);
    const runAudit = () => onNavigate?.('/seo?tab=audit');
    if (settings.loading) {
        return (_jsxs("div", { className: "space-y-4", "aria-busy": "true", "aria-live": "polite", children: [_jsx("span", { className: "sr-only", children: "Loading settings\u2026" }), [0, 1, 2, 3].map((i) => (_jsxs("div", { className: "border-border bg-card rounded-lg border p-6", children: [_jsx("div", { className: "bg-muted mb-4 h-4 w-40 animate-pulse rounded" }), _jsxs("div", { className: "space-y-3", children: [_jsx("div", { className: "bg-muted h-9 w-full animate-pulse rounded" }), _jsx("div", { className: "bg-muted h-9 w-full animate-pulse rounded" })] })] }, i)))] }));
    }
    return (_jsxs("div", { className: "space-y-4", children: [settings.loadError && (_jsxs("div", { role: "alert", className: "border-destructive/30 bg-destructive/10 text-destructive flex items-center gap-3 rounded-lg border p-3 text-sm", children: [_jsx(AlertTriangle, { size: 16, className: "shrink-0", "aria-hidden": "true" }), _jsx("span", { className: "flex-1", children: settings.loadError }), _jsx("button", { type: "button", onClick: settings.refetch, className: "border-destructive/40 rounded-md border px-3 py-1 transition-colors hover:opacity-80", children: "Retry" })] })), !canEdit && (_jsxs("div", { className: "border-border bg-muted text-muted-foreground flex items-center gap-2 rounded-lg border p-3 text-sm", children: [_jsx(Info, { size: 16, className: "shrink-0", "aria-hidden": "true" }), "You have read-only access to settings. Only administrators can make changes."] })), _jsx(SettingsValidationSummary, { issues: settings.issues }), _jsx(SiteIndexStatusCard, { status: settings.indexStatus, loading: settings.loading, onNavigate: onNavigate, onRunAudit: runAudit }), _jsx(SiteInformationCard, { form: settings.form, setField: settings.setField, sources: settings.sources, issues: settings.issues, canEdit: canEdit }), _jsx(LanguageRegionCard, { form: settings.form, setField: settings.setField, issues: settings.issues, canEdit: canEdit }), _jsx(SeoRobotsDefaultsCard, { form: settings.form, setField: settings.setField, isProduction: settings.isProduction, indexStatus: settings.indexStatus, canEdit: canEdit, onNavigate: onNavigate }), settings.saveState === 'error' && settings.saveError && (_jsxs("div", { role: "alert", className: "border-destructive/30 bg-destructive/10 text-destructive flex items-center gap-3 rounded-lg border p-3 text-sm", children: [_jsx(AlertTriangle, { size: 16, className: "shrink-0", "aria-hidden": "true" }), _jsx("span", { className: "flex-1", children: settings.saveError }), _jsx("button", { type: "button", onClick: settings.save, className: "border-destructive/40 rounded-md border px-3 py-1 transition-colors hover:opacity-80", children: "Retry" })] })), _jsx(SettingsSaveBar, { dirty: settings.dirty, canEdit: canEdit, hasErrors: settings.hasErrors, saveState: settings.saveState, onSave: settings.save, onReset: settings.reset })] }));
}
//# sourceMappingURL=GeneralSettingsTab.js.map