/*
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 { 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 { AxisAnnotationFrame } from "./AxisAnnotationFrame";
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 {
        bj() {
            return new ValueOverlay();
        }
        constructor() {
            super();
            this.xd = 0;
            this.xe = 0;
            this.xa = 0;
            this.wx = null;
            this.w3 = null;
            this.w2 = null;
            this.ab = ValueOverlay.$;
        }
        i5(a, b, c) {
            return this.xf;
        }
        xb(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;
        }
        wa(a, b, c) {
            if (this.ww == null) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            let d = this.xc();
            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.ww.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.cv.bx.top + this.cv.bx.height * (f - this.cv.by.top) / this.cv.by.height;
                    e = this.cv.bx.left + this.cv.bx.width * (e - this.cv.by.left) / this.cv.by.width;
                    break;
                case 0:
                    e = d;
                    f = a.y;
                    f = this.cv.bx.top + this.cv.bx.height * (f - this.cv.by.top) / this.cv.by.height;
                    break;
                case 1:
                    f = d;
                    e = a.x;
                    e = this.cv.bx.left + this.cv.bx.width * (e - this.cv.by.left) / this.cv.by.width;
                    break;
                case 3:
                    g = this.xb(a, h);
                    i = d;
                    e = h.x + Math.cos(g) * i;
                    f = h.y + Math.sin(g) * i;
                    f = this.cv.bx.top + this.cv.bx.height * (f - this.cv.by.top) / this.cv.by.height;
                    e = this.cv.bx.left + this.cv.bx.width * (e - this.cv.by.left) / this.cv.by.width;
                    break;
            }
            return { $type: Point_$type, x: e, y: f };
        }
        j3(a) {
            throw new NotImplementedException(0);
        }
        kn(a) {
            return this;
        }
        gd(a) {
            return false;
        }
        ay(a) {
            let b = typeCast(NumericAxisBase.$, a);
            let c = this.xf;
            if (isNaN_(c) || isInfinity(c)) {
                return null;
            }
            return new AxisRange(c, c);
        }
        rq(a) {
            this.o5(true, this.cv);
            if (!this.w1()) {
                if (this.wx != null) {
                    this.xy(NaN, this.d3());
                }
                return;
            }
            if (this.gf(a)) {
                if (this.d3()) {
                    if (this.dc.g) {
                        this.dc.t();
                    }
                    let b = this.xd;
                    this.xd = this.xe;
                    this.xe = b;
                }
                else {
                    this.xd = this.xa;
                }
                this.xa = this.xc();
                this.r5();
            }
            else {
                this.xa = this.xc();
                this.xx(this.xa, this.wz);
            }
        }
        xc() {
            let a, b;
            let c = this.getViewInfo(b, a);
            b = c.p0;
            a = c.p1;
            let d = this.getEffectiveViewport1(this.cv);
            let e = new ScalerParams(0, a, b, this.ww.ch, d);
            return this.ww.el(this.xf, e);
        }
        xx(a, b) {
            if (this.ww == null) {
                return;
            }
            let c = typeCast(CategoryAxisBase.$, this.ww);
            if (c != null && !c.ce) {
                if (this.xf > c.lk - 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.ww);
            if (g != null) {
                if (this.xf < g.l4 || this.xf > g.l3) {
                    return;
                }
                if (g.lp && this.xf < 0) {
                    return;
                }
            }
            let h;
            switch (this.ww.a2) {
                case 2:
                case 3:
                    h = this.ww.j8(a, b.by, b.bx, this.getEffectiveViewport1(b), this.wh(b));
                    break;
                default:
                    h = this.ww.j8(a, b.by, b.bx, this.getEffectiveViewport1(b), this.wh(b));
                    break;
            }
            if (h != null) {
                b.b1(h);
            }
            if (!b.q) {
                this.xy(a, this.d3());
            }
        }
        he(a, b, c) {
            let d = true;
            d = super.he(a, b, c);
            if (!c.o() || b.isEmpty || a.isEmpty || this.ww == null || this.ww.bi == null) {
                d = false;
            }
            return d;
        }
        sp(a, b) {
            this.rp(false);
        }
        so(a, b) {
            this.rp(false);
        }
        pb(a, b, c, d) {
            throw new NotImplementedException(0);
        }
        q7(a, b, c, d) {
            super.q7(a, b, c, d);
            switch (b) {
                case ValueOverlay.$$p[11]:
                    if (c != null) {
                        c.b0(this);
                    }
                    if (d != null) {
                        d.ct(this);
                    }
                    this.rp(false);
                    this.qj();
                    break;
                case "TransitionProgress":
                    this.xe = this.xd + this.jq * (this.xa - this.xd);
                    if (this.d5(this.cv)) {
                        return;
                    }
                    if (this.jq == 1) {
                        this.xx(this.xa, this.wz);
                        this.qm();
                    }
                    else {
                        this.xx(this.xe, this.wz);
                    }
                    if (this.db != null) {
                        this.db.qo(this);
                    }
                    break;
                case ValueOverlay.$$p[13]:
                    let e = typeCast(NumericAxisBase.$, this.ww);
                    if (e != null) {
                        e.c1();
                    }
                    this.rp(true);
                    this.qk();
                    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.rp(true);
                    break;
            }
        }
        p9() {
            super.p9();
            if (this.ww != null) {
                this.ww.ib(false);
            }
        }
        o5(a, b) {
            super.o5(a, b);
            let c = b;
            c.b0();
        }
        w1() {
            if (this.ww == null || this.ww.bi == null || isNaN_(this.xf) || this._visibility != 0) {
                return false;
            }
            let a = typeCast(CategoryAxisBase.$, this.ww);
            if (a != null && a.lk == 0) {
                return false;
            }
            return true;
        }
        preferredCategoryMode(a) {
            return 0;
        }
        get categoryAxis() {
            return typeCast(CategoryAxisBase.$, this.ww);
        }
        cs() {
            return new ValueOverlayView(this);
        }
        qz(a) {
            super.qz(a);
            this.wz = typeCast(ValueOverlayView.$, a);
        }
        rr(a, b) {
            super.rr(a, b);
            if (!this.g0) {
                this.cv.a4(b);
                return;
            }
            this.cv.a4(b);
            if (this.d5(this.cu) || !this.w1()) {
                return;
            }
            let c = this.getEffectiveViewport1(this.cv);
            let d = this.ww.el(this.xf, new ScalerParams(0, this.cu.by, a, this.ww.ch, c));
            this.xx(d, typeCast(ValueOverlayView.$, this.cu));
            this.g0 = false;
        }
        getOffsetValue() {
            return 0;
        }
        getCategoryWidth() {
            return 0;
        }
        get yg() {
            return new Thickness(1, this.w6, this.w8, this.w7, this.w5);
        }
        ai() {
            return [this.ww];
        }
        xy(a, b) {
            if (isNaN_(a)) {
                if (this.wx != null) {
                    AxisAnnotationFrameManager.b(this.wx);
                    AxisAnnotationFrameManager.d(this, this.wx, true, this.w2, this.w3, b, this.xg, this.xg, this.wy, this.wy);
                }
                return;
            }
            let c = false;
            if (this.w2 == null) {
                c = true;
                this.w3 = new List$1(Axis.$, 0);
                this.w2 = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
            }
            this.wx = new AxisAnnotationFrame();
            let d = this.u7;
            if (d == null) {
                d = this.vd;
            }
            let e = this.ww.cp;
            AxisAnnotationFrameManager.c(this.wx, { $type: Point_$type, x: a, y: a }, this, this.db, this.getEffectiveViewport(), d, this.yd, this.w4, this.yf, this.ye, this.yg, this.w9, this.yd, this.w4, this.yf, this.ye, this.yg, this.w9, !e && this.w0, e && this.w0);
            AxisAnnotationFrameManager.d(this, this.wx, c, this.w2, this.w3, b, this.xg, this.xg, this.wy, this.wy);
        }
        get_isValueOverlay() {
            return true;
        }
        xt(a) {
            if (this.ww != null) {
                return this.ww.gf(a);
            }
            return null;
        }
        get xv() {
            let a = this.xt(this.xf);
            return a != null ? a : stringFormat("{0:0.##}", this.xf);
        }
    }
    ValueOverlay.$t = /*@__PURE__*/ markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]);
    ValueOverlay.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:w4:xz', [1, /*@__PURE__*/ DeviceUtils.g(3)], 'AxisAnnotationBackground:yd:x0', [Brush.$, null], 'AxisAnnotationFormatLabel:wy:x1', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:xg:x2', [1, -1], 'AxisAnnotationOutline:ye:x3', [Brush.$, null], 'AxisAnnotationPaddingBottom:w5:x4', [1, NaN], 'AxisAnnotationPaddingLeft:w6:x5', [1, NaN], 'AxisAnnotationPaddingRight:w7:x6', [1, NaN], 'AxisAnnotationPaddingTop:w8:x7', [1, NaN], 'AxisAnnotationStrokeThickness:w9:x8', [1, NaN], 'AxisAnnotationTextColor:yf:x9', [Brush.$, null], 'Axis:ww:ya', [Axis.$, null], 'IsAxisAnnotationEnabled:w0:yb', [0, false], 'Value:xf:yc', [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.u7;
            this.b2.ad = this.e.ie;
            this.b2.ai = this.e.v0;
            this.b2.aj = this.e.v1;
        }
        be() {
            super.be();
            let a = this.br();
            this.b2._stroke = a;
            this.b2.ad = this.e.ie + 3;
            this.b2._stroke = a;
            this.b2.ad = this.e.ie + 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.bc.exportPathData(a, this.b2, "ValueOverlayPath", []);
        }
    }
    ValueOverlayView.$t = /*@__PURE__*/ markType(ValueOverlayView, 'ValueOverlayView', SeriesView.$);
    return ValueOverlayView;
})();
