import { __read } from "tslib";
// @ts-nocheck
import React, { Fragment, useEffect } from 'react';
import { useMatchMedia } from './useMatchMedia';
import { isPointerEventsSupported, isTouchSupported } from './utils';
var IS_BROWSER = typeof window !== 'undefined';
var SUPPORTS_TOUCH = IS_BROWSER && (isPointerEventsSupported() || isTouchSupported());
export var Mq = function (_a) {
    var children = _a.children, _b = _a.query, query = _b === void 0 ? '' : _b, touch = _a.touch, onMatchChange = _a.onMatchChange;
    var _c = __read(useMatchMedia(query), 1), queryMatches = _c[0];
    var touchPass = touch === undefined ? true : touch === SUPPORTS_TOUCH;
    var matches = touchPass && (!query || queryMatches);
    useEffect(function () {
        if (onMatchChange) {
            onMatchChange(matches);
        }
    }, [matches, onMatchChange]);
    return React.createElement(Fragment, null, matches && IS_BROWSER ? children : null);
};
