Liferay.Loader.define("frontend-js-web@4.0.60/liferay/util/in_browser_view", ['module', 'exports', 'require', './get_element'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = inBrowserView;

    var _get_element = _interopRequireDefault(require("./get_element"));

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

    /**
     * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
     * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
     */
    function inBrowserView(node, baseWindow, nodeRegion) {
      var viewable = false;
      node = (0, _get_element.default)(node);

      if (node) {
        if (!nodeRegion) {
          nodeRegion = node.getBoundingClientRect();
          nodeRegion = {
            left: nodeRegion.left + window.scrollX,
            top: nodeRegion.top + window.scrollY
          };
          nodeRegion.bottom = nodeRegion.top + node.offsetHeight;
          nodeRegion.right = nodeRegion.left + node.offsetWidth;
        }

        if (!baseWindow) {
          baseWindow = window;
        }

        baseWindow = (0, _get_element.default)(baseWindow);
        var winRegion = {};
        winRegion.left = baseWindow.scrollX;
        winRegion.right = winRegion.left + baseWindow.innerWidth;
        winRegion.top = baseWindow.scrollY;
        winRegion.bottom = winRegion.top + baseWindow.innerHeight;
        viewable = nodeRegion.bottom <= winRegion.bottom && nodeRegion.left >= winRegion.left && nodeRegion.right <= winRegion.right && nodeRegion.top >= winRegion.top;

        if (viewable) {
          var frameElement = baseWindow.frameElement;

          if (frameElement) {
            var frameOffset = frameElement.getBoundingClientRect();
            frameOffset = {
              left: frameOffset.left + window.scrollX,
              top: frameOffset.top + window.scrollY
            };
            var xOffset = frameOffset.left - winRegion.left;
            nodeRegion.left += xOffset;
            nodeRegion.right += xOffset;
            var yOffset = frameOffset.top - winRegion.top;
            nodeRegion.top += yOffset;
            nodeRegion.bottom += yOffset;
            viewable = inBrowserView(node, baseWindow.parent, nodeRegion);
          }
        }
      }

      return viewable;
    }
    //# sourceMappingURL=in_browser_view.js.map
  }
});
//# sourceMappingURL=in_browser_view.js.map