"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SwmmModel = void 0;
class SwmmModel {
    constructor(model) {
        this.oneDimensionalTables = ['SUBCATCHMENTS', 'JUNCTIONS', 'RAINGAGES', ''];
        this.model = model;
    }
    /**
     * Get the value of a property of a one-dimensional table object.
     * @param tableName A swmm model one-dimensional table name, e.g.: SUBCATCHMENTS, JUNCTIONS, etc.
     * @param keyName The name of the key within the table. Generally referred to as the object name.
     * @param valName The name of the property of the object.
     * @returns
     */
    get_table_val(tableName, keyName, valName) {
        var _a;
        const key = (_a = this.model[tableName]) === null || _a === void 0 ? void 0 : _a[keyName];
        const val = key === null || key === void 0 ? void 0 : key[valName];
        if (val !== undefined) {
            return val;
        }
        else {
            throw new Error(`Unable to retrieve ${valName} from table '${tableName}' for key '${keyName}'.`);
        }
    }
    set_table_val(setModel, tableName, keyName, valName, updateVal) {
        setModel((prev) => {
            var _a;
            return (Object.assign(Object.assign({}, prev), { [tableName]: Object.assign(Object.assign({}, prev === null || prev === void 0 ? void 0 : prev[tableName]), { [keyName]: Object.assign(Object.assign({}, (_a = prev === null || prev === void 0 ? void 0 : prev[tableName]) === null || _a === void 0 ? void 0 : _a[keyName]), { [valName]: updateVal }) }) }));
        });
    }
}
exports.SwmmModel = SwmmModel;
