/*
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 { FinancialIndicator } from "./FinancialIndicator";
import { String_$type, Number_$type, typeCast, fromEnum, markType } from "igniteui-react-core/ES5/type";
import { DependencyProperty } from "igniteui-react-core/ES5/DependencyProperty";
import { PropertyMetadata } from "igniteui-react-core/ES5/PropertyMetadata";
import { List$1 } from "igniteui-react-core/ES5/List$1";
import { AxisRange } from "./AxisRange";
import { isNaN_ } from "igniteui-react-core/ES5/number";
var StrategyBasedIndicator = /** @class */ (function (_super) {
    tslib_1.__extends(StrategyBasedIndicator, _super);
    function StrategyBasedIndicator() {
        var _this = _super.call(this) || this;
        _this.qh();
        return _this;
    }
    StrategyBasedIndicator.prototype.qh = function () {
        this.p2 = this.p3;
        this.ab = this.qg;
    };
    StrategyBasedIndicator.prototype.p9 = function () {
        return -2147483648;
    };
    StrategyBasedIndicator.prototype.qi = function (a) {
    };
    StrategyBasedIndicator.prototype.qb = function () {
        return -2147483648;
    };
    StrategyBasedIndicator.prototype.p8 = function () {
        return -2147483648;
    };
    StrategyBasedIndicator.qm = function (a, b, c) {
        var d = DependencyProperty.i(c, Number_$type, b, new PropertyMetadata(2, a, function (e, f) { return (typeCast(StrategyBasedIndicator.$, e)).raisePropertyChanged(c, f.oldValue, f.newValue); }));
        StrategyBasedIndicator.p6.add(c);
        return d;
    };
    StrategyBasedIndicator.ql = function (a, b) {
        return StrategyBasedIndicator.qm(a, b, "Period");
    };
    StrategyBasedIndicator.qj = function (a, b) {
        return StrategyBasedIndicator.qm(a, b, "LongPeriod");
    };
    StrategyBasedIndicator.qn = function (a, b) {
        return StrategyBasedIndicator.qm(a, b, "ShortPeriod");
    };
    StrategyBasedIndicator.prototype.pf = function (a, b) {
        var c = this.mb(a, b);
        var d = this.mc(c);
        return this.p2.b(c, d);
    };
    StrategyBasedIndicator.prototype.pc = function (a, b) {
        var c = this.mb(a, b);
        if (b == 0) {
            return false;
        }
        if (!this.m8(this.pf(a, b))) {
            return false;
        }
        var d = this.mc(c);
        if (this.o9 != null) {
            c.minimumValue = this.o9.c;
            c.maximumValue = this.o9.b;
        }
        var e = this.p2.a(c, d);
        for (var f = 0; f < this.ph && f < c.indicatorColumn.count; f++) {
            c.indicatorColumn.item(f, NaN);
        }
        if (this.mk != null && this.p5(c)) {
            this.mk.ck();
        }
        return e;
    };
    StrategyBasedIndicator.prototype.p5 = function (a) {
        var e_1, _a;
        if (!isNaN_(a.minimumValue) && !isNaN_(a.maximumValue) && a.specifiesRange) {
            var b = this.o9;
            this.o9 = new AxisRange(a.minimumValue, a.maximumValue);
            return this.p4(b, this.o9);
        }
        var c = 1.7976931348623157E+308;
        var d = -1.7976931348623157E+308;
        try {
            for (var _b = tslib_1.__values(fromEnum(a.indicatorColumn)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var e = _c.value;
                if (!isNaN_(e)) {
                    c = Math.min(c, e);
                    d = Math.max(d, e);
                }
            }
        }
        catch (e_1_1) { e_1 = { error: e_1_1 }; }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
            }
            finally { if (e_1) throw e_1.error; }
        }
        var f = this.o9;
        this.o9 = new AxisRange(c, d);
        return this.p4(f, this.o9);
    };
    StrategyBasedIndicator.prototype.p4 = function (a, b) {
        if (a == null || b == null) {
            return true;
        }
        if (a.c != b.c) {
            return true;
        }
        if (a.b != b.b) {
            return true;
        }
        return false;
    };
    StrategyBasedIndicator.prototype.qa = function (a) {
        if (a == -2147483648) {
            return 0;
        }
        if (a > this.indicatorColumn.count && this.indicatorColumn.count > 0) {
            a = this.indicatorColumn.count - 1;
        }
        if (a < 1) {
            return 1;
        }
        return a;
    };
    StrategyBasedIndicator.prototype.mb = function (a, b) {
        var c = _super.prototype.mb.call(this, a, b);
        c.indicatorColumn = this.indicatorColumn;
        c.period = this.qa(this.p9());
        c.shortPeriod = this.qa(this.qb());
        c.longPeriod = this.qa(this.p8());
        c.multiplier = this.p7();
        return c;
    };
    StrategyBasedIndicator.prototype.p7 = function () {
        return 1;
    };
    StrategyBasedIndicator.qk = function (a, b) {
        var c = DependencyProperty.i("Multiplier", Number_$type, b, new PropertyMetadata(2, a, function (d, e) { return (typeCast(StrategyBasedIndicator.$, d)).raisePropertyChanged("Multiplier", e.oldValue, e.newValue); }));
        StrategyBasedIndicator.p6.add("Multiplier");
        return c;
    };
    StrategyBasedIndicator.prototype.ir = function (a, b, c, d) {
        _super.prototype.ir.call(this, a, b, c, d);
        if (StrategyBasedIndicator.p6.contains(b)) {
            if (this.mk != null && !this.mk.ck()) {
                this.mf.bu.e(this.eq);
                this.pc(0, this.indicatorColumn.count);
                if (this.pa.b4) {
                    this.pa.b2.g$i();
                }
                this.i4(false);
            }
        }
    };
    StrategyBasedIndicator.$t = markType(StrategyBasedIndicator, 'StrategyBasedIndicator', FinancialIndicator.$);
    StrategyBasedIndicator.p6 = new List$1(String_$type, 0);
    return StrategyBasedIndicator;
}(FinancialIndicator));
export { StrategyBasedIndicator };
