/*
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";
/**
 * @hidden
 */
var StrategyBasedIndicator = /** @class */ (function (_super) {
    tslib_1.__extends(StrategyBasedIndicator, _super);
    function StrategyBasedIndicator() {
        var _this = _super.call(this) || this;
        _this.qj();
        return _this;
    }
    StrategyBasedIndicator.prototype.qj = function () {
        this.p4 = this.p5;
        this.ab = this.qi;
    };
    StrategyBasedIndicator.prototype.qb = function () {
        return -2147483648;
    };
    StrategyBasedIndicator.prototype.qk = function (a) {
    };
    StrategyBasedIndicator.prototype.qd = function () {
        return -2147483648;
    };
    StrategyBasedIndicator.prototype.qa = function () {
        return -2147483648;
    };
    StrategyBasedIndicator.qo = 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.p8.add(c);
        return d;
    };
    StrategyBasedIndicator.qn = function (a, b) {
        return StrategyBasedIndicator.qo(a, b, "Period");
    };
    StrategyBasedIndicator.ql = function (a, b) {
        return StrategyBasedIndicator.qo(a, b, "LongPeriod");
    };
    StrategyBasedIndicator.qp = function (a, b) {
        return StrategyBasedIndicator.qo(a, b, "ShortPeriod");
    };
    StrategyBasedIndicator.prototype.ph = function (a, b) {
        var c = this.md(a, b);
        var d = this.me(c);
        return this.p4.b(c, d);
    };
    StrategyBasedIndicator.prototype.pe = function (a, b) {
        var c = this.md(a, b);
        if (b == 0) {
            return false;
        }
        if (!this.na(this.ph(a, b))) {
            return false;
        }
        var d = this.me(c);
        if (this.pb != null) {
            c.minimumValue = this.pb.c;
            c.maximumValue = this.pb.b;
        }
        var e = this.p4.a(c, d);
        for (var f = 0; f < this.pj && f < c.indicatorColumn.count; f++) {
            c.indicatorColumn.item(f, NaN);
        }
        if (this.mm != null && this.p7(c)) {
            this.mm.ck();
        }
        return e;
    };
    StrategyBasedIndicator.prototype.p7 = function (a) {
        var e_1, _a;
        if (!isNaN_(a.minimumValue) && !isNaN_(a.maximumValue) && a.specifiesRange) {
            var b = this.pb;
            this.pb = new AxisRange(a.minimumValue, a.maximumValue);
            return this.p6(b, this.pb);
        }
        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.pb;
        this.pb = new AxisRange(c, d);
        return this.p6(f, this.pb);
    };
    StrategyBasedIndicator.prototype.p6 = 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.qc = 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.md = function (a, b) {
        var c = _super.prototype.md.call(this, a, b);
        c.indicatorColumn = this.indicatorColumn;
        c.period = this.qc(this.qb());
        c.shortPeriod = this.qc(this.qd());
        c.longPeriod = this.qc(this.qa());
        c.multiplier = this.p9();
        return c;
    };
    StrategyBasedIndicator.prototype.p9 = function () {
        return 1;
    };
    StrategyBasedIndicator.qm = 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.p8.add("Multiplier");
        return c;
    };
    StrategyBasedIndicator.prototype.is = function (a, b, c, d) {
        _super.prototype.is.call(this, a, b, c, d);
        if (StrategyBasedIndicator.p8.contains(b)) {
            if (this.mm != null && !this.mm.ck()) {
                this.mh.bu.e(this.er);
                this.pe(0, this.indicatorColumn.count);
                if (this.pc.b4) {
                    this.pc.b2.g$i();
                }
                this.i6(false);
            }
        }
    };
    StrategyBasedIndicator.$t = markType(StrategyBasedIndicator, 'StrategyBasedIndicator', FinancialIndicator.$);
    StrategyBasedIndicator.p8 = new List$1(String_$type, 0);
    return StrategyBasedIndicator;
}(FinancialIndicator));
export { StrategyBasedIndicator };
