var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import React, { createRef, useEffect } from 'react';
export const Iframe = (props) => {
    const { containerRef, src } = props, other = __rest(props, ["containerRef", "src"]);
    const iframeRef = createRef();
    useEffect(() => {
        const container = containerRef.current;
        const iframe = iframeRef.current;
        // Function to resize the iframe based on the container height
        const resizeIframe = () => {
            iframe.style.height = `${container.scrollHeight}px`;
        };
        // Initial resize when the component mounts
        resizeIframe();
        // Attach a resize event listener to the window to adjust iframe height on window resize
        window.addEventListener('resize', resizeIframe);
        // Cleanup: remove the event listener when the component unmounts
        return () => {
            window.removeEventListener('resize', resizeIframe);
        };
    }, [containerRef, iframeRef]);
    return (React.createElement("iframe", Object.assign({ ref: iframeRef, src: src, title: "udpIframe", width: "100%", style: { border: 'none' } }, other)));
};
//# sourceMappingURL=Iframe.js.map