"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useOverlayPreventScroll = exports.registerHookForOverlayPreventScroll = void 0;
const react_1 = require("react");
// init
let GLOBAL_SCROLL_TARGET = null;
let THROTTLE_KEWORD = '';
// WARN : 무조건 _app에서 불러야 사용 가능
const registerHookForOverlayPreventScroll = ({ throttleKeyword, globalScrollTarget = document === null || document === void 0 ? void 0 : document.body, }) => {
    GLOBAL_SCROLL_TARGET = globalScrollTarget;
    THROTTLE_KEWORD = throttleKeyword;
};
exports.registerHookForOverlayPreventScroll = registerHookForOverlayPreventScroll;
const useOverlayPreventScroll = (view) => {
    (0, react_1.useEffect)(() => {
        if (!GLOBAL_SCROLL_TARGET || !THROTTLE_KEWORD) {
            console.warn('GLOBAL_SCROLL_TARGET 혹은 THROTTLE_KEWORD 이 등록되지 않았습니다.');
            return;
        }
        if (view) {
            GLOBAL_SCROLL_TARGET === null || GLOBAL_SCROLL_TARGET === void 0 ? void 0 : GLOBAL_SCROLL_TARGET.classList.add(THROTTLE_KEWORD);
        }
        return () => {
            GLOBAL_SCROLL_TARGET === null || GLOBAL_SCROLL_TARGET === void 0 ? void 0 : GLOBAL_SCROLL_TARGET.classList.remove(THROTTLE_KEWORD);
        };
    }, [view]);
    return;
};
exports.useOverlayPreventScroll = useOverlayPreventScroll;
