import React, { useEffect, useRef } from "react";
import { getIframeSrc } from "../../utils/utils";
import { sendToChildIframe, useListenToPostMessage } from "../../utils/post-message";
export const SpacePanelIframe = ({ cloudBaseURL, streamedHostsData, }) => {
    const [helloFromSpacePanel] = useListenToPostMessage("hello-from-space-panel");
    const spacePanelIframeRef = useRef(null);
    useEffect(() => {
        if (helloFromSpacePanel && spacePanelIframeRef.current) {
            sendToChildIframe(spacePanelIframeRef.current, {
                type: "streamed-hosts-data",
                payload: streamedHostsData,
            });
        }
    }, [helloFromSpacePanel, spacePanelIframeRef, streamedHostsData]);
    return (React.createElement(React.Fragment, null,
        React.createElement("iframe", { ref: spacePanelIframeRef, title: "space panel", src: getIframeSrc(cloudBaseURL, "space-panel"), width: "100%", height: "100%", style: { border: "none" } })));
};
//# sourceMappingURL=space-panel-iframe.js.map