/**
* A base class for UI component classes.
*
* @memberof module:libresignage/ui/components
*/
class BaseComponent {
	/**
	* Construct a new BaseComponent object.
	*/
	constructor() {
		this.state_vars = {};
	}

	/**
	* Initialize a set of state variables.
	*
	* @params {object} vars The state variables as an object.
	*/

	init_state(vars) {
		this.state_vars = vars;
	}

	/**
	* Get all state variables.
	*
	* @returns {object} A set of state variables as an object.
	*/
	get_state_vars() {
		return this.state_vars;
	}

	/**
	* Get the value of a state variable.
	*
	* @param {string} key The state variable to get.
	*/
	get_state(key) {
		return this.state_vars[key]
	}

	/**
	* Set a state variable.
	*
	* @param {string} key   The state variable to set.
	* @param {mixed}  value The new value of the state variable.
	*/
	state(key, value) {
		if (value !== undefined) {
			this.state_vars[key] = value;
		} else {
			return this.state_vars[key];
		}
	}
}
module.exports = BaseComponent;
