import { m as _anObject } from './_to-object-a4107da3.js';
import { b as _wks, e as _iterators } from './es6.string.iterator-c990c18c.js';

// call something on iterator step with safe closing on error

var _iterCall = function (iterator, fn, value, entries) {
  try {
    return entries ? fn(_anObject(value)[0], value[1]) : fn(value);
  // 7.4.6 IteratorClose(iterator, completion)
  } catch (e) {
    var ret = iterator['return'];
    if (ret !== undefined) _anObject(ret.call(iterator));
    throw e;
  }
};

// check on default Array iterator

var ITERATOR = _wks('iterator');
var ArrayProto = Array.prototype;

var _isArrayIter = function (it) {
  return it !== undefined && (_iterators.Array === it || ArrayProto[ITERATOR] === it);
};

var ITERATOR$1 = _wks('iterator');
var SAFE_CLOSING = false;

try {
  var riter = [7][ITERATOR$1]();
  riter['return'] = function () { SAFE_CLOSING = true; };
  // eslint-disable-next-line no-throw-literal
  Array.from(riter, function () { throw 2; });
} catch (e) { /* empty */ }

var _iterDetect = function (exec, skipClosing) {
  if (!skipClosing && !SAFE_CLOSING) return false;
  var safe = false;
  try {
    var arr = [7];
    var iter = arr[ITERATOR$1]();
    iter.next = function () { return { done: safe = true }; };
    arr[ITERATOR$1] = function () { return iter; };
    exec(arr);
  } catch (e) { /* empty */ }
  return safe;
};

export { _iterDetect as _, _isArrayIter as a, _iterCall as b };
