import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { executeTransactionOperation } from '../deployCreate2.js';
import { useOperation } from '../../../stores/operationStore.js';
import { useWaitForTransactionReceipt } from 'wagmi';
import { Spinner, Badge } from '@inkjs/ui';
import { Text, Box } from 'ink';
import { getBlockExplorerAddressLink } from '../../../util/blockExplorer.js';
export const ExternalSignerExecution = ({ chain, initCode, baseSalt, deterministicAddress, }) => {
    const { data: hash } = useOperation(executeTransactionOperation({
        chainId: chain.id,
        deterministicAddress,
        initCode,
        baseSalt,
    }));
    const { data: receipt, isLoading: isReceiptLoading } = useWaitForTransactionReceipt({
        hash,
        chainId: chain.id,
    });
    if (!hash) {
        return (_jsxs(Box, { gap: 1, children: [_jsx(Spinner, { label: "Waiting for signature..." }), _jsxs(Box, { flexDirection: "row", children: [_jsx(Text, { children: "Send the transaction at " }), _jsx(Text, { color: "cyan", bold: true, children: "http://localhost:3000" })] })] }));
    }
    if (isReceiptLoading || !receipt) {
        return _jsx(Spinner, { label: "Waiting for receipt" });
    }
    return (_jsxs(Box, { gap: 1, children: [_jsx(Badge, { color: "green", children: "Deployed" }), _jsx(Text, { children: "Contract successfully deployed" }), _jsx(Text, { children: getBlockExplorerAddressLink(chain, deterministicAddress) })] }));
};
