/*
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 * as tslib_1 from "tslib";
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 { isNaN_, isInfinity } from "igniteui-react-core";
import { stringFormat } from "igniteui-react-core";
import { Path } from "igniteui-react-core";
/**
 * @hidden
 */
var ValueOverlay = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(ValueOverlay, _super);
    function ValueOverlay() {
        var _this = _super.call(this) || this;
        _this.op = 0;
        _this.oq = 0;
        _this.om = 0;
        _this.oa = null;
        _this.og = null;
        _this.of = null;
        _this.ab = ValueOverlay.$;
        return _this;
    }
    ValueOverlay.prototype.fh = function (a, b, c) {
        return this.or;
    };
    ValueOverlay.prototype.on = function (a, b) {
        var c = Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
        var d = Math.acos((a.x - b.x) / c);
        if ((a.y - b.y) < 0) {
            d = (2 * Math.PI) - d;
        }
        return d;
    };
    ValueOverlay.prototype.nt = function (a, b, c) {
        if (this.n9 == null) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        var d = this.oo();
        var e = NaN;
        var f = NaN;
        var g = NaN;
        var h = { $type: Point_$type, x: 0.5, y: 0.5 };
        var i = NaN;
        switch (this.n9.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.bs.bu.top + this.bs.bu.height * (f - this.bs.bv.top) / this.bs.bv.height;
                e = this.bs.bu.left + this.bs.bu.width * (e - this.bs.bv.left) / this.bs.bv.width;
                break;
            case 0:
                e = d;
                f = a.y;
                f = this.bs.bu.top + this.bs.bu.height * (f - this.bs.bv.top) / this.bs.bv.height;
                break;
            case 1:
                f = d;
                e = a.x;
                e = this.bs.bu.left + this.bs.bu.width * (e - this.bs.bv.left) / this.bs.bv.width;
                break;
            case 3:
                g = this.on(a, h);
                i = d;
                e = h.x + Math.cos(g) * i;
                f = h.y + Math.sin(g) * i;
                f = this.bs.bu.top + this.bs.bu.height * (f - this.bs.bv.top) / this.bs.bv.height;
                e = this.bs.bu.left + this.bs.bu.width * (e - this.bs.bv.left) / this.bs.bv.width;
                break;
        }
        return { $type: Point_$type, x: e, y: f };
    };
    ValueOverlay.prototype.f9 = function (a) {
        throw new NotImplementedException(0);
    };
    ValueOverlay.prototype.gq = function (a) {
        return this;
    };
    ValueOverlay.prototype.dq = function (a) {
        return false;
    };
    ValueOverlay.prototype.ao = function (a) {
        var b = typeCast(NumericAxisBase.$, a);
        var c = this.or;
        if (isNaN_(c) || isInfinity(c)) {
            return null;
        }
        return new AxisRange(c, c);
    };
    ValueOverlay.prototype.k4 = function (a) {
        this.jl(true, this.bs);
        if (!this.oe()) {
            if (this.oa != null) {
                this.o9(NaN, this.cn());
            }
            return;
        }
        if (this.dr(a)) {
            if (this.cn()) {
                if (this.b7.g) {
                    this.b7.t();
                }
                var b = this.op;
                this.op = this.oq;
                this.oq = b;
            }
            else {
                this.op = this.om;
            }
            this.om = this.oo();
            this.lb();
        }
        else {
            this.om = this.oo();
            this.o8(this.om, this.oc);
        }
    };
    ValueOverlay.prototype.oo = function () {
        var a, b;
        var c = this.getViewInfo(b, a);
        b = c.p0;
        a = c.p1;
        var d = this.getEffectiveViewport1(this.bs);
        var e = new ScalerParams(0, a, b, this.n9.ca, d);
        return this.n9.dz(this.or, e);
    };
    ValueOverlay.prototype.o8 = function (a, b) {
        if (this.n9 == null) {
            return;
        }
        var c = typeCast(CategoryAxisBase.$, this.n9);
        if (c != null && !c.b7) {
            if (this.or > c.j9 - 1) {
                return;
            }
            if (c.categoryMode == 2) {
                var d = this.getEffectiveViewport1(b);
                var e = 0.5 * c.getCategorySize(b.bv, b.bu, d);
                var f = false;
                if (c.ch && !c.ca) {
                    f = true;
                }
                if (typeCast(CategoryXAxis.$, c) !== null && c.ca) {
                    f = true;
                }
                if (f) {
                    e = -e;
                }
                a += e;
            }
        }
        var g = typeCast(NumericAxisBase.$, this.n9);
        if (g != null) {
            if (this.or < g.kd || this.or > g.kc) {
                return;
            }
            if (g.j3 && this.or < 0) {
                return;
            }
        }
        var h;
        switch (this.n9.a1) {
            case 2:
            case 3:
                h = this.n9.i2(a, b.bv, b.bu, this.getEffectiveViewport1(b), this.ny(b));
                break;
            default:
                h = this.n9.i2(a, b.bv, b.bu);
                break;
        }
        if (h != null) {
            b.by(h);
        }
        this.o9(a, this.cn());
    };
    ValueOverlay.prototype.ec = function (a, b, c) {
        var d = true;
        d = _super.prototype.ec.call(this, a, b, c);
        if (!c.o() || b.isEmpty || a.isEmpty || this.n9 == null || this.n9.bh == null) {
            d = false;
        }
        return d;
    };
    ValueOverlay.prototype.lo = function (a, b) {
        this.k3(false);
    };
    ValueOverlay.prototype.ln = function (a, b) {
        this.k3(false);
    };
    ValueOverlay.prototype.jo = function (a, b, c, d) {
        throw new NotImplementedException(0);
    };
    ValueOverlay.prototype.kp = function (a, b, c, d) {
        _super.prototype.kp.call(this, a, b, c, d);
        switch (b) {
            case ValueOverlay.$$p[10]:
                if (c != null) {
                    c.bx(this);
                }
                if (d != null) {
                    d.ck(this);
                }
                this.k3(false);
                this.ka();
                break;
            case "TransitionProgress":
                this.oq = this.op + this.fw * (this.om - this.op);
                if (this.cp(this.bs)) {
                    return;
                }
                if (this.fw == 1) {
                    this.o8(this.om, this.oc);
                }
                else {
                    this.o8(this.oq, this.oc);
                }
                if (this.b6 != null) {
                    this.b6.k7(this);
                }
                break;
            case ValueOverlay.$$p[12]:
                var e = typeCast(NumericAxisBase.$, this.n9);
                if (e != null) {
                    e.cn();
                }
                this.k3(true);
                this.kb();
                break;
            case ValueOverlay.$$p[11]:
            case ValueOverlay.$$p[9]:
            case ValueOverlay.$$p[0]:
            case ValueOverlay.$$p[2]:
            case ValueOverlay.$$p[3]:
            case ValueOverlay.$$p[8]:
            case ValueOverlay.$$p[4]:
            case ValueOverlay.$$p[5]:
            case ValueOverlay.$$p[6]:
            case ValueOverlay.$$p[7]:
                this.k3(true);
                break;
        }
    };
    ValueOverlay.prototype.j2 = function () {
        _super.prototype.j2.call(this);
        if (this.n9 != null) {
            this.n9.hc(false);
        }
    };
    ValueOverlay.prototype.jl = function (a, b) {
        _super.prototype.jl.call(this, a, b);
        var c = b;
        c.bx();
    };
    ValueOverlay.prototype.oe = function () {
        if (this.n9 == null || this.n9.bh == null || isNaN_(this.or) || this._visibility == 1) {
            return false;
        }
        var a = typeCast(CategoryAxisBase.$, this.n9);
        if (a != null && a.j9 == 0) {
            return false;
        }
        return true;
    };
    ValueOverlay.prototype.preferredCategoryMode = function (a) {
        return 0;
    };
    Object.defineProperty(ValueOverlay.prototype, "categoryAxis", {
        get: function () {
            return typeCast(CategoryAxisBase.$, this.n9);
        },
        enumerable: true,
        configurable: true
    });
    ValueOverlay.prototype.bp = function () {
        return new ValueOverlayView(this);
    };
    ValueOverlay.prototype.kk = function (a) {
        _super.prototype.kk.call(this, a);
        this.oc = typeCast(ValueOverlayView.$, a);
    };
    ValueOverlay.prototype.k5 = function (a, b) {
        _super.prototype.k5.call(this, a, b);
        if (!this.d2) {
            this.bs.a2(b);
            return;
        }
        this.bs.a2(b);
        if (this.cp(this.br) || !this.oe()) {
            return;
        }
        var c = this.getEffectiveViewport1(this.bs);
        var d = this.n9.dz(this.or, new ScalerParams(0, this.br.bv, a, this.n9.ca, c));
        this.o8(d, typeCast(ValueOverlayView.$, this.br));
        this.d2 = false;
    };
    ValueOverlay.prototype.getOffsetValue = function () {
        return 0;
    };
    ValueOverlay.prototype.getCategoryWidth = function () {
        return 0;
    };
    Object.defineProperty(ValueOverlay.prototype, "pq", {
        get: function () {
            return new Thickness(1, this.oi, this.ok, this.oj, this.oh);
        },
        enumerable: true,
        configurable: true
    });
    ValueOverlay.prototype.ag = function () {
        return [this.n9];
    };
    ValueOverlay.prototype.o9 = function (a, b) {
        if (isNaN_(a)) {
            if (this.oa != null) {
                AxisAnnotationFrameManager.b(this.oa);
                AxisAnnotationFrameManager.d(this, this.oa, true, this.of, this.og, b, this.os, this.os, this.ob, this.ob);
            }
            return;
        }
        var c = false;
        if (this.of == null) {
            c = true;
            this.og = new List$1(Axis.$, 0);
            this.of = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        this.oa = new AxisAnnotationFrame();
        var d = this.m9;
        if (d == null) {
            d = this.nb;
        }
        var e = this.n9.ch;
        AxisAnnotationFrameManager.c(this.oa, { $type: Point_$type, x: a, y: a }, this, this.b6, this.getEffectiveViewport(), d, this.pn, this.pp, this.po, this.pq, this.ol, this.pn, this.pp, this.po, this.pq, this.ol, !e && this.od, e && this.od);
        AxisAnnotationFrameManager.d(this, this.oa, c, this.of, this.og, b, this.os, this.os, this.ob, this.ob);
    };
    ValueOverlay.prototype.get_dm = function () {
        return true;
    };
    ValueOverlay.prototype.o4 = function (a) {
        if (this.n9 != null) {
            return this.n9.fm(a);
        }
        return null;
    };
    Object.defineProperty(ValueOverlay.prototype, "o6", {
        get: function () {
            var a = this.o4(this.or);
            return a != null ? a : stringFormat("{0:0.##}", this.or);
        },
        enumerable: true,
        configurable: true
    });
    ValueOverlay.$t = markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]);
    ValueOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackground:pn:pa', [Brush.$, null], 'AxisAnnotationFormatLabel:ob:pb', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:os:pc', [1, -1], 'AxisAnnotationOutline:po:pd', [Brush.$, null], 'AxisAnnotationPaddingBottom:oh:pe', [1, NaN], 'AxisAnnotationPaddingLeft:oi:pf', [1, NaN], 'AxisAnnotationPaddingRight:oj:pg', [1, NaN], 'AxisAnnotationPaddingTop:ok:ph', [1, NaN], 'AxisAnnotationStrokeThickness:ol:pi', [1, NaN], 'AxisAnnotationTextColor:pp:pj', [Brush.$, null], 'Axis:n9:pk', [Axis.$, null], 'IsAxisAnnotationEnabled:od:pl', [0, false], 'Value:or:pm', [1, 0]]);
    return ValueOverlay;
}(Series));
export { ValueOverlay };
/**
 * @hidden
 */
