/*
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-react-core";
import { CategoryAxisBase } from "./CategoryAxisBase";
import { Point_$type, typeCast, Delegate_$type, markType, markDep } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { Thickness } from "igniteui-react-core";
import { AxisAnnotationFrame } from "./AxisAnnotationFrame";
import { List$1 } from "igniteui-react-core";
import { Dictionary$2 } from "igniteui-react-core";
import { Pool$1 } from "igniteui-react-core";
import { AxisAnnotation } from "./AxisAnnotation";
import { SeriesView } from "./SeriesView";
import { NotImplementedException } from "igniteui-react-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-react-core";
import { DeviceUtils } from "igniteui-react-core";
import { isNaN_, isInfinity } from "igniteui-react-core";
import { stringFormat } from "igniteui-react-core";
import { Path } from "igniteui-react-core";
/**
 * @hidden
 */
export let ValueOverlay = /*@__PURE__*/ (() => {
    class ValueOverlay extends Series {
        constructor() {
            super();
            this.ui = 0;
            this.uj = 0;
            this.uf = 0;
            this.t2 = null;
            this.t8 = null;
            this.t7 = null;
            this.ab = ValueOverlay.$;
        }
        h9(a, b, c) {
            return this.uk;
        }
        ug(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;
        }
        th(a, b, c) {
            if (this.t1 == null) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            let d = this.uh();
            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.t1.a2) {
                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.cj.bx.top + this.cj.bx.height * (f - this.cj.by.top) / this.cj.by.height;
                    e = this.cj.bx.left + this.cj.bx.width * (e - this.cj.by.left) / this.cj.by.width;
                    break;
                case 0:
                    e = d;
                    f = a.y;
                    f = this.cj.bx.top + this.cj.bx.height * (f - this.cj.by.top) / this.cj.by.height;
                    break;
                case 1:
                    f = d;
                    e = a.x;
                    e = this.cj.bx.left + this.cj.bx.width * (e - this.cj.by.left) / this.cj.by.width;
                    break;
                case 3:
                    g = this.ug(a, h);
                    i = d;
                    e = h.x + Math.cos(g) * i;
                    f = h.y + Math.sin(g) * i;
                    f = this.cj.bx.top + this.cj.bx.height * (f - this.cj.by.top) / this.cj.by.height;
                    e = this.cj.bx.left + this.cj.bx.width * (e - this.cj.by.left) / this.cj.by.width;
                    break;
            }
            return { $type: Point_$type, x: e, y: f };
        }
        i8(a) {
            throw new NotImplementedException(0);
        }
        jr(a) {
            return this;
        }
        fo(a) {
            return false;
        }
        aq(a) {
            let b = typeCast(NumericAxisBase.$, a);
            let c = this.uk;
            if (isNaN_(c) || isInfinity(c)) {
                return null;
            }
            return new AxisRange(c, c);
        }
        pq(a) {
            this.nj(true, this.cj);
            if (!this.t6()) {
                if (this.t2 != null) {
                    this.u3(NaN, this.dj());
                }
                return;
            }
            if (this.fp(a)) {
                if (this.dj()) {
                    if (this.cz.g) {
                        this.cz.t();
                    }
                    let b = this.ui;
                    this.ui = this.uj;
                    this.uj = b;
                }
                else {
                    this.ui = this.uf;
                }
                this.uf = this.uh();
                this.p3();
            }
            else {
                this.uf = this.uh();
                this.u2(this.uf, this.t4);
            }
        }
        uh() {
            let a, b;
            let c = this.getViewInfo(b, a);
            b = c.p0;
            a = c.p1;
            let d = this.getEffectiveViewport1(this.cj);
            let e = new ScalerParams(0, a, b, this.t1.ch, d);
            return this.t1.ej(this.uk, e);
        }
        u2(a, b) {
            if (this.t1 == null) {
                return;
            }
            let c = typeCast(CategoryAxisBase.$, this.t1);
            if (c != null && !c.ce) {
                if (this.uk > c.lg - 1) {
                    return;
                }
                if (c.categoryMode != 0) {
                    let d = this.getEffectiveViewport1(b);
                    let e = 0.5 * c.getCategorySize(b.by, b.bx, d);
                    let f = false;
                    if (c.cp && !c.ch) {
                        f = true;
                    }
                    if (typeCast(CategoryXAxis.$, c) !== null && c.ch) {
                        f = true;
                    }
                    if (f) {
                        e = -e;
                    }
                    a += e;
                }
            }
            let g = typeCast(NumericAxisBase.$, this.t1);
            if (g != null) {
                if (this.uk < g.lx || this.uk > g.lw) {
                    return;
                }
                if (g.lj && this.uk < 0) {
                    return;
                }
            }
            let h;
            switch (this.t1.a2) {
                case 2:
                case 3:
                    h = this.t1.j5(a, b.by, b.bx, this.getEffectiveViewport1(b), this.to(b));
                    break;
                default:
                    h = this.t1.j5(a, b.by, b.bx);
                    break;
            }
            if (h != null) {
                b.b1(h);
            }
            if (!b.q) {
                this.u3(a, this.dj());
            }
        }
        gl(a, b, c) {
            let d = true;
            d = super.gl(a, b, c);
            if (!c.o() || b.isEmpty || a.isEmpty || this.t1 == null || this.t1.bi == null) {
                d = false;
            }
            return d;
        }
        qn(a, b) {
            this.pp(false);
        }
        qm(a, b) {
            this.pp(false);
        }
        no(a, b, c, d) {
            throw new NotImplementedException(0);
        }
        o8(a, b, c, d) {
            super.o8(a, b, c, d);
            switch (b) {
                case ValueOverlay.$$p[11]:
                    if (c != null) {
                        c.b0(this);
                    }
                    if (d != null) {
                        d.ct(this);
                    }
                    this.pp(false);
                    this.ol();
                    break;
                case "TransitionProgress":
                    this.uj = this.ui + this.iv * (this.uf - this.ui);
                    if (this.dl(this.cj)) {
                        return;
                    }
                    if (this.iv == 1) {
                        this.u2(this.uf, this.t4);
                    }
                    else {
                        this.u2(this.uj, this.t4);
                    }
                    if (this.cy != null) {
                        this.cy.on(this);
                    }
                    break;
                case ValueOverlay.$$p[13]:
                    let e = typeCast(NumericAxisBase.$, this.t1);
                    if (e != null) {
                        e.c1();
                    }
                    this.pp(true);
                    this.om();
                    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.pp(true);
                    break;
            }
        }
        ob() {
            super.ob();
            if (this.t1 != null) {
                this.t1.h8(false);
            }
        }
        nj(a, b) {
            super.nj(a, b);
            let c = b;
            c.b0();
        }
        t6() {
            if (this.t1 == null || this.t1.bi == null || isNaN_(this.uk) || this._visibility != 0) {
                return false;
            }
            let a = typeCast(CategoryAxisBase.$, this.t1);
            if (a != null && a.lg == 0) {
                return false;
            }
            return true;
        }
        preferredCategoryMode(a) {
            return 0;
        }
        get categoryAxis() {
            return typeCast(CategoryAxisBase.$, this.t1);
        }
        cg() {
            return new ValueOverlayView(this);
        }
        o0(a) {
            super.o0(a);
            this.t4 = typeCast(ValueOverlayView.$, a);
        }
        pr(a, b) {
            super.pr(a, b);
            if (!this.f8) {
                this.cj.a4(b);
                return;
            }
            this.cj.a4(b);
            if (this.dl(this.ci) || !this.t6()) {
                return;
            }
            let c = this.getEffectiveViewport1(this.cj);
            let d = this.t1.ej(this.uk, new ScalerParams(0, this.ci.by, a, this.t1.ch, c));
            this.u2(d, typeCast(ValueOverlayView.$, this.ci));
            this.f8 = false;
        }
        getOffsetValue() {
            return 0;
        }
        getCategoryWidth() {
            return 0;
        }
        get vl() {
            return new Thickness(1, this.ub, this.ud, this.uc, this.ua);
        }
        ag() {
            return [this.t1];
        }
        u3(a, b) {
            if (isNaN_(a)) {
                if (this.t2 != null) {
                    AxisAnnotationFrameManager.b(this.t2);
                    AxisAnnotationFrameManager.d(this, this.t2, true, this.t7, this.t8, b, this.ul, this.ul, this.t3, this.t3);
                }
                return;
            }
            let c = false;
            if (this.t7 == null) {
                c = true;
                this.t8 = new List$1(Axis.$, 0);
                this.t7 = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
            }
            this.t2 = new AxisAnnotationFrame();
            let d = this.ss;
            if (d == null) {
                d = this.sw;
            }
            let e = this.t1.cp;
            AxisAnnotationFrameManager.c(this.t2, { $type: Point_$type, x: a, y: a }, this, this.cy, this.getEffectiveViewport(), d, this.vi, this.t9, this.vk, this.vj, this.vl, this.ue, this.vi, this.t9, this.vk, this.vj, this.vl, this.ue, !e && this.t5, e && this.t5);
            AxisAnnotationFrameManager.d(this, this.t2, c, this.t7, this.t8, b, this.ul, this.ul, this.t3, this.t3);
        }
        get_isValueOverlay() {
            return true;
        }
        uy(a) {
            if (this.t1 != null) {
                return this.t1.gd(a);
            }
            return null;
        }
        get u0() {
            let a = this.uy(this.uk);
            return a != null ? a : stringFormat("{0:0.##}", this.uk);
        }
    }
    ValueOverlay.$t = /*@__PURE__*/ markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]);
    ValueOverlay.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:t9:u4', [1, /*@__PURE__*/ DeviceUtils.g(3)], 'AxisAnnotationBackground:vi:u5', [Brush.$, null], 'AxisAnnotationFormatLabel:t3:u6', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:ul:u7', [1, -1], 'AxisAnnotationOutline:vj:u8', [Brush.$, null], 'AxisAnnotationPaddingBottom:ua:u9', [1, NaN], 'AxisAnnotationPaddingLeft:ub:va', [1, NaN], 'AxisAnnotationPaddingRight:uc:vb', [1, NaN], 'AxisAnnotationPaddingTop:ud:vc', [1, NaN], 'AxisAnnotationStrokeThickness:ue:vd', [1, NaN], 'AxisAnnotationTextColor:vk:ve', [Brush.$, null], 'Axis:t1:vf', [Axis.$, null], 'IsAxisAnnotationEnabled:t5:vg', [0, false], 'Value:uk:vh', [1, 0]]);
    return ValueOverlay;
})();
/**
 * @hidden
 */
export let ValueOverlayView = /*@__PURE__*/ (() => {
    class ValueOverlayView extends SeriesView {
        constructor(a) {
            super(a);
            this.b2 = null;
            this.b2 = new Path();
        }
        bd() {
            super.bd();
            this.b2._stroke = this.e.ss;
            this.b2.ad = this.e.hk;
            this.b2.ai = this.e.s7;
            this.b2.aj = this.e.s8;
        }
        be() {
            super.be();
            let a = this.br();
            this.b2._stroke = a;
            this.b2.ad = this.e.hk + 3;
            this.b2._stroke = a;
            this.b2.ad = this.e.hk + 3;
        }
        b1(a) {
            this.b2.an = a;
            this.as();
        }
        b0() {
            this.b2.an = null;
            this.as();
        }
        a8(a, b) {
            super.a8(a, b);
            if (a.d) {
                a.t(this.b2);
            }
        }
        an(a) {
            super.an(a);
            this.e.a9.exportPathData(a, this.b2, "ValueOverlayPath", []);
        }
    }
    ValueOverlayView.$t = /*@__PURE__*/ markType(ValueOverlayView, 'ValueOverlayView', SeriesView.$);
    return ValueOverlayView;
})();
