'use strict';var wellKnownSymbol=require('./well-known-symbol-08f3111a.js'),arraySpeciesCreate=require('./array-species-create-447f37c0.js'),createProperty=require('./create-property-8fd8ad81.js'),arrayMethodHasSpeciesSupport=require('./array-method-has-species-support-9fe8fcbb.js'),functionBindContext=require('./function-bind-context-e4685306.js'),normalizeComponent=require('./normalize-component-ebe0c011.js'),arrayMethodIsStrict=require('./array-method-is-strict-46936434.js');var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport.a('splice');

var max = Math.max;
var min = Math.min;
var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF;
var MAXIMUM_ALLOWED_LENGTH_EXCEEDED = 'Maximum allowed length exceeded';

// `Array.prototype.splice` method
// https://tc39.es/ecma262/#sec-array.prototype.splice
// with adding support of @@species
wellKnownSymbol._({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, {
  splice: function splice(start, deleteCount /* , ...items */) {
    var O = wellKnownSymbol.t(this);
    var len = wellKnownSymbol.a(O.length);
    var actualStart = wellKnownSymbol.C(start, len);
    var argumentsLength = arguments.length;
    var insertCount, actualDeleteCount, A, k, from, to;
    if (argumentsLength === 0) {
      insertCount = actualDeleteCount = 0;
    } else if (argumentsLength === 1) {
      insertCount = 0;
      actualDeleteCount = len - actualStart;
    } else {
      insertCount = argumentsLength - 2;
      actualDeleteCount = min(max(wellKnownSymbol.d(deleteCount), 0), len - actualStart);
    }
    if (len + insertCount - actualDeleteCount > MAX_SAFE_INTEGER) {
      throw TypeError(MAXIMUM_ALLOWED_LENGTH_EXCEEDED);
    }
    A = arraySpeciesCreate.a(O, actualDeleteCount);
    for (k = 0; k < actualDeleteCount; k++) {
      from = actualStart + k;
      if (from in O) createProperty.c(A, k, O[from]);
    }
    A.length = actualDeleteCount;
    if (insertCount < actualDeleteCount) {
      for (k = actualStart; k < len - actualDeleteCount; k++) {
        from = k + actualDeleteCount;
        to = k + insertCount;
        if (from in O) O[to] = O[from];
        else delete O[to];
      }
      for (k = len; k > len - actualDeleteCount + insertCount; k--) delete O[k - 1];
    } else if (insertCount > actualDeleteCount) {
      for (k = len - actualDeleteCount; k > actualStart; k--) {
        from = k + actualDeleteCount - 1;
        to = k + insertCount - 1;
        if (from in O) O[to] = O[from];
        else delete O[to];
      }
    }
    for (k = 0; k < insertCount; k++) {
      O[k + actualStart] = arguments[k + 2];
    }
    O.length = len - actualDeleteCount + insertCount;
    return A;
  }
});var test = [];
var nativeSort = test.sort;

// IE8-
var FAILS_ON_UNDEFINED = normalizeComponent.f(function () {
  test.sort(undefined);
});
// V8 bug
var FAILS_ON_NULL = normalizeComponent.f(function () {
  test.sort(null);
});
// Old WebKit
var STRICT_METHOD = arrayMethodIsStrict.a('sort');

var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD;

// `Array.prototype.sort` method
// https://tc39.es/ecma262/#sec-array.prototype.sort
wellKnownSymbol._({ target: 'Array', proto: true, forced: FORCED }, {
  sort: function sort(comparefn) {
    return comparefn === undefined
      ? nativeSort.call(wellKnownSymbol.t(this))
      : nativeSort.call(wellKnownSymbol.t(this), functionBindContext.a(comparefn));
  }
});