function _define_property(obj, key, value) {
    if (key in obj) Object.defineProperty(obj, key, {
        value: value,
        enumerable: true,
        configurable: true,
        writable: true
    });
    else obj[key] = value;
    return obj;
}
class SchemaSettingsManager {
    add() {
        for(var _len = arguments.length, schemaSettingList = new Array(_len), _key = 0; _key < _len; _key++)schemaSettingList[_key] = arguments[_key];
        schemaSettingList.forEach((schemaSetting)=>{
            this.schemaSettings[schemaSetting.name] = schemaSetting;
            if (Array.isArray(this.actionList[schemaSetting.name])) {
                this.actionList[schemaSetting.name].forEach((item)=>{
                    schemaSetting[item.type](item.itemName, item.data);
                });
                this.actionList[schemaSetting.name] = void 0;
            }
        });
    }
    addItem(schemaSettingName, itemName, data) {
        if (Array.isArray(schemaSettingName)) {
            schemaSettingName.forEach((name)=>{
                this.addItem(name, itemName, data);
            });
            return;
        }
        const schemaSetting = this.get(schemaSettingName);
        if (schemaSetting) schemaSetting.add(itemName, data);
        else {
            if (!this.actionList[schemaSettingName]) this.actionList[schemaSettingName] = [];
            this.actionList[schemaSettingName].push({
                type: 'add',
                itemName: itemName,
                data
            });
        }
    }
    get(name) {
        return this.schemaSettings[name];
    }
    getAll() {
        return this.schemaSettings;
    }
    has(name) {
        return !!this.get(name);
    }
    remove(name) {
        delete this.schemaSettings[name];
    }
    removeItem(schemaSettingName, itemName) {
        const schemaSetting = this.get(schemaSettingName);
        if (schemaSetting) schemaSetting.remove(itemName);
        else {
            if (!this.actionList[schemaSettingName]) this.actionList[schemaSettingName] = [];
            this.actionList[schemaSettingName].push({
                type: 'remove',
                itemName: itemName
            });
        }
    }
    constructor(_schemaSettings = [], app){
        _define_property(this, "_schemaSettings", void 0);
        _define_property(this, "app", void 0);
        _define_property(this, "schemaSettings", void 0);
        _define_property(this, "actionList", void 0);
        this._schemaSettings = _schemaSettings;
        this.app = app;
        this.schemaSettings = {};
        this.actionList = {};
        this.app = app;
        this.add(..._schemaSettings);
    }
}
export { SchemaSettingsManager };
