import * as tracing_1 from "../../Tracing"
const fileName_1 = "(@effect-ts/system): _src/Structural/HasEquals/index.ts"
import { hash, hasHash } from "../HasHash"
import { createComparator } from "./comparator"
import { createCircularEqualCreator, sameValueZeroEqual } from "./utils"
export const equalsSym = /*#__PURE__*/ Symbol()
export function hasEquals(u) {
  return hasHash(u) && equalsSym in u
}
export const deepEquals = /*#__PURE__*/ createComparator(
  /*#__PURE__*/ createCircularEqualCreator((eq) => (a, b, meta) => {
    if (hasEquals(a)) {
      return a[equalsSym](b)
    } else {
      return eq(a, b, meta)
    }
  })
)
export function equals(a, b) {
  if (!sameValueZeroEqual(hash(a), hash(b))) {
    return false
  } else if (hasEquals(a)) {
    return a[equalsSym](b)
  } else if (hasEquals(b)) {
    return b[equalsSym](a)
  }

  return sameValueZeroEqual(a, b)
}
//# sourceMappingURL=index.js.map
