/*
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 { Series } from "./Series";
import { IHasCategoryModePreference_$type } from "./IHasCategoryModePreference";
import { Axis } from "./Axis";
import { DependencyProperty } from "igniteui-angular-core";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { Point_$type, typeCast, Delegate_$type, markType, markDep } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { Thickness } from "igniteui-angular-core";
import { AxisAnnotationFrame } from "./AxisAnnotationFrame";
import { List$1 } from "igniteui-angular-core";
import { Dictionary$2 } from "igniteui-angular-core";
import { Pool$1 } from "igniteui-angular-core";
import { AxisAnnotation } from "./AxisAnnotation";
import { SeriesView } from "./SeriesView";
import { NotImplementedException } from "igniteui-angular-core";
import { AxisRange } from "./AxisRange";
import { NumericAxisBase } from "./NumericAxisBase";
import { ScalerParams } from "./ScalerParams";
import { CategoryXAxis } from "./CategoryXAxis";
import { AxisAnnotationFrameManager } from "./AxisAnnotationFrameManager";
import { PropertyMetadata } from "igniteui-angular-core";
import { DeviceUtils } from "igniteui-angular-core";
import { isNaN_, isInfinity } from "igniteui-angular-core";
import { stringFormat } from "igniteui-angular-core";
import { Path } from "igniteui-angular-core";
/**
 * @hidden
 */
