"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "BottomNavBar", {
    enumerable: true,
    get: function() {
        return BottomNavBar;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = require("react");
const _accountStatus = require("../../../../../block/accountStatus");
const _WsStatus = require("../../../../../block/accountStatus/sections/WsStatus");
const _chainIdSwitch = require("../../../../../block/accountStatus/sections/chainIdSwitch");
const _getTestUSDC = require("../../../../../block/operation/getTestUSDC");
const _walletConnect = require("../../../../../block/walletConnect");
const _modal = require("../../../../../modal");
const _provider = require("../../../../../provider");
const _hooks = require("@orderly.network/hooks");
const _types = require("@orderly.network/types");
const _utils = require("@orderly.network/utils");
const BottomNavBar = (props)=>{
    const { state } = (0, _hooks.useAccount)();
    const { data } = (0, _hooks.useAccountInfo)();
    const { totalValue } = (0, _hooks.useCollateral)();
    const { errors } = (0, _react.useContext)(_provider.OrderlyAppContext);
    const { ws: wsStatus } = (0, _react.useContext)(_hooks.StatusContext);
    const { onWalletConnect, onSetChain, onWalletDisconnect } = (0, _react.useContext)(_provider.OrderlyAppContext);
    const { connectedChain } = (0, _hooks.useWalletConnector)();
    const onConnect = (0, _react.useCallback)(()=>{
        onWalletConnect().then((result)=>{
            if (result && result.status < _types.AccountStatusEnum.EnableTrading) {
                _modal.modal.show(_walletConnect.WalletConnectSheet, {
                    status: result.status
                });
            }
        });
    }, []);
    const showGetTestUSDC = (0, _react.useMemo)(()=>{
        const chainId = connectedChain?.id;
        if (chainId === undefined) {
            return false;
        }
        return state.status === _types.AccountStatusEnum.EnableTrading && // @ts-ignore
        (0, _utils.isTestnet)(parseInt(chainId));
    }, [
        state.status,
        connectedChain
    ]);
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
        children: [
            wsStatus === _hooks.WsNetworkStatus.Unstable ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_WsStatus.WsStatus, {}) : errors?.ChainNetworkNotSupport && /*#__PURE__*/ (0, _jsxruntime.jsx)(_chainIdSwitch.ChainIdSwtich, {
                onSetChain: onSetChain
            }),
            showGetTestUSDC && /*#__PURE__*/ (0, _jsxruntime.jsx)(_getTestUSDC.GetTestUSDC, {}),
            /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                id: "orderly-botom-bar-container",
                className: "orderly-fixed orderly-left-0 orderly-bottom-0 orderly-w-screen orderly-bg-base-800 orderly-p-[14px] orderly-pb-[20px] orderly-border-t orderly-border-base-contrast/10 orderly-z-30 orderly-h-[64px] orderly-flex orderly-justify-between orderly-items-center",
                children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_accountStatus.AccountStatusBar, {
                    chains: [],
                    status: state.status,
                    address: state.address,
                    accountInfo: data,
                    totalValue: totalValue,
                    onConnect: onConnect,
                    onDisconnect: onWalletDisconnect,
                    showGetTestUSDC: showGetTestUSDC
                })
            })
        ]
    });
};

//# sourceMappingURL=index.js.map