"use strict";

exports.__esModule = true;
exports.default = void 0;

var _react = require("react");

var _utils = require("../utils");

var _useEventListener = _interopRequireDefault(require("./use-event-listener"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function useWindowSize() {
  var _useState = (0, _react.useState)(_utils.inBrowser ? window.innerWidth : 0),
      width = _useState[0],
      setWidth = _useState[1];

  var _useState2 = (0, _react.useState)(_utils.inBrowser ? window.innerHeight : 0),
      height = _useState2[0],
      setHeight = _useState2[1];

  var onResize = function onResize() {
    setWidth(window.innerWidth);
    setHeight(window.innerHeight);
  };

  (0, _useEventListener.default)('resize', onResize);
  (0, _useEventListener.default)('orientationchange', onResize);
  return {
    width: width,
    height: height
  };
}

var _default = useWindowSize;
exports.default = _default;