/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @format
 * 
 * @emails oncall+draft_js
 */

var findRangesImmutable_1;
var hasRequiredFindRangesImmutable;

function requireFindRangesImmutable () {
	if (hasRequiredFindRangesImmutable) return findRangesImmutable_1;
	hasRequiredFindRangesImmutable = 1;

	/**
	 * Search through an array to find contiguous stretches of elements that
	 * match a specified filter function.
	 *
	 * When ranges are found, execute a specified `found` function to supply
	 * the values to the caller.
	 */
	function findRangesImmutable(haystack, areEqualFn, filterFn, foundFn) {
	  if (!haystack.size) {
	    return;
	  }

	  var cursor = 0;
	  haystack.reduce(function (value, nextValue, nextIndex) {
	    if (!areEqualFn(value, nextValue)) {
	      if (filterFn(value)) {
	        foundFn(cursor, nextIndex);
	      }

	      cursor = nextIndex;
	    }

	    return nextValue;
	  });
	  filterFn(haystack.last()) && foundFn(cursor, haystack.count());
	}

	findRangesImmutable_1 = findRangesImmutable;
	return findRangesImmutable_1;
}

export { requireFindRangesImmutable as __require };
//# sourceMappingURL=findRangesImmutable.js.map
