"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "TPSLOrderEditorSheet", {
    enumerable: true,
    get: function() {
        return TPSLOrderEditorSheet;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = require("react");
const _tp_sl_editor = require("../../block/tp_sl/tp_sl_editor");
const _statistic = require("../../statistic");
const _hooks = require("@orderly.network/hooks");
const _text = require("../../text/text");
const _types = require("@orderly.network/types");
const _modal = require("../../modal");
const _divider = require("../../divider");
const TPSLOrderEditorSheet = (props)=>{
    const { position, order, isEditing } = props;
    const { data: markPrice } = (0, _hooks.useMarkPrice)(position.symbol);
    const { hide, setStates } = (0, _modal.useModal)();
    const priceDp = (0, _hooks.useSymbolsInfo)()[position.symbol]("quote_dp") || 2;
    const [type, setType] = (0, _react.useState)(order?.algo_type);
    const onTypeChange = (type)=>{
        // console.log(type);
        setStates({
            type
        });
        setType(type);
    };
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
        children: [
            /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                className: "orderly-py-3 orderly-space-x-2",
                children: [
                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Text, {
                        rule: "symbol",
                        children: position.symbol
                    }),
                    isEditing ? null : /*#__PURE__*/ (0, _jsxruntime.jsx)(_jsxruntime.Fragment, {
                        children: position.position_qty > 0 ? /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                            className: "orderly-text-trade-profit orderly-text-xs",
                            children: "Long"
                        }) : /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                            className: "orderly-text-trade-loss orderly-text-xs",
                            children: "Short"
                        })
                    })
                ]
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                className: "orderly-grid orderly-grid-cols-3 orderly-gap-2 orderly-pb-4",
                children: [
                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_statistic.Statistic, {
                        label: "Order type",
                        value: type === _types.AlgoOrderRootType.POSITIONAL_TP_SL ? "Position TP/SL" : "TP/SL",
                        labelClassName: "orderly-text-4xs orderly-text-base-contrast-36",
                        valueClassName: "orderly-text-xs"
                    }),
                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_statistic.Statistic, {
                        label: "Avg. open",
                        value: position.average_open_price,
                        rule: "price",
                        precision: priceDp,
                        labelClassName: "orderly-text-4xs orderly-text-base-contrast-36",
                        valueClassName: "orderly-text-xs"
                    }),
                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_statistic.Statistic, {
                        label: "Mark price",
                        value: markPrice,
                        precision: priceDp,
                        rule: "price",
                        align: "right",
                        labelClassName: "orderly-text-4xs orderly-text-base-contrast-36",
                        valueClassName: "orderly-text-xs"
                    })
                ]
            }),
            !props.canModifyQty && /*#__PURE__*/ (0, _jsxruntime.jsx)(_divider.Divider, {
                className: "orderly-mb-3"
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsx)(_tp_sl_editor.TPSLEditor, {
                position: position,
                symbol: position.symbol,
                maxQty: position.position_qty,
                order: props.order,
                isEditing: props.isEditing,
                canModifyQty: props.canModifyQty,
                onCancel: hide,
                onSuccess: hide,
                onTypeChange: onTypeChange,
                quoteDp: priceDp
            })
        ]
    });
};

//# sourceMappingURL=tpslSheet.js.map