/*
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 { 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
 */
export let NumericXAxis = /*@__PURE__*/ (() => {
    class NumericXAxis extends StraightNumericAxisBase {
        constructor() {
            super();
            this.ab = NumericXAxis.$;
            this.oq = this.oo();
        }
        bm() {
            return new NumericXAxisView(this);
        }
        kb(a) {
            super.kb(a);
            this.sn = a;
        }
        ak() {
            return new NumericXAxis();
        }
        az() {
            if (this.d7) {
                return (TypeRegistrar.create('HorizontalSmartAxisLabelPanel'));
            }
            else {
                return new HorizontalAxisLabelPanel();
            }
        }
        oo() {
            let a = super.oo();
            a.b.c = (b) => {
                if ((this.a3 == null || this.a3.visibility == 0) && this.am != null) {
                    this.a0.bj = b;
                    if (this.a3 != null && (this.a3.location == 4 || this.a3.location == 5)) {
                        this.b0.o1();
                    }
                }
            };
            a.k = (b, c, d) => this.lg(c, d, b.aa, b.b, false);
            a.l = (b, c, d, e) => this.lh(c, d, e, b.aa);
            a.m = (b, c) => {
                let d = b.z;
                let e = new ScalerParams(0, b.ab, b.aa, this.dg, d);
                return this.ft(c, e);
            };
            a.q = (b, c) => true;
            a.j = (b) => this.j9(b.u, b.n, b.aa, b.a, true);
            a.e = (b) => {
                b.n = b.aa.bottom;
                if (this.am != null && this.am.b0 != null) {
                    let c = b.n;
                    let d = b.r;
                    let e = this.k9(c, d, b.ab, b.aa, b.z, b.aa.top, b.aa.bottom);
                    c = e.p0;
                    d = e.p1;
                    b.n = c;
                    b.r = d;
                }
            };
            a.p = (b, c, d) => {
                let e = Math.round(c);
                return e >= Math.floor(b.aa.left) && e <= Math.ceil(b.aa.right);
            };
            return a;
        }
        ft(a, b) {
            if (this.r6 != null) {
                return this.r6.p(a, b);
            }
            return this.r5.p(a, b);
        }
        fw(a, b) {
            if (this.r6 != null) {
                return this.r6.q(a, b);
            }
            return this.r5.q(a, b);
        }
        j6(a, b, c, d) {
            if (this.r6 != null) {
                this.r6.v(a, b, c, d);
                return;
            }
            this.r5.v(a, b, c, d);
        }
        j5(a, b, c, d, e) {
            if (this.r6 != null) {
                this.r6.u(a, b, c, d, e);
                return;
            }
            this.r5.u(a, b, c, d, e);
        }
        j7(a, b, c, d) {
            if (this.r6 != null) {
                this.r6.j(a, b, c, d);
                return;
            }
            this.r5.j(a, b, c, d);
        }
        so(a, b) {
            if (this.b0 == null || isNaN_(a) || isNaN_(b)) {
                return;
            }
            let c = this.sb(a, this);
            let d = this.sb(b, this);
            if (isNaN_(c) || isNaN_(d)) {
                return;
            }
            this.b0.x5 = new Rect(0, c, this.b0.x5.y, d - c, this.b0.x5.height);
        }
        or(a, b, c, d) {
            let e = d;
            let f = super.or(a, b, c, d);
            let g = new ScalerParams(0, b, a, this.df, c);
            let h = NaN;
            let i = NaN;
            if (!this.df && b.right == 1) {
                i = this.pq;
            }
            else if (this.df && b.left == 0) {
                h = this.pq;
            }
            if (isNaN_(h)) {
                h = this.fw(e.left, g);
            }
            if (isNaN_(i)) {
                i = this.fw(e.right, g);
            }
            let j = Math.min(h, i);
            let k = Math.max(h, i);
            this.pu = j;
            this.pt = k;
            f.k.add(((() => {
                let $ret = new RangeInfo();
                $ret.d = j;
                $ret.c = k;
                $ret.b = e.width;
                return $ret;
            })()));
            return f;
        }
        k4(a) {
            super.k4(a);
            let b = this.b0 != null ? this.b0.xm : Rect.empty;
            let c = !b.isEmpty ? this.n1 : Rect.empty;
            let d = this.nw();
            let e = this.nv();
            let f = this.oq.c(a, c, b, d, e);
            if (f != null) {
                this.pp = f.f.m;
                this.ps = f.f.l;
            }
        }
        li(a, b) {
            super.li(a, b);
            if (b.height != a.height) {
                this.d2();
            }
        }
        get_bk() {
            return 0;
        }
        get bk() {
            return this.get_bk();
        }
        ot() {
            if (this.pb) {
                return new HorizontalLogarithmicScaler();
            }
            switch (this.r4) {
                case 0: return new FastHorizontalLinearScaler();
                case 1: return new HorizontalLogarithmicScaler();
            }
            return null;
        }
        j$d(a, b) {
            return this.fw.apply(this, arguments);
        }
        j$c(a, b) {
            return this.ft.apply(this, arguments);
        }
        j$e(a, b, c, d, e) {
            this.j5.apply(this, arguments);
        }
        j$f(a, b, c, d) {
            this.j6.apply(this, arguments);
        }
        j$g(a, b, c, d) {
            this.j7.apply(this, arguments);
        }
        get j$b() {
            return this.df;
        }
        j$a() {
            return this.ag.apply(this, arguments);
        }
    }
    NumericXAxis.$t = markType(NumericXAxis, 'NumericXAxis', StraightNumericAxisBase.$, [IScaler_$type]);
    return NumericXAxis;
})();
/**
 * @hidden
 */
export let NumericXAxisView = /*@__PURE__*/ (() => {
    class NumericXAxisView extends StraightNumericAxisBaseView {
        constructor(a) {
            super(a);
            this.bo = null;
            this.bo = a;
        }
        al() {
            super.al();
            this.a.ni = AxisDefaults.axis_MajorBrush;
        }
    }
    NumericXAxisView.$t = markType(NumericXAxisView, 'NumericXAxisView', StraightNumericAxisBaseView.$);
    return NumericXAxisView;
})();
