import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Input } from "../../../input";
import { usePositionsRowContext } from "./positionRowContext";
import { ArrowIcon } from "../../../icon";
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../../../dropdown/dropdown";
import { OrderType } from "@orderly.network/types";
import { cn } from "../../../utils/css";
export const PriceInput = ()=>{
    const { price, position: posotion, updatePriceChange, type, updateOrderType } = usePositionsRowContext();
    //   console.log("priceInput: render", price, posotion);
    const onFocus = ()=>{
        if (!!price && price !== "Market") return;
        updateOrderType(OrderType.LIMIT, posotion.mark_price.toString());
    };
    return /*#__PURE__*/ _jsx(Input, {
        size: "small",
        onFocus: onFocus,
        value: type === OrderType.LIMIT ? price : "Market",
        onChange: (e)=>updatePriceChange(e.target.value),
        className: cn("orderly-pr-0 orderly-font-semibold", {
            "orderly-text-base-contrast-54": type === OrderType.MARKET
        }),
        suffix: /*#__PURE__*/ _jsxs(DropdownMenu, {
            children: [
                /*#__PURE__*/ _jsx(DropdownMenuTrigger, {
                    asChild: true,
                    children: /*#__PURE__*/ _jsx("button", {
                        className: "orderly-px-1 orderly-h-full orderly-text-base-contrast-54 hover:orderly-text-base-contrast-80",
                        children: /*#__PURE__*/ _jsx(ArrowIcon, {
                            size: 10
                        })
                    })
                }),
                /*#__PURE__*/ _jsx(DropdownMenuContent, {
                    align: "end",
                    className: "orderly-py-0 orderly-w-[92px] orderly-min-w-[92px]",
                    children: /*#__PURE__*/ _jsx(DropdownMenuItem, {
                        onSelect: (e)=>{
                            // console.log(e);
                            updateOrderType(OrderType.MARKET);
                        },
                        textValue: OrderType.MARKET,
                        children: "Market"
                    })
                })
            ]
        })
    });
};

//# sourceMappingURL=priceInput.js.map