import * as tracing_1 from "../../../../Tracing";
const fileName_1 = "(@effect-ts/system): _src/Collections/Immutable/Chunk/api/dropWhileM.ts";
import * as core from "../../../../Effect/core";
import * as coreMap from "../../../../Effect/map";
import * as Chunk from "../core";
import { concreteId } from "../definition";
/**
 * Drops all elements so long as the predicate returns true.
 */

export function dropWhileM_(self, f) {
  return core.suspend(() => {
    const iterator = self.arrayLikeIterator();
    let next;
    let dropping = core.succeed(true, fileName_1 + ":17:55");
    let builder = Chunk.empty();

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

      while (i < len) {
        const a = array[i];
        dropping = core.chain_(dropping, d => coreMap.map_(d ? f(a) : core.succeed(false, fileName_1 + ":27:47"), b => {
          if (!b) {
            builder = Chunk.append_(builder, a);
          }

          return b;
        }, fileName_1 + ":27:23"), fileName_1 + ":26:31");
        i++;
      }
    }

    return coreMap.map_(dropping, () => builder, fileName_1 + ":37:24");
  }, fileName_1 + ":14:22");
}
/**
 * Drops all elements so long as the predicate returns true.
 *
 * @ets_data_first dropWhileM_
 */

export function dropWhileM(f) {
  return self => dropWhileM_(self, f);
}
//# sourceMappingURL=dropWhileM.js.map