import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { useState, useEffect, useRef } from "react";
import { useEditContext } from "../client/editContext";
import { version, buildDate } from "../../revision";
import { Info as InfoIcon, Package, FileText, Code, Mail, CheckCircle2, Calendar, Building2, Edit, Users, KeyRound } from "lucide-react";
import { useLicense } from "../../licensing";
import { Dialog, DialogContent, DialogTitle } from "../../components/ui/dialog";
import { EmailEntry } from "../../licensing/EmailEntry";
import { LicenseActivationForm } from "../../licensing/LicenseActivationForm";
import { LicenseCodeEntry } from "../../licensing/LicenseCodeEntry";
import { requestLicense, verifyActivationCode, storeLicense, clearLicenseCache, formatRetryTimeSimple } from "../../licensing/licenseService";
import { setupWizardService } from "../../setup/services/setupWizardService";
export function About() {
    const editContext = useEditContext();
    const license = useLicense();
    const editLicenseButtonRef = useRef(null);
    const [showLicenseDialog, setShowLicenseDialog] = useState(false);
    const [dialogState, setDialogState] = useState("email_entry");
    const [dialogError, setDialogError] = useState();
    const [dialogEmail, setDialogEmail] = useState("");
    const [dialogRetryAfterSeconds, setDialogRetryAfterSeconds] = useState();
    const [editLicenseHighlight, setEditLicenseHighlight] = useState(false);
    // Refresh license status when About is shown and poll while open so active user count stays current
    const refreshLicenseStatus = license.refreshLicenseStatus;
    useEffect(() => {
        refreshLicenseStatus();
        const intervalMs = 45_000; // 45 seconds
        const interval = setInterval(refreshLicenseStatus, intervalMs);
        return () => clearInterval(interval);
    }, [refreshLicenseStatus]);
    // When navigated from status warning (hash #edit-license), scroll to and highlight the Edit license button
    useEffect(() => {
        if (typeof window === "undefined")
            return;
        const run = () => {
            const hash = window.location.hash?.replace(/^#/, "") || "";
            if (hash !== "edit-license")
                return;
            editLicenseButtonRef.current?.scrollIntoView({ behavior: "smooth", block: "center" });
            setEditLicenseHighlight(true);
            const t = setTimeout(() => setEditLicenseHighlight(false), 2500);
            return t;
        };
        let t;
        t = run();
        const onHashChange = () => {
            if (t)
                clearTimeout(t);
            t = run();
        };
        window.addEventListener("hashchange", onHashChange);
        return () => {
            window.removeEventListener("hashchange", onHashChange);
            if (t)
                clearTimeout(t);
        };
    }, []);
    // Handle email check (determines if trial or code is needed)
    const handleEmailCheck = async (email) => {
        setDialogState("loading");
        setDialogError(undefined);
        setDialogEmail(email);
        setDialogRetryAfterSeconds(undefined);
        try {
            // Submit email with placeholder name/company to check license availability
            const response = await requestLicense({
                email,
                name: "Temporary", // Placeholder - will be replaced when trial form is submitted
                companyName: "Temporary", // Placeholder - will be replaced when trial form is submitted
                parheliaBuildDate: license.licenseStatus?.buildDate || "",
            });
            switch (response.status) {
                case "trial": {
                    const complete = response.license && response.requiresProfileCompletion === false;
                    if (complete) {
                        try {
                            const settingsExist = await setupWizardService.getSettingsExists();
                            if (!settingsExist) {
                                await setupWizardService.createSettingsItem();
                            }
                            const storeResult = await storeLicense(response.license, response.signature);
                            if (storeResult.success) {
                                try {
                                    await clearLicenseCache();
                                }
                                catch (err) {
                                    console.warn("Failed to clear license cache:", err);
                                }
                                await new Promise((resolve) => setTimeout(resolve, 100));
                                await license.refreshLicenseStatus();
                                setDialogRetryAfterSeconds(undefined);
                                setDialogState("welcome_back");
                                setTimeout(() => {
                                    setShowLicenseDialog(false);
                                    setDialogState("email_entry");
                                }, 2000);
                            }
                            else {
                                setDialogError(storeResult.message || "Failed to store license");
                                setDialogState("trial_form");
                            }
                        }
                        catch (e) {
                            console.error("Welcome-back license store failed:", e);
                            setDialogError("Failed to store license");
                            setDialogState("email_entry");
                        }
                    }
                    else {
                        setDialogState("trial_form");
                    }
                    break;
                }
                case "code_sent":
                    // One-time code sent, show code entry form
                    setDialogRetryAfterSeconds(undefined);
                    setDialogState("code");
                    break;
                case "trial_expired":
                    setDialogError("Your trial period has ended. Please contact sales to purchase a license.");
                    setDialogState("email_entry");
                    break;
                case "rate_limited":
                    setDialogRetryAfterSeconds(response.retryAfterSeconds || 60);
                    setDialogError(`Too many requests for sending a new code. If you already have a code, enter it now. Otherwise try again in ${formatRetryTimeSimple(response.retryAfterSeconds || 60)}.`);
                    setDialogState("code");
                    break;
                case "error":
                    setDialogRetryAfterSeconds(undefined);
                    setDialogError(response.message || "An error occurred");
                    setDialogState("email_entry");
                    break;
            }
        }
        catch (error) {
            console.error("Email check failed:", error);
            setDialogRetryAfterSeconds(undefined);
            setDialogError("Failed to contact license server");
            setDialogState("email_entry");
        }
    };
    // Handle license request submission
    const handleLicenseRequest = async (email, name, companyName) => {
        setDialogState("loading");
        setDialogError(undefined);
        setDialogEmail(email);
        setDialogRetryAfterSeconds(undefined);
        try {
            const response = await requestLicense({
                email,
                name,
                companyName,
                parheliaBuildDate: license.licenseStatus?.buildDate || "",
            });
            switch (response.status) {
                case "trial":
                    // Got a trial license, store it
                    if (response.license) {
                        const settingsExist = await setupWizardService.getSettingsExists();
                        if (!settingsExist) {
                            await setupWizardService.createSettingsItem();
                        }
                        const storeResult = await storeLicense(response.license, response.signature);
                        if (storeResult.success) {
                            // Clear the backend cache and refresh status
                            try {
                                await clearLicenseCache();
                            }
                            catch (err) {
                                console.warn("Failed to clear license cache:", err);
                            }
                            // Wait a bit for the backend to process
                            await new Promise(resolve => setTimeout(resolve, 100));
                            await license.refreshLicenseStatus();
                            setDialogRetryAfterSeconds(undefined);
                            setDialogState("success");
                            setTimeout(() => {
                                setShowLicenseDialog(false);
                                setDialogState("email_entry");
                            }, 2000);
                        }
                        else {
                            setDialogError(storeResult.message || "Failed to store license");
                            setDialogState("trial_form");
                        }
                    }
                    break;
                case "code_sent":
                    // One-time code sent, show code entry form
                    setDialogRetryAfterSeconds(undefined);
                    setDialogState("code");
                    break;
                case "trial_expired":
                    setDialogError("Your trial period has ended. Please contact sales to purchase a license.");
                    setDialogState("trial_form");
                    break;
                case "rate_limited":
                    setDialogRetryAfterSeconds(response.retryAfterSeconds || 60);
                    setDialogError(`Too many requests. Please try again in ${response.retryAfterSeconds || 60} seconds.`);
                    setDialogState("trial_form");
                    break;
                case "error":
                    setDialogRetryAfterSeconds(undefined);
                    setDialogError(response.message || "An error occurred");
                    setDialogState("trial_form");
                    break;
            }
        }
        catch (error) {
            console.error("License request failed:", error);
            setDialogRetryAfterSeconds(undefined);
            setDialogError("Failed to contact license server");
            setDialogState("trial_form");
        }
    };
    // Handle activation code submission
    const handleActivationCode = async (code) => {
        setDialogState("loading");
        setDialogError(undefined);
        setDialogRetryAfterSeconds(undefined);
        try {
            const response = await verifyActivationCode({
                email: dialogEmail,
                code,
            });
            switch (response.status) {
                case "purchased":
                    // Got a purchased license, store it
                    if (response.license) {
                        const settingsExist = await setupWizardService.getSettingsExists();
                        if (!settingsExist) {
                            await setupWizardService.createSettingsItem();
                        }
                        const storeResult = await storeLicense(response.license, response.signature);
                        if (storeResult.success) {
                            // Clear the backend cache and refresh status
                            try {
                                await clearLicenseCache();
                            }
                            catch (err) {
                                console.warn("Failed to clear license cache:", err);
                            }
                            // Wait a bit for the backend to process
                            await new Promise(resolve => setTimeout(resolve, 100));
                            await license.refreshLicenseStatus();
                            setDialogRetryAfterSeconds(undefined);
                            setDialogState("success");
                            setTimeout(() => {
                                setShowLicenseDialog(false);
                                setDialogState("email_entry");
                            }, 2000);
                        }
                        else {
                            setDialogError(storeResult.message || "Failed to store license");
                            setDialogState("code");
                        }
                    }
                    break;
                case "invalid_code":
                    setDialogRetryAfterSeconds(undefined);
                    setDialogError(response.message || "Invalid activation code");
                    setDialogState("code");
                    break;
                case "rate_limited":
                    setDialogRetryAfterSeconds(response.retryAfterSeconds || 60);
                    setDialogError(response.message ||
                        `Too many incorrect activation code attempts. Try again in ${formatRetryTimeSimple(response.retryAfterSeconds || 60)}.`);
                    setDialogState("code");
                    break;
                case "error":
                    setDialogRetryAfterSeconds(undefined);
                    setDialogError(response.message || "An error occurred");
                    setDialogState("code");
                    break;
            }
        }
        catch (error) {
            console.error("Activation code verification failed:", error);
            setDialogRetryAfterSeconds(undefined);
            setDialogError("Failed to verify activation code");
            setDialogState("code");
        }
    };
    // Helper to check if dialog can be closed (only when there's a valid license)
    const canCloseDialog = () => {
        return (license?.isLicensed &&
            license?.licenseStatus?.status !== "invalid" &&
            license?.licenseStatus?.status !== "no_license");
    };
    return (_jsxs("div", { className: "space-y-6 p-6", children: [_jsxs("div", { className: "space-y-6", children: [_jsxs("div", { className: "border border-gray-200 bg-white shadow-sm", children: [_jsx("div", { className: "border-b border-gray-200 bg-gray-50 px-6 py-4", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Package, { className: "h-5 w-5 text-gray-600", strokeWidth: 1.5 }), _jsx("h3", { className: "text-lg font-semibold text-gray-900", children: "Version Information" })] }) }), _jsx("div", { className: "p-6", children: _jsxs("div", { className: "grid grid-cols-1 gap-6 md:grid-cols-2", children: [_jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-gray-500", children: [_jsx(InfoIcon, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx("span", { children: "Version" })] }), _jsx("p", { className: "text-base text-gray-900", children: version })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-gray-500", children: [_jsx(Code, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx("span", { children: "Build Date" })] }), _jsx("p", { className: "text-base text-gray-900", children: buildDate })] })] }) })] }), !license?.licenseStatus?.licensingDisabled && (_jsxs("div", { className: "border border-gray-200 bg-white shadow-sm", children: [_jsx("div", { className: "border-b border-gray-200 bg-gray-50 px-6 py-4", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(FileText, { className: "h-5 w-5 text-gray-600", strokeWidth: 1.5 }), _jsx("h3", { className: "text-lg font-semibold text-gray-900", children: "License Information" })] }) }), _jsx("div", { className: "p-6", children: _jsxs("div", { className: "space-y-6", children: [_jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-gray-500", children: [_jsx(FileText, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx("span", { children: "Copyright" })] }), _jsxs("p", { className: "text-base text-gray-900", children: ["\u00A9 ", new Date().getFullYear(), " Canvas Reply GmbH"] })] }), license?.isLicensed ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-gray-500", children: [_jsx(CheckCircle2, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx("span", { children: "License Status" })] }), _jsxs("button", { id: "edit-license", ref: editLicenseButtonRef, onClick: () => {
                                                                        setDialogState("email_entry");
                                                                        setDialogError(undefined);
                                                                        setDialogEmail("");
                                                                        setShowLicenseDialog(true);
                                                                    }, className: `flex items-center gap-1.5 rounded-md px-2.5 py-1.5 text-sm font-medium transition-colors ${editLicenseHighlight
                                                                        ? "ring-2 ring-amber-400 ring-offset-2 bg-amber-50 text-amber-800"
                                                                        : "text-gray-700 hover:bg-gray-100"}`, title: "Change license", children: [_jsx(Edit, { className: "h-3.5 w-3.5", strokeWidth: 1.5 }), _jsx("span", { children: "Edit" })] })] }), _jsx("div", { className: "flex items-center gap-2", children: _jsx("p", { className: "text-base text-gray-900 capitalize", children: license.licenseType === "trial" ? "Trial License" : license.licenseType === "purchased" ? "Purchased License" : "License" }) }), !license?.isLicensed && license?.licenseStatus?.message && (_jsx("p", { className: "text-sm text-amber-600 mt-1", children: license.licenseStatus.message }))] }), license.licenseStatus?.companyName && (_jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-gray-500", children: [_jsx(Building2, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx("span", { children: "Company" })] }), _jsx("p", { className: "text-base text-gray-900", children: license.licenseStatus.companyName })] })), _jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-gray-500", children: [_jsx(Calendar, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx("span", { children: "Expires" })] }), _jsx("p", { className: "text-base text-gray-900", children: license.expiresAt ? (_jsxs(_Fragment, { children: [license.expiresAt.toLocaleDateString(), license.daysRemaining !== undefined && license.daysRemaining !== null && (_jsxs("span", { className: `ml-2 text-sm ${license.daysRemaining <= 0 ? "text-red-600 font-medium" :
                                                                            license.daysRemaining <= 7 ? "text-amber-600" :
                                                                                "text-gray-500"}`, children: ["(", license.daysRemaining === 0 ? "Expired" :
                                                                                license.daysRemaining < 0 ? `${Math.abs(license.daysRemaining)} days ago` :
                                                                                    `${license.daysRemaining} ${license.daysRemaining === 1 ? "day" : "days"} remaining`, ")"] }))] })) : ("Unlimited") })] }), license.features && license.features.length > 0 && (_jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-gray-500", children: [_jsx(Package, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx("span", { children: "Features" })] }), _jsx("div", { className: "flex flex-wrap gap-2", children: license.features.map((feature) => (_jsx("span", { className: "inline-flex items-center rounded-md bg-blue-50 px-2.5 py-0.5 text-sm font-medium text-blue-700", children: feature }, feature))) })] })), _jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-gray-500", children: [_jsx(Users, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx("span", { children: "Max Concurrent Users" })] }), _jsx("p", { className: "text-base text-gray-900", children: license.licenseStatus?.maxConcurrentUsers !== undefined &&
                                                                license.licenseStatus.maxConcurrentUsers !== null
                                                                ? license.licenseStatus.maxConcurrentUsers
                                                                : "Unlimited" })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-gray-500", children: [_jsx(Users, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx("span", { children: license.licenseStatus?.maxConcurrentUsers !== undefined &&
                                                                        license.licenseStatus?.maxConcurrentUsers !== null
                                                                        ? "Currently active"
                                                                        : "Active users" })] }), _jsx("p", { className: "text-base text-gray-900", children: license.licenseStatus?.maxConcurrentUsers !== undefined &&
                                                                license.licenseStatus?.maxConcurrentUsers !== null
                                                                ? `${license.licenseStatus?.currentLicenseUserCount ?? 0} of ${license.licenseStatus.maxConcurrentUsers}`
                                                                : license.licenseStatus?.currentLicenseUserCount ?? 0 })] })] })) : (
                                        /* No license - show generic message */
                                        _jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-gray-500", children: [_jsx(FileText, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx("span", { children: "License" })] }), _jsx("p", { className: "text-base text-gray-900", children: "All rights reserved. Please contact Canvas Reply GmbH for licensing information." })] }))] }) })] })), _jsxs("div", { className: "border border-gray-200 bg-white shadow-sm", children: [_jsx("div", { className: "border-b border-gray-200 bg-gray-50 px-6 py-4", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Code, { className: "h-5 w-5 text-gray-600", strokeWidth: 1.5 }), _jsx("h3", { className: "text-lg font-semibold text-gray-900", children: "Third-Party Components" })] }) }), _jsx("div", { className: "p-6", children: _jsxs("div", { className: "max-h-96 space-y-3 overflow-y-auto", children: [_jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "React" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "A JavaScript library for building user interfaces", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "Next.js" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "The React Framework for Production", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "TypeScript" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "Apache 2.0 License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "TypeScript is a language for application scale JavaScript development", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "Tailwind CSS" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "A utility-first CSS framework for rapidly building custom designs", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "Lucide React" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "ISC License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "Beautiful & consistent icon toolkit made by the community", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "Radix UI" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "Low-level UI primitives for React with accessibility built-in", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "Axios" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "Promise based HTTP client for the browser and node.js", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "React Inspector" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "Power of Browser DevTools inspectors right inside your React app", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "Lodash" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "A modern JavaScript utility library delivering modularity, performance & extras", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "clsx" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "A tiny utility for constructing className strings conditionally", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "PostCSS" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "Tool for transforming CSS with JavaScript", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "Universal Cookie" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "Universal cookies for JavaScript", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "Slate" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "A completely customizable framework for building rich text editors", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "Sonner" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "An opinionated toast component for React", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "cmdk" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "Fast, composable, unstyled command menu for React", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "date-fns" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "Modern JavaScript date utility library", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "morphdom" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "Fast and lightweight DOM diffing/patching library", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "react-day-picker" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "Flexible date picker component for React", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "tailwind-merge" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "Merge Tailwind CSS classes without style conflicts", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "use-debounce" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "React hook for debouncing values and callbacks", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "diff" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "BSD 3-Clause License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "JavaScript text diff implementation", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "html-entities" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "Encode and decode HTML entities", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "react-json-view-lite" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "Lightweight JSON viewer component for React", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "class-variance-authority" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "Apache 2.0 License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "Create type-safe UI component variants", " "] }), " "] }), " ", _jsxs("div", { className: "rounded-lg bg-gray-50 p-3", children: [" ", _jsxs("div", { className: "mb-2 flex items-center justify-between", children: [" ", _jsx("h4", { className: "text-sm font-medium text-gray-700", children: "react-uuid" }), " ", _jsx("span", { className: "text-xs text-gray-500", children: "MIT License" }), " "] }), " ", _jsxs("p", { className: "text-xs text-gray-600", children: [" ", "Generate unique identifiers in React applications", " "] }), " "] }), " "] }) })] }), _jsxs("div", { className: "border border-gray-200 bg-white shadow-sm", children: [_jsx("div", { className: "border-b border-gray-200 bg-gray-50 px-6 py-4", children: _jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Mail, { className: "h-5 w-5 text-gray-600", strokeWidth: 1.5 }), _jsx("h3", { className: "text-lg font-semibold text-gray-900", children: "Contact & Support" })] }) }), _jsx("div", { className: "p-6", children: _jsxs("div", { className: "space-y-6", children: [_jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-gray-500", children: [_jsx(Building2, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx("span", { children: "Company" })] }), _jsx("p", { className: "text-base text-gray-900", children: "Canvas Reply GmbH" })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-gray-500", children: [_jsx(Mail, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx("span", { children: "Email" })] }), _jsx("p", { className: "text-base text-gray-900", children: _jsx("a", { href: "mailto:info@canvas-reply.com", className: "text-blue-600 underline hover:text-blue-800", children: "info@canvas-reply.com" }) })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-gray-500", children: [_jsx(FileText, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx("span", { children: "Website" })] }), _jsx("p", { className: "text-base text-gray-900", children: _jsx("a", { href: "https://www.canvas-reply.com", target: "_blank", rel: "noopener noreferrer", className: "text-blue-600 underline hover:text-blue-800", children: "www.canvas-reply.com" }) })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-gray-500", children: [_jsx(Mail, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx("span", { children: "Support" })] }), _jsx("p", { className: "text-base text-gray-900", children: _jsx("a", { href: "mailto:support@canvas-reply.com", className: "text-blue-600 underline hover:text-blue-800", children: "support@canvas-reply.com" }) })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsxs("div", { className: "flex items-center gap-2 text-sm font-medium text-gray-500", children: [_jsx(FileText, { className: "h-4 w-4", strokeWidth: 1.5 }), _jsx("span", { children: "Licensing" })] }), _jsxs("p", { className: "text-base text-gray-900", children: ["For licensing information, please contact", " ", _jsx("a", { href: "mailto:sales@canvas-reply.com", className: "text-blue-600 underline hover:text-blue-800", children: "sales@canvas-reply.com" })] })] })] }) })] })] }), _jsx(Dialog, { open: showLicenseDialog, onOpenChange: (open) => {
                    // Only allow closing if there's a valid license
                    if (!open && !canCloseDialog()) {
                        // Don't allow closing when there's no license or invalid license
                        return;
                    }
                    setShowLicenseDialog(open);
                    if (!open) {
                        setDialogState("email_entry");
                        setDialogError(undefined);
                        setDialogEmail("");
                        setDialogRetryAfterSeconds(undefined);
                    }
                }, children: _jsxs(DialogContent, { className: "max-w-2xl w-full border-none bg-white p-0 overflow-hidden rounded-2xl shadow-2xl", overlayClassName: "bg-gray-900/40 backdrop-blur-sm", showCloseButton: canCloseDialog(), onInteractOutside: (e) => {
                        // Prevent closing when clicking outside if there's no license or invalid license
                        if (!canCloseDialog()) {
                            e.preventDefault();
                        }
                    }, onPointerDownOutside: (e) => {
                        // Prevent closing when clicking outside if there's no license or invalid license
                        if (!canCloseDialog()) {
                            e.preventDefault();
                        }
                    }, children: [_jsx("div", { className: "h-1 w-full bg-gray-100", children: _jsx("div", { className: "h-full w-full bg-blue-600" }) }), _jsxs("div", { className: "min-h-[520px] flex flex-col items-center justify-center p-12", children: [_jsx(DialogTitle, { className: "sr-only", children: "Change License" }), (dialogState === "email_entry" ||
                                    dialogState === "trial_form" ||
                                    dialogState === "code" ||
                                    dialogState === "loading") && (_jsx("div", { className: "mb-8 rounded-2xl bg-blue-50 p-6 ring-1 ring-blue-100", children: _jsx(KeyRound, { className: "h-16 w-12 text-blue-600", strokeWidth: 1.5 }) })), dialogState === "email_entry" && (_jsx(EmailEntry, { onSubmit: handleEmailCheck, error: dialogError })), dialogState === "trial_form" && (_jsx(LicenseActivationForm, { email: dialogEmail, onSubmit: handleLicenseRequest, onBack: () => {
                                        setDialogState("email_entry");
                                        setDialogError(undefined);
                                        setDialogRetryAfterSeconds(undefined);
                                    }, error: dialogError })), dialogState === "code" && (_jsx(LicenseCodeEntry, { email: dialogEmail, onSubmit: handleActivationCode, onBack: () => {
                                        setDialogState("email_entry");
                                        setDialogError(undefined);
                                        setDialogRetryAfterSeconds(undefined);
                                    }, error: dialogError, retryAfterSeconds: dialogRetryAfterSeconds })), dialogState === "loading" && (_jsxs("div", { className: "flex flex-col items-center gap-3 text-gray-600", children: [_jsx("div", { className: "h-12 w-12 animate-spin rounded-full border-4 border-blue-600 border-t-transparent" }), _jsx("p", { className: "text-sm font-medium", children: "Processing..." })] })), dialogState === "welcome_back" && (_jsxs("div", { className: "flex flex-col items-center gap-3 text-green-600 animate-in fade-in zoom-in duration-500", children: [_jsx("div", { className: "rounded-full bg-green-100 p-3", children: _jsx(CheckCircle2, { className: "h-10 w-10", strokeWidth: 2 }) }), _jsx("h2", { className: "text-xl font-semibold text-gray-900", children: "Welcome back" }), _jsx("p", { className: "text-center text-gray-600", children: "Your trial is active again on this environment." })] })), dialogState === "success" && (_jsxs("div", { className: "flex flex-col items-center gap-3 text-green-600 animate-in fade-in zoom-in duration-500", children: [_jsx("div", { className: "rounded-full bg-green-100 p-3", children: _jsx(CheckCircle2, { className: "h-10 w-10", strokeWidth: 2 }) }), _jsx("h2", { className: "text-xl font-semibold text-gray-900", children: "License Activated" }), _jsx("p", { className: "text-center text-gray-600", children: "Your license has been successfully updated." })] }))] })] }) })] }));
}
//# sourceMappingURL=About.js.map