"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var Internal_exports = {};
__export(Internal_exports, {
  Internal: () => Internal
});
module.exports = __toCommonJS(Internal_exports);
/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
var Internal;
((Internal2) => {
  Internal2.reference = /* @__PURE__ */ Symbol("reference");
  Internal2.session = /* @__PURE__ */ Symbol("session");
  function unmanage(value) {
    if (value === null || value === void 0 || typeof value !== "object") {
      return value;
    }
    const ref = value[Internal2.reference];
    if (ref) {
      return unmanage(ref.value);
    }
    if (Array.isArray(value)) {
      let changed = false;
      const result = new Array(value.length);
      for (let i = 0; i < value.length; i++) {
        const child = unmanage(value[i]);
        if (child !== value[i]) {
          changed = true;
        }
        result[i] = child;
      }
      return changed ? result : value;
    }
    const proto = Object.getPrototypeOf(value);
    if (proto === Object.prototype || proto === null) {
      let changed = false;
      const result = {};
      for (const key in value) {
        const child = unmanage(value[key]);
        if (child !== value[key]) {
          changed = true;
        }
        result[key] = child;
      }
      return changed ? result : value;
    }
    return value;
  }
  Internal2.unmanage = unmanage;
})(Internal || (Internal = {}));
//# sourceMappingURL=Internal.js.map
