"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.$ = void 0;
const EventEmitter_1 = require("../EventEmitter");
const global_1 = require("../global");
class $ extends EventEmitter_1.EventEmitter_ {
    constructor(system) {
        super();
        this.__ = [];
        this.$__ = [];
        this.__system = system;
    }
    getGlobalId() {
        return this.__global_id;
    }
    getInterface() {
        return this.__;
    }
    refSystem() {
        return this.__system;
    }
    register() {
        if (!this.__global_id) {
            this.__global_id = (0, global_1.setGlobalRef)(this.__system, this);
            this.emit('register', this.__global_id);
        }
    }
    unregister() {
        if (this.__global_id) {
            (0, global_1.deleteGlobalRef)(this.__system, this.__global_id);
            this.__global_id = undefined;
            this.emit('unregister');
        }
    }
    destroy() {
        if (this.__done) {
            return;
        }
        this.__done = true;
        this.emit('destroy', []);
    }
    raw() {
        throw new Error("object doesn't have raw form");
    }
}
exports.$ = $;
//# sourceMappingURL=$.js.map