import { __require as requireGopd } from "../../gopd/index.js";
import { __require as requireSyntax } from "../../es-errors/syntax.js";
import { __require as requireType } from "../../es-errors/type.js";
import { __require as requireIsObject } from "../../es-object-atoms/isObject.js";
import { __require as requirePropertyDescriptor } from "../helpers/records/property-descriptor.js";
import { __require as requireIsAccessorDescriptor } from "./IsAccessorDescriptor.js";
import { __require as requireIsExtensible } from "./IsExtensible.js";
import { __require as requireIsPropertyKey } from "../helpers/isPropertyKey.js";
import { __require as requireToPropertyDescriptor } from "./ToPropertyDescriptor.js";
import { __require as requireSameValue } from "./SameValue.js";
import { __require as requireValidateAndApplyPropertyDescriptor } from "./ValidateAndApplyPropertyDescriptor.js";
var OrdinaryDefineOwnProperty;
var hasRequiredOrdinaryDefineOwnProperty;
function requireOrdinaryDefineOwnProperty() {
  if (hasRequiredOrdinaryDefineOwnProperty) return OrdinaryDefineOwnProperty;
  hasRequiredOrdinaryDefineOwnProperty = 1;
  var $gOPD = requireGopd();
  var $SyntaxError = requireSyntax();
  var $TypeError = requireType();
  var isObject = requireIsObject();
  var isPropertyDescriptor = requirePropertyDescriptor();
  var IsAccessorDescriptor = requireIsAccessorDescriptor();
  var IsExtensible = requireIsExtensible();
  var isPropertyKey = requireIsPropertyKey();
  var ToPropertyDescriptor = requireToPropertyDescriptor();
  var SameValue = requireSameValue();
  var ValidateAndApplyPropertyDescriptor = requireValidateAndApplyPropertyDescriptor();
  OrdinaryDefineOwnProperty = function OrdinaryDefineOwnProperty2(O, P, Desc) {
    if (!isObject(O)) {
      throw new $TypeError("Assertion failed: O must be an Object");
    }
    if (!isPropertyKey(P)) {
      throw new $TypeError("Assertion failed: P must be a Property Key");
    }
    if (!isPropertyDescriptor(Desc)) {
      throw new $TypeError("Assertion failed: Desc must be a Property Descriptor");
    }
    if (!$gOPD) {
      if (IsAccessorDescriptor(Desc)) {
        throw new $SyntaxError("This environment does not support accessor property descriptors.");
      }
      var creatingNormalDataProperty = !(P in O) && Desc["[[Writable]]"] && Desc["[[Enumerable]]"] && Desc["[[Configurable]]"] && "[[Value]]" in Desc;
      var settingExistingDataProperty = P in O && (!("[[Configurable]]" in Desc) || Desc["[[Configurable]]"]) && (!("[[Enumerable]]" in Desc) || Desc["[[Enumerable]]"]) && (!("[[Writable]]" in Desc) || Desc["[[Writable]]"]) && "[[Value]]" in Desc;
      if (creatingNormalDataProperty || settingExistingDataProperty) {
        O[P] = Desc["[[Value]]"];
        return SameValue(O[P], Desc["[[Value]]"]);
      }
      throw new $SyntaxError("This environment does not support defining non-writable, non-enumerable, or non-configurable properties");
    }
    var desc = $gOPD(O, P);
    var current = desc && ToPropertyDescriptor(desc);
    var extensible = IsExtensible(O);
    return ValidateAndApplyPropertyDescriptor(O, P, extensible, Desc, current);
  };
  return OrdinaryDefineOwnProperty;
}
export {
  requireOrdinaryDefineOwnProperty as __require
};
