"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "OrdersPane", {
    enumerable: true,
    get: function() {
        return OrdersPane;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _orders = require("../../../../../../block/orders");
const _react = require("react");
const _hooks = require("@orderly.network/hooks");
const _tradingPageContext = require("../../../../../../page/trading/context/tradingPageContext");
const _types = require("@orderly.network/types");
const _tab = require("../../../../../../tab");
const OrdersPane = (props)=>{
    // const {
    //   excludes = [AlgoOrderRootType.POSITIONAL_TP_SL, AlgoOrderRootType.TP_SL],
    // } = props;
    const context = (0, _react.useContext)(_tradingPageContext.TradingPageContext);
    const tabContext = (0, _react.useContext)(_tab.TabContext);
    const [showAllSymbol, setShowAllSymbol] = (0, _hooks.useSessionStorage)("showAllSymbol_orders", true);
    const [symbol, setSymbol] = (0, _react.useState)(()=>showAllSymbol ? "" : context.symbol);
    const [data, { isLoading, loadMore, cancelOrder, updateOrder, cancelAlgoOrder, updateAlgoOrder, cancelAllOrders, cancelAllTPSLOrders }] = (0, _hooks.useOrderStream)({
        status: _types.OrderStatus.INCOMPLETE,
        symbol: symbol,
        excludes: props.excludes,
        includes: props.includes
    });
    const onShowAllSymbolChange = (isAll)=>{
        setSymbol(isAll ? "" : context.symbol);
        setShowAllSymbol(isAll);
    };
    const { state } = (0, _hooks.useAccount)();
    const isStopOrder = (0, _react.useMemo)(()=>{
        return props.includes?.includes(_types.AlgoOrderRootType.POSITIONAL_TP_SL) || props.includes?.includes(_types.AlgoOrderRootType.TP_SL);
    }, [
        props.includes
    ]);
    const cancelAllOrdersHandler = ()=>{
        if (isStopOrder) {
            return cancelAllTPSLOrders();
        } else {
            return cancelAllOrders();
        }
    };
    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_orders.OrdersView, {
        // @ts-ignore
        dataSource: state.status < _types.AccountStatusEnum.EnableTrading ? [] : data,
        isLoading: isLoading,
        symbol: context.symbol,
        showAllSymbol: showAllSymbol,
        cancelOrder: cancelOrder,
        onCancelAll: cancelAllOrdersHandler,
        cancelAlgoOrder: cancelAlgoOrder,
        onShowAllSymbolChange: onShowAllSymbolChange,
        editOrder: updateOrder,
        editAlgoOrder: updateAlgoOrder,
        onSymbolChange: context.onSymbolChange,
        loadMore: loadMore,
        isStopOrder: isStopOrder
    });
};

//# sourceMappingURL=index.js.map