"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.useWindowSize = void 0;
const react_1 = require("react");
const Debounce_1 = require("../util/Debounce");
const ScreenSize_1 = __importDefault(require("../util/ScreenSize"));
const useWindowSize = (props) => {
    const { debounceTime = 5 } = props !== null && props !== void 0 ? props : {};
    const [windowSize, setWindowSize] = (0, react_1.useState)({
        width: undefined,
        height: undefined,
        isMobile: undefined,
    });
    const setWindowSizeDebounce = (0, react_1.useCallback)((0, Debounce_1.debounce)((value) => {
        setWindowSize(value);
    }, debounceTime), []);
    (0, react_1.useEffect)(() => {
        function handleResize() {
            setWindowSizeDebounce({
                width: window.innerWidth,
                height: window.innerHeight,
                isMobile: window.innerWidth <= ScreenSize_1.default.Large,
            });
        }
        window.addEventListener('resize', handleResize);
        handleResize();
        return () => window.removeEventListener('resize', handleResize);
    }, []);
    return windowSize;
};
exports.useWindowSize = useWindowSize;
//# sourceMappingURL=WindowSize.js.map