Liferay.Loader.define("layout-content-page-editor-web@2.0.166/page_editor/core/debounceRAF", ['module', 'exports', 'require'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = debounceRAF;

    function _toConsumableArray(arr) {
      return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
    }

    function _nonIterableSpread() {
      throw new TypeError("Invalid attempt to spread non-iterable instance");
    }

    function _iterableToArray(iter) {
      if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
    }

    function _arrayWithoutHoles(arr) {
      if (Array.isArray(arr)) {
        for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
          arr2[i] = arr[i];
        }return arr2;
      }
    }

    /**
     * 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
     */

    /**
     * Debounces function execution until next animation frame.
     * @param {!function()} fn
     * @return {!function()}
     */
    function debounceRAF(fn) {
      return function debounced() {
        var args = arguments;
        cancelDebounce(debounced);
        debounced.id = requestAnimationFrame(function () {
          fn.apply(void 0, _toConsumableArray(args));
        });
      };
    }
    /**
     * Cancels the scheduled debounced function.
     * @param {function()} debounced
     */

    function cancelDebounce(debounced) {
      cancelAnimationFrame(debounced.id);
    }
    //# sourceMappingURL=debounceRAF.js.map
  }
});
//# sourceMappingURL=debounceRAF.js.map