/*
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 { __extends } from "tslib";
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
 */
var ValueOverlay = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(ValueOverlay, _super);
    function ValueOverlay() {
        var _this = _super.call(this) || this;
        _this.qp = 0;
        _this.qq = 0;
        _this.qm = 0;
        _this.p9 = null;
        _this.qf = null;
        _this.qe = null;
        _this.ab = ValueOverlay.$;
        return _this;
    }
    ValueOverlay.prototype.gl = function (a, b, c) {
        return this.qr;
    };
    ValueOverlay.prototype.qn = 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.pq = function (a, b, c) {
        if (this.p8 == null) {
            return { $type: Point_$type, x: NaN, y: NaN };
        }
        var d = this.qo();
        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.p8.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.qn(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 };
    };
    ValueOverlay.prototype.hf = function (a) {
        throw new NotImplementedException(0);
    };
    ValueOverlay.prototype.hv = function (a) {
        return this;
    };
    ValueOverlay.prototype.eo = function (a) {
        return false;
    };
    ValueOverlay.prototype.ap = function (a) {
        var b = typeCast(NumericAxisBase.$, a);
        var c = this.qr;
        if (isNaN_(c) || isInfinity(c)) {
            return null;
        }
        return new AxisRange(c, c);
    };
    ValueOverlay.prototype.mm = function (a) {
        this.k0(true, this.b0);
        if (!this.qd()) {
            if (this.p9 != null) {
                this.ra(NaN, this.cv());
            }
            return;
        }
        if (this.ep(a)) {
            if (this.cv()) {
                if (this.ce.g) {
                    this.ce.t();
                }
                var b = this.qp;
                this.qp = this.qq;
                this.qq = b;
            }
            else {
                this.qp = this.qm;
            }
            this.qm = this.qo();
            this.mu();
        }
        else {
            this.qm = this.qo();
            this.q9(this.qm, this.qb);
        }
    };
    ValueOverlay.prototype.qo = function () {
        var a, b;
        var c = this.getViewInfo(b, a);
        b = c.p0;
        a = c.p1;
        var d = this.getEffectiveViewport1(this.b0);
        var e = new ScalerParams(0, a, b, this.p8.cg, d);
        return this.p8.ei(this.qr, e);
    };
    ValueOverlay.prototype.q9 = function (a, b) {
        if (this.p8 == null) {
            return;
        }
        var c = typeCast(CategoryAxisBase.$, this.p8);
        if (c != null && !c.cd) {
            if (this.qr > c.lf - 1) {
                return;
            }
            if (c.categoryMode != 0) {
                var d = this.getEffectiveViewport1(b);
                var e = 0.5 * c.getCategorySize(b.bv, b.bu, d);
                var f = false;
                if (c.co && !c.cg) {
                    f = true;
                }
                if (typeCast(CategoryXAxis.$, c) !== null && c.cg) {
                    f = true;
                }
                if (f) {
                    e = -e;
                }
                a += e;
            }
        }
        var g = typeCast(NumericAxisBase.$, this.p8);
        if (g != null) {
            if (this.qr < g.lv || this.qr > g.lu) {
                return;
            }
            if (g.lh && this.qr < 0) {
                return;
            }
        }
        var h;
        switch (this.p8.a1) {
            case 2:
            case 3:
                h = this.p8.j4(a, b.bv, b.bu, this.getEffectiveViewport1(b), this.pv(b));
                break;
            default:
                h = this.p8.j4(a, b.bv, b.bu);
                break;
        }
        if (h != null) {
            b.by(h);
        }
        if (!b.q) {
            this.ra(a, this.cv());
        }
    };
    ValueOverlay.prototype.fb = function (a, b, c) {
        var d = true;
        d = _super.prototype.fb.call(this, a, b, c);
        if (!c.o() || b.isEmpty || a.isEmpty || this.p8 == null || this.p8.bh == null) {
            d = false;
        }
        return d;
    };
    ValueOverlay.prototype.m9 = function (a, b) {
        this.ml(false);
    };
    ValueOverlay.prototype.m8 = function (a, b) {
        this.ml(false);
    };
    ValueOverlay.prototype.k3 = function (a, b, c, d) {
        throw new NotImplementedException(0);
    };
    ValueOverlay.prototype.l7 = function (a, b, c, d) {
        _super.prototype.l7.call(this, a, b, c, d);
        switch (b) {
            case ValueOverlay.$$p[11]:
                if (c != null) {
                    c.bz(this);
                }
                if (d != null) {
                    d.cs(this);
                }
                this.ml(false);
                this.ls();
                break;
            case "TransitionProgress":
                this.qq = this.qp + this.g2 * (this.qm - this.qp);
                if (this.cx(this.b0)) {
                    return;
                }
                if (this.g2 == 1) {
                    this.q9(this.qm, this.qb);
                }
                else {
                    this.q9(this.qq, this.qb);
                }
                if (this.cd != null) {
                    this.cd.oa(this);
                }
                break;
            case ValueOverlay.$$p[13]:
                var e = typeCast(NumericAxisBase.$, this.p8);
                if (e != null) {
                    e.c0();
                }
                this.ml(true);
                this.lt();
                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.ml(true);
                break;
        }
    };
    ValueOverlay.prototype.li = function () {
        _super.prototype.li.call(this);
        if (this.p8 != null) {
            this.p8.h7(false);
        }
    };
    ValueOverlay.prototype.k0 = function (a, b) {
        _super.prototype.k0.call(this, a, b);
        var c = b;
        c.bx();
    };
    ValueOverlay.prototype.qd = function () {
        if (this.p8 == null || this.p8.bh == null || isNaN_(this.qr) || this._visibility != 0) {
            return false;
        }
        var a = typeCast(CategoryAxisBase.$, this.p8);
        if (a != null && a.lf == 0) {
            return false;
        }
        return true;
    };
    ValueOverlay.prototype.preferredCategoryMode = function (a) {
        return 0;
    };
    Object.defineProperty(ValueOverlay.prototype, "categoryAxis", {
        get: function () {
            return typeCast(CategoryAxisBase.$, this.p8);
        },
        enumerable: false,
        configurable: true
    });
    ValueOverlay.prototype.bx = function () {
        return new ValueOverlayView(this);
    };
    ValueOverlay.prototype.l2 = function (a) {
        _super.prototype.l2.call(this, a);
        this.qb = typeCast(ValueOverlayView.$, a);
    };
    ValueOverlay.prototype.mn = function (a, b) {
        _super.prototype.mn.call(this, a, b);
        if (!this.e1) {
            this.b0.a2(b);
            return;
        }
        this.b0.a2(b);
        if (this.cx(this.bz) || !this.qd()) {
            return;
        }
        var c = this.getEffectiveViewport1(this.b0);
        var d = this.p8.ei(this.qr, new ScalerParams(0, this.bz.bv, a, this.p8.cg, c));
        this.q9(d, typeCast(ValueOverlayView.$, this.bz));
        this.e1 = false;
    };
    ValueOverlay.prototype.getOffsetValue = function () {
        return 0;
    };
    ValueOverlay.prototype.getCategoryWidth = function () {
        return 0;
    };
    Object.defineProperty(ValueOverlay.prototype, "rs", {
        get: function () {
            return new Thickness(1, this.qi, this.qk, this.qj, this.qh);
        },
        enumerable: false,
        configurable: true
    });
    ValueOverlay.prototype.ag = function () {
        return [this.p8];
    };
    ValueOverlay.prototype.ra = function (a, b) {
        if (isNaN_(a)) {
            if (this.p9 != null) {
                AxisAnnotationFrameManager.b(this.p9);
                AxisAnnotationFrameManager.d(this, this.p9, true, this.qe, this.qf, b, this.qs, this.qs, this.qa, this.qa);
            }
            return;
        }
        var c = false;
        if (this.qe == null) {
            c = true;
            this.qf = new List$1(Axis.$, 0);
            this.qe = new Dictionary$2(Axis.$, Pool$1.$.specialize(AxisAnnotation.$), 0);
        }
        this.p9 = new AxisAnnotationFrame();
        var d = this.o3;
        if (d == null) {
            d = this.o7;
        }
        var e = this.p8.co;
        AxisAnnotationFrameManager.c(this.p9, { $type: Point_$type, x: a, y: a }, this, this.cd, this.getEffectiveViewport(), d, this.rp, this.qg, this.rr, this.rq, this.rs, this.ql, this.rp, this.qg, this.rr, this.rq, this.rs, this.ql, !e && this.qc, e && this.qc);
        AxisAnnotationFrameManager.d(this, this.p9, c, this.qe, this.qf, b, this.qs, this.qs, this.qa, this.qa);
    };
    ValueOverlay.prototype.get_isValueOverlay = function () {
        return true;
    };
    ValueOverlay.prototype.q5 = function (a) {
        if (this.p8 != null) {
            return this.p8.gc(a);
        }
        return null;
    };
    Object.defineProperty(ValueOverlay.prototype, "q7", {
        get: function () {
            var a = this.q5(this.qr);
            return a != null ? a : stringFormat("{0:0.##}", this.qr);
        },
        enumerable: false,
        configurable: true
    });
    ValueOverlay.$t = markType(ValueOverlay, 'ValueOverlay', Series.$, [IHasCategoryModePreference_$type]);
    ValueOverlay.$$p = markDep(DependencyProperty, PropertyMetadata, ValueOverlay, 'raisePropertyChanged', ['AxisAnnotationBackgroundCornerRadius:qg:rb', [1, DeviceUtils.g(3)], 'AxisAnnotationBackground:rp:rc', [Brush.$, null], 'AxisAnnotationFormatLabel:qa:rd', [Delegate_$type], 'AxisAnnotationInterpolatedValuePrecision:qs:re', [1, -1], 'AxisAnnotationOutline:rq:rf', [Brush.$, null], 'AxisAnnotationPaddingBottom:qh:rg', [1, NaN], 'AxisAnnotationPaddingLeft:qi:rh', [1, NaN], 'AxisAnnotationPaddingRight:qj:ri', [1, NaN], 'AxisAnnotationPaddingTop:qk:rj', [1, NaN], 'AxisAnnotationStrokeThickness:ql:rk', [1, NaN], 'AxisAnnotationTextColor:rr:rl', [Brush.$, null], 'Axis:p8:rm', [Axis.$, null], 'IsAxisAnnotationEnabled:qc:rn', [0, false], 'Value:qr:ro', [1, 0]]);
    return ValueOverlay;
}(Series));
export { ValueOverlay };
/**
 * @hidden
 */
var ValueOverlayView = /** @class */ /*@__PURE__*/ (function (_super) {
    __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.o3;
        this.bz.ac = this.e.fw;
        this.bz.ai = this.e.pg;
        this.bz.ad = this.e.ph;
    };
    ValueOverlayView.prototype.bc = function () {
        _super.prototype.bc.call(this);
        var a = this.bo();
        this.bz._stroke = a;
        this.bz.ac = this.e.fw + 3;
        this.bz._stroke = a;
        this.bz.ac = this.e.fw + 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.t(this.bz);
        }
    };
    ValueOverlayView.prototype.al = function (a) {
        _super.prototype.al.call(this, a);
        this.e.a8.exportPathData(a, this.bz, "ValueOverlayPath", []);
    };
    ValueOverlayView.$t = markType(ValueOverlayView, 'ValueOverlayView', SeriesView.$);
    return ValueOverlayView;
}(SeriesView));
export { ValueOverlayView };
