// This Source Code Form is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/
import { useDebounce } from "@luxonis/common-fe-utils";
import React from "react";
const DEBOUNCE_DELAY = 100; // milliseconds
export function useDebouncedCursorPosition() {
    const [cursorPosition, setCursorPosition] = React.useState(null);
    const [rawPosition, setRawPosition] = React.useState(null);
    useDebounce({
        effect: () => {
            setCursorPosition(rawPosition);
        },
        dependencies: [rawPosition],
        debounceDelay: DEBOUNCE_DELAY,
    });
    React.useEffect(() => {
        const handleMouseMove = (e) => {
            setRawPosition({ x: e.clientX, y: e.clientY });
        };
        window.addEventListener("mousemove", handleMouseMove);
        return () => {
            window.removeEventListener("mousemove", handleMouseMove);
        };
    }, []);
    return {
        cursorPosition,
    };
}
//# sourceMappingURL=debounced-cursor-position.js.map