/*
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 { fromEnum, markType } from "igniteui-react-core";
import { NumericYAxis } from "./NumericYAxis";
import { NumericScaler } from "./NumericScaler";
import { AxisRange } from "./AxisRange";
import { PercentChangeAxisRenderer } from "./PercentChangeAxisRenderer";
import { isNaN_ } from "igniteui-react-core";
import { AutoRangeCalculator } from "./AutoRangeCalculator";
/**
 * @hidden
 */
var PercentChangeYAxis = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(PercentChangeYAxis, _super);
    function PercentChangeYAxis() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    PercentChangeYAxis.prototype.jr = function () {
        return new VerticalPercentChangeScaler(this);
    };
    PercentChangeYAxis.prototype.jk = function () {
        var e_1, _a;
        var a = 1.7976931348623157E+308;
        var b = -1.7976931348623157E+308;
        try {
            for (var _b = tslib_1.__values(fromEnum(this.cw())), _c = _b.next(); !_c.done; _c = _b.next()) {
                var c = _c.value;
                var d = c.ao(this);
                if (d == null) {
                    continue;
                }
                var e = c.fa();
                if (isNaN_(e) || e == 0) {
                    continue;
                }
                var f = d.b - e;
                var g = e - d.c;
                var h = Math.abs(f / e * 100);
                var i = Math.abs(g / e * 100);
                a = Math.min(a, -i);
                b = Math.max(b, h);
            }
        }
        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;
            }
        }
        return new AxisRange(a, b);
    };
    PercentChangeYAxis.prototype.jn = function (a) {
        return new PercentChangeAxisRenderer(a);
    };
    PercentChangeYAxis.prototype.dk = function (a, b) {
        var c = ((a - b.b) / b.b) * 100;
        if (c < this.kd) {
            var d = ((this.kd / 100) * b.b) + b.b;
            return d;
        }
        if (c > this.kc) {
            var e = ((this.kc / 100) * b.b) + b.b;
            return e;
        }
        return a;
    };
    PercentChangeYAxis.prototype.j$c = function (a, b) {
        return this.d2.apply(this, arguments);
    };
    PercentChangeYAxis.prototype.j$b = function (a, b) {
        return this.dz.apply(this, arguments);
    };
    PercentChangeYAxis.prototype.j$d = function (a, b, c, d, e) {
        this.gs.apply(this, arguments);
    };
    PercentChangeYAxis.prototype.j$e = function (a, b, c, d) {
        this.gt.apply(this, arguments);
    };
    PercentChangeYAxis.prototype.j$f = function (a, b, c, d) {
        this.gu.apply(this, arguments);
    };
    Object.defineProperty(PercentChangeYAxis.prototype, "j$a", {
        get: function () {
            return this.ca;
        },
        enumerable: true,
        configurable: true
    });
    PercentChangeYAxis.$t = markType(PercentChangeYAxis, 'PercentChangeYAxis', NumericYAxis.$);
    return PercentChangeYAxis;
}(NumericYAxis));
export { PercentChangeYAxis };
/**
 * @hidden
 */
var VerticalPercentChangeScaler = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(VerticalPercentChangeScaler, _super);
    function VerticalPercentChangeScaler(a) {
        var _this = _super.call(this) || this;
        _this.ad = null;
        _this.ad = a;
        return _this;
    }
    VerticalPercentChangeScaler.prototype.t = function (a, b, c, d, e) {
        var f = AutoRangeCalculator.a(this.ad, b, c, false, -1, d, e);
        d = f.p5;
        e = f.p6;
        return {
            p3: d,
            p4: e
        };
    };
    VerticalPercentChangeScaler.prototype.p = function (a, b) {
        if (!b.c.isEmpty) {
            var c = this.ae(a, NumericScaler.ac, b.c, b.b, b.a);
            c = (c - b.d.top) / b.d.height;
            c = b.d.top + b.d.height * (c - b.e.top) / b.e.height;
            return c;
        }
        return this.ae(a, b.e, b.d, b.b, b.a);
    };
    VerticalPercentChangeScaler.prototype.ae = function (a, b, c, d, e) {
        var f;
        if (isNaN_(d)) {
            f = a;
        }
        else {
            var g = (a - d) / Math.abs(d) * 100;
            f = g;
        }
        var h = (f - this.o) / this.m;
        if (!e) {
            h = 1 - h;
        }
        return c.top + c.height * (h - b.top) / b.height;
    };
    VerticalPercentChangeScaler.prototype.q = function (a, b) {
        var c = b.e.top + b.e.height * (a - b.d.top) / b.d.height;
        if (!b.a) {
            c = 1 - c;
        }
        return this.o + c * (this.m);
    };
    VerticalPercentChangeScaler.$t = markType(VerticalPercentChangeScaler, 'VerticalPercentChangeScaler', NumericScaler.$);
    return VerticalPercentChangeScaler;
}(NumericScaler));
export { VerticalPercentChangeScaler };
//# sourceMappingURL=PercentChangeYAxis_combined.js.map
