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

//# sourceMappingURL=priceInput.js.map