"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

var _react = require("react");

function useDetectPrint() {
  var _useState = (0, _react.useState)(false),
      _useState2 = (0, _slicedToArray2.default)(_useState, 2),
      isPrinting = _useState2[0],
      toggleStatus = _useState2[1];

  (0, _react.useEffect)(function () {
    var printMq = typeof window !== 'undefined' && window.matchMedia && window.matchMedia('print');

    var mqEvent = function mqEvent(mqList) {
      return toggleStatus(!!mqList.matches);
    };

    printMq.addListener(mqEvent);
    return function () {
      return printMq.removeListener(mqEvent);
    };
  });
  return isPrinting;
}

var _default = useDetectPrint;
exports.default = _default;