"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "MemorizedLeverage", {
    enumerable: true,
    get: function() {
        return MemorizedLeverage;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _react = require("react");
const _hooks = require("@orderly.network/hooks");
const _text = require("../../../text");
const _lucidereact = require("lucide-react");
const _leverageDialog = require("./leverageDialog");
const LeverageAndMarginRatio = ()=>{
    const { marginRatio, currentLeverage } = (0, _hooks.useMarginRatio)();
    const [maxLeverage, { update, config: leverageLevers }] = (0, _hooks.useLeverage)();
    return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
        className: "orderly-flex orderly-justify-between orderly-text-xs",
        children: [
            /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                className: "orderly-flex orderly-flex-col",
                children: [
                    /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                        className: "orderly-flex orderly-items-center orderly-gap-1 orderly-text-2xs",
                        children: [
                            /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Numeral, {
                                surfix: "x",
                                children: currentLeverage
                            }),
                            /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                                className: "orderly-text-base-contrast-54",
                                children: "/"
                            }),
                            /*#__PURE__*/ (0, _jsxruntime.jsx)(_leverageDialog.LeverageDialog, {
                                children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("button", {
                                    className: "orderly-flex orderly-items-center orderly-gap-1",
                                    children: [
                                        /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                                            children: `${maxLeverage ?? "-"}x`
                                        }),
                                        typeof maxLeverage !== "undefined" && // @ts-ignore
                                        /*#__PURE__*/ (0, _jsxruntime.jsx)(_lucidereact.Pencil, {
                                            size: 14,
                                            className: "orderly-text-base-contrast-54"
                                        })
                                    ]
                                })
                            })
                        ]
                    }),
                    /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
                        className: "orderly-text-base-contrast-54 orderly-text-3xs",
                        children: "Account leverage"
                    })
                ]
            }),
            /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                className: "orderly-flex orderly-flex-col orderly-tabular-nums orderly-items-end",
                children: [
                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Numeral, {
                        rule: "percentages",
                        coloring: true,
                        children: marginRatio === 0 ? 10 : Math.min(marginRatio, 10)
                    }),
                    /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
                        className: "orderly-text-base-contrast-54 orderly-text-2xs",
                        children: "Margin ratio"
                    })
                ]
            })
        ]
    });
};
const MemorizedLeverage = /*#__PURE__*/ (0, _react.memo)(LeverageAndMarginRatio);

//# sourceMappingURL=leverage.js.map