import { __require as requireHasPropertyDescriptors } from "../../has-property-descriptors/index.js";
import { __require as requireEsDefineProperty } from "../../es-define-property/index.js";
import { __require as requireIsArray } from "./IsArray.js";
import { __require as requireCallBound } from "../../call-bound/index.js";
var DefineOwnProperty;
var hasRequiredDefineOwnProperty;
function requireDefineOwnProperty() {
  if (hasRequiredDefineOwnProperty) return DefineOwnProperty;
  hasRequiredDefineOwnProperty = 1;
  var hasPropertyDescriptors = requireHasPropertyDescriptors();
  var $defineProperty = requireEsDefineProperty();
  var hasArrayLengthDefineBug = hasPropertyDescriptors.hasArrayLengthDefineBug();
  var isArray = hasArrayLengthDefineBug && requireIsArray();
  var callBound = requireCallBound();
  var $isEnumerable = callBound("Object.prototype.propertyIsEnumerable");
  DefineOwnProperty = function DefineOwnProperty2(IsDataDescriptor, SameValue, FromPropertyDescriptor, O, P, desc) {
    if (!$defineProperty) {
      if (!IsDataDescriptor(desc)) {
        return false;
      }
      if (!desc["[[Configurable]]"] || !desc["[[Writable]]"]) {
        return false;
      }
      if (P in O && $isEnumerable(O, P) !== !!desc["[[Enumerable]]"]) {
        return false;
      }
      var V = desc["[[Value]]"];
      O[P] = V;
      return SameValue(O[P], V);
    }
    if (hasArrayLengthDefineBug && P === "length" && "[[Value]]" in desc && isArray(O) && O.length !== desc["[[Value]]"]) {
      O.length = desc["[[Value]]"];
      return O.length === desc["[[Value]]"];
    }
    $defineProperty(O, P, FromPropertyDescriptor(desc));
    return true;
  };
  return DefineOwnProperty;
}
export {
  requireDefineOwnProperty as __require
};