export let ValueOverlay = /*@__PURE__*/ (() => {
    class ValueOverlay extends Series {
        constructor() {
            super();
            this.qk = 0;
            this.ql = 0;
            this.qh = 0;
            this.p4 = null;
            this.qa = null;
            this.p9 = null;
            this.ab = ValueOverlay.$;
        }
        gj(a, b, c) {
            return this.qm;
        }
        qi(a, b) {
            let c = Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
            let d = Math.acos((a.x - b.x) / c);
            if ((a.y - b.y) < 0) {
                d = (2 * Math.PI) - d;
            }
            return d;
        }
        pl(a, b, c) {
            if (this.p3 == null) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            let d = this.qj();
            let e = NaN;
            let f = NaN;
            let g = NaN;
            let h = { $type: Point_$type, x: 0.5, y: 0.5 };
            let i = NaN;
            switch (this.p3.a1) {
                case 2:
                    i = Math.sqrt(Math.pow(a.x - h.x, 2) + Math.pow(a.y - h.y, 2));
                    g = d;
                    e = h.x + Math.cos(g) * i;
                    f = h.y + Math.sin(g) * i;
                    f = this.b0.bu.top + this.b0.bu.height * (f - this.b0.bv.top) / this.b0.bv.height;
                    e = this.b0.bu.left + this.b0.bu.width * (e - this.b0.bv.left) / this.b0.bv.width;
                    break;
                case 0:
                    e = d;
                    f = a.y;
                    f = this.b0.bu.top + this.b0.bu.height * (f - this.b0.bv.top) / this.b0.bv.height;
                    break;
                case 1:
                    f = d;
                    e = a.x;
                    e = this.b0.bu.left + this.b0.bu.width * (e - this.b0.bv.left) / this.b0.bv.width;
                    break;
                case 3:
                    g = this.qi(a, h);
                    i = d;
                    e = h.x + Math.cos(g) * i;
                    f = h.y + Math.sin(g) * i;
                    f = this.b0.bu.top + this.b0.bu.height * (f - this.b0.bv.top) / this.b0.bv.height;
                    e = this.b0.bu.left + this.b0.bu.width * (e - this.b0.bv.left) / this.b0.bv.width;
                    break;
            }
            return { $type: Point_$type, x: e, y: f };
        }
        hd(a) {
            throw new NotImplementedException(0);
        }
        ht(a) {
            return this;
        }
        en(a) {
            return false;
        }
        ap(a) {
            let b = typeCast(NumericAxisBase.$, a);
            let c = this.qm;
            if (isNaN_(c) || isInfinity(c)) {
                return null;
            }
            return new AxisRange(c, c);
        }
        mi(a) {
            this.kx(true, this.b0);
            if (!this.p8()) {
                if (this.p4 != null) {
                    this.q5(NaN, this.cv());
                }
                return;
            }
            if (this.eo(a)) {
                if (this.cv()) {
                    if (this.ce.g) {
                        this.ce.t();
                    }
                    let b = this.qk;
                    this.qk = this.ql;
                    this.ql = b;
                }
                else {
                    this.qk = this.qh;
                }
                this.qh = this.qj();
                this.mq();
            }
            else {
                this.qh = this.qj();
                this.q4(this.qh, this.p6);
            }
        }
        qj() {
            let a, b;
            let c = this.getViewInfo(b, a);
            b = c.p0;
            a = c.p1;
            let d = this.getEffectiveViewport1(this.b0);
            let e = new ScalerParams(0, a, b, this.p3.cg, d);
            return this.p3.ei(this.qm, e);
        }
        q4(a, b) {
            if (this.p3 == null) {
                return;
            }
            let c = typeCast(CategoryAxisBase.$, this.p3);
            if (c != null && !c.cd) {
                if (this.qm > c.lf - 1) {
                    return;
                }
                if (c.categoryMode != 0) {
                    let d = this.getEffectiveViewport1(b);
                    let e = 0.5 * c.getCategorySize(b.bv, b.bu, d);
                    let f = false;
                    if (c.co && !c.cg) {
                        f = true;
                    }
                    if (typeCast(CategoryXAxis.$, c) !== null && c.cg) {
                        f = true;
                    }
                    if (f) {
                        e = -e;
                    }
                    a += e;
                }
            }
            let g = typeCast(NumericAxisBase.$, this.p3);
            if (g != null) {
                if (this.qm < g.lv || this.qm > g.lu) {
                    return;
                }
                if (g.lh && this.qm < 0) {
                    return;
                }
            }
            let h;
            switch (this.p3.a1) {
                case 2:
                case 3:
                    h = this.p3.j4(a, b.bv, b.bu, this.getEffectiveViewport1(b), this.pq(b));
                    break;
                default:
                    h = this.p3.j4(a, b.bv, b.bu);
                    break;
            }
            if (h != null) {
                b.by(h);
            }
            if (!b.q) {
                this.q5(a, this.cv());
            }
        }
        e9(a, b, c) {
            let d = true;
            d = super.e9(a, b, c);
            if (!c.o() || b.isEmpty || a.isEmpty || this.p3 == null || this.p3.bh == null) {
                d = false;
            }
            return d;
        }
        m5(a, b) {
            this.mh(false);
        }
        m4(a, b) {
            this.mh(false);
        }
        k0(a, b, c, d) {
            throw new NotImplementedException(0);
        }
        l3(a, b, c, d) {
            super.l3(a, b, c, d);
            switch (b) {
                case ValueOverlay.$$p[11]:
                    if (c != null) {
                        c.bz(this);
                    }
                    if (d != null) {
                        d.cs(this);
                    }
                    this.mh(false);
                    this.lo();
                    break;
                case "TransitionProgress":
                    this.ql = this.qk + this.g0 * (this.qh - this.qk);
                    if (this.cx(this.b0)) {
                        return;
                    }
                    if (this.g0 == 1) {
                        this.q4(this.qh, this.p6);
                    }
                    else {
                        this.q4(this.ql, this.p6);
                    }
                    if (this.cd != null) {
                        this.cd.nn(this);
                    }
                    break;
                case ValueOverlay.$$p[13]:
                    let e = typeCast(NumericAxisBase.$, this.p3);
                    if (e != null) {
                        e.c0();
                    }
                    this.mh(true);
                    this.lp();
                    break;
                case ValueOverlay.$$p[12]:
                case ValueOverlay.$$p[10]:
                case ValueOverlay.$$p[1]:
                case ValueOverlay.$$p[0]:
                case ValueOverlay.$$p[3]:
                case ValueOverlay.$$p[4]:
                case ValueOverlay.$$p[9]:
                case ValueOverlay.$$p[5]:
                case ValueOverlay.$$p[6]:
                case ValueOverlay.$$p[7]:
                case ValueOverlay.$$p[8]:
                    this.mh(true);
                    break;
            }
        }
        le() {
            super.le();
            if (this.p3 != null) {
                this.p3.h7(false);
            }
        }
        kx(a, b) {
            super.kx(a, b);
            let c = b;
            c.bx();
        }
        p8() {
            if (this.p3 == null || this.p3.bh == null || isNaN_(this.qm) || this._visibility != 0) {
                return false;
            }
            let a = typeCast(CategoryAxisBase.$, this.p3);
            if (a != null && a.lf == 0) {
                return false;
            }
            return true;
        }
        preferredCategoryMode(a) {
            return 0;
        }
        get categoryAxis() {
            return typeCast(CategoryAxisBase.$, this.p3);
        }
        bx() {
            return new ValueOverlayView(this);
        }
        ly(a) {
            super.ly(a);
            this.p6 = typeCast(ValueOverlayView.$, a);
        }
        mj(a, b) {
            super.mj(a, b);
            if (!this.ez) {
                this.b0.a2(b);
                return;
            }
            this.b0.a2(b);
            if (this.cx(this.bz) || !this.p8()) {
                return;
            }
            let c = this.getEffectiveViewport1(this.b0);
            let d = this.p3.ei(this.qm, new ScalerParams(0, this.bz.bv, a, this.p3.cg, c));
            this.q4(d, typeCast(ValueOverlayView.$, this.bz));
            this.ez = false;
        }
        getOffsetValue() {
            return 0;
        }
        getCategoryWidth() {
            return 0;
        }
        get rn() {
            return new Thickness(1, this.qd, this.qf, this.qe, this.qc);
        }
        ag() {
            return [this.p3];
        }
        q5(a, b) {
            if (isNaN_(a)) {
                if (this.p4 != null) {
                    AxisAnnotationFrameManager.b(this.p4);
                    AxisAnnotationFrameManager.d(this, this.p4, true, this.p9, this.qa, b, this.qn, this.qn, this.p5, this.p5);
                }
                return;
            }
            let c = false;
            if (this.p9 == null) {
                c = true;
                this.qa = new List$1(Axis.$, 0);
                this.p9 = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
            }
            this.p4 = new AxisAnnotationFrame();
            let d = this.oy;
            if (d == null) {
                d = this.o2;
            }
            let e = this.p3.co;
            AxisAnnotationFrameManager.c(this.p4, { $type: Point_$type, x: a, y: a }, this, this.cd, this.getEffectiveViewport(), d, this.rk, this.qb, this.rm, this.rl, this.rn, this.qg, this.rk, this.qb, this.rm, this.rl, this.rn, this.qg, !e && this.p7, e && this.p7);
            AxisAnnotationFrameManager.d(this, this.p4, c, this.p9, this.qa, b, this.qn, this.qn, this.p5, this.p5);
        }
        get_isValueOverlay() {
            return true;
        }
        q0(a) {
            if (this.p3 != null) {
                return this.p3.gc(a);
            }
            return null;
        }
        get q2() {
            let a = this.q0(this.qm);
            return a != null ? a : stringFormat("{0:0.##}", this.qm);
        }
    }
    ValueOverlay.$t = markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]);
    ValueOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:qb:q6', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:rk:q7', [Brush.$, null], 'AxisAnnotationFormatLabel:p5:q8', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:qn:q9', [1, -1], 'AxisAnnotationOutline:rl:ra', [Brush.$, null], 'AxisAnnotationPaddingBottom:qc:rb', [1, NaN], 'AxisAnnotationPaddingLeft:qd:rc', [1, NaN], 'AxisAnnotationPaddingRight:qe:rd', [1, NaN], 'AxisAnnotationPaddingTop:qf:re', [1, NaN], 'AxisAnnotationStrokeThickness:qg:rf', [1, NaN], 'AxisAnnotationTextColor:rm:rg', [Brush.$, null], 'Axis:p3:rh', [Axis.$, null], 'IsAxisAnnotationEnabled:p7:ri', [0, false], 'Value:qm:rj', [1, 0]]);
    return ValueOverlay;
})();
/**
 * @hidden
 */
export let ValueOverlayView = /*@__PURE__*/ (() => {
    class ValueOverlayView extends SeriesView {
        constructor(a) {
            super(a);
            this.bz = null;
            this.bz = new Path();
        }
        bb() {
            super.bb();
            this.bz._stroke = this.e.oy;
            this.bz.ac = this.e.fu;
            this.bz.ai = this.e.pb;
            this.bz.ad = this.e.pc;
        }
        bc() {
            super.bc();
            let a = this.bo();
            this.bz._stroke = a;
            this.bz.ac = this.e.fu + 3;
            this.bz._stroke = a;
            this.bz.ac = this.e.fu + 3;
        }
        by(a) {
            this.bz.ak = a;
            this.aq();
        }
        bx() {
            this.bz.ak = null;
            this.aq();
        }
        a6(a, b) {
            super.a6(a, b);
            if (a.d) {
                a.s(this.bz);
            }
        }
        al(a) {
            super.al(a);
            this.e.a8.exportPathData(a, this.bz, "ValueOverlayPath", []);
        }
    }
    ValueOverlayView.$t = markType(ValueOverlayView, 'ValueOverlayView', SeriesView.$);
    return ValueOverlayView;
})();
