"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 _react = require("react");
const _reactslot = require("@radix-ui/react-slot");
const _layoutContext = require("./layoutContext");
const _tradingPageContext = require("../page/trading/context/tradingPageContext");
const _ = require("..");
const Header = (props)=>{
    const ref = (0, _react.useRef)(null);
    const { asChild, ...rest } = props;
    const { setHeaderHeight, isTopLevel } = (0, _react.useContext)(_layoutContext.LayoutContext);
    const { disableFeatures } = (0, _tradingPageContext.useTradingPageContext)();
    if (!isTopLevel) {
        throw new Error("Header component must be in top layout component.");
    }
    (0, _react.useEffect)(()=>{
        setTimeout(()=>{
            const boundingClientRect = ref.current?.getBoundingClientRect();
            if (boundingClientRect && boundingClientRect.height) {
                // console.log(boundingClientRect);
                setHeaderHeight(boundingClientRect.height);
            }
        }, 50);
    }, []);
    /**
   * if disableFeatures includes TradingFeatures.Header, then return null
   */ if (disableFeatures?.includes(_.TradingFeatures.Header)) {
        return null;
    }
    const Comp = asChild ? _reactslot.Slot : "div";
    return /*#__PURE__*/ (0, _jsxruntime.jsx)(Comp, {
        ...rest,
        ref: ref
    });
};
Header.displayName = "Header";

//# sourceMappingURL=header.js.map