"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "ListViewFull", {
    enumerable: true,
    get: function() {
        return ListViewFull;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = require("react");
const _listView = require("../../../listView");
const _text = require("../../../text");
const _sortGroup = require("./sortGroup");
const _css = require("../../../utils/css");
const _icon = require("../../../icon");
const _hooks = require("@orderly.network/hooks");
const ListViewFull = /*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
    const config = (0, _hooks.useSymbolsInfo)();
    const renderItem = (item, index, extraData)=>{
        if (config.isNil) return null;
        const symbolInfo = config?.[item.symbol];
        const baseDp = symbolInfo("quote_dp", 2);
        return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
            onMouseEnter: ()=>{
                props.updateActiveIndex?.(index);
            },
            className: (0, _css.cn)("orderly-grid orderly-grid-cols-5 orderly-py-3 orderly-px-5 orderly-cursor-pointer orderly-h-[46px] hover:orderly-bg-base-800", {
                "orderly-bg-base-contrast/5": extraData === index,
                "orderly-grid-cols-6": props.suffixRender
            }),
            onClick: ()=>props.onItemClick?.(item),
            children: [
                /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                    className: "orderly-col-span-2 orderly-flex orderly-items-center",
                    children: [
                        props.prefixRender && props.prefixRender(item, extraData),
                        /*#__PURE__*/ (0, _jsxruntime.jsx)(_icon.NetworkImage, {
                            type: "symbol",
                            symbol: item.symbol,
                            size: "small",
                            className: "orderly-mr-2"
                        }),
                        /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Text, {
                            rule: "symbol",
                            children: item.symbol
                        }),
                        item.leverage && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                            className: "orderly-ml-1 orderly-rounded-sm orderly-px-1 orderly-py-[2px] orderly-flex orderly-items-center orderly-text-3xs orderly-text-primary orderly-bg-base-600",
                            children: `${item.leverage}x`
                        })
                    ]
                }),
                /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                    className: "orderly-col-span-1 orderly-text-right",
                    children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Numeral, {
                        precision: baseDp,
                        children: item["24h_close"]
                    })
                }),
                /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                    className: "orderly-col-span-1 orderly-text-right",
                    children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Numeral, {
                        coloring: true,
                        rule: "percentages",
                        showIcon: true,
                        icons: {
                            loss: /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                                children: "-"
                            }),
                            profit: /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                                children: "+"
                            })
                        },
                        children: item?.change ?? 0
                    })
                }),
                /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                    className: "orderly-col-span-1 orderly-text-right orderly-text-base-contrast-54",
                    children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Numeral, {
                        rule: "human",
                        className: "orderly-text-base-contrast-54",
                        children: item?.["24h_amount"]
                    })
                }),
                props.suffixRender && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                    className: "orderly-col-span-1 orderly-text-right orderly-text-base-contrast-54",
                    children: props.suffixRender(item, index)
                })
            ]
        });
    };
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
        children: [
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_sortGroup.SortGroup, {
                readLastSortCondition: props.readLastSortCondition,
                onChange: props.onSort,
                hasSuffix: props.suffixRender !== undefined
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_listView.ListView, {
                // @ts-ignore
                ref: ref,
                dataSource: props.dataSource,
                // @ts-ignore
                renderItem: renderItem,
                className: "orderly-text-xs orderly-overflow-y-auto orderly-bg-base-900",
                contentClassName: "orderly-space-y-0",
                // extraData={props.activeIndex}
                extraData: props.favoriteTabs,
                style: props.maxHeight ? {
                    height: `${props.maxHeight}px`
                } : {}
            })
        ]
    });
});

//# sourceMappingURL=listview.js.map