import * as tracing_1 from "../../../../Tracing"
import * as tracing_2 from "../../../../Tracing"
const fileName_1 =
  "(@effect-ts/system): _src/Collections/Immutable/Chunk/api/dropWhile.ts"
import * as Chunk from "../core"
import { ArrTypeId, concrete } from "../definition"
/**
 * Drops all elements so long as the predicate returns true.
 */

export function dropWhile_(self, f) {
  switch (self._typeId) {
    case ArrTypeId: {
      const arr = self.arrayLike()
      const len = arr.length
      let i = 0

      while (i < len && f(arr[i])) {
        i++
      }

      return Chunk.drop_(self, i)
    }

    default: {
      const iterator = self.arrayLikeIterator()
      let cont = true
      let i = 0
      let next

      while (cont && (next = iterator.next()) && !next.done) {
        const array = next.value
        const len = array.length
        let j = 0

        while (cont && j < len) {
          const a = array[j]

          if (f(a)) {
            i++
            j++
          } else {
            cont = false
          }
        }
      }

      return Chunk.drop_(self, i)
    }
  }
}
/**
 * Drops all elements so long as the predicate returns true.
 *
 * @dataFirst dropWhile_
 */

export function dropWhile(f) {
  return (self) => dropWhile_(self, f)
}
//# sourceMappingURL=dropWhile.js.map
