/*
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 { IndicatorCalculationStrategy } from "./IndicatorCalculationStrategy";
import { String_$type, toEnum, markType, getEnumerator } from "igniteui-react-core/ES2015/type";
import { List$1 } from "igniteui-react-core/ES2015/List$1";
/**
 * @hidden
 */
export class AverageDirectionalIndexIndicatorStrategy extends IndicatorCalculationStrategy {
    b(a, b) {
        let 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;
    }
    j(a, b, c) {
        return b.item(a) - b.item(a - 1);
    }
    i(a, b, c) {
        return c.item(a - 1) - c.item(a);
    }
    *_h(a, b) {
        yield 0;
        let c = 0;
        let d = 0;
        for (let e = 1; e < a.count; e++) {
            c = this.j(e, a, b);
            d = this.i(e, a, b);
            if (c > d && c > 0) {
                yield c;
            }
            else {
                yield 0;
            }
        }
    }
    h(a, b) {
        return toEnum(() => this._h(a, b));
    }
    *_f(a, b) {
        yield 0;
        let c = 0;
        let d = 0;
        for (let e = 1; e < a.count; e++) {
            c = this.j(e, a, b);
            d = this.i(e, a, b);
            if (d > c && d > 0) {
                yield d;
            }
            else {
                yield 0;
            }
        }
    }
    f(a, b) {
        return toEnum(() => this._f(a, b));
    }
    *_g(a, b) {
        let c = getEnumerator(b.a.b(this.h(a.highColumn, a.lowColumn), a.period));
        let d = getEnumerator(b.a.b(a.trueRange, a.period));
        while (c.moveNext() && d.moveNext()) {
            yield b.i(c.current / d.current);
        }
    }
    g(a, b) {
        return toEnum(() => this._g(a, b));
    }
    *_e(a, b) {
        let c = getEnumerator(b.a.b(this.f(a.highColumn, a.lowColumn), a.period));
        let d = getEnumerator(b.a.b(a.trueRange, a.period));
        while (c.moveNext() && d.moveNext()) {
            yield b.i(c.current / d.current);
        }
    }
    e(a, b) {
        return toEnum(() => this._e(a, b));
    }
    *_d(a, b) {
        let c = getEnumerator(this.g(a, b));
        let d = getEnumerator(this.e(a, b));
        c.moveNext();
        d.moveNext();
        while (c.moveNext() && d.moveNext()) {
            yield Math.abs(b.i((c.current - d.current) / (c.current + d.current)));
        }
    }
    d(a, b) {
        return toEnum(() => this._d(a, b));
    }
    *_c(a, b) {
        let c = getEnumerator(b.a.b(this.d(a, b), a.period));
        yield 0;
        while (c.moveNext()) {
            yield c.current * 100;
        }
    }
    c(a, b) {
        return toEnum(() => this._c(a, b));
    }
    a(a, b) {
        let c = getEnumerator(this.c(a, b));
        let d = a.indicatorColumn;
        for (let e = 0; e < d.count; e++) {
            if (c.moveNext()) {
                d.item(e, c.current);
            }
        }
        return true;
    }
}
AverageDirectionalIndexIndicatorStrategy.$t = markType(AverageDirectionalIndexIndicatorStrategy, 'AverageDirectionalIndexIndicatorStrategy', IndicatorCalculationStrategy.$);
