/*
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 { __extends } from "tslib";
import { StraightNumericAxisBase } from "./StraightNumericAxisBase";
import { IScaler_$type } from "./IScaler";
import { markType, TypeRegistrar } from "igniteui-angular-core";
import { HorizontalAxisLabelPanel } from "./HorizontalAxisLabelPanel";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-angular-core";
import { RangeInfo } from "./RangeInfo";
import { HorizontalLogarithmicScaler } from "./HorizontalLogarithmicScaler";
import { FastHorizontalLinearScaler } from "./FastHorizontalLinearScaler";
import { isNaN_ } from "igniteui-angular-core";
import { StraightNumericAxisBaseView } from "./StraightNumericAxisBaseView";
import { AxisDefaults } from "./AxisDefaults";
/**
 * @hidden
 */
var NumericXAxis = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(NumericXAxis, _super);
    function NumericXAxis() {
        var _this = _super.call(this) || this;
        _this.ab = NumericXAxis.$;
        _this.kz = _this.kx();
        return _this;
    }
    NumericXAxis.prototype.a3 = function () {
        return new NumericXAxisView(this);
    };
    NumericXAxis.prototype.hr = function (a) {
        _super.prototype.hr.call(this, a);
        this.nz = a;
    };
    NumericXAxis.prototype.au = function () {
        if (this.c5) {
            return (TypeRegistrar.create('HorizontalSmartAxisLabelPanel'));
        }
        else {
            return new HorizontalAxisLabelPanel();
        }
    };
    NumericXAxis.prototype.kx = function () {
        var _this = this;
        var a = _super.prototype.kx.call(this);
        a.b.c = function (b) {
            if ((_this.ay == null || _this.ay.visibility == 0) && _this.ai != null) {
                _this.av.bg = b;
                if (_this.ay != null && (_this.ay.location == 4 || _this.ay.location == 5)) {
                    _this.bh.l7();
                }
            }
        };
        a.k = function (b, c, d) { return _this.il(c, d, b.z, b.b, false); };
        a.l = function (b, c, d, e) { return _this.im(c, d, e, b.z); };
        a.m = function (b, c) {
            var d = b.y;
            var e = new ScalerParams(0, b.aa, b.z, _this.ch, d);
            return _this.ei(c, e);
        };
        a.q = function (b, c) { return true; };
        a.j = function (b) { return _this.hp(b.t, b.n, b.z, b.a, true); };
        a.e = function (b) {
            b.n = b.z.bottom;
            if (_this.ai != null && _this.ai.bh != null) {
                var c = b.n;
                var d = b.r;
                var e = _this.id(c, d, b.aa, b.z, b.y, b.z.top, b.z.bottom);
                c = e.p0;
                d = e.p1;
                b.n = c;
                b.r = d;
            }
        };
        a.p = function (b, c, d) {
            var e = Math.round(c);
            return e >= Math.floor(b.z.left) && e <= Math.ceil(b.z.right);
        };
        return a;
    };
    NumericXAxis.prototype.ei = function (a, b) {
        if (this.ni != null) {
            return this.ni.p(a, b);
        }
        return this.nh.p(a, b);
    };
    NumericXAxis.prototype.el = function (a, b) {
        if (this.ni != null) {
            return this.ni.q(a, b);
        }
        return this.nh.q(a, b);
    };
    NumericXAxis.prototype.hm = function (a, b, c, d) {
        if (this.ni != null) {
            this.ni.v(a, b, c, d);
            return;
        }
        this.nh.v(a, b, c, d);
    };
    NumericXAxis.prototype.hl = function (a, b, c, d, e) {
        if (this.ni != null) {
            this.ni.u(a, b, c, d, e);
            return;
        }
        this.nh.u(a, b, c, d, e);
    };
    NumericXAxis.prototype.hn = function (a, b, c, d) {
        if (this.ni != null) {
            this.ni.j(a, b, c, d);
            return;
        }
        this.nh.j(a, b, c, d);
    };
    NumericXAxis.prototype.n0 = function (a, b) {
        if (this.bh == null || isNaN_(a) || isNaN_(b)) {
            return;
        }
        var c = this.nn(a, this);
        var d = this.nn(b, this);
        if (isNaN_(c) || isNaN_(d)) {
            return;
        }
        this.bh.tq = new Rect(0, c, this.bh.tq.y, d - c, this.bh.tq.height);
    };
    NumericXAxis.prototype.k0 = function (a, b, c, d) {
        var e = d;
        var f = _super.prototype.k0.call(this, a, b, c, d);
        var g = new ScalerParams(0, b, a, this.cg, c);
        var h = NaN;
        var i = NaN;
        if (!this.cg && b.right == 1) {
            i = this.lv;
        }
        else if (this.cg && b.left == 0) {
            h = this.lv;
        }
        if (isNaN_(h)) {
            h = this.el(e.left, g);
        }
        if (isNaN_(i)) {
            i = this.el(e.right, g);
        }
        var j = Math.min(h, i);
        var k = Math.max(h, i);
        this.lz = j;
        this.ly = k;
        f.k.add(((function () {
            var $ret = new RangeInfo();
            $ret.d = j;
            $ret.c = k;
            $ret.b = e.width;
            return $ret;
        })()));
        return f;
    };
    NumericXAxis.prototype.h8 = function (a) {
        _super.prototype.h8.call(this, a);
        var b = this.bh != null ? this.bh.ta : Rect.empty;
        var c = !b.isEmpty ? this.kc : Rect.empty;
        var d = this.j7();
        var e = this.j6();
        var f = this.kz.c(a, c, b, d, e);
        if (f != null) {
            this.lu = f.f.m;
            this.lx = f.f.l;
        }
    };
    NumericXAxis.prototype.io = function (a, b) {
        _super.prototype.io.call(this, a, b);
        if (b.height != a.height) {
            this.c0();
        }
    };
    NumericXAxis.prototype.get_a1 = function () {
        return 0;
    };
    Object.defineProperty(NumericXAxis.prototype, "a1", {
        get: function () {
            return this.get_a1();
        },
        enumerable: false,
        configurable: true
    });
    NumericXAxis.prototype.k2 = function () {
        if (this.lh) {
            return new HorizontalLogarithmicScaler();
        }
        switch (this.ng) {
            case 0: return new FastHorizontalLinearScaler();
            case 1: return new HorizontalLogarithmicScaler();
        }
        return null;
    };
    NumericXAxis.prototype.j$c = function (a, b) {
        return this.el.apply(this, arguments);
    };
    NumericXAxis.prototype.j$b = function (a, b) {
        return this.ei.apply(this, arguments);
    };
    NumericXAxis.prototype.j$d = function (a, b, c, d, e) {
        this.hl.apply(this, arguments);
    };
    NumericXAxis.prototype.j$e = function (a, b, c, d) {
        this.hm.apply(this, arguments);
    };
    NumericXAxis.prototype.j$f = function (a, b, c, d) {
        this.hn.apply(this, arguments);
    };
    Object.defineProperty(NumericXAxis.prototype, "j$a", {
        get: function () {
            return this.cg;
        },
        enumerable: false,
        configurable: true
    });
    NumericXAxis.$t = markType(NumericXAxis, 'NumericXAxis', StraightNumericAxisBase.$, [IScaler_$type]);
    return NumericXAxis;
}(StraightNumericAxisBase));
export { NumericXAxis };
/**
 * @hidden
 */
var NumericXAxisView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(NumericXAxisView, _super);
    function NumericXAxisView(a) {
        var _this = _super.call(this, a) || this;
        _this.bl = null;
        _this.bl = a;
        return _this;
    }
    NumericXAxisView.prototype.aj = function () {
        _super.prototype.aj.call(this);
        this.a.jv = AxisDefaults.h;
    };
    NumericXAxisView.$t = markType(NumericXAxisView, 'NumericXAxisView', StraightNumericAxisBaseView.$);
    return NumericXAxisView;
}(StraightNumericAxisBaseView));
export { NumericXAxisView };
