"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    SchemaSettingsManager: ()=>SchemaSettingsManager
});
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)) return void schemaSettingName.forEach((name)=>{
            this.addItem(name, itemName, data);
        });
        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
            });
        }
    }
    addItemWithIndex(param) {
        let { schemaSettingName, itemName, index, data } = param;
        if (Array.isArray(schemaSettingName)) return void schemaSettingName.forEach((name, i)=>{
            this.addItemWithIndex({
                schemaSettingName: name,
                itemName,
                index: Array.isArray(index) ? index[i] : index,
                data
            });
        });
        const schemaSetting = this.get(schemaSettingName);
        if (!schemaSetting) return;
        const targetIndex = Array.isArray(index) ? index[0] : index;
        schemaSetting.add(itemName, data, targetIndex);
    }
    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);
    }
}
exports.SchemaSettingsManager = __webpack_exports__.SchemaSettingsManager;
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
    "SchemaSettingsManager"
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
Object.defineProperty(exports, '__esModule', {
    value: true
});
