import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Tag } from "../../tag/tag";
import { AlgoOrderRootType, AlgoOrderType, OrderType } from "@orderly.network/types";
import { useMemo } from "react";
export const OrderTypeTag = (props)=>{
    const positionType = useMemo(()=>{
        if (!("parent_algo_type" in props.order)) {
            return null;
        }
        if (props.order.parent_algo_type === AlgoOrderRootType.POSITIONAL_TP_SL) {
            return /*#__PURE__*/ _jsx(Tag, {
                className: "orderly-bg-primary/20",
                children: "Position"
            });
        }
    }, [
        props.order
    ]);
    const orderType = useMemo(()=>{
        // if (!("algo_type" in props.order)) {
        //   return null;
        // }
        let type;
        if ("algo_type" in props.order) {
            if (props.order.algo_type === AlgoOrderType.TAKE_PROFIT) {
                // need check if it is STOP LIMIT or STOP MARKET
                if (props.order.type === OrderType.MARKET) {
                    type = "Stop market";
                } else if (props.order.type === OrderType.LIMIT) {
                    type = "Stop limit";
                } else {
                    type = "TP";
                }
            }
            if (props.order.algo_type === AlgoOrderType.STOP_LOSS) {
                type = "SL";
            }
        } else {
            if (props.order.type === OrderType.MARKET) {
                type = "Market";
            } else if (props.order.type === OrderType.LIMIT) {
                type = "Limit";
            }
        }
        if (!type) {
            return null;
        }
        return /*#__PURE__*/ _jsx(Tag, {
            className: "orderly-bg-white/10 orderly-text-base-contrast-54",
            children: type
        });
    }, [
        props.order
    ]);
    return /*#__PURE__*/ _jsxs("div", {
        className: "orderly-flex orderly-mt-1 orderly-space-x-1",
        children: [
            positionType,
            orderType
        ]
    });
};

//# sourceMappingURL=typeTag.js.map