"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.usePointerDevice = usePointerDevice;
const react_1 = require("react");
const react_native_1 = require("react-native");
/**
 * Hook to detect if the device is primarily mouse-driven vs touch-driven
 * Uses CSS media queries to detect hover and pointer capabilities
 */
function usePointerDevice() {
    const [pointerDevice, setPointerDevice] = (0, react_1.useState)(() => {
        // Default values for non-web platforms
        if (react_native_1.Platform.OS !== "web") {
            return {
                hasHover: false,
                hasFinePointer: false,
                isMouseDriven: false,
                isTouchDriven: true,
            };
        }
        // Initial web detection
        if (typeof window !== "undefined" && window.matchMedia) {
            const hasHover = window.matchMedia("(hover: hover)").matches;
            const hasFinePointer = window.matchMedia("(pointer: fine)").matches;
            return {
                hasHover,
                hasFinePointer,
                isMouseDriven: hasHover && hasFinePointer,
                isTouchDriven: !hasHover || !hasFinePointer,
            };
        }
        // Fallback for SSR or environments without matchMedia
        return {
            hasHover: false,
            hasFinePointer: false,
            isMouseDriven: false,
            isTouchDriven: true,
        };
    });
    (0, react_1.useEffect)(() => {
        // Only run on web platforms
        if (react_native_1.Platform.OS !== "web" ||
            typeof window === "undefined" ||
            !window.matchMedia) {
            return;
        }
        const hoverQuery = window.matchMedia("(hover: hover)");
        const pointerQuery = window.matchMedia("(pointer: fine)");
        const updatePointerDevice = () => {
            const hasHover = hoverQuery.matches;
            const hasFinePointer = pointerQuery.matches;
            setPointerDevice({
                hasHover,
                hasFinePointer,
                isMouseDriven: hasHover && hasFinePointer,
                isTouchDriven: !hasHover || !hasFinePointer,
            });
        };
        // Set up listeners for media query changes
        hoverQuery.addEventListener("change", updatePointerDevice);
        pointerQuery.addEventListener("change", updatePointerDevice);
        // Initial update
        updatePointerDevice();
        // Cleanup
        return () => {
            hoverQuery.removeEventListener("change", updatePointerDevice);
            pointerQuery.removeEventListener("change", updatePointerDevice);
        };
    }, []);
    return pointerDevice;
}
//# sourceMappingURL=usePointerDevice.js.map