"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
class ManagedEvent {
    constructor(data, id) {
        this._data = data;
        this._managed = {};
        this.id = id;
    }
    toString() {
        if (this._data === undefined) {
            return "undefined";
        }
        return JSON.stringify(this._data);
    }
    hasAddComponentGroup(id) {
        if (!this._data || !this._data.add || !this._data.add.component_groups) {
            return false;
        }
        if (this._data.add.component_groups.includes(id)) {
            return true;
        }
        return false;
    }
    ensureData() {
        if (this._data === undefined) {
            this._data = {};
        }
    }
    ensureAddComponentGroup(id) {
        if (this.hasAddComponentGroup(id)) {
            return;
        }
        if (!this._data) {
            this.ensureData();
        }
        if (!this._data) {
            return;
        }
        if (!this._data.add) {
            this._data.add = { component_groups: [] };
        }
        if (!this._data.add.component_groups) {
            this._data.add.component_groups = [];
        }
        if (this._data.add.component_groups.includes(id)) {
            return;
        }
        this._data.add.component_groups.push(id);
    }
    removeAddComponentGroup(id) {
        if (!this._data || !this._data.add || !this._data.add.component_groups) {
            return false;
        }
        if (this._data.add.component_groups.includes(id)) {
            const newarr = [];
            for (const elt of this._data.add.component_groups) {
                if (elt !== id) {
                    newarr.push(elt);
                }
            }
            this._data.add.component_groups = newarr;
            return true;
        }
        return false;
    }
    hasRemoveComponentGroup(id) {
        if (!this._data || !this._data.remove || !this._data.remove.component_groups) {
            return false;
        }
        if (this._data.remove.component_groups.includes(id)) {
            return true;
        }
        return false;
    }
    ensureRemoveComponentGroup(id) {
        if (this.hasRemoveComponentGroup(id)) {
            return;
        }
        if (!this._data) {
            this.ensureData();
        }
        if (!this._data) {
            return;
        }
        if (!this._data.remove) {
            this._data.remove = { component_groups: [] };
        }
        if (!this._data.remove.component_groups) {
            this._data.remove.component_groups = [];
        }
        if (this._data.remove.component_groups.includes(id)) {
            return;
        }
        this._data.remove.component_groups.push(id);
    }
    removeRemoveComponentGroup(id) {
        if (!this._data || !this._data.remove || !this._data.remove.component_groups) {
            return false;
        }
        if (this._data.remove.component_groups.includes(id)) {
            const newarr = [];
            for (const elt of this._data.remove.component_groups) {
                if (elt !== id) {
                    newarr.push(elt);
                }
            }
            this._data.remove.component_groups = newarr;
            return true;
        }
        return false;
    }
}
exports.default = ManagedEvent;

//# sourceMappingURL=../maps/minecraft/ManagedEvent.js.map
