import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useContext, useMemo, useState } from "react";
import { AccountStatusEnum } from "@orderly.network/types";
import { Chains } from "../sections/desktop/chains.desktop";
import { cn } from "../../../utils/css";
import { useAccount, useChains, useWalletConnector } from "@orderly.network/hooks";
import { OrderlyAppContext } from "../../../provider";
import { DesktopWalletConnnectButton } from "./walletConnectButton.desktop";
import { isTestnet } from "@orderly.network/utils";
export const AccountStatus = (props)=>{
    const { status = AccountStatusEnum.NotConnected } = props;
    const { account, state } = useAccount();
    const [open, setOpen] = useState(false);
    const { onWalletDisconnect } = useContext(OrderlyAppContext);
    const { connectedChain } = useWalletConnector();
    const [allChains, { findByChainId }] = useChains(undefined, {
        pick: "network_infos",
        filter: (chain)=>chain.network_infos?.bridge_enable || chain.network_infos?.bridgeless
    });
    const chains = useMemo(()=>{
        if (Array.isArray(allChains)) return allChains;
        if (allChains === undefined) return [];
        // @ts-ignore
        if (connectedChain && isTestnet(parseInt(connectedChain.id))) {
            return allChains.testnet ?? [];
        }
        return allChains.mainnet;
    }, [
        allChains,
        connectedChain
    ]);
    return /*#__PURE__*/ _jsxs("div", {
        className: cn("orderly-h-full orderly-flex orderly-items-center orderly-space-x-2", props.className),
        children: [
            /*#__PURE__*/ _jsx(Chains, {
                disabled: status < AccountStatusEnum.NotConnected,
                className: "orderly-rounded-full"
            }),
            /*#__PURE__*/ _jsx(DesktopWalletConnnectButton, {
                status: status,
                // @ts-ignore
                chains: chains,
                address: props.address,
                balance: props.balance,
                currency: props.currency,
                totalValue: props.totalValue,
                accountInfo: account,
                loading: props.loading,
                onConnect: props.onConnect,
                onDisconnect: props.onDisconnect,
                showGetTestUSDC: props.showGetTestUSDC,
                className: props.className,
                dropMenuItem: props.dropMenuItem,
                onClickDropMenuItem: props.onClickDropMenuItem
            })
        ]
    });
};

//# sourceMappingURL=accountStatus.desktop.js.map