import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { useState, useCallback } from "react";
import { Button } from "../../../components/ui/button";
import { setupWizardService } from "../../../setup/services/setupWizardService";
import { CheckCircle, PartyPopper, RefreshCw, ArrowRight, AlertCircle, } from "lucide-react";
export function CompleteStep({ licenseConfigured, chatModelId, imageModelId, embeddingsModelId, onFinish, onBack, }) {
    const [finishing, setFinishing] = useState(false);
    const handleFinish = useCallback(async () => {
        try {
            setFinishing(true);
            // 1. Set default chat/image models on Settings item
            await setupWizardService.setDefaultModels({
                chatModelId,
                imageModelId,
            });
            // 2. If embeddings model selected, create/update Search Settings
            if (embeddingsModelId) {
                await setupWizardService.setEmbeddingsConfig({
                    modelId: embeddingsModelId,
                });
            }
            // 3. Mark setup as complete
            await setupWizardService.completeSetup();
            onFinish();
        }
        catch (e) {
            alert("Failed to save final settings: " + e.message);
        }
        finally {
            setFinishing(false);
        }
    }, [chatModelId, imageModelId, embeddingsModelId, onFinish]);
    return (_jsxs("div", { className: "flex h-full flex-col items-center p-12 text-center", children: [_jsx("div", { className: "mb-8 animate-bounce rounded-full bg-green-50 p-6 shadow-xl ring-1 shadow-green-500/10 ring-green-100", children: _jsx(PartyPopper, { className: "h-16 w-12 text-green-600", strokeWidth: 1.5 }) }), _jsx("h2", { className: "mb-4 text-4xl font-bold tracking-tight text-gray-900", children: "You're Ready!" }), _jsx("p", { className: "mb-10 max-w-md leading-relaxed text-gray-500", children: "Parhelia is now configured and ready to transform your content workflow. Let's get to work." }), _jsxs("div", { className: "mb-12 w-full max-w-sm space-y-3 rounded-2xl border border-gray-100 bg-gray-50/50 p-6 text-left shadow-inner", children: [_jsx("h3", { className: "mb-4 text-center text-[10px] font-bold tracking-[0.2em] text-gray-400 uppercase", children: "Final Configuration" }), _jsx("div", { className: "space-y-2", children: [
                            { label: "License", value: licenseConfigured ? "configured" : undefined },
                            { label: "Chat", value: chatModelId },
                            { label: "Image", value: imageModelId },
                            { label: "Embeddings", value: embeddingsModelId },
                        ].map((item) => (_jsxs("div", { className: "flex items-center justify-between rounded-lg border border-gray-100 bg-white/50 px-3 py-2.5", children: [_jsx("span", { className: "text-xs font-bold text-gray-500", children: item.label }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: `text-xs font-medium ${item.value ? "text-green-600" : "text-gray-400"}`, children: item.value ? "Configured" : "Not Set" }), item.value ? (_jsx(CheckCircle, { className: "h-3 w-3 text-green-500", strokeWidth: 3 })) : (_jsx(AlertCircle, { className: "h-3 w-3 text-gray-300" }))] })] }, item.label))) })] }), _jsxs("div", { className: "mt-auto flex items-center gap-4", children: [_jsx(Button, { variant: "ghost", onClick: onBack, disabled: finishing, className: "h-10 rounded-full px-8 text-xs font-bold tracking-widest text-gray-400 uppercase hover:text-gray-600", children: "Back" }), _jsx(Button, { onClick: handleFinish, disabled: finishing, className: "h-10 rounded-full bg-blue-600 px-10 text-xs font-black tracking-widest text-white uppercase shadow-xl shadow-blue-500/20 transition-all hover:bg-blue-700 hover:shadow-blue-500/30 active:scale-95", children: finishing ? (_jsx(RefreshCw, { className: "h-4 w-4 animate-spin" })) : (_jsxs(_Fragment, { children: ["Launch Parhelia", _jsx(ArrowRight, { className: "ml-2 h-4 w-4", strokeWidth: 3 })] })) })] })] }));
}
//# sourceMappingURL=CompleteStep.js.map