import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/**
 * ToSScreen — Terms of Service acceptance on the create-account onboarding path
 * (`--auth-onboarding create-account`; legacy alias: `--signup`).
 *
 * Pattern inspired by Stripe CLI: presents terms and privacy policy
 * links, requires explicit acceptance before proceeding to authentication.
 */
import { Box, Text } from 'ink';
import { useWizardStore } from '../hooks/useWizardStore.js';
import { useEscapeBack } from '../hooks/useEscapeBack.js';
import { PickerMenu } from '../primitives/index.js';
import { Colors, Icons } from '../styles.js';
import { TERMS_OF_SERVICE_URL, PRIVACY_POLICY_URL, } from '../../../lib/constants.js';
const TOS_EXTRA_HINTS = Object.freeze([
    { key: '↑↓', label: 'Navigate' },
    { key: 'Enter', label: 'Select' },
]);
const OPTIONS = [
    {
        label: 'I accept the Terms of Service and Privacy Policy',
        value: 'accept',
    },
    {
        label: 'I do not accept',
        value: 'decline',
    },
];
export const ToSScreen = ({ store }) => {
    useWizardStore(store);
    useEscapeBack(store, { extraHints: TOS_EXTRA_HINTS });
    const handleSelect = (value) => {
        const choice = Array.isArray(value) ? value[0] : value;
        if (choice === 'accept') {
            store.acceptTermsOfService();
        }
        else {
            store.cancelWizard('Terms of Service not accepted');
        }
    };
    return (_jsxs(Box, { flexDirection: "column", flexGrow: 1, children: [_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsx(Text, { bold: true, color: Colors.heading, children: "Terms of Service" }), _jsx(Text, { color: Colors.muted, children: "By continuing, you agree to Amplitude's terms" })] }), _jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Text, { children: ["Please review and accept our", ' ', _jsx(Text, { color: Colors.accent, children: "Terms of Service" }), " and", ' ', _jsx(Text, { color: Colors.accent, children: "Privacy Policy" }), " to continue:"] }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsxs(Text, { color: Colors.muted, children: [Icons.arrowRight, " Terms: ", TERMS_OF_SERVICE_URL] }), _jsxs(Text, { color: Colors.muted, children: [Icons.arrowRight, " Privacy: ", PRIVACY_POLICY_URL] })] })] }), _jsx(PickerMenu, { options: OPTIONS, onSelect: handleSelect }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { color: Colors.muted, children: [Icons.dot, " This is required to create an Amplitude account"] }) })] }));
};
