"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const Hash = require("./dist-esm-Hash.cjs");
const Predicate = require("./dist-esm-Predicate.cjs");
const Utils = require("./dist-esm-Utils.cjs");
const symbol = /* @__PURE__ */ Symbol.for("effect/Equal");
function equals() {
  if (arguments.length === 1) {
    return (self) => compareBoth(self, arguments[0]);
  }
  return compareBoth(arguments[0], arguments[1]);
}
function compareBoth(self, that) {
  if (self === that) {
    return true;
  }
  const selfType = typeof self;
  if (selfType !== typeof that) {
    return false;
  }
  if (selfType === "object" || selfType === "function") {
    if (self !== null && that !== null) {
      if (isEqual(self) && isEqual(that)) {
        if (Hash.hash(self) === Hash.hash(that) && self[symbol](that)) {
          return true;
        } else {
          return Utils.structuralRegionState.enabled && Utils.structuralRegionState.tester ? Utils.structuralRegionState.tester(self, that) : false;
        }
      } else if (self instanceof Date && that instanceof Date) {
        return self.toISOString() === that.toISOString();
      } else if (self instanceof URL && that instanceof URL) {
        return self.href === that.href;
      }
    }
    if (Utils.structuralRegionState.enabled) {
      if (Array.isArray(self) && Array.isArray(that)) {
        return self.length === that.length && self.every((v, i) => compareBoth(v, that[i]));
      }
      if (Object.getPrototypeOf(self) === Object.prototype && Object.getPrototypeOf(self) === Object.prototype) {
        const keysSelf = Object.keys(self);
        const keysThat = Object.keys(that);
        if (keysSelf.length === keysThat.length) {
          for (const key of keysSelf) {
            if (!(key in that && compareBoth(self[key], that[key]))) {
              return Utils.structuralRegionState.tester ? Utils.structuralRegionState.tester(self, that) : false;
            }
          }
          return true;
        }
      }
      return Utils.structuralRegionState.tester ? Utils.structuralRegionState.tester(self, that) : false;
    }
  }
  return Utils.structuralRegionState.enabled && Utils.structuralRegionState.tester ? Utils.structuralRegionState.tester(self, that) : false;
}
const isEqual = (u) => Predicate.hasProperty(u, symbol);
exports.equals = equals;
exports.isEqual = isEqual;
exports.symbol = symbol;
//# sourceMappingURL=dist-esm-Equal.cjs.map
