/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import * as tslib_1 from "tslib";
import { StreamingIndicatorCalculationStrategy } from "./StreamingIndicatorCalculationStrategy";
import { String_$type, fromEnum, toEnum, markType } from "igniteui-react-core/ES5/type";
import { List$1 } from "igniteui-react-core/ES5/List$1";
var RelativeStrengthIndexIndicatorStrategy = /** @class */ (function (_super) {
    tslib_1.__extends(RelativeStrengthIndexIndicatorStrategy, _super);
    function RelativeStrengthIndexIndicatorStrategy() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    RelativeStrengthIndexIndicatorStrategy.prototype.b = function (a, b) {
        var c = new List$1(String_$type, 0);
        c.add("CloseColumn");
        return c;
    };
    RelativeStrengthIndexIndicatorStrategy.prototype.a = function (a, b) {
        var c = 0;
        try {
            for (var _a = tslib_1.__values(fromEnum(this.c(a, b))), _b = _a.next(); !_b.done; _b = _a.next()) {
                var d = _b.value;
                a.indicatorColumn.item(c, d);
                c++;
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (_b && !_b.done && (_d = _a.return)) _d.call(_a);
            }
            finally { if (e_1) throw e_1.error; }
        }
        return true;
        var e_1, _d;
    };
    RelativeStrengthIndexIndicatorStrategy.prototype._c = function (a, b) {
        var c, d, e, f, g, h, i, j, k, l, m, n, o, p;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    c = a.period;
                    d = 2 / (c + 1);
                    e = 0;
                    f = 0;
                    g = a.indicatorColumn;
                    h = a.closeColumn;
                    if (!(g.count > 0)) return [3 /*break*/, 2];
                    return [4 /*yield*/, 0];
                case 1:
                    _a.sent();
                    _a.label = 2;
                case 2:
                    i = 1;
                    _a.label = 3;
                case 3:
                    if (!(i < Math.min(a.period, g.count))) return [3 /*break*/, 6];
                    j = h.item(i) - h.item(i - 1);
                    k = j > 0 ? j : 0;
                    l = j > 0 ? 0 : -j;
                    e += k / (c - 1);
                    f += l / (c - 1);
                    return [4 /*yield*/, 0];
                case 4:
                    _a.sent();
                    _a.label = 5;
                case 5:
                    ++i;
                    return [3 /*break*/, 3];
                case 6:
                    m = a.period;
                    _a.label = 7;
                case 7:
                    if (!(m < g.count)) return [3 /*break*/, 10];
                    n = h.item(m) - h.item(m - 1);
                    o = n > 0 ? n : 0;
                    p = n > 0 ? 0 : -n;
                    e = (e * (c - 1) + o) / c;
                    f = (f * (c - 1) + p) / c;
                    return [4 /*yield*/, b.i(e != 0 ? 100 * e / (e + f) : 0)];
                case 8:
                    _a.sent();
                    _a.label = 9;
                case 9:
                    ++m;
                    return [3 /*break*/, 7];
                case 10: return [2 /*return*/];
            }
        });
    };
    RelativeStrengthIndexIndicatorStrategy.prototype.c = function (a, b) {
        var _this = this;
        return toEnum(function () { return _this._c(a, b); });
    };
    RelativeStrengthIndexIndicatorStrategy.$t = markType(RelativeStrengthIndexIndicatorStrategy, 'RelativeStrengthIndexIndicatorStrategy', StreamingIndicatorCalculationStrategy.$);
    return RelativeStrengthIndexIndicatorStrategy;
}(StreamingIndicatorCalculationStrategy));
export { RelativeStrengthIndexIndicatorStrategy };
