function getNonDisabledIndex(
  start,
  backwards,
  items,
  isItemDisabled,
  circular = false,
) {
  const count = items.length

  if (backwards) {
    for (let index = start; index >= 0; index--) {
      if (!isItemDisabled(items[index], index)) {
        return index
      }
    }
  } else {
    for (let index = start; index < count; index++) {
      if (!isItemDisabled(items[index], index)) {
        return index
      }
    }
  }

  if (circular) {
    return getNonDisabledIndex(
      backwards ? count - 1 : 0,
      backwards,
      items,
      isItemDisabled,
    )
  }

  return -1
}
Returns the next non-disabled highlightedIndex value.

@param {number} start The current highlightedIndex.
@param {boolean} backwards If true, it will search backwards from the start.
@param {unknown[]} items The items array.
@param {(item: unknown, index: number) => boolean} isItemDisabled Function that tells if an item is disabled or not.
@param {boolean} circular If the search reaches the end, if it can search again starting from the other end.
@returns {number} The next non-disabled index.