import { _ as _export, w as wellKnownSymbol$1, a as toLength$1, f as toIndexedObject$1, C as toAbsoluteIndex$1 } from './well-known-symbol-9b7e0fd8.js';
import { b as isObject$1 } from './normalize-component-43ce05b9.js';
import { i as isArray$1 } from './array-species-create-f23f8d86.js';
import { c as createProperty$1 } from './create-property-5dd3883c.js';
import { a as arrayMethodHasSpeciesSupport$1 } from './array-method-has-species-support-118179bf.js';

var $ = _export;
var isObject = isObject$1;
var isArray = isArray$1;
var toAbsoluteIndex = toAbsoluteIndex$1;
var toLength = toLength$1;
var toIndexedObject = toIndexedObject$1;
var createProperty = createProperty$1;
var wellKnownSymbol = wellKnownSymbol$1;
var arrayMethodHasSpeciesSupport = arrayMethodHasSpeciesSupport$1;

var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('slice');

var SPECIES = wellKnownSymbol('species');
var nativeSlice = [].slice;
var max = Math.max;

// `Array.prototype.slice` method
// https://tc39.es/ecma262/#sec-array.prototype.slice
// fallback for not array-like ES3 strings and DOM objects
$({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  slice: function slice(start, end) {
    var O = toIndexedObject(this);
    var length = toLength(O.length);
    var k = toAbsoluteIndex(start, length);
    var fin = toAbsoluteIndex(end === undefined ? length : end, length);
    // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible
    var Constructor, result, n;
    if (isArray(O)) {
      Constructor = O.constructor;
      // cross-realm fallback
      if (typeof Constructor == 'function' && (Constructor === Array || isArray(Constructor.prototype))) {
        Constructor = undefined;
      } else if (isObject(Constructor)) {
        Constructor = Constructor[SPECIES];
        if (Constructor === null) Constructor = undefined;
      }
      if (Constructor === Array || Constructor === undefined) {
        return nativeSlice.call(O, k, fin);
      }
    }
    result = new (Constructor === undefined ? Array : Constructor)(max(fin - k, 0));
    for (n = 0; k < fin; k++, n++) if (k in O) createProperty(result, n, O[k]);
    result.length = n;
    return result;
  }
});
