"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "Header", {
    enumerable: true,
    get: function() {
        return Header;
    }
});
const _jsxruntime = require("react/jsx-runtime");
const _statistic = require("../../../statistic");
const _react = require("react");
const _defaultStaticStyle = require("../../../statistic/defaultStaticStyle");
const _text = require("../../../text");
const _css = require("../../../utils/css");
const _assetsProvider = require("../../../provider/assetsProvider");
const _modal = require("../../../modal");
const _withdraw = require("../../../block/withdraw");
const Header = (props)=>{
    const unrealPnL = props.aggregated?.unrealPnL ?? 0;
    const { onSettle } = (0, _react.useContext)(_assetsProvider.AssetsContext);
    const { pnlNotionalDecimalPrecision } = props;
    const onSettleClick = (0, _react.useCallback)(()=>{
        _modal.modal.confirm({
            title: "Settle PnL",
            content: /*#__PURE__*/ (0, _jsxruntime.jsx)(_withdraw.SettlePnlContent, {}),
            maxWidth: "xs",
            onCancel () {
                return Promise.reject("cancel");
            },
            onOk () {
                return onSettle().catch((e)=>{});
            }
        }).then(()=>{}, (error)=>{});
    }, []);
    return /*#__PURE__*/ (0, _jsxruntime.jsx)(_defaultStaticStyle.StatisticStyleProvider, {
        labelClassName: "orderly-text-3xs orderly-text-base-contrast-54",
        valueClassName: "orderly-text-base-contrast/80 orderly-tabular-nums orderly-font-semibold",
        children: /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
            className: "orderly-flex orderly-justify-between orderly-py-3 orderly-items-center",
            children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                className: "orderly-flex orderly-space-x-6",
                children: [
                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_statistic.Statistic, {
                        label: "Unreal. PnL",
                        value: /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
                            className: (0, _css.cn)("orderly-flex orderly-gap-1", {
                                "orderly-text-trade-loss": unrealPnL < 0,
                                "orderly-text-trade-profit": unrealPnL > 0
                            }),
                            children: [
                                /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Numeral, {
                                    precision: pnlNotionalDecimalPrecision,
                                    children: unrealPnL
                                }),
                                /*#__PURE__*/ (0, _jsxruntime.jsx)(_text.Numeral, {
                                    rule: "percentages",
                                    prefix: "(",
                                    surfix: ")",
                                    className: "orderly-ml-1",
                                    precision: pnlNotionalDecimalPrecision,
                                    children: props.aggregated?.unrealPnlROI ?? 0
                                })
                            ]
                        }),
                        rule: "price",
                        coloring: true
                    }),
                    /*#__PURE__*/ (0, _jsxruntime.jsx)(_statistic.Statistic, {
                        label: "Notional",
                        value: props.aggregated?.notional,
                        rule: "price",
                        precision: pnlNotionalDecimalPrecision
                    })
                ]
            })
        })
    });
};

//# sourceMappingURL=header.js.map