/*
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, __values } from "tslib";
import { AnnotationLayer } from "./AnnotationLayer";
import { DependencyProperty } from "igniteui-react-core";
import { Base, runOn, delegateCombine, String_$type, enumGetBox, EnumUtil, typeCast, fromEnum, delegateRemove, Point_$type, Date_$type, markType, markDep } from "igniteui-react-core";
import { Series } from "./Series";
import { CalloutPlacementPositionsCollection } from "./CalloutPlacementPositionsCollection";
import { AutoCalloutVisibilityMode_$type } from "./AutoCalloutVisibilityMode";
import { Brush } from "igniteui-react-core";
import { Thickness } from "igniteui-react-core";
import { CalloutCollisionMode_$type } from "./CalloutCollisionMode";
import { FontUtil } from "igniteui-react-core";
import { Rect } from "igniteui-react-core";
import { CalloutLayerFrame } from "./CalloutLayerFrame";
import { HashSet$1 } from "igniteui-react-core";
import { CalloutAnnotationWrapper } from "./CalloutAnnotationWrapper";
import { List$1 } from "igniteui-react-core";
import { LinkedList$1 } from "igniteui-react-core";
import { Dictionary$2 } from "igniteui-react-core";
import { LinkedListNode$1 } from "igniteui-react-core";
import { LabelCollisionManager } from "igniteui-react-core";
import { SeriesPointOfInterest } from "./SeriesPointOfInterest";
import { CalloutAnnotation } from "./CalloutAnnotation";
import { IFastItemsSource_$type } from "igniteui-react-core";
import { CalloutLabelUpdatingEventArgs } from "./CalloutLabelUpdatingEventArgs";
import { CalloutSeriesSelectingEventArgs } from "./CalloutSeriesSelectingEventArgs";
import { CalloutStyleUpdatingEventArgs } from "./CalloutStyleUpdatingEventArgs";
import { DeviceUtils } from "igniteui-react-core";
import { CalloutRenderStyleUpdatingEventArgs } from "./CalloutRenderStyleUpdatingEventArgs";
import { LabelCollisionInfo } from "igniteui-react-core";
import { QuadTreeBoundingBox } from "igniteui-react-core";
import { ScalerParams } from "./ScalerParams";
import { ViewportUtils } from "./ViewportUtils";
import { Size } from "igniteui-react-core";
import { CalloutContentUpdatingEventArgs } from "./CalloutContentUpdatingEventArgs";
import { CalloutKey } from "./CalloutKey";
import { DataContext } from "igniteui-react-core";
import { HashPool$2 } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
import { stringIsNullOrEmpty } from "igniteui-react-core";
import { FastItemObjectColumn } from "igniteui-react-core";
import { AnnotationLayerView } from "./AnnotationLayerView";
import { BrushUtil } from "igniteui-react-core";
import { TextBlock } from "igniteui-react-core";
import { Color } from "igniteui-react-core";
import { Line } from "igniteui-react-core";
import { CalloutViewHelper } from "./CalloutViewHelper";
import { Rectangle } from "igniteui-react-core";
import { TranslateTransform } from "igniteui-react-core";
/**
 * @hidden
 */
