import React, { useEffect } from "react";
import { ChannelEvents } from "@local-logic/channel";
import { useStateManagerContext } from "~/context/stateManager";
/**
 * SDKs wrapped in ResizeWrapper will automatically adjust their height to fit
 * the content.
 *
 * To read more about this functionality see:
 * https://locallogic.atlassian.net/wiki/spaces/PROD/pages/2050031624/Adjustable+vs+nonadjustable+SDK+sizing
 */
const ResizeWrapper = ({ children }) => {
    const { followerNode } = useStateManagerContext();
    useEffect(() => {
        const observer = new ResizeObserver(() => {
            followerNode === null || followerNode === void 0 ? void 0 : followerNode.message(ChannelEvents.RESIZE, {
                scrollHeight: document.body.scrollHeight,
                scrollWidth: document.body.scrollWidth,
            });
        });
        observer.observe(document.body);
        return () => observer.unobserve(document.body);
    }, []);
    return React.createElement(React.Fragment, null, children);
};
export default ResizeWrapper;
//# sourceMappingURL=index.js.map