var ValueOverlayView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(ValueOverlayView, _super);
    function ValueOverlayView(a) {
        var _this = _super.call(this, a) || this;
        _this.bz = null;
        _this.bz = new Path();
        return _this;
    }
    ValueOverlayView.prototype.bb = function () {
        _super.prototype.bb.call(this);
        this.bz._stroke = this.e.m9;
        this.bz.ac = this.e.eu;
        this.bz.ai = this.e.nj;
        this.bz.ad = this.e.nk;
    };
    ValueOverlayView.prototype.bc = function () {
        _super.prototype.bc.call(this);
        var a = this.bo();
        this.bz._stroke = a;
        this.bz.ac = this.e.eu + 3;
        this.bz._stroke = a;
        this.bz.ac = this.e.eu + 3;
    };
    ValueOverlayView.prototype.by = function (a) {
        this.bz.ak = a;
        this.aq();
    };
    ValueOverlayView.prototype.bx = function () {
        this.bz.ak = null;
        this.aq();
    };
    ValueOverlayView.prototype.a6 = function (a, b) {
        _super.prototype.a6.call(this, a, b);
        if (a.d) {
            a.s(this.bz);
        }
    };
    ValueOverlayView.prototype.al = function (a) {
        _super.prototype.al.call(this, a);
        this.e.a5.exportPathData(a, this.bz, "ValueOverlayPath", []);
    };
    ValueOverlayView.$t = markType(ValueOverlayView, 'ValueOverlayView', SeriesView.$);
    return ValueOverlayView;
}(SeriesView));
export { ValueOverlayView };
//# sourceMappingURL=ValueOverlay_combined.js.map