var CalloutLayer = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CalloutLayer, _super);
    function CalloutLayer() {
        var _this = _super.call(this) || this;
        _this.calloutStyleUpdating = null;
        _this.calloutRenderStyleUpdating = null;
        _this.xm = null;
        _this.xn = null;
        _this.xo = null;
        _this.xl = null;
        _this.xk = null;
        _this.ye = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        _this.yh = new List$1(CalloutAnnotationWrapper.$, 0);
        _this.yi = new List$1(CalloutAnnotationWrapper.$, 0);
        _this.xc = null;
        _this.w2 = null;
        _this.xi = null;
        _this.yf = new LinkedList$1(CalloutAnnotationWrapper.$);
        _this.yc = new Dictionary$2(CalloutAnnotationWrapper.$, LinkedListNode$1.$.specialize(CalloutAnnotationWrapper.$), 0);
        _this.xu = null;
        _this.abo = new Rect(0, 0, 0, 1, 1);
        _this.x1 = false;
        _this.yt = 0;
        _this.abn = Rect.empty;
        _this.xz = false;
        _this.x0 = false;
        _this.calloutContentUpdating = null;
        _this.calloutLabelUpdating = null;
        _this.calloutSeriesSelecting = null;
        _this.yg = new List$1(SeriesPointOfInterest.$, 0);
        _this.x3 = false;
        _this.x4 = false;
        _this.yk = 0;
        _this.x2 = false;
        _this.xy = true;
        _this.w4 = 1;
        FastItemObjectColumn.m();
        _this.w2 = null;
        _this.xc = new CalloutPlacementPositionsCollection();
        var a = _this.xc;
        a.collectionChanged = delegateCombine(a.collectionChanged, runOn(_this, _this.z8));
        _this.up = true;
        var b = new CalloutLayerFrame();
        var c = new CalloutLayerFrame();
        var d = new CalloutLayerFrame();
        var e = _this.jj / 1000;
        _this.uh = b;
        _this.ug = c;
        _this.ui = d;
        _this.ab = CalloutLayer.$;
        return _this;
    }
    CalloutLayer.prototype.bc = function () {
        return new CalloutLayer();
    };
    CalloutLayer.prototype.get_d3 = function () {
        return true;
    };
    CalloutLayer.prototype.z8 = function (a, b) {
        this.aah();
    };
    CalloutLayer.prototype.aah = function () {
        this.w2 = this.w3(this.xd);
        this.aae();
    };
    CalloutLayer.prototype.z9 = function (a, b) {
        this.yi.clear();
        this.pr(false);
    };
    CalloutLayer.prototype.np = function (a, b, c, d) {
        _super.prototype.np.call(this, a, b, c, d);
        var e = this.yd();
        switch (a) {
            case 3:
                this.aam(b, e);
                break;
            case 1:
                for (var f = b; f < b + c; f++) {
                    var g = new CalloutAnnotation();
                    var h = new CalloutAnnotationWrapper();
                    h.b = g;
                    h.b.series = this.xh;
                    this.yi.insert(f, h);
                    this.aam(f, e);
                }
                break;
            case 0:
                this.yi.v(b, c);
                break;
            case 2:
                for (var i = b; i < b + c; i++) {
                    this.aam(i, e);
                }
                break;
            case 4:
                this.yi.clear();
                for (var j = 0; j < this.c7.count; j++) {
                    var k = new CalloutAnnotation();
                    var l = new CalloutAnnotationWrapper();
                    l.b = k;
                    l.b.series = this.xh;
                    this.yi.add(l);
                    this.aam(j, e);
                }
                break;
        }
        this.pr(true);
    };
    CalloutLayer.prototype.fq = function (a) {
        return false;
    };
    CalloutLayer.prototype.yd = function () {
        var a = new Dictionary$2(String_$type, Series.$, 0);
        if (this.cv != null) {
            for (var b = 0; b < this.cv.series.count; b++) {
                var c = this.cv.series._inner[b];
                if (c.name != null && !a.containsKey(c.name)) {
                    a.addItem(c.name, c);
                }
            }
        }
        return a;
    };
    CalloutLayer.prototype.aam = function (a, b) {
        var _this = this;
        if (this.xt == null || this.xr == null) {
            return;
        }
        var c = a;
        if (this.xs != null) {
            c = this.xs.item(a);
        }
        var d = this.xt.item(a);
        var e = this.xr.item(a);
        var f = this.yi._inner[a];
        if (this.xq != null) {
            if (f.b.ab != this.xq.item(a)) {
                f.b.key = this.xq.item(a);
            }
        }
        if (this.yc.containsKey(f)) {
            f.b = this.yc.item(f).c.b;
        }
        f.b.xValue = c;
        f.b.yValue = d;
        if (this.calloutLabelUpdating != null) {
            var g = ((function () {
                var $ret = new CalloutLabelUpdatingEventArgs();
                $ret.d = c;
                $ret.e = d;
                $ret.item = _this.c7.item(a);
                return $ret;
            })());
            this.calloutLabelUpdating(this, g);
            if (g.c != null && !Base.equalsStatic(g.c, f.b.ao)) {
                var h = g.c;
                f.b.text = h != null ? h.toString() : "";
            }
        }
        else {
            f.b.text = e != null ? e.toString() : "";
        }
        if (this.xp != null) {
            f.b.content = this.xp.item(a);
        }
        else {
            f.b.content = this.c7.item(a);
        }
        if (this.calloutSeriesSelecting != null) {
            var i = ((function () {
                var $ret = new CalloutSeriesSelectingEventArgs();
                $ret.c = c;
                $ret.d = d;
                $ret.item = _this.c7.item(a);
                return $ret;
            })());
            this.calloutSeriesSelecting(this, i);
            if (i.a != null) {
                f.b.series = i.a;
            }
            else if (i.e != null) {
                if (b.containsKey(i.e)) {
                    f.b.series = b.item(i.e);
                }
            }
        }
        this.aan(f);
    };
    CalloutLayer.prototype.aan = function (a) {
        var b = new Thickness(0, DeviceUtils.g(3));
        if (isNaN_(this.abq.left) || isNaN_(this.abq.top) || isNaN_(this.abq.right) || isNaN_(this.abq.bottom)) {
            b = new Thickness(0, DeviceUtils.g(3));
        }
        else {
            b = this.abq;
        }
        var c = DeviceUtils.g(3);
        if (isNaN_(this.yl)) {
            c = DeviceUtils.g(3);
        }
        else {
            c = this.yl;
        }
        var d = this.abj != null ? this.abj : this.xb.cl(a.b.l);
        var e = this.abm != null ? this.abm : this.xb.co();
        var f = this.abl != null ? this.abl : this.xb.cn(a.b.l);
        var g = this.abk != null ? this.abk : this.xb.cm(a.b.l);
        var h = isNaN_(this.yr) ? 0 : this.yr;
        if (this.x8 && this.calloutStyleUpdating != null) {
            var i = new CalloutStyleUpdatingEventArgs();
            i.item = a.b.aa;
            i.xValue = a.b.ac;
            i.yValue = a.b.ad;
            i.series = a.b.l;
            i.background = d;
            i.textColor = e;
            i.outline = f;
            i.leaderBrush = g;
            i.strokeThickness = h;
            this.calloutStyleUpdating(this, i);
            d = i.background;
            e = i.textColor;
            f = i.outline;
            g = i.leaderBrush;
            h = i.strokeThickness;
        }
        a.b.backgroundPadding = b;
        a.b.backgroundCornerRadius = c;
        a.b.background = d;
        a.b.textColor = e;
        a.b.outline = f;
        a.b.leaderBrush = g;
        a.b.strokeThickness = h;
    };
    CalloutLayer.prototype.jv = function (a, b) {
        var c = this.lw(b);
        if (c == CalloutLayer.$$p[21]) {
            return this.jw(a, b, this.zs);
        }
        if (c == CalloutLayer.$$p[28]) {
            return this.jw(a, b, this.z3);
        }
        if (c == CalloutLayer.$$p[29]) {
            return this.jw(a, b, this.z6);
        }
        if (c == CalloutLayer.$$p[20]) {
            return this.jw(a, b, this.zp);
        }
        if (c == CalloutLayer.$$p[15]) {
            return this.jw(a, b, this.zi);
        }
        return _super.prototype.jv.call(this, a, b);
    };
    Object.defineProperty(CalloutLayer.prototype, "xr", {
        get: function () {
            return this.xm;
        },
        set: function (a) {
            if (this.xm != a) {
                var b = this.xm;
                this.xm = a;
                this.raisePropertyChanged("LabelColumn", b, this.xm);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "xs", {
        get: function () {
            return this.xn;
        },
        set: function (a) {
            if (this.xn != a) {
                var b = this.xn;
                this.xn = a;
                this.raisePropertyChanged("XColumn", b, this.xn);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "xt", {
        get: function () {
            return this.xo;
        },
        set: function (a) {
            if (this.xo != a) {
                var b = this.xo;
                this.xo = a;
                this.raisePropertyChanged("YColumn", b, this.xo);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "xq", {
        get: function () {
            return this.xl;
        },
        set: function (a) {
            if (this.xl != a) {
                var b = this.xl;
                this.xl = a;
                this.raisePropertyChanged("KeyColumn", b, this.xl);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "xp", {
        get: function () {
            return this.xk;
        },
        set: function (a) {
            if (this.xk != a) {
                var b = this.xk;
                this.xk = a;
                this.raisePropertyChanged("ContentColumn", b, this.xk);
            }
        },
        enumerable: false,
        configurable: true
    });
    CalloutLayer.prototype.aab = function (a, b) {
        if (b.propertyName == CalloutAnnotation.$$p[14] || b.propertyName == CalloutAnnotation.$$p[15]) {
            var c = a.k;
            if (!this.ye.contains(c)) {
                this.ye.add_1(c);
                this.yh.add(c);
                this.pr(false);
            }
        }
    };
    CalloutLayer.prototype.cd = function () {
        return new CalloutLayerView(this);
    };
    CalloutLayer.prototype.o2 = function (a) {
        _super.prototype.o2.call(this, a);
        this.xb = a;
    };
    Object.defineProperty(CalloutLayer.prototype, "xd", {
        get: function () {
            return this.xc;
        },
        set: function (a) {
            var b = this.xd;
            if (a != b) {
                this.xc = a;
                this.raisePropertyChanged("AllowedPositions", b, this.xd);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "w6", {
        get: function () {
            return EnumUtil.getEnumValue(AutoCalloutVisibilityMode_$type, this.c(CalloutLayer.aa2));
        },
        set: function (a) {
            this.h(CalloutLayer.aa2, enumGetBox(AutoCalloutVisibilityMode_$type, a));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "w5", {
        get: function () {
            return this.w4;
        },
        set: function (a) {
            this.w4 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "abq", {
        get: function () {
            return new Thickness(1, this.yn, this.yp, this.yo, this.ym);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutLayer.prototype, "xj", {
        get: function () {
            if (this.xi == null) {
                this.xi = FontUtil.toFontInfo(this.i5, this.zx);
            }
            return this.xi;
        },
        enumerable: false,
        configurable: true
    });
    CalloutLayer.prototype.vu = function (a, b) {
        if (this.xh == null || this.xh == a) {
            if (!this.at.c) {
                this.pr(b);
            }
        }
    };
    CalloutLayer.prototype.vw = function (a, b) {
        var e_1, _a;
        _super.prototype.vw.call(this, a, b);
        var c = a;
        c.q.clear();
        c.r.clear();
        c.n.clear();
        c.f.clear();
        c.i.clear();
        c.h.clear();
        c.k.clear();
        c.m.clear();
        c.l.clear();
        c.j.clear();
        c.g.clear();
        c.o.clear();
        c.p.clear();
        c.u.clear();
        c.v.clear();
        c.s.clear();
        c.t.clear();
        var d = this.yj();
        var e = new List$1(CalloutAnnotationWrapper.$, 0);
        var f = true;
        if (this.x5) {
            if (this.un(this.xh)) {
                this.aaj(this.xh, c, e);
            }
            else {
                try {
                    for (var _b = __values(fromEnum(this.cv.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                        var g = _c.value;
                        if (this.un(g)) {
                            if (!g.d7) {
                                if (!g.isVertical) {
                                    f = false;
                                }
                            }
                            this.aaj(g, c, e);
                        }
                    }
                }
                catch (e_1_1) {
                    e_1 = { error: e_1_1 };
                }
                finally {
                    try {
                        if (_c && !_c.done && (_a = _b.return))
                            _a.call(_b);
                    }
                    finally {
                        if (e_1)
                            throw e_1.error;
                    }
                }
            }
        }
        if (this.x5 && this.w5 == 2) {
            var h = 0;
            var i = 0;
            var j = 1.7976931348623157E+308;
            var k = 1.7976931348623157E+308;
            var l = -1.7976931348623157E+308;
            var m = -1.7976931348623157E+308;
            if (e.count > 0) {
                if (e._inner[0].c != null) {
                    h = e._inner[0].e;
                    i = e._inner[0].f;
                }
                for (var n = 0; n < e.count; n++) {
                    var o = e._inner[n];
                    if (o.c != null) {
                        var p = o.e;
                        var q = o.f;
                        if (p != h) {
                            j = Math.min(j, Math.abs(p - h));
                        }
                        if (q != i) {
                            k = Math.min(k, Math.abs(q - i));
                        }
                        l = Math.max(o.c.l + o.c.l, l);
                        m = Math.max(o.c.k + o.c.k, m);
                    }
                }
                if (f) {
                    if (m > k) {
                        e.clear();
                    }
                }
                else {
                    if (l > j) {
                        e.clear();
                    }
                }
            }
        }
        this.aai(c, d, e);
    };
    CalloutLayer.prototype.qp = function (a, b) {
        _super.prototype.qp.call(this, a, b);
        var c = b.width - this.abo.width;
        var d = b.height - this.abo.height;
        var e = 0;
        if (Math.abs(c) > Math.abs(d)) {
            e = c;
            this.yk = c * this.ty.width;
        }
        else {
            e = d;
            this.yk = d * this.ty.height;
        }
        if (e > 0 && this.yk > 5) {
            this.x4 = true;
        }
        if (e < 0 && this.yk > 5) {
            this.x3 = true;
        }
    };
    CalloutLayer.prototype.qo = function (a, b) {
        _super.prototype.qo.call(this, a, b);
        if (!a.equals1(b)) {
            this.x2 = true;
        }
    };
    Object.defineProperty(CalloutLayer.prototype, "abp", {
        get: function () {
            return this.abn;
        },
        set: function (a) {
            this.abn = a;
        },
        enumerable: false,
        configurable: true
    });
    CalloutLayer.prototype.aai = function (a, b, c) {
        var e_2, _a;
        if (this.cv != null) {
            this.abo = this.cv.tr;
        }
        if (this.ty.isEmpty) {
            return;
        }
        this.abp = new Rect(0, this.ty.left, this.ty.top, this.ty.width, this.ty.height);
        if (this.xu != null && this.zf != null && this.zf != this.xu.ap) {
            this.aad();
        }
        if (this.xu == null) {
            var d = this.xv();
            if (d != null) {
                this.xu = d;
                var e = this.xu;
                e.labelsMoved = delegateCombine(e.labelsMoved, runOn(this, this.aaa));
            }
            else {
                var f = this.tq(this.cg);
                var g = new Array(2);
                g[0] = 0;
                g[1] = 3;
                if (this.xh != null) {
                    if (this.xh.isVertical) {
                        g = new Array(2);
                        g[0] = 2;
                        g[1] = 1;
                    }
                }
                else {
                    var h = false;
                    if (this.cv != null && this.cv.series.count > 0) {
                        h = true;
                        try {
                            for (var _b = __values(fromEnum(this.cv.series)), _c = _b.next(); !_c.done; _c = _b.next()) {
                                var i = _c.value;
                                if (!i.d7) {
                                    if (!i.isVertical) {
                                        h = false;
                                    }
                                }
                            }
                        }
                        catch (e_2_1) {
                            e_2 = { error: e_2_1 };
                        }
                        finally {
                            try {
                                if (_c && !_c.done && (_a = _b.return))
                                    _a.call(_b);
                            }
                            finally {
                                if (e_2)
                                    throw e_2.error;
                            }
                        }
                    }
                    if (h) {
                        g = new Array(2);
                        g[0] = 2;
                        g[1] = 1;
                    }
                }
                this.xu = new LabelCollisionManager(this.ty.right, this.ty.bottom, this.ty, this.xb.j(), this.yq, this.xw(), g, this.yx(), this.yw(), this.x6, this.w2);
                if (this.zf != null) {
                    this.xu.ap = this.zf;
                    this.xu.an = this;
                }
                var j = this.xu;
                j.labelsMoved = delegateCombine(j.labelsMoved, runOn(this, this.aaa));
            }
        }
        if (this.x3) {
            this.x3 = false;
            if (this.xu.al > 2) {
                this.x1 = true;
            }
        }
        if (this.x4) {
            this.x4 = false;
            if (this.yk > 5) {
                this.x1 = true;
            }
        }
        if (this.x2) {
            this.x2 = false;
            this.xu.a3(this.ty.right, this.ty.bottom, this.ty);
            this.x1 = true;
        }
        var k = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        var l = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        var m = new List$1(CalloutAnnotationWrapper.$, 0);
        var n = new List$1(CalloutAnnotationWrapper.$, 0);
        var o = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        for (var p = 0; p < b.count; p++) {
            o.add_1(b._inner[p]);
        }
        for (var q = 0; q < c.count; q++) {
            o.add_1(c._inner[q]);
        }
        var r = this.yf.c;
        while (r != null) {
            var s = r.a;
            if (!o.contains(r.c)) {
                n.add(r.c);
                l.add_1(r.c);
                var t = r.c.b;
                t.propertyChanged = delegateRemove(t.propertyChanged, runOn(this, this.aab));
                this.yf.h(r);
                this.yc.removeItem(r.c);
                this.xu.a2(r.c.c);
            }
            r = s;
        }
        for (var u = 0; u < b.count; u++) {
            if (!this.yc.containsKey(b._inner[u])) {
                this.yf.f(b._inner[u]);
                var v = b._inner[u].b;
                v.propertyChanged = delegateCombine(v.propertyChanged, runOn(this, this.aab));
                this.yc.addItem(b._inner[u], this.yf.d);
                m.add(b._inner[u]);
                k.add_1(b._inner[u]);
                this.x1 = true;
            }
        }
        for (var w = 0; w < c.count; w++) {
            if (!this.yc.containsKey(c._inner[w])) {
                this.yf.f(c._inner[w]);
                this.yc.addItem(c._inner[w], this.yf.d);
                var x = c._inner[w].b;
                x.propertyChanged = delegateCombine(x.propertyChanged, runOn(this, this.aab));
                m.add(c._inner[w]);
                k.add_1(c._inner[w]);
                this.x1 = true;
            }
        }
        if (this.xz == true) {
            this.xz = false;
            this.x1 = true;
        }
        if (this.yh.count > 0) {
            this.x1 = true;
            this.yh.clear();
            this.ye.clear();
        }
        r = this.yf.c;
        while (r != null) {
            var y = this.xx(r.c);
            if (y == null) {
                return;
            }
            if (!Base.equalsStatic(y, r.c.c.c)) {
                var z = false;
                if (r.c.c.c == null) {
                    z = true;
                }
                var aa = r.c.c;
                aa.o = y.b;
                aa.p = y.c;
                if (!isNaN_(aa.o) && !isNaN_(aa.p)) {
                    aa.n = y.e;
                    aa.m = y.d;
                    if (aa.b == null) {
                        this.xu.t(aa, false);
                    }
                    if (z) {
                        this.xu.aq(aa);
                    }
                    else {
                        this.xu.az(aa);
                    }
                }
            }
            r = r.a;
        }
        var ab = this.xu.am();
        var ac = this.xu.u();
        if (ac) {
            if (this.xu.q()) {
                this.x1 = true;
            }
        }
        if (this.x1 && (ab != 0 || ac)) {
            this.x1 = false;
            this.yt = 0x7FFFFFFF;
            if (this.zf != null) {
                var ad = true;
                for (var ae = 0; ae < this.cv.series.count; ae++) {
                    var af = this.cv.series._inner[ae];
                    if (af.d7 && typeCast(CalloutLayer.$, af) !== null) {
                        var ag = af;
                        if (ag.zf == this.zf) {
                            if (!ag.abp.equals1(this.xu.a5)) {
                                ad = false;
                                break;
                            }
                        }
                    }
                }
                if (ad) {
                    this.xu.a4();
                }
                else {
                    this.xu.ar();
                    this.xu.as();
                }
            }
            else {
                this.xu.a4();
            }
        }
        else {
            this.xu.as();
        }
        var ah = this.yf.c;
        var ai;
        var aj;
        var ak;
        var al;
        var am;
        var an;
        var ao;
        var ap;
        var aq;
        var ar;
        var as;
        var at;
        var au;
        var av;
        var aw;
        var ax;
        var ay = this.x7;
        while (ah != null) {
            var az = ah.c;
            var a0 = az.b;
            ai = a0.bk;
            aj = a0.bm;
            ak = a0.bl;
            al = a0.backgroundPadding.left;
            am = a0.backgroundPadding.top;
            an = a0.backgroundPadding.right;
            ao = a0.backgroundPadding.bottom;
            aq = a0.backgroundCornerRadius;
            ap = a0.y;
            ar = a0.bn;
            as = a0.ao;
            at = a0.aa;
            var a1 = az.c;
            au = a1.o - (a1.g - a1.l);
            av = a1.p - (a1.h - a1.k);
            aw = a1.g - a1.l;
            ax = a1.h - a1.k;
            if (ay) {
                var a2 = new CalloutRenderStyleUpdatingEventArgs();
                a2.background = ai;
                a2.outline = aj;
                a2.leaderBrush = ak;
                a2.strokeThickness = ap;
                a2.textColor = ar;
                a2.item = at;
                a2.series = a0.l;
                a2.actualPosition = a1.a;
                a2.xValue = a0.ac;
                a2.yValue = a0.ad;
                if (this.calloutRenderStyleUpdating != null) {
                    this.calloutRenderStyleUpdating(this, a2);
                    ai = a2.background;
                    aj = a2.outline;
                    ak = a2.leaderBrush;
                    ap = a2.strokeThickness;
                    ar = a2.textColor;
                }
            }
            a.n.add1(az);
            a.f.add(ai);
            a.i.add(aj);
            a.h.add(ak);
            a.k.add(al);
            a.m.add(am);
            a.l.add(an);
            a.j.add(ao);
            a.g.add(aq);
            a.o.add(ap);
            a.p.add(ar);
            a.q.add1(as);
            a.r.add1(at);
            a.u.add(au);
            a.v.add(av);
            a.s.add(aw);
            a.t.add(ax);
            ah = ah.a;
        }
    };
    CalloutLayer.prototype.aad = function () {
        if (this.xu != null) {
            var a = this.yf.c;
            while (a != null) {
                var b = a.c.c;
                if (b != null) {
                    this.xu.a2(b);
                }
                a = a.a;
            }
            var c = this.xu;
            c.labelsMoved = delegateRemove(c.labelsMoved, runOn(this, this.aaa));
            this.xu = null;
        }
        this.aac();
    };
    CalloutLayer.prototype.xv = function () {
        if (this.cv == null) {
            return null;
        }
        for (var a = 0; a < this.cv.series.count; a++) {
            var b = this.cv.series._inner[a];
            if (b.d7 && typeCast(CalloutLayer.$, b) !== null) {
                var c = b;
                if (c != this) {
                    if (c.zf != null && c.zf == this.zf) {
                        if (c.xu != null) {
                            return c.xu;
                        }
                    }
                }
            }
        }
        return null;
    };
    CalloutLayer.prototype.yw = function () {
        return 20000;
    };
    CalloutLayer.prototype.yx = function () {
        return 300;
    };
    CalloutLayer.prototype.xw = function () {
        switch (this.w8) {
            case 0: return 2;
            case 2: return 1;
            case 3: return 2;
            case 1: return 0;
        }
        return 2;
    };
    CalloutLayer.prototype.aaa = function (a) {
        var b = this.xu.am();
        if (b < this.yt) {
            this.yt = b;
            this.pr(false);
        }
    };
    CalloutLayer.prototype.xx = function (a) {
        var b = this.xh;
        if (a.b.l != null) {
            b = a.b.l;
        }
        if (b == null) {
            for (var c = 0; c < this.cv.series.count; c++) {
                var d = this.cv.series._inner[c];
                if (!d.d7) {
                    b = d;
                    break;
                }
            }
        }
        if (b == null) {
            return null;
        }
        var e = b.ag();
        var f = b.h3();
        var g = null;
        var h = null;
        var i = false;
        for (var j = 0; j < e.length; j++) {
            if (e[j].b9) {
                i = true;
                g = e[j];
            }
            else if (e[j].cm) {
                i = true;
                h = e[j];
            }
            else if (e[j].cp) {
                h = e[j];
            }
            else {
                g = e[j];
            }
        }
        if (g == null || h == null) {
            return null;
        }
        if (!g.co() || !h.co()) {
            return null;
        }
        var k = 0;
        var l = 0;
        if (g.cb && g.categoryMode != 0) {
            if (b.el) {
                k = b.getOffsetValue();
            }
            else if (b.ed) {
                k = b.getOffsetValue();
            }
        }
        if (h.cb && h.categoryMode != 0) {
            if (b.ed) {
                l = b.getOffsetValue();
            }
        }
        var m = new ScalerParams(0, this.cv.tr, g.kd, g.ch, g.j8());
        m.b = f;
        var n = new ScalerParams(0, this.cv.tr, h.kd, h.ch, h.j8());
        n.b = f;
        var o = 0;
        var p = 0;
        if (i) {
            o = g.ej(this.ys(a.b.ac), m) + k;
            p = h.ej(this.ys(a.b.ad), n) + l;
            var q = o;
            var r = p;
            var s = { $type: Point_$type, x: 0.5, y: 0.5 };
            var t = s.x + (r * Math.cos(q));
            o = ViewportUtils.c(t, m.e, m.d);
            var u = s.y + (r * Math.sin(q));
            p = ViewportUtils.f(u, n.e, n.d);
        }
        else {
            o = g.ej(this.ys(a.b.ac), m) + k;
            p = h.ej(this.ys(a.b.ad), n) + l;
        }
        var v = new QuadTreeBoundingBox();
        v.b = o;
        v.c = p;
        v.e = 3;
        v.d = 3;
        v.g = a.b;
        return v;
    };
    CalloutLayer.prototype.ys = function (a) {
        if (typeCast(Date_$type, a) !== null) {
            return a.getTime();
        }
        if (a == null) {
            return 0;
        }
        return a;
    };
    CalloutLayer.prototype.yj = function () {
        var a = new List$1(CalloutAnnotationWrapper.$, 0);
        for (var b = 0; b < this.yi.count; b++) {
            if (stringIsNullOrEmpty(this.yi._inner[b].b.ao)) {
                continue;
            }
            if (this.yi._inner[b].c == null) {
                var c = new LabelCollisionInfo();
                this.yi._inner[b].c = c;
                var d = this.xb.cq(this.yy(this.yi._inner[b]), this.yi._inner[b].b.backgroundPadding);
                c.k = d.height / 2;
                c.l = d.width / 2;
            }
            var e = this.xx(this.yi._inner[b]);
            if (e == null || e.b < this.ty.left || e.b > this.ty.right || e.c < this.ty.top || e.c > this.ty.bottom) {
                continue;
            }
            a.add(this.yi._inner[b]);
        }
        return a;
    };
    CalloutLayer.prototype.yy = function (a) {
        return a.b.ao;
    };
    CalloutLayer.prototype.un = function (a) {
        if (!_super.prototype.un.call(this, a)) {
            return false;
        }
        if (this.zu != null) {
            if (a.eq) {
                var b = a.lv();
                if (!Base.equalsStatic(this.zu, b)) {
                    return false;
                }
            }
            else {
                if (!Base.equalsStatic(this.zu, a.name)) {
                    return false;
                }
            }
        }
        return true;
    };
    CalloutLayer.prototype.oq = function () {
        _super.prototype.oq.call(this);
        if (!this.at.c && !this.dk()) {
            return;
        }
        if (this.xy) {
            this.xy = false;
            this.aaf();
        }
        if (this.dk()) {
            this.aal(this.ui, false);
        }
        else {
            this.aal(this.ug, false);
        }
    };
    CalloutLayer.prototype.aag = function () {
        if (!this.x0) {
            this.x0 = true;
            this.pr(true);
        }
    };
    CalloutLayer.prototype.aaj = function (a, b, c) {
        var d = false;
        if (this.x0) {
            this.x0 = false;
            d = true;
        }
        if (!a.ft && a.dt(this.yg, this.yb, this.x9, this.yu)) {
            var e = this.yg;
            var _loop_1 = function (f) {
                var g = e._inner[f];
                var h = g.a != null ? g.a.item : null;
                var i = g.a.item != null ? g.a.item : g.a;
                var j = a;
                var k = new CalloutKey(i, j);
                var l = new CalloutAnnotationWrapper();
                var m = new CalloutAnnotation();
                l.b = m;
                m.key = k;
                var n = false;
                if (this_1.yc.containsKey(l)) {
                    l = this_1.yc.item(l).c;
                    m = l.b;
                    n = d;
                }
                else {
                    n = true;
                }
                var o = m.ac;
                var p = m.ad;
                if (this_1.ys(o) != this_1.ys(g.b)) {
                    m.xValue = g.b;
                }
                if (this_1.ys(p) != this_1.ys(g.c)) {
                    m.yValue = g.c;
                }
                m.series = a;
                var q = false;
                if (g.d != m.ay) {
                    m.ay = g.d;
                    q = true;
                }
                if (n || q) {
                    if (this_1.calloutLabelUpdating != null) {
                        var r = ((function () {
                            var $ret = new CalloutLabelUpdatingEventArgs();
                            $ret.d = m.ac;
                            $ret.e = m.ad;
                            $ret.item = h;
                            $ret.a = a;
                            $ret.f = a.name;
                            return $ret;
                        })());
                        this_1.calloutLabelUpdating(this_1, r);
                        if (r.c != null && !Base.equalsStatic(r.c, l.b.ao)) {
                            var s = r.c;
                            l.b.text = s != null ? s.toString() : "";
                        }
                    }
                    else {
                        if (g.d != null) {
                            m.text = g.d;
                        }
                    }
                }
                if (m.ao == null) {
                    return "continue";
                }
                if (n || q) {
                    if (this_1.calloutContentUpdating != null) {
                        var t = ((function () {
                            var $ret = new CalloutContentUpdatingEventArgs();
                            $ret.c = m.ac;
                            $ret.d = m.ad;
                            $ret.item = h;
                            $ret.a = i;
                            return $ret;
                        })());
                        this_1.calloutContentUpdating(this_1, t);
                        if (t.a != null && t.a != l.b.aa) {
                            l.b.content = t.a;
                        }
                    }
                    else {
                        if (i != null && i != l.b.aa) {
                            l.b.content = i;
                        }
                    }
                }
                if (n) {
                    this_1.aan(l);
                }
                if (l.c == null) {
                    var u = new LabelCollisionInfo();
                    l.c = u;
                    var v = this_1.xb.cq(this_1.yy(l), l.b.backgroundPadding);
                    u.k = v.height / 2;
                    u.l = v.width / 2;
                }
                var w = this_1.xx(l);
                if (w == null || w.b < this_1.ty.left || w.b > this_1.ty.right || w.c < this_1.ty.top || w.c > this_1.ty.bottom) {
                    return "continue";
                }
                l.e = w.b;
                l.f = w.c;
                c.add(l);
            };
            var this_1 = this;
            for (var f = 0; f < this.yg.count; f++) {
                _loop_1(f);
            }
        }
    };
    CalloutLayer.prototype.bu = function () {
        return 1;
    };
    CalloutLayer.prototype.au = function (a, b) {
        var c = this.xu.f(a, b);
        if (c == null) {
            return null;
        }
        return c.u;
    };
    CalloutLayer.prototype.f5 = function (a, b) {
        if (this.xu == null) {
            return false;
        }
        return this.xu.f(a, b) != null;
    };
    CalloutLayer.prototype.aal = function (a, b) {
        var e_3, _a;
        var c = 0;
        var d = new HashSet$1(CalloutAnnotationWrapper.$, 0);
        for (c = 0; c < a.q.count; c++) {
            var e = a.n._inner[c];
            if (isNaN_(a.u._inner[c]) || isNaN_(a.v._inner[c])) {
                continue;
            }
            var f = this.xb.cb.item(e);
            d.add_1(e);
            if (f.h != a.q._inner[c]) {
                f.h = a.q._inner[c];
                var g = f.u();
            }
            f.e = a.o._inner[c];
            f.m = a.f._inner[c];
            f.p = a.p._inner[c];
            f.o = f.e > 0 ? a.i._inner[c] : this.cg.bt();
            f.n = a.h._inner[c];
            f.x = new Thickness(1, a.k._inner[c], a.m._inner[c], a.l._inner[c], a.j._inner[c]);
            f.d = a.g._inner[c];
            this.xb.cj(f, Math.min(a.s._inner[c], a.s._inner[c] + a.u._inner[c]), Math.min(a.t._inner[c], a.t._inner[c] + a.v._inner[c]));
            this.xb.ck(f, e, a.r._inner[c]);
            f.r = { $type: Point_$type, x: a.u._inner[c], y: a.v._inner[c] };
        }
        var h = new List$1(CalloutAnnotationWrapper.$, 0);
        try {
            for (var _b = __values(fromEnum(this.xb.cb.c)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var i = _c.value;
                if (!d.contains(i)) {
                    h.add(i);
                }
            }
        }
        catch (e_3_1) {
            e_3 = { error: e_3_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_3)
                    throw e_3.error;
            }
        }
        for (var j = 0; j < h.count; j++) {
            this.xb.cb.h(h._inner[j]);
        }
    };
    CalloutLayer.prototype.vz = function (a, b) {
        _super.prototype.vz.call(this, a, b);
        if (this.dk()) {
            this.aal(this.ui, true);
        }
        else {
            this.aal(this.ug, false);
        }
    };
    CalloutLayer.prototype.fn = function () {
        return true;
    };
    CalloutLayer.prototype.pa = function (a, b, c, d) {
        _super.prototype.pa.call(this, a, b, c, d);
        switch (b) {
            case CalloutLayer.$$p[24]:
                this.xi = null;
                this.xb.ci();
                this.pr(true);
                break;
            case CalloutLayer.$$p[22]:
            case CalloutLayer.$$p[23]:
                this.pr(true);
                break;
            case CalloutLayer.$$p[14]:
                this.pr(true);
                break;
            case "SeriesViewer":
                if (c != null) {
                    var e = c;
                    e.seriesAnimating = delegateRemove(e.seriesAnimating, runOn(this, this.aak));
                }
                if (d != null) {
                    var f = d;
                    f.seriesAnimating = delegateCombine(f.seriesAnimating, runOn(this, this.aak));
                }
                if (d == null) {
                    this.aad();
                }
                break;
            case "AutoCalloutVisibilityMode":
                this.w5 = this.w7();
                this.aae();
                break;
            case "AllowedPositions":
                if (c != null) {
                    var g = c;
                    g.collectionChanged = delegateRemove(g.collectionChanged, runOn(this, this.z8));
                }
                if (d != null) {
                    var h = d;
                    h.collectionChanged = delegateCombine(h.collectionChanged, runOn(this, this.z8));
                }
                this.w2 = this.w3(this.xd);
                this.aae();
                break;
            case CalloutLayer.$$p[16]:
            case CalloutLayer.$$p[17]:
            case CalloutLayer.$$p[1]:
            case CalloutLayer.$$p[6]:
            case CalloutLayer.$$p[5]:
            case CalloutLayer.$$p[25]:
            case CalloutLayer.$$p[26]:
            case CalloutLayer.$$p[19]:
            case CalloutLayer.$$p[18]:
            case CalloutLayer.$$p[8]:
            case CalloutLayer.$$p[10]:
            case CalloutLayer.$$p[9]:
            case CalloutLayer.$$p[7]:
            case CalloutLayer.$$p[12]:
            case CalloutLayer.$$p[13]:
                this.aae();
                break;
            case CalloutLayer.$$p[21]:
                if (this.c7 != null) {
                    this.c7.deregisterColumn(this.xr);
                    this.xr = this.c6(this.zs);
                }
                break;
            case "LabelColumn":
                this.aae();
                break;
            case CalloutLayer.$$p[15]:
                if (this.c7 != null) {
                    this.c7.deregisterColumn(this.xp);
                    this.xp = this.c6(this.zi);
                }
                break;
            case "ContentColumn":
                this.aae();
                break;
            case CalloutLayer.$$p[28]:
                if (this.c7 != null) {
                    this.c7.deregisterColumn(this.xs);
                    this.xs = stringIsNullOrEmpty(this.z3) == false ? this.c6(this.z3) : null;
                }
                break;
            case "XColumn":
                this.aae();
                break;
            case CalloutLayer.$$p[29]:
                if (this.c7 != null) {
                    this.c7.deregisterColumn(this.xt);
                    this.xt = this.c6(this.z6);
                }
                break;
            case "YColumn":
                this.aae();
                break;
            case CalloutLayer.$$p[20]:
                if (this.c7 != null) {
                    this.c7.deregisterColumn(this.xq);
                    this.xq = this.c6(this.zp);
                }
                break;
            case "KeyColumn":
                this.aae();
                break;
            case "FastItemsSource":
                this.xz = true;
                if (typeCast(IFastItemsSource_$type, c) != null) {
                    c.deregisterColumn(this.xr);
                    c.deregisterColumn(this.xp);
                    c.deregisterColumn(this.xs);
                    c.deregisterColumn(this.xt);
                    c.deregisterColumn(this.xq);
                    this.xr = null;
                    this.xp = null;
                    this.xs = null;
                    this.xt = null;
                    this.xq = null;
                    this.yi.clear();
                }
                if (typeCast(IFastItemsSource_$type, d) != null) {
                    this.xr = this.c6(this.zs);
                    this.xp = this.c6(this.zi);
                    if (stringIsNullOrEmpty(this.z3) == false) {
                        this.xs = this.c6(this.z3);
                    }
                    this.xt = this.c6(this.z6);
                    this.xq = this.c6(this.zp);
                }
                this.aae();
                break;
        }
    };
    CalloutLayer.prototype.w7 = function () {
        if (this.w6 == 0) {
            return 1;
        }
        return this.w6;
    };
    CalloutLayer.prototype.w3 = function (a) {
        if (a == null || a.count == 0) {
            return null;
        }
        var b = new Array(a.count);
        for (var c = 0; c < a.count; c++) {
            b[c] = a._inner[c];
        }
        return b;
    };
    CalloutLayer.prototype.aak = function (a) {
        if (a.d7) {
            return;
        }
        if ((a == this.xh || this.xh == null) && this.x5) {
            this.pr(false);
        }
    };
    CalloutLayer.prototype.aae = function () {
        if (this.xy == false) {
            this.xy = true;
            this.pr(false);
        }
    };
    CalloutLayer.prototype.aac = function () {
        this.xb.cb.clear();
        this.yf.g();
        this.yc.clear();
    };
    CalloutLayer.prototype.aaf = function () {
        if (this.xt == null || this.xr == null) {
            var a = this.yf.c;
            while (a != null) {
                this.aan(a.c);
                a = a.a;
            }
            return;
        }
        var b = this.yd();
        for (var c = 0; c < this.xt.count; c++) {
            var d = void 0;
            if (this.yi.count <= c) {
                var e = new CalloutAnnotation();
                d = new CalloutAnnotationWrapper();
                d.b = e;
                d.b.series = this.xh;
                this.yi.add(d);
            }
            else {
                d = this.yi._inner[c];
            }
            this.aam(c, b);
        }
    };
    CalloutLayer.$t = markType(CalloutLayer, 'CalloutLayer', AnnotationLayer.$);
    CalloutLayer.aa2 = DependencyProperty.i("AutoCalloutVisibilityMode", AutoCalloutVisibilityMode_$type, CalloutLayer.$, new PropertyMetadata(2, enumGetBox(AutoCalloutVisibilityMode_$type, 0), function (a, b) { return a.raisePropertyChanged("AutoCalloutVisibilityMode", b.oldValue, b.newValue); }));
    CalloutLayer.$$p = markDep(DependencyProperty, PropertyMetadata, CalloutLayer, 'raisePropertyChanged', ['AutoCalloutLabelPrecision:yu:aao', [1, 5], 'CalloutBackground:abj:aap', [Brush.$, null], 'CalloutCollisionMode:w8:aaq', [CalloutCollisionMode_$type, enumGetBox(CalloutCollisionMode_$type, 3)], 'CalloutCornerRadius:yl:aar', [1, NaN], 'CalloutInterpolatedValuePrecision:yv:aas', [1, -1], 'CalloutLeaderBrush:abk:aat', [Brush.$, null], 'CalloutOutline:abl:aau', [Brush.$, null], 'CalloutPaddingBottom:ym:aav', [1, NaN], 'CalloutPaddingLeft:yn:aaw', [1, NaN], 'CalloutPaddingRight:yo:aax', [1, NaN], 'CalloutPaddingTop:yp:aay', [1, NaN], 'CalloutPositionPadding:yq:aaz', [1, 10], 'CalloutStrokeThickness:yr:aa0', [1, NaN], 'CalloutTextColor:abm:aa1', [Brush.$, null], 'CollisionChannel:zf:aa3', [2, null], 'ContentMemberPath:zi:aa4', [2, null], 'IsAutoCalloutBehaviorEnabled:x5:aa5', [0, false], 'IsCalloutOffsettingEnabled:x6:aa6', [0, true], 'IsCustomCalloutRenderStyleEnabled:x7:aa7', [0, false], 'IsCustomCalloutStyleEnabled:x8:aa8', [0, false], 'KeyMemberPath:zp:aa9', [2, null], 'LabelMemberPath:zs:aba', [2, null], 'TargetSeriesName:zu:abb', [2, null], 'TargetSeries:xh:abc', [Series.$, null], 'TextStyle:zx:abd', [2, null], 'UseInterpolatedValueForAutoCalloutLabels:x9:abe', [0, false], 'UseSeriesColorForOutline:ya:abf', [0, false], 'UseValueForAutoCalloutLabels:yb:abg', [0, true], 'XMemberPath:z3:abh', [2, null], 'YMemberPath:z6:abi', [2, null]]);
    return CalloutLayer;
}(AnnotationLayer));
export { CalloutLayer };
/**
 * @hidden
 */
var CalloutLayerView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CalloutLayerView, _super);
    function CalloutLayerView(a) {
        var _this = _super.call(this, a) || this;
        _this.b7 = null;
        _this.cc = null;
        _this.cb = null;
        _this.cd = NaN;
        _this.b8 = null;
        _this.b7 = a;
        _this.cc = new List$1(CalloutView.$, 0);
        return _this;
    }
    CalloutLayerView.prototype.au = function () {
        var _this = this;
        _super.prototype.au.call(this);
        this.cb = ((function () {
            var $ret = new HashPool$2(CalloutAnnotationWrapper.$, CalloutView.$);
            $ret.create = runOn(_this, _this.b9);
            $ret.activate = runOn(_this, _this.cf);
            $ret.disactivate = runOn(_this, _this.ch);
            $ret.destroy = runOn(_this, _this.cg);
            return $ret;
        })());
    };
    CalloutLayerView.prototype.b9 = function () {
        var a = new CalloutView(this);
        this.cc.add(a);
        return a;
    };
    CalloutLayerView.prototype.cf = function (a) {
        a.y = 0;
    };
    CalloutLayerView.prototype.ch = function (a) {
        a.y = 1;
    };
    CalloutLayerView.prototype.cg = function (a) {
        this.cc.remove(a);
    };
    CalloutLayerView.prototype.cp = function (a) {
        if (a == null) {
            return a;
        }
        return BrushUtil.m(a, 0.1);
    };
    CalloutLayerView.prototype.a8 = function (a, b) {
        _super.prototype.a8.call(this, a, b);
        a.ad(this.ca());
        if (a.d && !b) {
            for (var c = 0; c < this.cc.count; c++) {
                var d = this.cc._inner[c];
                if (d.y == 0) {
                    d.j(a);
                }
            }
        }
    };
    CalloutLayerView.prototype.ca = function () {
        if (this.b7.xj != null) {
            return this.b7.xj;
        }
        return this.e.cv.getFontInfo();
    };
    CalloutLayerView.prototype.an = function (a) {
        _super.prototype.an.call(this, a);
        for (var b = 0; b < this.cc.count; b++) {
            var c = this.cc._inner[b];
            if (c.y != 0) {
                continue;
            }
            c.i(this.b7, this.ca(), a);
        }
    };
    CalloutLayerView.prototype.cr = function (a) {
        this.k.ad(this.ca());
        this.cd = this.ce();
        var b = this.k.ah(a, this.cd, true);
        return new Size(1, b.c, b.b);
    };
    CalloutLayerView.prototype.ce = function () {
        var a = this.ca();
        if (isNaN_(this.cd)) {
            var b = FontUtil.getCurrentFontHeight(this.e.cv.cu.j.ae, a);
            this.cd = b;
        }
        return this.cd;
    };
    CalloutLayerView.prototype.cq = function (a, b) {
        if (this.b8 == null) {
            this.b8 = new CalloutView(this);
        }
        this.b8.h = a;
        this.b8.x = b;
        var c = this.b8.u();
        this.b8.h = null;
        return c;
    };
    CalloutLayerView.prototype.cj = function (a, b, c) {
        a.f = b;
        a.g = c;
    };
    CalloutLayerView.prototype.ck = function (a, b, c) {
        a.k(this.e, b, c);
    };
    CalloutLayerView.prototype.cl = function (a) {
        if (a != null) {
            return this.cp(a.sz);
        }
        return this.e.sz;
    };
    CalloutLayerView.prototype.co = function () {
        return ((function () {
            var $ret = new Brush();
            $ret.color = Color.u(255, 255, 255, 255);
            return $ret;
        })());
    };
    CalloutLayerView.prototype.cn = function (a) {
        if (this.b7.ya) {
            if (a != null) {
                return this.cp(a.sz);
            }
        }
        return ((function () {
            var $ret = new Brush();
            $ret.color = Color.u(255, 255, 255, 255);
            return $ret;
        })());
    };
    CalloutLayerView.prototype.cm = function (a) {
        if (a != null) {
            return this.cp(a.su);
        }
        return this.e.su;
    };
    CalloutLayerView.prototype.ci = function () {
        this.cd = NaN;
    };
    CalloutLayerView.$t = markType(CalloutLayerView, 'CalloutLayerView', AnnotationLayerView.$);
    return CalloutLayerView;
}(AnnotationLayerView));
export { CalloutLayerView };
/**
 * @hidden
 */
var CalloutView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(CalloutView, _super);
    function CalloutView(a) {
        var _this = _super.call(this) || this;
        _this.a = null;
        _this.y = 0;
        _this.l = null;
        _this.t = null;
        _this.q = { $type: Point_$type, x: 0, y: 0 };
        _this.s = null;
        _this.w = new Thickness(0, 0);
        _this.v = null;
        _this.c = 0;
        _this.f = 0;
        _this.g = 0;
        _this.b = null;
        _this.s = new Line();
        _this.s.ab = false;
        _this.s._stroke = ((function () {
            var $ret = new Brush();
            $ret.color = Color.u(255, 0, 0, 0);
            return $ret;
        })());
        _this.s.ad = 2;
        _this.l = new TextBlock();
        _this.t = new Rectangle();
        _this.t.ad = 0;
        _this.a = a;
        _this.y = 0;
        return _this;
    }
    CalloutView.prototype.j = function (a) {
        a.aa();
        a.ag(this.f, this.g);
        var b = new TranslateTransform();
        b.j = this.v.left;
        b.k = this.v.top;
        this.t.j = b;
        a.s(this.s);
        a.aa();
        this.t.width = this.l.m + this.w.left + this.w.right;
        this.t.height = this.l.l + this.w.top + this.w.bottom;
        this.t.ap = this.c;
        this.t.aq = this.c;
        a.k(this.t.j);
        a.w(this.t);
        this.l.ag = true;
        this.l.o = this.w.top;
        this.l.n = this.w.left;
        a.x(this.l);
        a.z();
        a.z();
    };
    Object.defineProperty(CalloutView.prototype, "r", {
        get: function () {
            return this.q;
        },
        set: function (a) {
            if (this.q.x != a.x || this.q.y != a.y) {
                var b = this.u();
                var c = b.height;
                var d = b.width;
                this.q = a;
                var e = CalloutViewHelper.b(this.r, d, c, this.s);
                this.v = e;
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "p", {
        get: function () {
            return this.l.ao;
        },
        set: function (a) {
            this.l.ao = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "o", {
        get: function () {
            return this.t._stroke;
        },
        set: function (a) {
            this.t._stroke = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "n", {
        get: function () {
            return this.s._stroke;
        },
        set: function (a) {
            this.s._stroke = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "m", {
        get: function () {
            return this.t._fill;
        },
        set: function (a) {
            this.t._fill = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "e", {
        get: function () {
            return this.t.ad;
        },
        set: function (a) {
            this.t.ad = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "x", {
        get: function () {
            return this.w;
        },
        set: function (a) {
            this.w = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "d", {
        get: function () {
            return this.c;
        },
        set: function (a) {
            this.c = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(CalloutView.prototype, "h", {
        get: function () {
            return this.l.al;
        },
        set: function (a) {
            if (a == null) {
                this.l.al = "";
            }
            else {
                this.l.al = a.toString();
            }
            var b = this.u();
            var c = b.height;
            var d = b.width;
            var e = CalloutViewHelper.b(this.r, d, c, this.s);
            this.v = e;
        },
        enumerable: false,
        configurable: true
    });
    CalloutView.prototype.u = function () {
        var a = this.a.cr(this.l);
        this.l.m = a.width;
        this.l.l = a.height;
        return new Size(1, a.width + this.w.left + this.w.right, a.height + this.w.top + this.w.bottom);
    };
    CalloutView.prototype.k = function (a, b, c) {
        if (this.b == null) {
            this.b = new DataContext();
        }
        this.b.series = a;
        this.b.item = c;
        if (b.c != null) {
            b.c.u = this.b;
        }
    };
    CalloutView.prototype.i = function (a, b, c) {
        a.a5.exportCalloutData(this.f, this.g, this.v.left, this.v.top, c, this.t, this.l, b, this.s, "callout", ["Main", "Callout"]);
    };
    CalloutView.$t = markType(CalloutView, 'CalloutView');
    return CalloutView;
}(Base));
export { CalloutView };
