'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var getWindow = require('./getWindow.js');
var getDocumentElement = require('./getDocumentElement.js');
var getWindowScrollBarX = require('./getWindowScrollBarX.js');
var isLayoutViewport = require('./isLayoutViewport.js');

function getViewportRect(element, strategy) {
  var win = getWindow.default(element);
  var html = getDocumentElement.default(element);
  var visualViewport = win.visualViewport;
  var width = html.clientWidth;
  var height = html.clientHeight;
  var x = 0;
  var y = 0;

  if (visualViewport) {
    width = visualViewport.width;
    height = visualViewport.height;
    var layoutViewport = isLayoutViewport.default();

    if (layoutViewport || !layoutViewport && strategy === 'fixed') {
      x = visualViewport.offsetLeft;
      y = visualViewport.offsetTop;
    }
  }

  return {
    width: width,
    height: height,
    x: x + getWindowScrollBarX.default(element),
    y: y
  };
}

exports.default = getViewportRect;
//# sourceMappingURL=getViewportRect.js.map
