/*
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-react-core";
import { HorizontalAxisLabelPanel } from "./HorizontalAxisLabelPanel";
import { ScalerParams } from "./ScalerParams";
import { Rect } from "igniteui-react-core";
import { RangeInfo } from "./RangeInfo";
import { HorizontalLogarithmicScaler } from "./HorizontalLogarithmicScaler";
import { FastHorizontalLinearScaler } from "./FastHorizontalLinearScaler";
import { isNaN_ } from "igniteui-react-core";
import { StraightNumericAxisBaseView } from "./StraightNumericAxisBaseView";
import { AxisDefaults } from "./AxisDefaults";
/**
 * @hidden
 */
export let NumericXAxis = /*@__PURE__*/ (() => {
    class NumericXAxis extends StraightNumericAxisBase {
        a4() {
            return new NumericXAxisView(this);
        }
        ht(a) {
            super.ht(a);
            this.n1 = a;
        }
        constructor() {
            super();
            this.ab = NumericXAxis.$;
            this.k1 = this.kz();
        }
        av() {
            if (this.c6) {
                return (TypeRegistrar.create('HorizontalSmartAxisLabelPanel'));
            }
            else {
                return new HorizontalAxisLabelPanel();
            }
        }
        kz() {
            let a = super.kz();
            a.b.c = (b) => {
                if ((this.az == null || this.az.visibility == 0) && this.aj != null) {
                    this.aw.bg = b;
                    if (this.az != null && (this.az.location == 4 || this.az.location == 5)) {
                        this.bi.nr();
                    }
                }
            };
            a.k = (b, c, d) => this.io(c, d, b.z, b.b, false);
            a.l = (b, c, d, e) => this.ip(c, d, e, b.z);
            a.m = (b, c) => {
                let d = b.y;
                let e = new ScalerParams(0, b.aa, b.z, this.ci, d);
                return this.ek(c, e);
            };
            a.q = (b, c) => true;
            a.j = (b) => this.hr(b.t, b.n, b.z, b.a, true);
            a.e = (b) => {
                b.n = b.z.bottom;
                if (this.aj != null && this.aj.bi != null) {
                    let c = b.n;
                    let d = b.r;
                    let e = this.ig(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 = (b, c, d) => {
                let e = Math.round(c);
                return e >= Math.floor(b.z.left) && e <= Math.ceil(b.z.right);
            };
            return a;
        }
        ek(a, b) {
            if (this.nk != null) {
                return this.nk.p(a, b);
            }
            return this.nj.p(a, b);
        }
        en(a, b) {
            if (this.nk != null) {
                return this.nk.q(a, b);
            }
            return this.nj.q(a, b);
        }
        ho(a, b, c, d) {
            if (this.nk != null) {
                this.nk.v(a, b, c, d);
                return;
            }
            this.nj.v(a, b, c, d);
        }
        hn(a, b, c, d, e) {
            if (this.nk != null) {
                this.nk.u(a, b, c, d, e);
                return;
            }
            this.nj.u(a, b, c, d, e);
        }
        hp(a, b, c, d) {
            if (this.nk != null) {
                this.nk.j(a, b, c, d);
                return;
            }
            this.nj.j(a, b, c, d);
        }
        n2(a, b) {
            if (this.bi == null || isNaN_(a) || isNaN_(b)) {
                return;
            }
            let c = this.np(a, this);
            let d = this.np(b, this);
            if (isNaN_(c) || isNaN_(d)) {
                return;
            }
            this.bi.v1 = new Rect(0, c, this.bi.v1.y, d - c, this.bi.v1.height);
        }
        k2(a, b, c, d) {
            let e = d;
            let f = super.k2(a, b, c, d);
            let g = new ScalerParams(0, b, a, this.ch, c);
            let h = NaN;
            let i = NaN;
            if (!this.ch && b.right == 1) {
                i = this.lx;
            }
            else if (this.ch && b.left == 0) {
                h = this.lx;
            }
            if (isNaN_(h)) {
                h = this.en(e.left, g);
            }
            if (isNaN_(i)) {
                i = this.en(e.right, g);
            }
            let j = Math.min(h, i);
            let k = Math.max(h, i);
            this.l1 = j;
            this.l0 = k;
            f.k.add(((() => {
                let $ret = new RangeInfo();
                $ret.d = j;
                $ret.c = k;
                $ret.b = e.width;
                return $ret;
            })()));
            return f;
        }
        ia(a) {
            super.ia(a);
            let b = this.bi != null ? this.bi.vl : Rect.empty;
            let c = !b.isEmpty ? this.ke : Rect.empty;
            let d = this.j9();
            let e = this.j8();
            let f = this.k1.c(a, c, b, d, e);
            if (f != null) {
                this.lw = f.f.m;
                this.lz = f.f.l;
            }
        }
        iq(a, b) {
            super.iq(a, b);
            if (b.height != a.height) {
                this.c1();
            }
        }
        get_a2() {
            return 0;
        }
        get a2() {
            return this.get_a2();
        }
        k4() {
            if (this.lj) {
                return new HorizontalLogarithmicScaler();
            }
            switch (this.ni) {
                case 0: return new FastHorizontalLinearScaler();
                case 1: return new HorizontalLogarithmicScaler();
            }
            return null;
        }
        j$d(a, b) {
            return this.en.apply(this, arguments);
        }
        j$c(a, b) {
            return this.ek.apply(this, arguments);
        }
        j$e(a, b, c, d, e) {
            this.hn.apply(this, arguments);
        }
        j$f(a, b, c, d) {
            this.ho.apply(this, arguments);
        }
        j$g(a, b, c, d) {
            this.hp.apply(this, arguments);
        }
        get j$b() {
            return this.ch;
        }
        j$a() {
            return this.ag.apply(this, arguments);
        }
    }
    NumericXAxis.$t = /*@__PURE__*/ 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.jx = AxisDefaults.h;
        }
    }
    NumericXAxisView.$t = /*@__PURE__*/ markType(NumericXAxisView, 'NumericXAxisView', StraightNumericAxisBaseView.$);
    return NumericXAxisView;
})();
