/*
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, markType, getEnumerator } from "igniteui-react-core/ES5/type";
import { List$1 } from "igniteui-react-core/ES5/List$1";
var MoneyFlowIndexIndicatorStrategy = /** @class */ (function (_super) {
    tslib_1.__extends(MoneyFlowIndexIndicatorStrategy, _super);
    function MoneyFlowIndexIndicatorStrategy() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MoneyFlowIndexIndicatorStrategy.prototype.b = function (a, b) {
        var c = new List$1(String_$type, 0);
        c.o(a.typicalColumn.basedOn);
        c.add("VolumeColumn");
        return c;
    };
    MoneyFlowIndexIndicatorStrategy.prototype.a = function (a, b) {
        var c = a.typicalColumn.getEnumerator();
        var d = getEnumerator(a.volumeColumn);
        var e = a.period;
        var f = 0;
        var g = new Array(e);
        for (f = 0; f < e; f++) {
            g[f] = 0;
        }
        var h = 0;
        var i = new Array(e);
        for (f = 0; f < e; f++) {
            i[f] = 0;
        }
        var j = 0;
        var k = 0;
        f = 0;
        while (c.moveNext() && d.moveNext()) {
            var l = f % e;
            var m = c.current * d.current;
            h -= g[l];
            j -= i[l];
            switch (Math.sign(m - k)) {
                case -1:
                    g[l] = 0;
                    i[l] = m;
                    break;
                case 0:
                    g[l] = 0;
                    i[l] = 0;
                    break;
                case 1:
                    g[l] = m;
                    i[l] = 0;
                    break;
            }
            h += g[l];
            j += i[l];
            var n = b.i(100 * h / (h + j));
            a.indicatorColumn.item(f, n);
            k = m;
            ++f;
        }
        return true;
    };
    MoneyFlowIndexIndicatorStrategy.$t = markType(MoneyFlowIndexIndicatorStrategy, 'MoneyFlowIndexIndicatorStrategy', IndicatorCalculationStrategy.$);
    return MoneyFlowIndexIndicatorStrategy;
}(IndicatorCalculationStrategy));
export { MoneyFlowIndexIndicatorStrategy };
