export class DomainElement {
    /**
     * A reference to the root DataDomain instance.
     */
    root;
    /**
     * The root DataDomain instance.
     */
    get domain() {
        return this.root;
    }
    /**
     * The unique key of the domain element.
     * Since keys are immutable, we use a private field to store the key.
     */
    #key;
    /**
     * The unique key of the domain element.
     */
    get key() {
        return this.#key;
    }
    #namespace;
    /**
     * The key of the DataDomain this element belongs to.
     * In a data domain that has foreign namespaces, this is the key of the namespace this element originally belongs to.
     *
     * It might be different from the `domain.key` if the element is a foreign object.
     */
    get namespace() {
        return this.#namespace;
    }
    /**
     * @param root The root DataDomain instance.
     * @param key The unique key of the domain element.
     */
    constructor(root, key) {
        this.root = root;
        this.#key = key;
        // When dependencies are loaded, they all first belong to the root domain.
        // When the foreign domain is merged, the object is transferred to the other domain,
        // but the namespace is still the root domain key.
        this.#namespace = root.key;
    }
}
//# sourceMappingURL=DomainElement.js.map