/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { NodeJsStyleInspectable } from "@matter/general";
class CrossReference {
  document;
  section;
  static instances = {};
  constructor(definition) {
    if (typeof definition === "object") {
      this.document = definition.document;
      this.section = definition.section;
    } else {
      [this.document, this.section] = definition.split("\xA7");
    }
  }
  toString() {
    return `${this.document}\xA7${this.section}`;
  }
  static get(xref) {
    if (xref instanceof CrossReference) {
      return xref;
    }
    const key = typeof xref === "string" ? xref : `${xref.document}\xA7${xref.section}`;
    const canonical = this.instances[key];
    if (canonical) {
      return canonical;
    }
    return this.instances[key] = new CrossReference(xref);
  }
}
NodeJsStyleInspectable(CrossReference.prototype, function(_depth, options, inspect) {
  return inspect(this.toString(), options);
});
export {
  CrossReference
};
//# sourceMappingURL=CrossReference.js.map
