"use strict"; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** * Licensed Materials - Property of IBM * * (C) Copyright IBM Corp. 2019, 2020 * * US Government Users Restricted Rights - Use, duplication or disclosure * restricted by GSA ADP Schedule Contract with IBM Corp. */ define([], function () { var MAX_CALL_COUNT = 3; /** * Class to keep prompts state. The owner of this class is a widget since prompt values are cached at widget level. */ var PromptsState = function () { function PromptsState() { _classCallCheck(this, PromptsState); this._promptsState = {}; } PromptsState.prototype.destroy = function destroy() { this._promptsState = null; }; PromptsState.prototype.reset = function reset() { this._promptsState = {}; }; /** * @param {PromptSpec[]} specList Array of the prompt specs */ PromptsState.prototype.updatePromptsState = function updatePromptsState(specList) { var _this = this; specList && specList.forEach(function (spec) { // Increase the call count for each prompt var state = _this._promptsState[spec.name]; if (!state) { _this._promptsState[spec.name] = 0; } _this._promptsState[spec.name]++; }); }; PromptsState.prototype.hasInProgressPrompts = function hasInProgressPrompts() { return Object.keys(this._promptsState).length > 0; }; PromptsState.prototype.hasInValidState = function hasInValidState(specList) { var _this2 = this; // Is invalid if specList is undefined or at least one prompt tries to resolve the prompt values more than MAX_CALL_COUNT return !specList || specList.find(function (spec) { return _this2._promptsState[spec.name] && _this2._promptsState[spec.name] >= MAX_CALL_COUNT; }) !== undefined; }; return PromptsState; }(); return PromptsState; }); //# sourceMappingURL=PromptsState.js.map