import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import React, { useState } from 'react';
import { Box, Text, useInput } from 'ink';
import { theme } from '../semantic-colors.js';
import {} from 'sixth-cli-core';
export const SubscriptionBlockedScreen = ({ status, onRefresh, }) => {
    const [isRefreshing, setIsRefreshing] = useState(false);
    const [isActive, setIsActive] = useState(true);
    useInput((input, key) => {
        if (key.return && !isRefreshing && isActive) {
            setIsRefreshing(true);
            setIsActive(false); // Disable immediately
            // Call parent refresh handler which handles everything
            onRefresh();
            // Reset refreshing state after a delay
            setTimeout(() => {
                setIsRefreshing(false);
                setIsActive(true); // Re-enable input after refresh completes
            }, 3000);
        }
    }, { isActive });
    return (_jsxs(Box, { flexDirection: "column", alignItems: "center", justifyContent: "center", height: 25, paddingX: 4, children: [_jsxs(Box, { flexDirection: "column", alignItems: "center", marginBottom: 3, children: [_jsx(Text, { color: theme.status.error, bold: true, children: "\uD83D\uDEAB Free Trial Exhausted" }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: theme.text.secondary, children: ["You've used ", status.totalTokensUsed.toLocaleString(), " tokens (limit: 100,000 tokens for testing)"] }) })] }), status.userInfo && (_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: theme.border.default, paddingX: 3, paddingY: 1, marginBottom: 3, width: 60, children: [_jsx(Text, { color: theme.text.primary, bold: true, children: "Account Details:" }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: theme.text.secondary, children: ["\u2022 Name: ", status.userInfo.fullname] }) }), _jsxs(Text, { color: theme.text.secondary, children: ["\u2022 Email: ", status.userInfo.email] }), _jsxs(Text, { color: theme.text.secondary, children: ["\u2022 Company: ", status.userInfo.company_name] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.status.error, children: "\u2022 Status: Free Trial (Expired)" }) })] })), _jsxs(Box, { flexDirection: "column", alignItems: "center", borderStyle: "round", borderColor: theme.status.warning, paddingX: 3, paddingY: 2, marginBottom: 3, width: 70, children: [_jsx(Text, { color: theme.status.warning, bold: true, children: "Upgrade Required" }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.text.secondary, children: "To continue using Sixth CLI, please upgrade your account." }) }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.text.secondary, children: "We've automatically opened the pricing page in your browser." }) }), _jsx(Box, { marginTop: 2, children: _jsx(Text, { color: theme.text.primary, bold: true, children: "Benefits of upgrading:" }) }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.text.accent, children: "\u2022 Unlimited token usage" }) }), _jsx(Text, { color: theme.text.accent, children: "\u2022 Priority support" }), _jsx(Text, { color: theme.text.accent, children: "\u2022 Advanced features" }), _jsx(Text, { color: theme.text.accent, children: "\u2022 No usage interruptions" })] }), _jsx(Box, { flexDirection: "column", alignItems: "center", children: !isRefreshing ? (_jsxs(_Fragment, { children: [_jsxs(Text, { color: theme.text.primary, bold: true, children: ["After completing your payment, press", ' ', _jsx(Text, { color: theme.text.accent, bold: true, children: "ENTER" }), ' ', "to refresh your subscription"] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.text.secondary, children: "This will check your updated account status and resume the CLI" }) })] })) : (_jsxs(Box, { flexDirection: "column", alignItems: "center", children: [_jsx(Text, { color: theme.status.warning, children: "\uD83D\uDD04 Refreshing subscription status..." }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { color: theme.text.secondary, children: "Checking your payment and account updates" }) })] })) })] }));
};
//# sourceMappingURL=SubscriptionBlockedScreen.js.map