import { __module as esGetIterator } from "../../_virtual/index7.js";
import { i as isArguments$1 } from "../is-arguments/index.js";
import { s as stopIterationIterator } from "../stop-iteration-iterator/index.js";
import { h as hasSymbols } from "../has-symbols/index.js";
import { s as shams } from "../has-symbols/shams.js";
import { __require as requireIsarray } from './_node_modules/isarray/index.js';
import { i as isString$1 } from "../is-string/index.js";
import { g as getIntrinsic } from "../get-intrinsic/index.js";
import { c as callBound$1 } from "../call-bind/callBound.js";
import { i as isMap$1 } from "../is-map/index.js";
import { i as isSet$1 } from "../is-set/index.js";
var isArguments = isArguments$1;
var getStopIterationIterator = stopIterationIterator;
if (hasSymbols() || shams()) {
  var $iterator = Symbol.iterator;
  esGetIterator.exports = function getIterator(iterable) {
    if (iterable != null && typeof iterable[$iterator] !== "undefined") {
      return iterable[$iterator]();
    }
    if (isArguments(iterable)) {
      return Array.prototype[$iterator].call(iterable);
    }
  };
} else {
  var isArray = requireIsarray();
  var isString = isString$1;
  var GetIntrinsic = getIntrinsic;
  var $Map = GetIntrinsic("%Map%", true);
  var $Set = GetIntrinsic("%Set%", true);
  var callBound = callBound$1;
  var $arrayPush = callBound("Array.prototype.push");
  var $charCodeAt = callBound("String.prototype.charCodeAt");
  var $stringSlice = callBound("String.prototype.slice");
  var advanceStringIndex = function advanceStringIndex2(S, index) {
    var length = S.length;
    if (index + 1 >= length) {
      return index + 1;
    }
    var first = $charCodeAt(S, index);
    if (first < 55296 || first > 56319) {
      return index + 1;
    }
    var second = $charCodeAt(S, index + 1);
    if (second < 56320 || second > 57343) {
      return index + 1;
    }
    return index + 2;
  };
  var getArrayIterator = function getArrayIterator2(arraylike) {
    var i = 0;
    return {
      next: function next() {
        var done = i >= arraylike.length;
        var value;
        if (!done) {
          value = arraylike[i];
          i += 1;
        }
        return {
          done,
          value
        };
      }
    };
  };
  var getNonCollectionIterator = function getNonCollectionIterator2(iterable, noPrimordialCollections) {
    if (isArray(iterable) || isArguments(iterable)) {
      return getArrayIterator(iterable);
    }
    if (isString(iterable)) {
      var i = 0;
      return {
        next: function next() {
          var nextIndex = advanceStringIndex(iterable, i);
          var value = $stringSlice(iterable, i, nextIndex);
          i = nextIndex;
          return {
            done: nextIndex > iterable.length,
            value
          };
        }
      };
    }
    if (noPrimordialCollections && typeof iterable["_es6-shim iterator_"] !== "undefined") {
      return iterable["_es6-shim iterator_"]();
    }
  };
  if (!$Map && !$Set) {
    esGetIterator.exports = function getIterator(iterable) {
      if (iterable != null) {
        return getNonCollectionIterator(iterable, true);
      }
    };
  } else {
    var isMap = isMap$1;
    var isSet = isSet$1;
    var $mapForEach = callBound("Map.prototype.forEach", true);
    var $setForEach = callBound("Set.prototype.forEach", true);
    if (typeof process === "undefined" || !process.versions || !process.versions.node) {
      var $mapIterator = callBound("Map.prototype.iterator", true);
      var $setIterator = callBound("Set.prototype.iterator", true);
    }
    var $mapAtAtIterator = callBound("Map.prototype.@@iterator", true) || callBound("Map.prototype._es6-shim iterator_", true);
    var $setAtAtIterator = callBound("Set.prototype.@@iterator", true) || callBound("Set.prototype._es6-shim iterator_", true);
    var getCollectionIterator = function getCollectionIterator2(iterable) {
      if (isMap(iterable)) {
        if ($mapIterator) {
          return getStopIterationIterator($mapIterator(iterable));
        }
        if ($mapAtAtIterator) {
          return $mapAtAtIterator(iterable);
        }
        if ($mapForEach) {
          var entries = [];
          $mapForEach(iterable, function(v, k) {
            $arrayPush(entries, [k, v]);
          });
          return getArrayIterator(entries);
        }
      }
      if (isSet(iterable)) {
        if ($setIterator) {
          return getStopIterationIterator($setIterator(iterable));
        }
        if ($setAtAtIterator) {
          return $setAtAtIterator(iterable);
        }
        if ($setForEach) {
          var values = [];
          $setForEach(iterable, function(v) {
            $arrayPush(values, v);
          });
          return getArrayIterator(values);
        }
      }
    };
    esGetIterator.exports = function getIterator(iterable) {
      return getCollectionIterator(iterable) || getNonCollectionIterator(iterable);
    };
  }
}
var esGetIteratorExports = esGetIterator.exports;
export {
  esGetIteratorExports as e
};
//# sourceMappingURL=index.js.map
