/*
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 { IndicatorCalculationStrategy } from "./IndicatorCalculationStrategy";
import { String_$type, toEnum, markType, getEnumerator } from "igniteui-react-core/ES5/type";
import { List$1 } from "igniteui-react-core/ES5/List$1";
var AverageDirectionalIndexIndicatorStrategy = /** @class */ (function (_super) {
    tslib_1.__extends(AverageDirectionalIndexIndicatorStrategy, _super);
    function AverageDirectionalIndexIndicatorStrategy() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    AverageDirectionalIndexIndicatorStrategy.prototype.b = function (a, b) {
        var c = new List$1(String_$type, 0);
        c.add("LowColumn");
        c.add("HighColumn");
        c.o(a.trueRange.basedOn);
        c.o(b.a.c);
        return c;
    };
    AverageDirectionalIndexIndicatorStrategy.prototype.j = function (a, b, c) {
        return b.item(a) - b.item(a - 1);
    };
    AverageDirectionalIndexIndicatorStrategy.prototype.i = function (a, b, c) {
        return c.item(a - 1) - c.item(a);
    };
    AverageDirectionalIndexIndicatorStrategy.prototype._h = function (a, b) {
        var c, d, e;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, 0];
                case 1:
                    _a.sent();
                    c = 0;
                    d = 0;
                    e = 1;
                    _a.label = 2;
                case 2:
                    if (!(e < a.count)) return [3 /*break*/, 7];
                    c = this.j(e, a, b);
                    d = this.i(e, a, b);
                    if (!(c > d && c > 0)) return [3 /*break*/, 4];
                    return [4 /*yield*/, c];
                case 3:
                    _a.sent();
                    return [3 /*break*/, 6];
                case 4: return [4 /*yield*/, 0];
                case 5:
                    _a.sent();
                    _a.label = 6;
                case 6:
                    e++;
                    return [3 /*break*/, 2];
                case 7: return [2 /*return*/];
            }
        });
    };
    AverageDirectionalIndexIndicatorStrategy.prototype.h = function (a, b) {
        var _this = this;
        return toEnum(function () { return _this._h(a, b); });
    };
    AverageDirectionalIndexIndicatorStrategy.prototype._f = function (a, b) {
        var c, d, e;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, 0];
                case 1:
                    _a.sent();
                    c = 0;
                    d = 0;
                    e = 1;
                    _a.label = 2;
                case 2:
                    if (!(e < a.count)) return [3 /*break*/, 7];
                    c = this.j(e, a, b);
                    d = this.i(e, a, b);
                    if (!(d > c && d > 0)) return [3 /*break*/, 4];
                    return [4 /*yield*/, d];
                case 3:
                    _a.sent();
                    return [3 /*break*/, 6];
                case 4: return [4 /*yield*/, 0];
                case 5:
                    _a.sent();
                    _a.label = 6;
                case 6:
                    e++;
                    return [3 /*break*/, 2];
                case 7: return [2 /*return*/];
            }
        });
    };
    AverageDirectionalIndexIndicatorStrategy.prototype.f = function (a, b) {
        var _this = this;
        return toEnum(function () { return _this._f(a, b); });
    };
    AverageDirectionalIndexIndicatorStrategy.prototype._g = function (a, b) {
        var c, d;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    c = getEnumerator(b.a.b(this.h(a.highColumn, a.lowColumn), a.period));
                    d = getEnumerator(b.a.b(a.trueRange, a.period));
                    _a.label = 1;
                case 1:
                    if (!(c.moveNext() && d.moveNext())) return [3 /*break*/, 3];
                    return [4 /*yield*/, b.i(c.current / d.current)];
                case 2:
                    _a.sent();
                    return [3 /*break*/, 1];
                case 3: return [2 /*return*/];
            }
        });
    };
    AverageDirectionalIndexIndicatorStrategy.prototype.g = function (a, b) {
        var _this = this;
        return toEnum(function () { return _this._g(a, b); });
    };
    AverageDirectionalIndexIndicatorStrategy.prototype._e = function (a, b) {
        var c, d;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    c = getEnumerator(b.a.b(this.f(a.highColumn, a.lowColumn), a.period));
                    d = getEnumerator(b.a.b(a.trueRange, a.period));
                    _a.label = 1;
                case 1:
                    if (!(c.moveNext() && d.moveNext())) return [3 /*break*/, 3];
                    return [4 /*yield*/, b.i(c.current / d.current)];
                case 2:
                    _a.sent();
                    return [3 /*break*/, 1];
                case 3: return [2 /*return*/];
            }
        });
    };
    AverageDirectionalIndexIndicatorStrategy.prototype.e = function (a, b) {
        var _this = this;
        return toEnum(function () { return _this._e(a, b); });
    };
    AverageDirectionalIndexIndicatorStrategy.prototype._d = function (a, b) {
        var c, d;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    c = getEnumerator(this.g(a, b));
                    d = getEnumerator(this.e(a, b));
                    c.moveNext();
                    d.moveNext();
                    _a.label = 1;
                case 1:
                    if (!(c.moveNext() && d.moveNext())) return [3 /*break*/, 3];
                    return [4 /*yield*/, Math.abs(b.i((c.current - d.current) / (c.current + d.current)))];
                case 2:
                    _a.sent();
                    return [3 /*break*/, 1];
                case 3: return [2 /*return*/];
            }
        });
    };
    AverageDirectionalIndexIndicatorStrategy.prototype.d = function (a, b) {
        var _this = this;
        return toEnum(function () { return _this._d(a, b); });
    };
    AverageDirectionalIndexIndicatorStrategy.prototype._c = function (a, b) {
        var c;
        return tslib_1.__generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    c = getEnumerator(b.a.b(this.d(a, b), a.period));
                    return [4 /*yield*/, 0];
                case 1:
                    _a.sent();
                    _a.label = 2;
                case 2:
                    if (!c.moveNext()) return [3 /*break*/, 4];
                    return [4 /*yield*/, c.current * 100];
                case 3:
                    _a.sent();
                    return [3 /*break*/, 2];
                case 4: return [2 /*return*/];
            }
        });
    };
    AverageDirectionalIndexIndicatorStrategy.prototype.c = function (a, b) {
        var _this = this;
        return toEnum(function () { return _this._c(a, b); });
    };
    AverageDirectionalIndexIndicatorStrategy.prototype.a = function (a, b) {
        var c = getEnumerator(this.c(a, b));
        var d = a.indicatorColumn;
        for (var e = 0; e < d.count; e++) {
            if (c.moveNext()) {
                d.item(e, c.current);
            }
        }
        return true;
    };
    AverageDirectionalIndexIndicatorStrategy.$t = markType(AverageDirectionalIndexIndicatorStrategy, 'AverageDirectionalIndexIndicatorStrategy', IndicatorCalculationStrategy.$);
    return AverageDirectionalIndexIndicatorStrategy;
}(IndicatorCalculationStrategy));
export { AverageDirectionalIndexIndicatorStrategy };
