import React, { forwardRef } from "react";
import { fnWithProps } from "../../../types/fnWithProps.js";
import { Header } from "./Header.js";
import { Content, StyledStickyHeader } from "./StickyHeader.styled.js";
const err = new TypeError("StickyHeader needs two children - Header and StickyHeader.Content");
const StickyHeader = fnWithProps(forwardRef((props, ref) => {
    const { children: _children, position = "top", __dangerouslyDisableChildrenGuard, ...rest } = props;
    if (__dangerouslyDisableChildrenGuard) {
        return (React.createElement(StyledStickyHeader, { ref: ref, ...rest, position: position }, _children));
    }
    const children = React.Children.toArray(_children);
    if (children.length !== 2) {
        throw err;
    }
    let header = children.find(c => typeof c === "object" && "type" in c && c.type === Header), content = children.find(c => typeof c === "object" && "type" in c && c.type === Content);
    if (!header || !content) {
        throw err;
    }
    header = header;
    content = content;
    return (React.createElement(StyledStickyHeader, { ref: ref, ...rest, position: position },
        React.cloneElement(header, { position }),
        React.cloneElement(content, { position })));
}), {
    displayName: "StickyHeader",
    Content,
    selectors: {
        root: StyledStickyHeader.toString(),
    },
    toString: () => StyledStickyHeader.toString(),
});
export { StickyHeader, };
//# sourceMappingURL=StickyHeader.js.map