"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    DataListView: function() {
        return DataListView;
    },
    MemoizedDataListView: function() {
        return MemoizedDataListView;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _tab = require("../../../../../tab");
const _react = require("react");
const _positions = require("./positions");
const _orders = require("./orders");
const _types = require("@orderly.network/types");
const _tabTitle = require("../../../../../page/trading/mobile/sections/dataList/orders/tabTitle");
const _tabbarExtraNode = require("../../../../../page/trading/desktop/sections/datalist/tabbarExtraNode");
const _history = require("./history");
const _hooks = require("@orderly.network/hooks");
const _decimalPrecisionCheckBox = require("./decimalPrecisionCheckBox");
const _unPnlPriceBasisCheckBox = require("./unPnlPriceBasisCheckBox");
const _tpslTabTitle = require("../../../../../page/trading/desktop/sections/datalist/tpslTabTitle");
const _tp_sl_list = require("../../../../../block/tp_sl/tp_sl_list");
const DataListView = ()=>{
    const [activeTab, setActiveTab] = (0, _react.useState)("positions");
    const [data] = (0, _hooks.usePositionStream)();
    const hasPositions = (data.rows?.length || 0) > 0;
    const [decimalPrecision, setDecimalPrecision] = (0, _hooks.useSessionStorage)("orderly_dicimal_precision_key", _decimalPrecisionCheckBox.DecimalPrecisionType.TWO);
    const [unPnlPriceBasis, setUnPnlPriceBasic] = (0, _hooks.useSessionStorage)("orderly_unrealized_pnl_price_basis_key", _unPnlPriceBasisCheckBox.UnPnlPriceBasisType.MARKET_PRICE);
    // const [orderStatus, setOrderStatus] = useSessionStorage(
    //   "orderly_order_status",
    //   "positions"
    // );
    const onTabChange = (0, _react.useCallback)((value)=>{
        setActiveTab(value);
    }, []);
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)(_tab.Tabs, {
        autoFit: true,
        value: activeTab,
        onTabChange: onTabChange,
        tabBarClassName: "orderly-h-[48px] orderly-text-sm desktop:orderly-font-semibold",
        tabBarExtra: /*#__PURE__*/ (0, _jsxruntime.jsx)(_tabbarExtraNode.TabBarExtraNode, {
            decimalPrecision: decimalPrecision,
            setDecimalPrecision: setDecimalPrecision,
            unPnlPriceBasis: unPnlPriceBasis,
            setUnPnlPriceBasic: setUnPnlPriceBasic
        }),
        extraData: {
            showAllSymbol: false,
            // value is 0 1 2
            pnlNotionalDecimalPrecision: decimalPrecision,
            // 0: mark price 1: last price
            unPnlPriceBasis: unPnlPriceBasis
        },
        children: [
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_tab.TabPane, {
                title: hasPositions ? `Positions(${data.rows?.length})` : "Positions",
                value: "positions",
                className: "orderly-px-3",
                children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_positions.PositionPane, {
                    unPnlPriceBasis: unPnlPriceBasis,
                    setUnPnlPriceBasic: setUnPnlPriceBasic
                })
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_tab.TabPane, {
                title: /*#__PURE__*/ (0, _jsxruntime.jsx)(_tabTitle.MemoizedOrdersTabTitle, {}),
                value: "orders",
                className: "orderly-px-3",
                children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_orders.MyOrders, {
                    status: _types.OrderStatus.INCOMPLETE
                })
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_tab.TabPane, {
                title: /*#__PURE__*/ (0, _jsxruntime.jsx)(_tpslTabTitle.MemoizedTPSLTabTitle, {}),
                value: "tpsl",
                className: "orderly-px-3",
                children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_tp_sl_list.TPSLList, {})
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_tab.TabPane, {
                title: "Filled",
                value: "filled",
                className: "orderly-px-3",
                children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_orders.MyOrders, {
                    status: _types.OrderStatus.FILLED
                })
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_tab.TabPane, {
                title: "Order history",
                value: "history",
                className: "orderly-px-3",
                children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_history.HistoryView, {})
            })
        ]
    });
};
const MemoizedDataListView = /*#__PURE__*/ (0, _react.memo)(DataListView);

//# sourceMappingURL=index.js.map