"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "columnsBasis", {
    enumerable: true,
    get: function() {
        return columnsBasis;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _types = require("@orderly.network/types");
const _renew = require("../orderHistory/full/renew");
const _cancelButton = require("./full/cancelButton");
const _string = require("../../utils/string");
const _text = require("../../text");
const _classvarianceauthority = require("class-variance-authority");
const _numeralWithCtx = require("../../text/numeralWithCtx");
const columnsBasis = (props)=>{
    const { status, onSymbolChange } = props || {};
    const columns = [
        {
            title: "Instrument",
            dataIndex: "symbol",
            width: 120,
            className: "orderly-h-[48px] orderly-font-semibold",
            render: (value)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Text, {
                    rule: "symbol",
                    onClick: (e)=>{
                        onSymbolChange?.({
                            symbol: value
                        });
                        e.stopPropagation();
                        e.preventDefault();
                    },
                    children: value
                })
        },
        {
            title: "Type",
            width: 100,
            className: "orderly-h-[48px] orderly-font-semibold",
            dataIndex: "type",
            formatter: (value, record)=>{
                if (record.algo_order_id) {
                    return `Stop ` + `${record.type}`.toLowerCase();
                }
                return (0, _string.upperCaseFirstLetter)(value);
            }
        },
        {
            title: "Side",
            className: "orderly-h-[48px]",
            width: 100,
            dataIndex: "side",
            render: (value, record)=>/*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                    className: (0, _classvarianceauthority.cx)("orderly-font-semibold", value === _types.OrderSide.BUY ? "orderly-text-trade-profit" : "orderly-text-trade-loss"),
                    children: (0, _string.upperCaseFirstLetter)(value)
                })
        },
        {
            title: "Filled / Quantity",
            className: "orderly-h-[48px] orderly-font-semibold",
            dataIndex: "quantity",
            width: 200,
            render: (value, record)=>{
                return /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                    className: (0, _classvarianceauthority.cx)("orderly-font-semibold", record.side === _types.OrderSide.BUY ? "orderly-text-trade-profit" : "orderly-text-trade-loss"),
                    children: `${record.total_executed_quantity} / ${record.quantity}`
                });
            }
        },
        {
            title: "Order Price",
            className: "orderly-h-[48px] orderly-font-semibold",
            dataIndex: "price",
            width: 100,
            render: (value, record)=>{
                if (record.type === "MARKET") {
                    return /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                        children: "Market"
                    });
                }
                return /*#__PURE__*/ (0, _jsxruntime.jsx)(_numeralWithCtx.NumeralWithCtx, {
                    className: "orderly-font-semibold orderly-text-2xs",
                    children: value || "-"
                });
            }
        },
        {
            title: "Avg. price",
            width: 100,
            className: "orderly-h-[48px] orderly-font-semibold",
            dataIndex: "average_executed_price",
            render: (value, record)=>{
                return /*#__PURE__*/ (0, _jsxruntime.jsx)(_numeralWithCtx.NumeralWithCtx, {
                    className: "orderly-font-semibold orderly-text-2xs",
                    children: value || "-"
                });
            }
        },
        {
            title: "Trigger",
            width: 100,
            className: "orderly-h-[48px] orderly-font-semibold",
            dataIndex: "trigger_price",
            render: (value, record)=>{
                return /*#__PURE__*/ (0, _jsxruntime.jsx)(_numeralWithCtx.NumeralWithCtx, {
                    className: "orderly-font-semibold orderly-text-2xs",
                    children: value
                });
            }
        },
        {
            title: "Est. total",
            width: 100,
            className: "orderly-h-[48px] orderly-font-semibold",
            dataIndex: "executed",
            render: (value, record)=>{
                return /*#__PURE__*/ (0, _jsxruntime.jsx)(_numeralWithCtx.NumeralWithCtx, {
                    className: "orderly-font-semibold orderly-text-2xs",
                    children: record.total_executed_quantity === 0 || Number.isNaN(record.average_executed_price) || record.average_executed_price === null ? "-" : `${record.total_executed_quantity * record.average_executed_price}`
                });
            }
        },
        {
            title: "Fee",
            width: 100,
            className: "orderly-h-[48px] orderly-font-semibold",
            dataIndex: "total_fee"
        },
        {
            title: "Status",
            width: 120,
            className: "orderly-h-[48px] orderly-font-semibold",
            dataIndex: "status",
            formatter: (value, record)=>{
                const status = value || record.algo_status;
                if (status === "NEW") {
                    return (0, _string.upperCaseFirstLetter)("pending");
                }
                return (0, _string.upperCaseFirstLetter)(status);
            }
        },
        {
            title: "Reduce",
            width: 80,
            dataIndex: "reduce_only",
            className: "orderly-h-[48px] orderly-font-semibold",
            render: (value)=>{
                return /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                    children: value ? "Yes" : "No"
                });
            }
        },
        {
            title: "Hidden",
            width: 80,
            dataIndex: "visible",
            className: "orderly-h-[48px] orderly-font-semibold",
            render: (value, record)=>{
                return /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                    children: record.visible_quantity !== 0 ? "No" : "Yes"
                });
            }
        },
        {
            title: "Order time",
            dataIndex: "created_time",
            width: 150,
            // onSort: status === OrderStatus.INCOMPLETE,
            className: "orderly-h-[48px]",
            render: (value)=>/*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Text, {
                    rule: "date",
                    className: "orderly-break-normal orderly-whitespace-nowrap orderly-font-semibold",
                    children: value
                })
        }
    ];
    if (status !== _types.OrderStatus.REJECTED && status !== _types.OrderStatus.FILLED) {
        columns.push({
            title: "",
            dataIndex: "action",
            width: 120,
            className: "orderly-h-[48px] orderly-font-semibold !orderly-pr-2",
            align: "right",
            fixed: "right",
            render: (value, record)=>{
                if (record.status === _types.OrderStatus.CANCELLED) {
                    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_renew.Renew, {
                        record: record
                    });
                }
                if (record.status === _types.OrderStatus.NEW) {
                    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_cancelButton.CancelButton, {
                        order: record
                    });
                }
                return null;
            }
        });
    }
    return columns;
};

//# sourceMappingURL=columnsUtil.js.map