/*
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 {
        bi() {
            return new ValueOverlay();
        }
        constructor() {
            super();
            this.w6 = 0;
            this.w7 = 0;
            this.w3 = 0;
            this.wq = null;
            this.ww = null;
            this.wv = null;
            this.ab = ValueOverlay.$;
        }
        i3(a, b, c) {
            return this.w8;
        }
        w4(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;
        }
        v5(a, b, c) {
            if (this.wp == null) {
                return { $type: Point_$type, x: NaN, y: NaN };
            }
            let d = this.w5();
            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.wp.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.ct.bx.top + this.ct.bx.height * (f - this.ct.by.top) / this.ct.by.height;
                    e = this.ct.bx.left + this.ct.bx.width * (e - this.ct.by.left) / this.ct.by.width;
                    break;
                case 0:
                    e = d;
                    f = a.y;
                    f = this.ct.bx.top + this.ct.bx.height * (f - this.ct.by.top) / this.ct.by.height;
                    break;
                case 1:
                    f = d;
                    e = a.x;
                    e = this.ct.bx.left + this.ct.bx.width * (e - this.ct.by.left) / this.ct.by.width;
                    break;
                case 3:
                    g = this.w4(a, h);
                    i = d;
                    e = h.x + Math.cos(g) * i;
                    f = h.y + Math.sin(g) * i;
                    f = this.ct.bx.top + this.ct.bx.height * (f - this.ct.by.top) / this.ct.by.height;
                    e = this.ct.bx.left + this.ct.bx.width * (e - this.ct.by.left) / this.ct.by.width;
                    break;
            }
            return { $type: Point_$type, x: e, y: f };
        }
        j1(a) {
            throw new NotImplementedException(0);
        }
        kl(a) {
            return this;
        }
        gb(a) {
            return false;
        }
        ax(a) {
            let b = typeCast(NumericAxisBase.$, a);
            let c = this.w8;
            if (isNaN_(c) || isInfinity(c)) {
                return null;
            }
            return new AxisRange(c, c);
        }
        rn(a) {
            this.o2(true, this.ct);
            if (!this.wu()) {
                if (this.wq != null) {
                    this.xr(NaN, this.d1());
                }
                return;
            }
            if (this.gd(a)) {
                if (this.d1()) {
                    if (this.da.g) {
                        this.da.t();
                    }
                    let b = this.w6;
                    this.w6 = this.w7;
                    this.w7 = b;
                }
                else {
                    this.w6 = this.w3;
                }
                this.w3 = this.w5();
                this.r0();
            }
            else {
                this.w3 = this.w5();
                this.xq(this.w3, this.ws);
            }
        }
        w5() {
            let a, b;
            let c = this.getViewInfo(b, a);
            b = c.p0;
            a = c.p1;
            let d = this.getEffectiveViewport1(this.ct);
            let e = new ScalerParams(0, a, b, this.wp.ch, d);
            return this.wp.ek(this.w8, e);
        }
        xq(a, b) {
            if (this.wp == null) {
                return;
            }
            let c = typeCast(CategoryAxisBase.$, this.wp);
            if (c != null && !c.ce) {
                if (this.w8 > c.lh - 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.wp);
            if (g != null) {
                if (this.w8 < g.ly || this.w8 > g.lx) {
                    return;
                }
                if (g.lk && this.w8 < 0) {
                    return;
                }
            }
            let h;
            switch (this.wp.a2) {
                case 2:
                case 3:
                    h = this.wp.j6(a, b.by, b.bx, this.getEffectiveViewport1(b), this.wc(b));
                    break;
                default:
                    h = this.wp.j6(a, b.by, b.bx, this.getEffectiveViewport1(b), this.wc(b));
                    break;
            }
            if (h != null) {
                b.b1(h);
            }
            if (!b.q) {
                this.xr(a, this.d1());
            }
        }
        hc(a, b, c) {
            let d = true;
            d = super.hc(a, b, c);
            if (!c.o() || b.isEmpty || a.isEmpty || this.wp == null || this.wp.bi == null) {
                d = false;
            }
            return d;
        }
        sk(a, b) {
            this.rm(false);
        }
        sj(a, b) {
            this.rm(false);
        }
        o8(a, b, c, d) {
            throw new NotImplementedException(0);
        }
        q4(a, b, c, d) {
            super.q4(a, b, c, d);
            switch (b) {
                case ValueOverlay.$$p[11]:
                    if (c != null) {
                        c.b0(this);
                    }
                    if (d != null) {
                        d.ct(this);
                    }
                    this.rm(false);
                    this.qg();
                    break;
                case "TransitionProgress":
                    this.w7 = this.w6 + this.jo * (this.w3 - this.w6);
                    if (this.d3(this.ct)) {
                        return;
                    }
                    if (this.jo == 1) {
                        this.xq(this.w3, this.ws);
                        this.qj();
                    }
                    else {
                        this.xq(this.w7, this.ws);
                    }
                    if (this.c9 != null) {
                        this.c9.qa(this);
                    }
                    break;
                case ValueOverlay.$$p[13]:
                    let e = typeCast(NumericAxisBase.$, this.wp);
                    if (e != null) {
                        e.c1();
                    }
                    this.rm(true);
                    this.qh();
                    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.rm(true);
                    break;
            }
        }
        p5() {
            super.p5();
            if (this.wp != null) {
                this.wp.h9(false);
            }
        }
        o2(a, b) {
            super.o2(a, b);
            let c = b;
            c.b0();
        }
        wu() {
            if (this.wp == null || this.wp.bi == null || isNaN_(this.w8) || this._visibility != 0) {
                return false;
            }
            let a = typeCast(CategoryAxisBase.$, this.wp);
            if (a != null && a.lh == 0) {
                return false;
            }
            return true;
        }
        preferredCategoryMode(a) {
            return 0;
        }
        get categoryAxis() {
            return typeCast(CategoryAxisBase.$, this.wp);
        }
        cq() {
            return new ValueOverlayView(this);
        }
        qw(a) {
            super.qw(a);
            this.ws = typeCast(ValueOverlayView.$, a);
        }
        ro(a, b) {
            super.ro(a, b);
            if (!this.gy) {
                this.ct.a4(b);
                return;
            }
            this.ct.a4(b);
            if (this.d3(this.cs) || !this.wu()) {
                return;
            }
            let c = this.getEffectiveViewport1(this.ct);
            let d = this.wp.ek(this.w8, new ScalerParams(0, this.cs.by, a, this.wp.ch, c));
            this.xq(d, typeCast(ValueOverlayView.$, this.cs));
            this.gy = false;
        }
        getOffsetValue() {
            return 0;
        }
        getCategoryWidth() {
            return 0;
        }
        get x9() {
            return new Thickness(1, this.wz, this.w1, this.w0, this.wy);
        }
        ai() {
            return [this.wp];
        }
        xr(a, b) {
            if (isNaN_(a)) {
                if (this.wq != null) {
                    AxisAnnotationFrameManager.b(this.wq);
                    AxisAnnotationFrameManager.d(this, this.wq, true, this.wv, this.ww, b, this.w9, this.w9, this.wr, this.wr);
                }
                return;
            }
            let c = false;
            if (this.wv == null) {
                c = true;
                this.ww = new List$1(Axis.$, 0);
                this.wv = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
            }
            this.wq = new AxisAnnotationFrame();
            let d = this.u2;
            if (d == null) {
                d = this.u8;
            }
            let e = this.wp.cp;
            AxisAnnotationFrameManager.c(this.wq, { $type: Point_$type, x: a, y: a }, this, this.c9, this.getEffectiveViewport(), d, this.x6, this.wx, this.x8, this.x7, this.x9, this.w2, this.x6, this.wx, this.x8, this.x7, this.x9, this.w2, !e && this.wt, e && this.wt);
            AxisAnnotationFrameManager.d(this, this.wq, c, this.wv, this.ww, b, this.w9, this.w9, this.wr, this.wr);
        }
        get_isValueOverlay() {
            return true;
        }
        xm(a) {
            if (this.wp != null) {
                return this.wp.ge(a);
            }
            return null;
        }
        get xo() {
            let a = this.xm(this.w8);
            return a != null ? a : stringFormat("{0:0.##}", this.w8);
        }
    }
    ValueOverlay.$t = /*@__PURE__*/ markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]);
    ValueOverlay.$$p = /*@__PURE__*/ markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:wx:xs', [1, /*@__PURE__*/ DeviceUtils.g(3)], 'AxisAnnotationBackground:x6:xt', [Brush.$, null], 'AxisAnnotationFormatLabel:wr:xu', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:w9:xv', [1, -1], 'AxisAnnotationOutline:x7:xw', [Brush.$, null], 'AxisAnnotationPaddingBottom:wy:xx', [1, NaN], 'AxisAnnotationPaddingLeft:wz:xy', [1, NaN], 'AxisAnnotationPaddingRight:w0:xz', [1, NaN], 'AxisAnnotationPaddingTop:w1:x0', [1, NaN], 'AxisAnnotationStrokeThickness:w2:x1', [1, NaN], 'AxisAnnotationTextColor:x8:x2', [Brush.$, null], 'Axis:wp:x3', [Axis.$, null], 'IsAxisAnnotationEnabled:wt:x4', [0, false], 'Value:w8:x5', [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.u2;
            this.b2.ad = this.e.ic;
            this.b2.ai = this.e.vv;
            this.b2.aj = this.e.vw;
        }
        be() {
            super.be();
            let a = this.br();
            this.b2._stroke = a;
            this.b2.ad = this.e.ic + 3;
            this.b2._stroke = a;
            this.b2.ad = this.e.ic + 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.bb.exportPathData(a, this.b2, "ValueOverlayPath", []);
        }
    }
    ValueOverlayView.$t = /*@__PURE__*/ markType(ValueOverlayView, 'ValueOverlayView', SeriesView.$);
    return ValueOverlayView;
})();
