import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useMemo } from "react";
import { AlgoOrderRootType, AlgoOrderType } from "@orderly.network/types";
import { Tag } from "../../tag";
export const AlgoOrderBadge = (props)=>{
    const positionBadge = useMemo(()=>{
        if (props.order.algo_type !== AlgoOrderRootType.POSITIONAL_TP_SL) {
            return null;
        }
        return /*#__PURE__*/ _jsx(Tag, {
            className: "orderly-text-primary orderly-bg-primary/10",
            children: "Position"
        });
    }, [
        props.order.algo_type
    ]);
    const tpslBadge = useMemo(()=>{
        const tpOrder = props.order.child_orders.find((order)=>order.algo_type === AlgoOrderType.TAKE_PROFIT && !!order.trigger_price);
        const slOrder = props.order.child_orders.find((order)=>order.algo_type === AlgoOrderType.STOP_LOSS && !!order.trigger_price);
        if (!tpOrder && !slOrder) {
            return null;
        }
        return /*#__PURE__*/ _jsx(Tag, {
            className: "orderly-text-base-contrast-36 orderly-bg-white/10",
            children: tpOrder && slOrder ? "TP/SL" : tpOrder ? "TP" : "SL"
        });
    }, [
        props.order.child_orders
    ]);
    return /*#__PURE__*/ _jsxs("div", {
        className: "orderly-flex orderly-gap-1 orderly-text-3xs orderly-td-bg-transparent orderly-h-[18px]",
        children: [
            positionBadge,
            " ",
            tpslBadge
        ]
    });
};

//# sourceMappingURL=algoOrderTypeBadge.js.map