/*
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 { Base, Point_$type, typeCast, runOn, delegateCombine, fromEnum, markType, String_$type, delegateRemove, EnumUtil, IEnumerable_$type, enumGetBox, markDep } from "igniteui-react-core";
import { IOuterLabelWidthDecider_$type } from "./IOuterLabelWidthDecider";
import { IFunnelLabelSizeDecider_$type } from "./IFunnelLabelSizeDecider";
import { ServiceProvider } from "./ServiceProvider";
import { MessageChannel } from "./MessageChannel";
import { MouseLeaveMessage } from "./MouseLeaveMessage";
import { MouseMoveMessage } from "./MouseMoveMessage";
import { MouseButtonMessage } from "./MouseButtonMessage";
import { Rect } from "igniteui-react-core";
import { RenderingContext } from "igniteui-react-core";
import { SetAreaSizeMessage } from "./SetAreaSizeMessage";
import { RenderingMessage } from "./RenderingMessage";
import { Polygon } from "igniteui-react-core";
import { PointCollection } from "igniteui-react-core";
import { TextBlock } from "igniteui-react-core";
import { RenderSliceMessage } from "./RenderSliceMessage";
import { List$1 } from "igniteui-react-core";
import { Brush } from "igniteui-react-core";
import { RenderOuterLabelMessage } from "./RenderOuterLabelMessage";
import { SliceInfo } from "./SliceInfo";
import { TooltipValueChangedMessage } from "./TooltipValueChangedMessage";
import { TooltipUpdateMessage } from "./TooltipUpdateMessage";
import { FunnelDataContext } from "./FunnelDataContext";
import { PropertyChangedMessage } from "./PropertyChangedMessage";
import { FontUtil } from "igniteui-react-core";
import { CanvasViewRenderer } from "igniteui-react-core";
import { DOMEventProxy } from "igniteui-react-core";
import { BrushCollection } from "igniteui-react-core";
import { BrushUtil } from "igniteui-react-core";
import { MessageHandler } from "./MessageHandler";
import { ClearMessage } from "./ClearMessage";
import { ClearTooltipMessage } from "./ClearTooltipMessage";
import { ContainerSizeChangedMessage } from "./ContainerSizeChangedMessage";
import { ViewportChangedMessage } from "./ViewportChangedMessage";
import { ViewPropertyChangedMessage } from "./ViewPropertyChangedMessage";
import { ObjectColumn } from "./ObjectColumn";
import { Size } from "igniteui-react-core";
import { isNaN_ } from "igniteui-react-core";
import { stringReplace } from "igniteui-react-core";
import { SliceInfoList } from "./SliceInfoList";
import { DoubleAnimator } from "igniteui-react-core";
import { Bezier } from "./Bezier";
import { DoubleColumn } from "./DoubleColumn";
import { OuterLabelAlignment_$type } from "./OuterLabelAlignment";
import { FunnelSliceDisplay_$type } from "./FunnelSliceDisplay";
import { IItemProvider_$type } from "./IItemProvider";
import { SliceSelectionManager } from "./SliceSelectionManager";
import { FunnelFrame } from "./FunnelFrame";
import { Style } from "igniteui-react-core";
import { IChartLegend_$type } from "igniteui-react-core";
import { DataTemplate } from "igniteui-react-core";
import { DataUpdatedMessage } from "./DataUpdatedMessage";
import { UserSelectedItemsChangedMessage } from "./UserSelectedItemsChangedMessage";
import { LabelSizeChangedMessage } from "./LabelSizeChangedMessage";
import { NotifyCollectionChangedEventArgs } from "igniteui-react-core";
import { FrameRenderCompleteMessage } from "./FrameRenderCompleteMessage";
import { IntColumn } from "./IntColumn";
import { PointList } from "./PointList";
import { Convert } from "igniteui-react-core";
import { ObservableCollection$1 } from "igniteui-react-core";
import { ILegendSeries_$type } from "igniteui-react-core";
import { UIElement } from "igniteui-react-core";
import { ContentControl } from "igniteui-react-core";
import { FunnelSliceDataContext } from "./FunnelSliceDataContext";
import { Control } from "igniteui-react-core";
import { SliceClickedMessage } from "./SliceClickedMessage";
import { SelectedItemsChangedMessage } from "./SelectedItemsChangedMessage";
import { SliceMouseMessage } from "./SliceMouseMessage";
import { ILegendOwner_$type } from "igniteui-react-core";
import { ILegendTemplateProvider_$type } from "igniteui-react-core";
import { DependencyProperty } from "igniteui-react-core";
import { FastItemsSource } from "igniteui-react-core";
import { Visibility_$type } from "igniteui-react-core";
import { Dictionary$2 } from "igniteui-react-core";
import { FunnelLegendTemplates } from "./FunnelLegendTemplates";
import { DeviceUtils } from "igniteui-react-core";
import { FunnelSliceClickedEventArgs } from "./FunnelSliceClickedEventArgs";
import { FunnelSliceEventArgs } from "./FunnelSliceEventArgs";
import { FunnelChartVisualData } from "./FunnelChartVisualData";
import { RectData } from "igniteui-react-core";
import { PropertyMetadata } from "igniteui-react-core";
/**
 * @hidden
 */
var XamFunnelView = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(XamFunnelView, _super);
    function XamFunnelView() {
        var _this = _super.call(this) || this;
        _this.g = null;
        _this.h = null;
        _this.f = null;
        _this.bg = null;
        _this.ad = null;
        _this.ae = null;
        _this.ah = null;
        _this.ai = null;
        _this.ag = null;
        _this.af = null;
        _this.o = null;
        _this.q = null;
        _this.r = null;
        _this.p = null;
        _this.j = null;
        _this.be = null;
        _this.bf = null;
        _this.k = null;
        _this.l = null;
        _this.x = -1;
        _this.y = -1;
        _this.z = -1;
        _this.u = 0;
        _this.v = 0;
        _this.aj = null;
        _this.c = null;
        _this.e = null;
        _this.t = 1;
        _this.w = NaN;
        _this.t = 1;
        _this.w = NaN;
        _this.f = new MessageChannel();
        _this.a9();
        _this.a8();
        var a = _this.g = new MessageHandler();
        a.b(ClearMessage.$, runOn(_this, _this.ap));
        a.b(RenderSliceMessage.$, runOn(_this, _this.a6));
        a.b(RenderOuterLabelMessage.$, runOn(_this, _this.a5));
        a.b(SetAreaSizeMessage.$, runOn(_this, _this.ba));
        a.b(TooltipValueChangedMessage.$, runOn(_this, _this.bc));
        a.b(TooltipUpdateMessage.$, runOn(_this, _this.bb));
        a.b(ClearTooltipMessage.$, runOn(_this, _this.ar));
        a.b(PropertyChangedMessage.$, runOn(_this, _this.a3));
        a.b(ContainerSizeChangedMessage.$, function (b) { return _this.as(); });
        _this.as();
        return _this;
    }
    Object.defineProperty(XamFunnelView.prototype, "i", {
        get: function () {
            return this.h;
        },
        set: function (a) {
            var b = this.h;
            this.h = a;
            this.a1(b, this.h);
        },
        enumerable: false,
        configurable: true
    });
    XamFunnelView.prototype.am = function (a) {
        this.f.i(new MouseLeaveMessage());
    };
    XamFunnelView.prototype.an = function (a, b, c) {
        var d = new MouseMoveMessage();
        d.c = a;
        this.f.i(d);
    };
    XamFunnelView.prototype.al = function (a) {
        var b = new MouseButtonMessage();
        b.h = a;
        b.c = 1;
        b.e = this.j.al ? 1 : 0;
        b.f = this.j.bi;
        this.f.i(b);
    };
    XamFunnelView.prototype.ao = function (a) {
        var b = new MouseButtonMessage();
        b.h = a;
        b.c = 0;
        b.e = this.j.al ? 1 : 0;
        b.f = this.j.bi;
        this.f.i(b);
    };
    XamFunnelView.prototype.ap = function (a) {
        var b = this.bg;
        if (Rect.l_op_Equality(b, null)) {
            return;
        }
        var c = b.left, d = b.top, e = b.width, f = b.height;
        this.aq(this.q, c, d, e, f);
        this.aq(this.o, c, d, e, f);
        this.aq(this.p, c, d, e, f);
        this.aq(this.r, c, d, e, f);
    };
    XamFunnelView.prototype.aq = function (a, b, c, d, e) {
        if (a != null) {
            if (a.d && this.t != 1) {
                a.aa();
                a.ab(this.t, this.t);
            }
            a.l(b, c, d, e);
            if (a.d && this.t != 1) {
                a.z();
            }
        }
    };
    XamFunnelView.prototype.ba = function (a) {
        var b = a.m;
        var c = a.e;
        if (c == "LeftPanel") {
            this.u = b;
        }
        if (c == "RightPanel") {
            this.v = b;
        }
    };
    XamFunnelView.prototype.a6 = function (a) {
        var b = a.g;
        var c = this.q;
        if (c.d && this.t != 1) {
            c.aa();
            c.ab(this.t, this.t);
        }
        var d = new Polygon();
        var e = new PointCollection(0);
        for (var f = 0; f < b.au.count; f++) {
            var g = b.au._inner[f];
            e.add({ $type: Point_$type, x: g.x + this.u + b.aq.x, y: g.y + b.aq.y });
        }
        d.an = e;
        d.ad = a.h;
        d._opacity = b.p;
        d._fill = b.ad;
        d._stroke = a.h < 1 ? b.ad : b.ag;
        if (b.a0 != null) {
            c.j(d, b.a0);
            b.ad = d._fill;
            b.ag = d._stroke;
            b.q = d.ad;
            b.p = d._opacity;
        }
        c.u(d);
        b.q = d.ad;
        if (b.i) {
            var h = new TextBlock();
            if (this.bf == null) {
                this.bf = new Brush();
                this.bf._fill = this.ak("ui-funnel-slice", "color", -1);
            }
            h.ao = this.bf;
            c.ad(this.m());
            var i = b.v.toString();
            var j = c.g(i);
            var k = this.ab();
            h.al = i;
            h.o = b.an.y + b.aq.y - (k / 2);
            h.n = b.an.x + this.u + b.aq.x - (j / 2);
            b.ax = new Rect(0, h.n, h.o, j, k);
            b.a2 = h._visibility;
            c.x(h);
        }
        if (c.d && this.t != 1) {
            c.z();
        }
    };
    XamFunnelView.prototype.a5 = function (a) {
        var b = 0;
        if (this.v > 0) {
            b = this.bg.width - this.v;
        }
        var c = a;
        var d = this.p;
        if (d.d && this.t != 1) {
            d.aa();
            d.ab(this.t, this.t);
        }
        var e = new TextBlock();
        e.al = c.j.toString();
        d.ad(this.n());
        if (this.be == null) {
            this.be = new Brush();
            this.be._fill = this.ad.rootWrapper.getStyleProperty("color");
        }
        e.ao = this.be;
        var f = this.ac();
        var g = c.l.y - f / 2;
        var h = d.g(e.al);
        e.n = b;
        e.o = g;
        c.f.b.ay = new Rect(0, b, g, h, f);
        d.x(e);
        if (d.d && this.t != 1) {
            d.z();
        }
    };
    XamFunnelView.prototype.az = function () {
        if (this.j != null) {
            this.j.bh(this.ai, "");
        }
    };
    XamFunnelView.prototype.ax = function (a) {
        this.av(a);
        if (this.j != null) {
            this.j.at(this.ai, "");
        }
    };
    XamFunnelView.prototype.bc = function (a) {
        this.aj = a.g;
    };
    XamFunnelView.prototype.bb = function (a) {
        this.at(a);
    };
    XamFunnelView.prototype.ar = function (a) {
        this.at(null);
    };
    XamFunnelView.prototype.at = function (a) {
        var x_ = 0, y_ = 0;
        var t_ = null, v_ = null, i_ = this.ad;
        {
            if (a != null) {
                t_ = this.aj;
                x_ = a.i.x + 6;
                y_ = a.i.y + 6;
                v_ = a.g.item;
            }
            var ren_ = this.ad;
            var dc_ = null;
            if (a != null) {
                dc_ = a.g;
            }
            if (dc_ == null) {
                dc_ = new FunnelDataContext();
            }
            dc_.item = v_;
            var tt_ = this.aj;
            if (tt_ != null) {
                if (v_ != null) {
                    tt_.updateToolTip(dc_);
                    tt_.setRawPosition(x_, y_);
                }
                else {
                    tt_.hideToolTip();
                }
            }
        }
    };
    XamFunnelView.prototype.a3 = function (a) {
        var b = a;
        var c = b.g;
        switch (c) {
            case "Container":
                this.ay(b.d);
                break;
            case "TextStyle":
                this.l = FontUtil.toFontInfo(this.ad, b.d.toString());
                break;
            case "OuterLabelTextStyle":
                this.k = FontUtil.toFontInfo(this.ad, b.d.toString());
                break;
            case "ActualPixelScalingRatio":
                if (isNaN_(this.w) || this.w == 0) {
                    this.t = b.d;
                }
                break;
            case "OuterLabelTextColor":
                this.be = typeCast(Brush.$, b.d);
                break;
            case "LabelTextColor":
                this.bf = typeCast(Brush.$, b.d);
                break;
        }
    };
    XamFunnelView.prototype.a4 = function (a) {
        if (this.ad != null) {
            this.ad.setTimeout(a, 0);
        }
        else {
            window.setTimeout(a, 0);
        }
    };
    XamFunnelView.prototype.ay = function (a) {
        if (a == null) {
            if (this.j != null) {
                this.j.av();
            }
            this.ad = null;
            this.ae = this.ah = this.ag = this.ai = null;
            this.o = this.q = this.p = this.r = null;
            this.j = null;
            return;
        }
        var b = a;
        var c = this.ad = b;
        c.rootWrapper.setStyleProperty("position", "relative");
        for (var d = 0; d < 4; d++) {
            var e = this.ad.createElement("canvas");
            e.setStyleProperty("position", "absolute");
            c.append(e);
            var f = new RenderingContext(new CanvasViewRenderer(), this.ad.get2DCanvasContext(e));
            if (d == 0) {
                this.ae = e;
                this.o = f;
            }
            if (d == 1) {
                this.ah = e;
                this.q = f;
            }
            if (d == 2) {
                this.ag = e;
                this.p = f;
            }
            if (d == 3) {
                this.ai = e;
                this.r = f;
            }
        }
        this.af = this.ad.createElement("span");
        this.af.setStyleProperty("position", "absolute");
        this.af.setStyleProperty("display", "none");
        c.append(this.af);
        this.j = new DOMEventProxy(this.ai, this.ad, false);
        var g = this.j;
        g.onMouseOver = delegateCombine(g.onMouseOver, runOn(this, this.an));
        var h = this.j;
        h.onMouseLeave = delegateCombine(h.onMouseLeave, runOn(this, this.am));
        var i = this.j;
        i.onMouseDown = delegateCombine(i.onMouseDown, runOn(this, this.al));
        var j = this.j;
        j.onMouseUp = delegateCombine(j.onMouseUp, runOn(this, this.ao));
        this.as();
    };
    XamFunnelView.prototype.aa = function () {
        var a = this.ak("ui-funnel-slice", "border-top-width", -1);
        return (a == null) ? -1 : parseInt(a);
    };
    XamFunnelView.prototype.m = function () {
        var a = this.l;
        if (a == null) {
            this.l = FontUtil.getFontForClass(this.ad, "ui-funnel-slice");
            a = this.l;
        }
        return a;
    };
    XamFunnelView.prototype.n = function () {
        var a = this.k;
        if (a == null) {
            this.k = a = FontUtil.getFont(this.ad);
        }
        return a;
    };
    XamFunnelView.prototype.ab = function () {
        var a = this.z;
        if (a < 0) {
            var b = this.l;
            a = FontUtil.getCurrentFontHeight(this.ad, b);
            this.z = a;
        }
        return a;
    };
    XamFunnelView.prototype.ac = function () {
        var a = this.y;
        if (a < 0) {
            var b = this.k;
            a = FontUtil.getCurrentFontHeight(this.ad, b);
            this.y = a;
        }
        return a;
    };
    XamFunnelView.prototype.d = function (a) {
        if (this.c != null) {
            return a ? this.c : this.e;
        }
        var b = BrushUtil.f("chart", this.ad, this.c, this.e);
        this.c = b.p2;
        this.e = b.p3;
        return a ? this.c : this.e;
    };
    XamFunnelView.prototype.ak = function (a, b, c) {
        var d = this.af;
        if (d == null) {
            return null;
        }
        d.addClass(a);
        var e = d.getStyleProperty(b);
        if (e == null || e.length == 0 || e == "null" || e == "transparent") {
            e = null;
        }
        if (c >= 0) {
            var f = new Brush();
            if (e != null && e.length != stringReplace(e, "(0, 0, 0, 0", "").length) {
                e = null;
            }
            f._fill = e == null ? XamFunnelView.a[c % XamFunnelView.a.length] : e;
            this.c.item(c, f);
            var g = null;
            if (e != null) {
                g = d.getStyleProperty("border-top-color");
                if (g == null || g.length == 0 || g == "null" || g == "transparent") {
                    g = e;
                }
            }
            f = new Brush();
            f._fill = (g == null) ? XamFunnelView.b[c % XamFunnelView.b.length] : g;
            this.e.item(c, f);
        }
        d.removeClass(a);
        return e;
    };
    XamFunnelView.prototype.a7 = function (a, b, c) {
        var d = new PropertyChangedMessage();
        d.g = a;
        d.e = b;
        d.d = c;
        this.f.i(d);
    };
    XamFunnelView.prototype.av = function (a) {
        var b = a.bs;
        var c = a.bn;
        if (!isNaN_(b) && b != 0) {
            return;
        }
        if (window.devicePixelRatio != undefined && window.devicePixelRatio != c) {
            a.bn = window.devicePixelRatio;
        }
    };
    XamFunnelView.prototype.aw = function (a) {
        this.g.c(a);
    };
    XamFunnelView.prototype.a1 = function (a, b) {
        if (a != null) {
            var c = typeCast(MessageChannel.$, a.b("RenderingMessages"));
            if (c != null) {
                c.h(runOn(this, this.aw));
            }
            this.f.g();
        }
        if (b != null) {
            var d = typeCast(MessageChannel.$, b.b("RenderingMessages"));
            if (d != null) {
                d.e(runOn(this, this.aw));
            }
            var e = typeCast(MessageChannel.$, b.b("InteractionMessages"));
            this.f.f(e);
        }
    };
    XamFunnelView.prototype.bd = function (a, b, c, d, e) {
        a.setAttribute("width", b.toString());
        a.setAttribute("height", c.toString());
        a.setStyleProperty("width", d.toString() + "px");
        a.setStyleProperty("height", e.toString() + "px");
    };
    XamFunnelView.prototype.as = function () {
        if (this.ad == null) {
            return;
        }
        var a = this.ad.rootWrapper.width();
        var b = this.ad.rootWrapper.height();
        this.bg = new Rect(0, 0, 0, a, b);
        if (this.j != null) {
            this.j.bl = this.bg;
        }
        this.bd(this.ae, a * this.t, b * this.t, a, b);
        this.bd(this.ah, a * this.t, b * this.t, a, b);
        this.bd(this.ag, a * this.t, b * this.t, a, b);
        this.bd(this.ai, a * this.t, b * this.t, a, b);
        var c = new ViewportChangedMessage();
        c.e = a;
        c.d = b;
        this.f.i(c);
    };
    XamFunnelView.prototype.a0 = function () {
        this.as();
    };
    XamFunnelView.prototype.a9 = function () {
        var a = new ViewPropertyChangedMessage();
        a.g = "OuterLabelWidthDecider";
        a.e = null;
        a.d = typeCast(IOuterLabelWidthDecider_$type, this);
        this.f.i(a);
    };
    XamFunnelView.prototype.a8 = function () {
        var a = new ViewPropertyChangedMessage();
        a.g = "FunnelLabelSizeDecider";
        a.e = null;
        a.d = typeCast(IFunnelLabelSizeDecider_$type, this);
        this.f.i(a);
    };
    XamFunnelView.prototype.decideWidth = function (a) {
        var e_1, _a;
        var b = a == null ? null : a.a;
        if (b == null) {
            return 0;
        }
        var c = 0;
        this.p.ad(this.n());
        try {
            for (var _b = __values(fromEnum(b)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var d = _c.value;
                if (d != null) {
                    c = Math.max(this.p.g(d.toString()), c);
                }
            }
        }
        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;
            }
        }
        return c;
    };
    XamFunnelView.prototype.decideLabelSize = function (a, b) {
        var c = 0;
        if (a.b.i) {
            this.p.ad(this.m());
            c = this.p.g(a.b.v.toString());
        }
        return new Size(1, c, b ? this.ab() : this.ac());
    };
    XamFunnelView.prototype.s = function (a, f_) {
        if (f_ == null) {
            return true;
        }
        var b = a.a;
        var c_ = this.ad;
        c_ = c_ ? c_.data('igFunnelChart') : null;
        if (b == null || c_ == null) {
            return false;
        }
        var i_ = b.count;
        var c = new Array(i_);
        while (i_-- > 0) {
            var v_ = b.item(i_);
            c[i_] = f_(v_, i_, c_);
        }
        a.b(c);
        return true;
    };
    XamFunnelView.prototype.au = function () {
    };
    XamFunnelView.prototype.a2 = function () {
    };
    XamFunnelView.$t = markType(XamFunnelView, 'XamFunnelView', Base.$, [IOuterLabelWidthDecider_$type, IFunnelLabelSizeDecider_$type]);
    XamFunnelView.a = ["#7000ff", "#70ff00", "#00f0f0", "#ff0070", "#ff00ff"];
    XamFunnelView.b = ["#7000dd", "#70dd00", "#00d0d0", "#dd0070", "#dd00dd"];
    return XamFunnelView;
}(Base));
export { XamFunnelView };
/**
 * @hidden
 */
var XamFunnelController = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(XamFunnelController, _super);
    function XamFunnelController() {
        var _this = _super.call(this) || this;
        _this.bp = null;
        _this.ag = null;
        _this.at = null;
        _this.cf = null;
        _this.cg = null;
        _this.cb = null;
        _this.cc = null;
        _this.bb = false;
        _this.bg = false;
        _this.au = null;
        _this.aj = null;
        _this.z = null;
        _this.al = null;
        _this.ao = null;
        _this.ap = null;
        _this.cl = null;
        _this.ci = null;
        _this.ch = null;
        _this.a4 = false;
        _this.bv = 0;
        _this.bu = 0;
        _this.w = null;
        _this.v = null;
        _this.t = null;
        _this.p = null;
        _this.a0 = false;
        _this.a3 = false;
        _this.bt = 0;
        _this.a2 = false;
        _this.bq = 0;
        _this.a = null;
        _this.b = null;
        _this.ad = 0;
        _this.m = 0;
        _this.ax = false;
        _this.bs = 0;
        _this.a5 = false;
        _this.dv = null;
        _this.du = null;
        _this.aw = false;
        _this.b5 = 0;
        _this.b6 = 0;
        _this.r = null;
        _this.ab = null;
        _this.ah = null;
        _this.g = null;
        _this.e = null;
        _this.f = null;
        _this.d0 = null;
        _this.d1 = null;
        _this.a7 = false;
        _this.a1 = false;
        _this.a6 = false;
        _this.az = false;
        _this.ck = null;
        _this.cj = null;
        _this.br = -1;
        _this.ay = false;
        _this.l = null;
        _this.o = null;
        _this.dp = null;
        _this.dn = null;
        _this.dz = null;
        _this.av = new DoubleAnimator(0, 1, 2000);
        var a = _this.av;
        a.propertyChanged = delegateCombine(a.propertyChanged, runOn(_this, _this.cz));
        _this.k = new FunnelFrame();
        _this.j = new FunnelFrame();
        _this.h = new FunnelFrame();
        _this.ai = new SliceSelectionManager();
        _this.am = new DoubleColumn();
        _this.ar = new ObjectColumn();
        _this.as = new ObjectColumn();
        _this.y = new MessageChannel();
        _this.x = new MessageChannel();
        _this.aa = new MessageHandler();
        _this.aa.b(PropertyChangedMessage.$, runOn(_this, _this.de));
        _this.aa.b(DataUpdatedMessage.$, runOn(_this, _this.cv));
        _this.aa.b(ViewportChangedMessage.$, runOn(_this, _this.dl));
        _this.aa.b(ViewPropertyChangedMessage.$, runOn(_this, _this.dm));
        _this.aa.b(MouseMoveMessage.$, runOn(_this, _this.c5));
        _this.aa.b(MouseButtonMessage.$, runOn(_this, _this.c3));
        _this.aa.b(MouseLeaveMessage.$, runOn(_this, _this.c4));
        _this.aa.b(UserSelectedItemsChangedMessage.$, runOn(_this, _this.dk));
        _this.aa.b(LabelSizeChangedMessage.$, runOn(_this, _this.c1));
        _this.aa.b(ContainerSizeChangedMessage.$, function (b) { return _this.y.i(b); });
        _this.bp = function (b, c) {
            _this.bj = true;
            _this.df();
        };
        return _this;
    }
    XamFunnelController.prototype.cz = function (a, b) {
        this.b2 = this.av.o;
        if (this.b2 == 1) {
            this.a9 = false;
            this.cw(this.h);
        }
        if (this.a9) {
            var c = 1 - this.b2;
            FunnelFrame.k(this.j, this.k, this.h, this.b2);
            this.cw(this.j);
        }
    };
    Object.defineProperty(XamFunnelController.prototype, "av", {
        get: function () {
            return this.au;
        },
        set: function (a) {
            this.au = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "ak", {
        get: function () {
            return this.aj;
        },
        set: function (a) {
            this.aj = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "aa", {
        get: function () {
            return this.z;
        },
        set: function (a) {
            this.z = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "am", {
        get: function () {
            return this.al;
        },
        set: function (a) {
            this.al = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "ar", {
        get: function () {
            if (!this.bb && this.at != null) {
                this.bb = this.at.s(this.ao, this.cb);
            }
            return this.ao;
        },
        set: function (a) {
            this.ao = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "as", {
        get: function () {
            if (!this.bg && this.at != null) {
                this.bg = this.at.s(this.ap, this.cc);
            }
            return this.ap;
        },
        set: function (a) {
            this.ap = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "cq", {
        get: function () {
            return this.cl;
        },
        set: function (a) {
            this.cl = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "cn", {
        get: function () {
            return this.ci;
        },
        set: function (a) {
            this.ci = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "cm", {
        get: function () {
            return this.ch;
        },
        set: function (a) {
            this.ch = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "bj", {
        get: function () {
            return this.a4;
        },
        set: function (a) {
            this.a4 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "b4", {
        get: function () {
            return this.bv;
        },
        set: function (a) {
            this.bv = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "b3", {
        get: function () {
            return this.bu;
        },
        set: function (a) {
            this.bu = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "y", {
        get: function () {
            return this.w;
        },
        set: function (a) {
            this.w = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "x", {
        get: function () {
            return this.v;
        },
        set: function (a) {
            this.v = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "u", {
        get: function () {
            return this.t;
        },
        set: function (a) {
            this.t = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "q", {
        get: function () {
            return this.p;
        },
        set: function (a) {
            this.p = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "bc", {
        get: function () {
            return this.a0;
        },
        set: function (a) {
            this.a0 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "bh", {
        get: function () {
            return this.a3;
        },
        set: function (a) {
            this.a3 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "b2", {
        get: function () {
            return this.bt;
        },
        set: function (a) {
            this.bt = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "be", {
        get: function () {
            return this.a2;
        },
        set: function (a) {
            this.a2 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "bw", {
        get: function () {
            return this.bq;
        },
        set: function (a) {
            this.bq = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "c", {
        get: function () {
            if ((this.a == null || this.a.count < 1) && this.at != null) {
                this.a = this.at.d(true);
            }
            return this.a;
        },
        set: function (a) {
            this.a = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "d", {
        get: function () {
            if ((this.b == null || this.b.count < 1) && this.at != null) {
                this.b = this.at.d(false);
            }
            return this.b;
        },
        set: function (a) {
            this.b = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "ae", {
        get: function () {
            return this.ad;
        },
        set: function (a) {
            this.ad = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "n", {
        get: function () {
            return this.m;
        },
        set: function (a) {
            this.m = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "a9", {
        get: function () {
            return this.ax;
        },
        set: function (a) {
            this.ax = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "b1", {
        get: function () {
            return this.bs;
        },
        set: function (a) {
            this.bs = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "bm", {
        get: function () {
            return this.a5;
        },
        set: function (a) {
            this.a5 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "dy", {
        get: function () {
            return this.dv;
        },
        set: function (a) {
            this.dv = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "dx", {
        get: function () {
            return this.du;
        },
        set: function (a) {
            this.du = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "a8", {
        get: function () {
            return this.aw;
        },
        set: function (a) {
            this.aw = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "b9", {
        get: function () {
            return this.b5;
        },
        set: function (a) {
            this.b5 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "ca", {
        get: function () {
            return this.b6;
        },
        set: function (a) {
            this.b6 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "s", {
        get: function () {
            return this.r;
        },
        set: function (a) {
            this.r = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "ac", {
        get: function () {
            return this.ab;
        },
        set: function (a) {
            var b = this.ab;
            this.ab = a;
            this.c7(b, this.ab);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "ai", {
        get: function () {
            return this.ah;
        },
        set: function (a) {
            this.ah = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "k", {
        get: function () {
            return this.g;
        },
        set: function (a) {
            this.g = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "h", {
        get: function () {
            return this.e;
        },
        set: function (a) {
            this.e = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "j", {
        get: function () {
            return this.f;
        },
        set: function (a) {
            this.f = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "d3", {
        get: function () {
            return this.d0;
        },
        set: function (a) {
            this.d0 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "d4", {
        get: function () {
            return this.d1;
        },
        set: function (a) {
            this.d1 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "bo", {
        get: function () {
            return this.a7;
        },
        set: function (a) {
            this.a7 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "bd", {
        get: function () {
            return this.a1;
        },
        set: function (a) {
            this.a1 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "bn", {
        get: function () {
            return this.a6;
        },
        set: function (a) {
            this.a6 = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "ba", {
        get: function () {
            return this.az;
        },
        set: function (a) {
            this.az = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "cp", {
        get: function () {
            return this.ck;
        },
        set: function (a) {
            this.ck = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "co", {
        get: function () {
            return this.cj;
        },
        set: function (a) {
            this.cj = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "bz", {
        get: function () {
            var a = this.br;
            if (a < 0 && this.at != null) {
                this.br = this.at.aa();
                a = this.br;
            }
            return a < 0 ? 1 : a;
        },
        enumerable: false,
        configurable: true
    });
    XamFunnelController.prototype.c7 = function (a, b) {
        if (a != null) {
            var c = typeCast(MessageChannel.$, a.b("ConfigurationMessages"));
            if (c != null) {
                c.h(runOn(this, this.c2));
            }
            c = typeCast(MessageChannel.$, a.b("InteractionMessages"));
            if (c != null) {
                c.h(runOn(this, this.c2));
            }
            this.y.g();
            this.x.g();
        }
        if (b != null) {
            var d = typeCast(MessageChannel.$, b.b("ConfigurationMessages"));
            if (d != null) {
                d.e(runOn(this, this.c2));
            }
            d = typeCast(MessageChannel.$, b.b("InteractionMessages"));
            if (d != null) {
                d.e(runOn(this, this.c2));
            }
            var e = typeCast(MessageChannel.$, b.b("RenderingMessages"));
            this.y.f(e);
            var f = typeCast(MessageChannel.$, b.b("ModelUpdateMessages"));
            this.x.f(f);
        }
        this.bj = true;
    };
    XamFunnelController.prototype.c2 = function (a) {
        this.aa.c(a);
        var b = typeCast(RenderingMessage.$, a);
        if (b != null) {
            this.bj = b.c;
        }
        this.df();
    };
    XamFunnelController.prototype.bl = function () {
        return this.b3 >= 0 && this.b4 >= 0;
    };
    XamFunnelController.prototype.bf = function () {
        return this.am != null && this.am.a != null && this.am.a.count > 0 && this.u != null && this.q != null && this.c != null && this.c.count > 0 && this.d != null && this.d.count > 0 && this.bl();
    };
    XamFunnelController.prototype.df = function () {
        if (!this.bj) {
            return;
        }
        if (!this.bf()) {
            this.cu();
            return;
        }
        this.bj = false;
        var a = this.u.decideWidth(this.aq());
        if (a > this.b4) {
            a = 0;
        }
        if (!this.bh) {
            a = 0;
        }
        var b = this.b4 - a;
        var c = a > 0;
        var d = this.bc;
        var e = b >= 0;
        if (e || c) {
            this.dc(e, c, d, b, a);
        }
    };
    XamFunnelController.prototype.cu = function () {
        if (this.bk() && this.b2 > 0) {
            this.av.w();
        }
        this.dh("LeftLabels");
        this.dh("RightLabels");
        this.dh("SliceArea");
        this.ct();
        this.h.b.clear();
        this.j.b.clear();
        this.k.b.clear();
    };
    XamFunnelController.prototype.ct = function () {
        var a = new FrameRenderCompleteMessage();
        this.y.i(a);
    };
    XamFunnelController.prototype.dc = function (a, b, c, d, e) {
        if (this.a9) {
            var f = this.k;
            this.k = this.j;
            this.j = f;
        }
        else {
            var g = this.k;
            this.k = this.h;
            this.h = g;
        }
        this.dd(this.h, a, b, c, d, e);
        this.av.w();
        this.b2 = 0;
        if (this.bk()) {
            FunnelFrame.k(this.j, this.k, this.h, this.b2);
            this.cw(this.j);
            this.a9 = true;
            this.av.v();
        }
        else {
            this.cw(this.h);
        }
    };
    XamFunnelController.prototype.b0 = function (a) {
        if (isNaN_(a)) {
            return 0;
        }
        return Math.abs(a);
    };
    XamFunnelController.prototype.dd = function (a, b, c, d, e, f) {
        var e_2, _a, e_3, _b;
        var g = e / 2;
        this.ay = this.bm;
        if (this.ay) {
            this.c0(e, g);
        }
        else {
            this.ak = null;
        }
        var h = this.n == 1;
        var i = this.an();
        var j = 0;
        try {
            for (var _c = __values(fromEnum(i.a)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var k = _d.value;
                j += this.b0(this.am.a.item(k));
            }
        }
        catch (e_2_1) {
            e_2 = { error: e_2_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_2)
                    throw e_2.error;
            }
        }
        if (j == 0) {
            h = false;
        }
        var l = this.b3 / i.a.count;
        var m = 0;
        var n = 0;
        n = this.bz / 2;
        a.j = f;
        a.f = d;
        a.h = c;
        a.g = this.ae == 0;
        a.b = new SliceInfoList();
        var o = 0;
        try {
            for (var _e = __values(fromEnum(i.a)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var p = _f.value;
                var q = void 0;
                if (h) {
                    q = (this.b0(this.am.a.item(p)) / j) * this.b3;
                }
                else {
                    q = l;
                }
                var r = this.by(e, m + n);
                var s = m + q;
                var t = this.by(e, s - n);
                var u = r / 2;
                var v = t / 2;
                var w = new SliceInfo();
                var x = w.b;
                x.o = m;
                x.n = s;
                var y = new Rect(4);
                var z = new Rect(4);
                var aa = 0;
                if (v > u) {
                    aa = g - v;
                }
                else {
                    aa = g - u;
                }
                var ab = m;
                x.ad = this.ds(p);
                x.ag = this.dt(p);
                x.a0 = this.d2(p);
                x.j = this.ai.c(p);
                if (b) {
                    w.h = true;
                    x.ar = { $type: Point_$type, x: g - u - aa + n, y: m - ab + n };
                    x.as = { $type: Point_$type, x: g + u - aa - n, y: m - ab + n };
                    x.ao = { $type: Point_$type, x: g - v - aa + n, y: s - ab - n };
                    x.ap = { $type: Point_$type, x: g + v - aa - n, y: s - ab - n };
                    if (this.ay) {
                        this.cr(x, m + n, s - n, g, aa - n, ab);
                    }
                    x.x();
                }
                if (d) {
                    x.i = true;
                    x.an = { $type: Point_$type, x: g - aa, y: (m + s) / 2 - ab };
                    x.v = this.cd(p);
                    var ac = this.q.decideLabelSize(w, true);
                    if (ac.width > e) {
                        x.i = false;
                    }
                    if (ac.height > q) {
                        x.i = false;
                    }
                    y.height = ac.height;
                    y.width = ac.width;
                    y.x = x.an.x;
                    y.y = x.an.y;
                    x.ax = y;
                }
                else {
                    x.i = false;
                    x.v = this.cd(p);
                }
                if (d || b) {
                    x.aq = { $type: Point_$type, x: aa, y: ab };
                    x.item = this.am.a.item(p);
                    x.s = p;
                }
                if (c) {
                    w.g = true;
                    w.n = { $type: Point_$type, x: 0, y: (m + s) / 2 };
                    w.l = this.ce(p);
                    var ad = this.q.decideLabelSize(w, false);
                    if (ad.height > q) {
                        w.g = false;
                    }
                    z.height = ad.height;
                    z.width = ad.width;
                    y.x = w.n.x;
                    y.y = w.n.y;
                    x.ay = z;
                }
                else {
                    w.g = false;
                    w.l = this.ce(p);
                }
                w.j = p;
                a.b.add(w);
                m += q;
                o++;
            }
        }
        catch (e_3_1) {
            e_3 = { error: e_3_1 };
        }
        finally {
            try {
                if (_f && !_f.done && (_b = _e.return))
                    _b.call(_e);
            }
            finally {
                if (e_3)
                    throw e_3.error;
            }
        }
        if ((this.ar != null && this.ar.a != null && this.ar.a.count > 0) || (this.as != null && this.as.a != null && this.as.a.count > 0)) {
            this.dg(a);
        }
        a.b.ae();
    };
    XamFunnelController.prototype.cr = function (a, b, c, d, e, f) {
        var g = this.ak.b(b);
        var h = this.ak.b(c);
        var i = new PointList();
        var j = new PointList();
        var k = g.b;
        var l = h.b;
        for (var m = k; m <= l; m++) {
            i.add({ $type: Point_$type, x: this.ak.e._inner[m].c.x - e, y: this.ak.e._inner[m].c.y - f });
        }
        e += this.bz;
        for (var n = l; n >= k; n--) {
            var o = this.ak.e._inner[n].c;
            j.add({ $type: Point_$type, x: d + d - o.x - e, y: o.y - f });
        }
        a.c = i;
        a.e = j;
    };
    XamFunnelController.prototype.bi = function (a, b) {
        if (a.x != b.x || a.y != b.y) {
            return true;
        }
        return false;
    };
    XamFunnelController.prototype.c0 = function (a, b) {
        var c;
        var d;
        var e = 0, f = this.b3;
        e = this.bz / 2;
        f -= e;
        if (this.bd) {
            c = { $type: Point_$type, x: b - (a * this.bw / 2), y: e };
            d = { $type: Point_$type, x: b - (a / 2), y: f };
        }
        else {
            c = { $type: Point_$type, x: b - (a / 2), y: e };
            d = { $type: Point_$type, x: b - (a * this.bw / 2), y: f };
        }
        var g = this.dy.y < this.dx.y ? this.dy : this.dx;
        var h = this.dx.y > this.dy.y ? this.dx : this.dy;
        if (g.y < 0) {
            g.y = 0;
        }
        if (h.y > 1) {
            h.y = 1;
        }
        if (this.bd) {
            var i = h.x;
            h.x = g.x;
            g.x = i;
            i = g.y;
            g.y = 1 - h.y;
            h.y = 1 - i;
        }
        var j = { $type: Point_$type, x: a * g.x, y: this.b3 * g.y };
        var k = { $type: Point_$type, x: a * h.x, y: this.b3 * h.y };
        if (this.ak == null || this.bi(c, this.ak.q) || this.bi(j, this.ak.r) || this.bi(k, this.ak.s) || this.bi(d, this.ak.t)) {
            this.ak = new Bezier(c, j, k, d, 2, b);
        }
        if (this.ak == null) {
            this.ay = false;
        }
        else {
            this.ay = this.ak.d;
        }
    };
    XamFunnelController.prototype.ce = function (a) {
        var b = this.as;
        var c = b == null ? null : b.a;
        return c == null || a >= c.count ? null : c.item(a);
    };
    XamFunnelController.prototype.cd = function (a) {
        var b = this.ar;
        var c = b == null ? null : b.a;
        return c == null || a >= c.count ? null : c.item(a);
    };
    XamFunnelController.prototype.d2 = function (a) {
        if (this.ai.c(a)) {
            return this.d3;
        }
        if (this.ai.d(a) && this.bo) {
            return this.d4;
        }
        return null;
    };
    XamFunnelController.prototype.dt = function (a) {
        return this.d.item(a % this.d.count);
    };
    XamFunnelController.prototype.ds = function (a) {
        return this.c.item(a % this.c.count);
    };
    XamFunnelController.prototype.by = function (a, b) {
        var c = a * this.bw;
        if (this.ay) {
            var d = this.ak.b(b).c.x;
            return ((a / 2) - d) * 2;
        }
        else {
            if (this.bd) {
                return a - ((a - c) * ((this.b3 - b) / this.b3));
            }
            else {
                return a - ((a - c) * (b / this.b3));
            }
        }
    };
    XamFunnelController.prototype.an = function () {
        var _this = this;
        var a = new IntColumn();
        a.b(this.am.a.count);
        a.c(function (b, c) {
            if (_this.am.a.item(b) < _this.am.a.item(c)) {
                return _this.bd ? -1 : 1;
            }
            if (_this.am.a.item(b) > _this.am.a.item(c)) {
                return _this.bd ? 1 : -1;
            }
            return 0;
        });
        return a;
    };
    XamFunnelController.prototype.cw = function (a) {
        this.cx(a);
    };
    XamFunnelController.prototype.cy = function () {
        if (this.l != null) {
            this.cx(this.l);
        }
    };
    XamFunnelController.prototype.cx = function (a) {
        var e_4, _a, e_5, _b;
        this.dh("LeftLabels");
        this.dh("RightLabels");
        this.dh("SliceArea");
        if (a.g) {
            this.di("LeftPanel", a.j);
            this.di("RightPanel", 0);
        }
        else {
            this.di("LeftPanel", 0);
            this.di("RightPanel", a.j);
        }
        this.ag = a.b;
        try {
            for (var _c = __values(fromEnum(a.b)), _d = _c.next(); !_d.done; _d = _c.next()) {
                var b = _d.value;
                if (b.h) {
                    var c = new RenderSliceMessage();
                    c.e = "SliceArea";
                    c.g = b.b;
                    c.h = this.bz;
                    this.y.i(c);
                }
            }
        }
        catch (e_4_1) {
            e_4 = { error: e_4_1 };
        }
        finally {
            try {
                if (_d && !_d.done && (_a = _c.return))
                    _a.call(_c);
            }
            finally {
                if (e_4)
                    throw e_4.error;
            }
        }
        try {
            for (var _e = __values(fromEnum(a.b)), _f = _e.next(); !_f.done; _f = _e.next()) {
                var d = _f.value;
                if (d.g) {
                    var e = new RenderOuterLabelMessage();
                    if (a.g) {
                        e.e = "LeftLabels";
                    }
                    else {
                        e.e = "RightLabels";
                    }
                    e.j = d.l;
                    e.l = d.n;
                    e.h = a.j;
                    e.f = d;
                    this.y.i(e);
                }
            }
        }
        catch (e_5_1) {
            e_5 = { error: e_5_1 };
        }
        finally {
            try {
                if (_f && !_f.done && (_b = _e.return))
                    _b.call(_e);
            }
            finally {
                if (e_5)
                    throw e_5.error;
            }
        }
        var f = new FrameRenderCompleteMessage();
        this.y.i(f);
    };
    XamFunnelController.prototype.di = function (a, b) {
        var c = new SetAreaSizeMessage();
        c.e = a;
        c.i = true;
        c.m = b;
        this.y.i(c);
    };
    XamFunnelController.prototype.bk = function () {
        return this.b1 > 0;
    };
    XamFunnelController.prototype.dh = function (a) {
        var b = new ClearMessage();
        b.e = a;
        this.y.i(b);
    };
    XamFunnelController.prototype.aq = function () {
        return this.as;
    };
    XamFunnelController.prototype.cv = function (a) {
        this.bj = true;
    };
    XamFunnelController.prototype.b7 = function (a) {
        return Convert.toInt32(a);
    };
    XamFunnelController.prototype.de = function (a) {
        var b = a;
        var c = b.d;
        switch (b.g) {
            case "TextStyle":
                this.cp = c != null ? c.toString() : "";
                var d = new PropertyChangedMessage();
                d.g = b.g;
                d.e = b.e;
                d.d = c;
                this.y.i(d);
                this.bj = true;
                break;
            case "OuterLabelTextStyle":
                this.co = c != null ? c.toString() : "";
                var e = new PropertyChangedMessage();
                e.g = b.g;
                e.e = b.e;
                e.d = c;
                this.y.i(e);
                this.bj = true;
                break;
            case "ValueColumn":
                this.am.b(c);
                this.bj = true;
                break;
            case "InnerLabelColumn":
                this.bb = false;
                this.cf = c;
                this.ar.b(c);
                this.bj = true;
                break;
            case "InnerLabelVisibility":
                this.bc = c;
                this.bj = true;
                break;
            case "OuterLabelVisibility":
                this.bh = c;
                this.bj = true;
                break;
            case "OuterLabelColumn":
                this.bg = false;
                this.cg = c;
                this.as.b(c);
                this.bj = true;
                break;
            case "ValueMemberPath":
                this.cq = typeCast(String_$type, c);
                break;
            case "OuterLabelMemberPath":
                this.cn = typeCast(String_$type, c);
                break;
            case "InnerLabelMemberPath":
                this.cm = typeCast(String_$type, c);
                break;
            case "BottomEdgeWidth":
                this.bw = c;
                if (this.bw > 1) {
                    this.bw = 1;
                }
                if (this.bw < 0.001) {
                    this.bw = 0.001;
                }
                this.bj = true;
                break;
            case "Brushes":
                if (b.e != null) {
                    var f = b.e;
                    f.collectionChanged = delegateRemove(f.collectionChanged, this.bp);
                }
                if (c != null) {
                    var g = c;
                    g.collectionChanged = delegateCombine(g.collectionChanged, this.bp);
                }
                this.c = typeCast(BrushCollection.$, c);
                this.bj = true;
                break;
            case "Outlines":
                this.d = typeCast(BrushCollection.$, c);
                this.bj = true;
                break;
            case "OuterLabelAlignment":
                this.ae = EnumUtil.getEnumValue(OuterLabelAlignment_$type, c);
                this.bj = true;
                break;
            case "FunnelSliceDisplay":
                this.n = EnumUtil.getEnumValue(FunnelSliceDisplay_$type, c);
                this.bj = true;
                break;
            case "FormatInnerLabel":
                this.ar.b(this.cf);
                this.bb = false;
                this.cb = c;
                this.bj = true;
                break;
            case "FormatOuterLabel":
                this.as.b(this.cg);
                this.cc = c;
                this.bg = false;
                this.bj = true;
                break;
            case "IsInverted":
                this.bd = c;
                this.bj = true;
                break;
            case "TransitionDuration":
                this.av.r = this.b7(c);
                this.b1 = this.av.r;
                break;
            case "AllowSliceSelection":
                this.a8 = c;
                break;
            case "SelectedSliceStyle":
                this.d3 = c;
                this.bj = true;
                break;
            case "UnselectedSliceStyle":
                this.d4 = c;
                this.bj = true;
                break;
            case "UseUnselectedStyle":
                this.bo = c;
                this.bj = true;
                break;
            case "UseBezierCurve":
                this.bm = c;
                this.bj = true;
                break;
            case "UpperBezierControlPoint":
                this.dy = c;
                this.bj = true;
                break;
            case "LowerBezierControlPoint":
                this.dx = c;
                this.bj = true;
                break;
            case "ItemProvider":
                this.s = c;
                break;
            case "ToolTip":
                var h = new TooltipValueChangedMessage();
                if (c != null) {
                    this.ba = true;
                }
                else {
                    this.ba = false;
                    var i = new ClearTooltipMessage();
                    this.y.i(i);
                }
                h.g = c;
                this.y.i(h);
                break;
            case "Legend":
                this.c6(c);
                this.bj = true;
                break;
            case "LegendItemTemplate":
                this.dr = c;
                this.bj = true;
                break;
            case "LegendItemBadgeTemplate":
                this.dq = c;
                this.bj = true;
                break;
            case "UseOuterLabelsForLegend":
                this.bn = c;
                this.bj = true;
                break;
            case "OutlineThickness":
                this.br = c;
                this.bj = true;
                this.y.i(b);
                break;
            case "Container":
            case "PixelScalingRatio":
            case "ActualPixelScalingRatio":
            case "OuterLabelTextColor":
            case "LabelTextColor":
                if (b.g == "Container") {
                    var j = b.d;
                    this.av.u(j);
                }
                var k = new PropertyChangedMessage();
                k.g = b.g;
                k.e = b.e;
                k.d = c;
                this.y.i(k);
                break;
        }
    };
    Object.defineProperty(XamFunnelController.prototype, "dr", {
        get: function () {
            return this.dp;
        },
        set: function (a) {
            this.dp = a;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelController.prototype, "dq", {
        get: function () {
            return this.dn;
        },
        set: function (a) {
            this.dn = a;
        },
        enumerable: false,
        configurable: true
    });
    XamFunnelController.prototype.c6 = function (a) {
        if (this.o != null) {
            this.o.clearLegendItemsForSeries(this.ac.b("Model"));
        }
        this.o = a;
    };
    XamFunnelController.prototype.dg = function (a) {
        var e_6, _a;
        var _this = this;
        var b = new List$1(UIElement.$, 0);
        var _loop_1 = function (c) {
            var d = new ContentControl();
            var e = "";
            if (c.b.v != null) {
                if (this_1.bn && c.l != null) {
                    e = c.l.toString();
                }
                else {
                    e = c.b.v.toString();
                }
            }
            else if (c.l != null) {
                e = c.l.toString();
            }
            var f = null;
            var g = null;
            if (f == null && c.b.ad != null) {
                f = c.b.ad;
            }
            if (g == null && c.b.ag != null) {
                g = c.b.ag;
            }
            var h = null;
            if (this_1.s != null) {
                h = this_1.s.getItem(c.b.s);
            }
            d.content = ((function () {
                var $ret = new FunnelSliceDataContext();
                $ret.series = _this.ac.b("Model");
                $ret.item = h;
                $ret.itemBrush = f;
                $ret.itemLabel = e;
                $ret.thickness = _this.bz;
                $ret.outline = g;
                $ret.itemOutline = g;
                return $ret;
            })());
            d.ah = this_1.dr;
            b.add(d);
        };
        var this_1 = this;
        try {
            for (var _b = __values(fromEnum(a.b)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var c = _c.value;
                _loop_1(c);
            }
        }
        catch (e_6_1) {
            e_6 = { error: e_6_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_6)
                    throw e_6.error;
            }
        }
        if (this.o != null) {
            if (this.o.isItemwise) {
                var i = this.o;
                i.createItemwiseLegendItems(b, this.ac.b("Model"));
            }
        }
    };
    XamFunnelController.prototype.dm = function (a) {
        var b = a;
        switch (b.g) {
            case "OuterLabelWidthDecider":
                this.u = typeCast(IOuterLabelWidthDecider_$type, b.d);
                this.bj = true;
                break;
            case "FunnelLabelSizeDecider":
                this.q = typeCast(IFunnelLabelSizeDecider_$type, b.d);
                this.bj = true;
                break;
        }
    };
    XamFunnelController.prototype.dl = function (a) {
        var b = a;
        this.b4 = b.e;
        this.b3 = b.d;
        this.bj = true;
    };
    XamFunnelController.prototype.c3 = function (a) {
        var b = a;
        if (b.e == 1) {
            return;
        }
        if (b.c == 1) {
            this.ca = this.b9;
        }
        else if (b.c == 0) {
            var c = this.ca;
            this.ca = -1;
            if (b.f == 0) {
            }
            else if (b.f != 2) {
                return;
            }
            if (c == this.b9) {
                this.c8(c);
            }
        }
    };
    XamFunnelController.prototype.c8 = function (a) {
        if (a < 0 || a > this.am.a.count - 1) {
            return;
        }
        if (this.a8) {
            this.ai.k(a, this.am.a.item(a));
            var b = this.ai.a();
            var c = new SelectedItemsChangedMessage();
            c.c = b;
            this.x.i(c);
            this.bj = true;
        }
        var d = new SliceClickedMessage();
        d.c = a;
        d.item = this.am.a.item(a);
        d.f = this.dz;
        this.x.i(d);
    };
    XamFunnelController.prototype.da = function (a) {
        if (this.am != null && a >= 0 && a < this.am.a.count) {
            var b = new SliceMouseMessage();
            b.e = a;
            b.item = this.am.a.item(a);
            b.c = 0;
            b.i = this.dz;
            this.x.i(b);
        }
    };
    XamFunnelController.prototype.db = function (a, b) {
        if (this.am != null && a >= 0 && a < this.am.a.count) {
            var c = new SliceMouseMessage();
            c.e = a;
            c.item = this.am.a.item(a);
            c.c = 2;
            c.i = this.dz;
            c.h = b;
            this.x.i(c);
        }
    };
    XamFunnelController.prototype.c9 = function (a) {
        if (this.am != null && a >= 0 && a < this.am.a.count) {
            var b = new SliceMouseMessage();
            b.e = a;
            b.item = this.am.a.item(a);
            b.c = 1;
            b.i = this.dz;
            this.x.i(b);
        }
    };
    XamFunnelController.prototype.c5 = function (a) {
        var b = a;
        var c = this.b9;
        this.b9 = this.b8(b.c);
        if (c != this.b9) {
            if (c != -1) {
                this.da(c);
            }
            if (this.b9 != -1) {
                this.c9(this.b9);
            }
        }
        else {
            if (this.b9 != -1) {
                this.db(this.b9, b.c);
            }
        }
        if (this.ba) {
            this.dj(b.c);
        }
    };
    XamFunnelController.prototype.c4 = function (a) {
        var b = this.b9;
        this.b9 = -1;
        if (b != -1) {
            this.da(b);
        }
        var c = new ClearTooltipMessage();
        this.y.i(c);
    };
    XamFunnelController.prototype.dj = function (a) {
        var b = new FunnelDataContext();
        if (this.s != null && this.b9 >= 0 && this.b9 < this.s.count) {
            b.item = this.s.getItem(this.b9);
        }
        b.b = this.b9;
        if (b.b < 0) {
            var c = new ClearTooltipMessage();
            this.y.i(c);
            return;
        }
        var d = new TooltipUpdateMessage();
        d.g = b;
        d.i = this.dw(a, b);
        this.y.i(d);
    };
    XamFunnelController.prototype.dw = function (a, b) {
        var c = { $type: Point_$type, x: a.x + 10, y: a.y + 10 };
        return c;
    };
    XamFunnelController.prototype.b8 = function (a) {
        if (!this.bf()) {
            return -1;
        }
        var b = a.y;
        var c = a.x;
        var d = this.i();
        if (d.g) {
            c -= d.j;
        }
        var e = this.af(b);
        if (e == null) {
            return -1;
        }
        var f = this.bx();
        var g = this.by(f, b);
        var h = g / 2;
        var i = f / 2;
        var j = new Rect(0, e.b.ar.x, e.b.ar.y, Math.max(e.b.ap.x - e.b.ar.x, 0), Math.max(e.b.ap.y - e.b.ar.y, 0));
        if (c >= (i - h) && c <= (i + h)) {
            this.dz = j;
            return e.j;
        }
        else {
            return -1;
        }
    };
    XamFunnelController.prototype.bx = function () {
        var a = this.i();
        return this.b4 - a.j;
    };
    XamFunnelController.prototype.af = function (a) {
        var b = this.i();
        var c = b.b.ad(a);
        if (c >= 0 && c < b.b.count) {
            return b.b._inner[c];
        }
        return null;
    };
    XamFunnelController.prototype.i = function () {
        var a = null;
        if (this.a9) {
            a = this.j;
        }
        else {
            a = this.h;
        }
        return a;
    };
    XamFunnelController.prototype.dk = function (a) {
        var b = a;
        this.ai.i(b.c, this.am);
        this.bj = true;
    };
    XamFunnelController.prototype.c1 = function (a) {
        this.cs(a);
    };
    XamFunnelController.prototype.cs = function (a) {
        var b = this.i();
        if (a.c == -1) {
            this.bj = true;
        }
        else {
            var c = b.b._inner[a.c];
            if (a.b) {
                if (a.d.width > b.j) {
                    this.bj = true;
                }
                if (a.d.height != a.e.height) {
                    this.bj = true;
                }
                if (a.d.height > c.b.ap.y - c.b.as.y) {
                    this.bj = true;
                }
            }
            else {
                if (a.d.height > c.b.ap.y - c.b.as.y) {
                    this.bj = true;
                }
            }
        }
    };
    XamFunnelController.$t = markType(XamFunnelController, 'XamFunnelController');
    return XamFunnelController;
}(Base));
export { XamFunnelController };
/**
 * @hidden
 */
var XamFunnelChart = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(XamFunnelChart, _super);
    function XamFunnelChart() {
        var _this = _super.call(this) || this;
        _this.aq = null;
        _this.as = null;
        _this.ap = null;
        _this.ax = null;
        _this.bt = null;
        _this.a2 = null;
        _this.a0 = null;
        _this.a1 = null;
        _this.bu = null;
        _this.bv = null;
        _this.bk = new ObservableCollection$1(Base.$, 0);
        _this.bh = new Dictionary$2(Base.$, Base.$, 0);
        _this.b2 = null;
        _this.b1 = null;
        _this.sliceClicked = null;
        _this.sliceEnter = null;
        _this.sliceLeave = null;
        _this.sliceHover = null;
        _this.bz = null;
        _this.bm = NaN;
        _this.bl = 1;
        _this.er = null;
        _this.es = null;
        _this.bl = 1;
        _this.bm = NaN;
        var a = _this.bk;
        a.collectionChanged = delegateCombine(a.collectionChanged, runOn(_this, _this.dt));
        _this.ar = new MessageHandler();
        _this.ar.b(SliceClickedMessage.$, runOn(_this, _this.dx));
        _this.ar.b(SliceMouseMessage.$, runOn(_this, _this.dy));
        _this.ar.b(SelectedItemsChangedMessage.$, runOn(_this, _this.du));
        _this.ap = new MessageChannel();
        _this.bt = function (b, c) { return _this.db(c.action, c.position, c.count, c.propertyName); };
        _this.dv();
        _this.ab = XamFunnelChart.$;
        _this.ax = new XamFunnelConnector(new XamFunnelView(), _this);
        _this.legendItemTemplate = ((function () {
            var $ret = new DataTemplate();
            $ret.render = FunnelLegendTemplates.e;
            $ret.measure = FunnelLegendTemplates.c;
            return $ret;
        })());
        _this.legendItemBadgeTemplate = ((function () {
            var $ret = new DataTemplate();
            $ret.render = FunnelLegendTemplates.d;
            $ret.measure = FunnelLegendTemplates.f;
            return $ret;
        })());
        return _this;
    }
    XamFunnelChart.prototype.destroy = function () {
        this.provideContainer(null);
    };
    Object.defineProperty(XamFunnelChart.prototype, "ar", {
        get: function () {
            return this.aq;
        },
        set: function (a) {
            this.aq = a;
        },
        enumerable: false,
        configurable: true
    });
    XamFunnelChart.prototype.dv = function () {
        this.dq(XamFunnelChart.$$p[1], 0, this.bo);
        this.dq(XamFunnelChart.$$p[6], enumGetBox(Visibility_$type, this.ez), enumGetBox(Visibility_$type, this.ez));
        this.dq(XamFunnelChart.$$p[13], enumGetBox(OuterLabelAlignment_$type, this.au), enumGetBox(OuterLabelAlignment_$type, this.au));
        this.dq(XamFunnelChart.$$p[4], enumGetBox(FunnelSliceDisplay_$type, this.ak), enumGetBox(FunnelSliceDisplay_$type, this.ak));
        this.dq(XamFunnelChart.$$p[22], this.ew, this.ew);
        this.dq(XamFunnelChart.$$p[12], this.ev, this.ev);
        this.dw();
    };
    XamFunnelChart.prototype.dw = function () {
        var a = new PropertyChangedMessage();
        a.g = "ItemProvider";
        a.e = null;
        a.d = this;
        this.ap.i(a);
    };
    Object.defineProperty(XamFunnelChart.prototype, "at", {
        get: function () {
            return this.as;
        },
        set: function (a) {
            var b = this.as;
            this.as = a;
            this.dr(b, this.as);
        },
        enumerable: false,
        configurable: true
    });
    XamFunnelChart.prototype.dr = function (a, b) {
        if (a != null) {
            var c = typeCast(MessageChannel.$, a.b("ModelUpdateMessages"));
            if (c != null) {
                c.h(runOn(this, this.dg));
            }
            this.ap.g();
        }
        if (b != null) {
            var d = typeCast(MessageChannel.$, b.b("ModelUpdateMessages"));
            if (d != null) {
                d.e(runOn(this, this.dg));
            }
            var e = typeCast(MessageChannel.$, b.b("ConfigurationMessages"));
            this.ap.f(e);
        }
    };
    XamFunnelChart.prototype.dg = function (a) {
        this.ar.c(a);
    };
    XamFunnelChart.prototype.db = function (a, b, c, d) {
        var e = ((function () {
            var $ret = new DataUpdatedMessage();
            $ret.g = b;
            $ret.f = c;
            $ret.i = d;
            return $ret;
        })());
        switch (a) {
            case 3:
                e.c = 3;
                break;
            case 1:
                e.c = 1;
                break;
            case 0:
                e.c = 0;
                break;
            case 2:
                e.c = 2;
                break;
            case 4:
                e.c = 4;
                break;
        }
        this.dq("ValueColumn", this.a7, this.a7);
        this.dq("InnerLabelColumn", this.a3, this.a3);
        this.dq("OuterLabelColumn", this.a4, this.a4);
        this.ap.i(e);
    };
    Object.defineProperty(XamFunnelChart.prototype, "a7", {
        get: function () {
            return this.a2;
        },
        set: function (a) {
            if (this.a2 != a) {
                var b = this.a2;
                this.a2 = a;
                this.dq("ValueColumn", b, this.a2);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "a3", {
        get: function () {
            return this.a0;
        },
        set: function (a) {
            if (this.a0 != a) {
                var b = this.a0;
                this.a0 = a;
                this.dq("InnerLabelColumn", b, this.a3);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "a4", {
        get: function () {
            return this.a1;
        },
        set: function (a) {
            if (this.a1 != a) {
                var b = this.a1;
                this.a1 = a;
                this.dq("OuterLabelColumn", b, this.a4);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "bw", {
        get: function () {
            return this.bu;
        },
        set: function (a) {
            var b = this.bu;
            this.bu = a;
            this.dq("FormatInnerLabel", b, a);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "bx", {
        get: function () {
            return this.bv;
        },
        set: function (a) {
            var b = this.bv;
            this.bv = a;
            this.dq("FormatOuterLabel", b, a);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "bj", {
        get: function () {
            return this.bk;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "cz", {
        get: function () {
            return this.b2;
        },
        set: function (a) {
            var b = this.b2;
            this.b2 = a;
            this.dq("TextStyle", b, a);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "cr", {
        get: function () {
            return this.b1;
        },
        set: function (a) {
            var b = this.b1;
            this.b1 = a;
            this.dq("OuterLabelTextStyle", b, a);
        },
        enumerable: false,
        configurable: true
    });
    XamFunnelChart.prototype.onDetachedFromUI = function () {
        this.ax.e.az();
    };
    XamFunnelChart.prototype.onAttachedToUI = function () {
        this.ax.e.ax(this);
    };
    XamFunnelChart.prototype.dq = function (a, b, c) {
        if (this.ba(a, b, c) || this.a9(a, b, c) || this.bc(a, b, c) || this.bb(a, b, c)) {
            return;
        }
        if (a == "PixelScalingRatio") {
            if (isNaN_(DeviceUtils.a(this.bs))) {
                this.bn = 1;
            }
            else {
                this.bn = DeviceUtils.a(this.bs);
            }
        }
        this.ap.i(((function () {
            var $ret = new PropertyChangedMessage();
            $ret.g = a;
            $ret.e = b;
            $ret.d = c;
            return $ret;
        })()));
    };
    XamFunnelChart.prototype.a9 = function (a, b, c) {
        if (a == XamFunnelChart.$$p[2] || a == XamFunnelChart.$$p[17]) {
            this.ap.i(((function () {
                var $ret = new PropertyChangedMessage();
                $ret.g = a;
                $ret.e = b == null ? null : b;
                $ret.d = c == null ? null : c;
                return $ret;
            })()));
            return true;
        }
        return false;
    };
    XamFunnelChart.prototype.ba = function (a, b, c) {
        var _this = this;
        if (a == XamFunnelChart.$$p[8]) {
            if (b != null) {
                this.az = null;
            }
            if (c != null) {
                this.bj.clear();
                this.az = ((function () {
                    var $ret = new FastItemsSource();
                    $ret.e = _this.itemsSource;
                    return $ret;
                })());
            }
            return true;
        }
        else if (a == XamFunnelChart.$$p[3]) {
            if (b != null) {
                var d = b;
                d.event = delegateRemove(d.event, this.bt);
            }
            if (c != null) {
                var e = c;
                e.event = delegateCombine(e.event, this.bt);
            }
            this.de(a, b, c);
            return true;
        }
        else if (a == XamFunnelChart.$$p[26] || a == XamFunnelChart.$$p[5] || a == XamFunnelChart.$$p[14]) {
            this.de(a, b, c);
            return false;
        }
        return false;
    };
    XamFunnelChart.prototype.a5 = function (a, b) {
        return a.registerColumn(b, null, false);
    };
    XamFunnelChart.prototype.a6 = function (a, b) {
        return a.registerColumnObject(b, null, false);
    };
    XamFunnelChart.prototype.de = function (a, b, c) {
        if (this.az == null) {
            var d = typeCast(FastItemsSource.$, b);
            if (d != null) {
                if (this.a7 != null) {
                    d.deregisterColumn(this.a7);
                }
                if (this.a3 != null) {
                    d.deregisterColumn(this.a3);
                }
                if (this.a4 != null) {
                    d.deregisterColumn(this.a4);
                }
                this.a7 = null;
                this.a3 = null;
                this.a4 = null;
            }
            return;
        }
        if (b != null && typeof b === 'string') {
            switch (a) {
                case XamFunnelChart.$$p[26]:
                    this.az.deregisterColumn(this.a7);
                    this.a7 = null;
                    break;
                case XamFunnelChart.$$p[5]:
                    this.az.deregisterColumn(this.a3);
                    this.a3 = null;
                    break;
                case XamFunnelChart.$$p[14]:
                    this.az.deregisterColumn(this.a4);
                    this.a4 = null;
                    break;
            }
        }
        if (c != null && typeCast(FastItemsSource.$, c) !== null) {
            if (this.c9 != null) {
                this.a7 = this.a5(c, this.c9);
            }
            if (this.cd != null) {
                this.a3 = this.a6(c, this.cd);
            }
            if (this.co != null) {
                this.a4 = this.a6(c, this.co);
            }
        }
        if (c != null && typeof c === 'string') {
            switch (a) {
                case XamFunnelChart.$$p[26]:
                    this.a7 = this.a5(this.az, this.c9);
                    break;
                case XamFunnelChart.$$p[5]:
                    this.a3 = this.a6(this.az, this.cd);
                    break;
                case XamFunnelChart.$$p[14]:
                    this.a4 = this.a6(this.az, this.co);
                    break;
            }
        }
    };
    XamFunnelChart.prototype.bc = function (a, b, c) {
        if (a == XamFunnelChart.$$p[6] || a == XamFunnelChart.$$p[15]) {
            var d_1 = EnumUtil.getEnumValue(Visibility_$type, b) == 0;
            var e_7 = EnumUtil.getEnumValue(Visibility_$type, c) == 0;
            this.ap.i(((function () {
                var $ret = new PropertyChangedMessage();
                $ret.g = a;
                $ret.d = e_7;
                $ret.e = d_1;
                return $ret;
            })()));
            return true;
        }
        return false;
    };
    XamFunnelChart.prototype.bb = function (a, b, c) {
        if (a == XamFunnelChart.$$p[20]) {
            var d = new PropertyChangedMessage();
            d.g = a;
            if (b != null) {
                d.e = b;
            }
            if (c != null) {
                d.d = c;
            }
            this.ap.i(d);
            return true;
        }
        return false;
    };
    XamFunnelChart.prototype.dx = function (a) {
        var b = a;
        if (this.sliceClicked != null) {
            var c = new FunnelSliceClickedEventArgs();
            c.index = b.c;
            c.bounds = b.f;
            if (this.az.count > b.c && b.c >= 0) {
                c.item = this.az.item(b.c);
            }
            this.sliceClicked(this, c);
        }
    };
    XamFunnelChart.prototype.dy = function (a) {
        var b = a;
        switch (b.c) {
            case 1:
                {
                    if (this.sliceEnter != null) {
                        var c = new FunnelSliceEventArgs();
                        c.index = b.e;
                        c.bounds = b.i;
                        if (this.az.count > b.e && b.e >= 0) {
                            c.item = this.az.item(b.e);
                        }
                        this.sliceEnter(this, c);
                    }
                    break;
                }
            case 0:
                {
                    if (this.sliceLeave != null) {
                        var d = new FunnelSliceEventArgs();
                        d.index = b.e;
                        d.bounds = b.i;
                        if (this.az.count > b.e && b.e >= 0) {
                            d.item = this.az.item(b.e);
                        }
                        this.sliceLeave(this, d);
                    }
                    break;
                }
            case 2:
                {
                    if (this.sliceHover != null) {
                        var e = new FunnelSliceEventArgs();
                        e.index = b.e;
                        e.bounds = b.i;
                        e.position = b.h;
                        if (this.az.count > b.e && b.e >= 0) {
                            e.item = this.az.item(b.e);
                        }
                        this.sliceHover(this, e);
                    }
                    break;
                }
        }
    };
    XamFunnelChart.prototype.du = function (a) {
    };
    XamFunnelChart.prototype.dt = function (a, b) {
    };
    XamFunnelChart.prototype.df = function (a, b, c, d) {
        var e_8, _a, e_9, _b, e_10, _c;
        var e = new List$1(Base.$, 0);
        try {
            for (var _d = __values(fromEnum(a)), _e = _d.next(); !_e.done; _e = _d.next()) {
                var f = _e.value;
                if (!d.containsKey(f)) {
                    e.add1(f);
                }
            }
        }
        catch (e_8_1) {
            e_8 = { error: e_8_1 };
        }
        finally {
            try {
                if (_e && !_e.done && (_a = _d.return))
                    _a.call(_d);
            }
            finally {
                if (e_8)
                    throw e_8.error;
            }
        }
        try {
            for (var _f = __values(fromEnum(e)), _g = _f.next(); !_g.done; _g = _f.next()) {
                var g = _g.value;
                a.remove(g);
                b.removeItem(g);
            }
        }
        catch (e_9_1) {
            e_9 = { error: e_9_1 };
        }
        finally {
            try {
                if (_g && !_g.done && (_b = _f.return))
                    _b.call(_f);
            }
            finally {
                if (e_9)
                    throw e_9.error;
            }
        }
        try {
            for (var _h = __values(fromEnum(c)), _j = _h.next(); !_j.done; _j = _h.next()) {
                var h = _j.value;
                if (!b.containsKey(h)) {
                    a.add(h);
                    b.addItem(h, h);
                }
            }
        }
        catch (e_10_1) {
            e_10 = { error: e_10_1 };
        }
        finally {
            try {
                if (_j && !_j.done && (_c = _h.return))
                    _c.call(_h);
            }
            finally {
                if (e_10)
                    throw e_10.error;
            }
        }
    };
    XamFunnelChart.prototype.getItem = function (a) {
        return this.az.item(a);
    };
    Object.defineProperty(XamFunnelChart.prototype, "count", {
        get: function () {
            return this.az != null ? this.az.count : 0;
        },
        enumerable: false,
        configurable: true
    });
    XamFunnelChart.prototype.dd = function () {
        this.ax.i();
    };
    XamFunnelChart.prototype.provideContainer = function (a) {
        var b = this.bz;
        this.bz = a;
        this.dq("Container", b, this.bz);
    };
    XamFunnelChart.prototype.notifyResized = function () {
        this.ax.g();
        this.ap.i(new ContainerSizeChangedMessage());
    };
    XamFunnelChart.prototype.dm = function (source_, a, b, c) {
        this.di(source_, new NotifyCollectionChangedEventArgs(2, 2, c, b, a));
    };
    XamFunnelChart.prototype.dh = function (source_) {
        this.di(source_, new NotifyCollectionChangedEventArgs(0, 4));
    };
    XamFunnelChart.prototype.dj = function (source_, a, b) {
        this.di(source_, new NotifyCollectionChangedEventArgs(1, 0, b, a));
    };
    XamFunnelChart.prototype.dk = function (source_, a, b) {
        this.di(source_, new NotifyCollectionChangedEventArgs(1, 1, b, a));
    };
    XamFunnelChart.prototype.di = function (s_, a) {
        if (s_.dataView && s_.dataSource) {
            s_ = s_.dataView();
        }
        ;
        if (s_ == this.itemsSource) {
            var b = this.az;
            if (b != null) {
                b.handleCollectionChanged(a);
            }
        }
    };
    XamFunnelChart.prototype.ay = function () {
        var a = this.ax;
        return a == null ? null : a.c;
    };
    XamFunnelChart.prototype.av = function () {
        var a = this.ay();
        return a == null ? null : a.ai;
    };
    Object.defineProperty(XamFunnelChart.prototype, "ag", {
        get: function () {
            var a = this.av();
            return a == null ? null : a.a();
        },
        set: function (a) {
            var b = this.av();
            if (b == null) {
                return;
            }
            var c = this.ay();
            b.f();
            var d = a == null ? 0 : a.length;
            while (d-- > 0) {
                b.k(a[d], c.am.a.item(a[d]));
            }
            c.bj = true;
            c.df();
        },
        enumerable: false,
        configurable: true
    });
    XamFunnelChart.prototype.dz = function (a) {
        var b = this.av();
        if (b == null) {
            return;
        }
        var c = this.ay();
        var d = c.am.a.item(a);
        if (d != null) {
            c.ai.k(a, d);
            c.bj = true;
            c.df();
        }
    };
    XamFunnelChart.prototype.aw = function () {
        var a = new FunnelChartVisualData();
        var b = this.ax.c.ag;
        if (b != null) {
            for (var c = 0; c < b.count; c++) {
                var d = b._inner[c].d();
                a.slices.add(d);
            }
        }
        a.opacity = this._opacity;
        a.isInverted = this.bd;
        a.selectedItems = this.bj;
        a.name = this.name;
        a.viewport = new RectData(0, 0, this.ax.c.b4, this.ax.c.b3);
        return a;
    };
    XamFunnelChart.prototype.b7 = function () {
        var a = this.aw();
        a.scaleByViewport();
        return a.serialize();
    };
    XamFunnelChart.prototype.resolveLegendIndex = function () {
        return -1;
    };
    XamFunnelChart.prototype.forSubItems = function (a) {
    };
    Object.defineProperty(XamFunnelChart.prototype, "bs", {
        get: function () {
            return this.bm;
        },
        set: function (a) {
            if (isNaN_(a) || a == 0) {
                return;
            }
            var b = this.bm;
            this.bm = a;
            this.dq("PixelScalingRatio", b, this.bm);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "bn", {
        get: function () {
            return this.bl;
        },
        set: function (a) {
            var b = this.bl;
            this.bl = a;
            if (this.bl != b) {
                this.dq("ActualPixelScalingRatio", b, this.bl);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "container", {
        get: function () {
            return this;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "isStacked", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "isVertical", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "isUsableInLegend", {
        get: function () {
            return true;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "hasSubItems", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "hasMarkers", {
        get: function () {
            return false;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "et", {
        get: function () {
            return this.er;
        },
        set: function (a) {
            var b = this.et;
            if (a != b) {
                this.er = a;
                this.dq("OuterLabelTextColor", b, this.et);
            }
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelChart.prototype, "eu", {
        get: function () {
            return this.es;
        },
        set: function (a) {
            var b = this.eu;
            if (a != b) {
                this.es = a;
                this.dq("LabelTextColor", b, this.eu);
            }
        },
        enumerable: false,
        configurable: true
    });
    XamFunnelChart.$t = markType(XamFunnelChart, 'XamFunnelChart', Control.$, [IItemProvider_$type, ILegendOwner_$type, ILegendTemplateProvider_$type, ILegendSeries_$type]);
    XamFunnelChart.$$p = markDep(DependencyProperty, PropertyMetadata, XamFunnelChart, 'dq', ['AllowSliceSelection:a8:d0', [0, false], 'BottomEdgeWidth:bo:d1', [1, 0.35], 'Brushes:ah:d2', [BrushCollection.$, null], 'FastItemsSource:az:d3', [FastItemsSource.$], 'FunnelSliceDisplay:ak:d4', [FunnelSliceDisplay_$type, enumGetBox(FunnelSliceDisplay_$type, 0)], 'InnerLabelMemberPath:cd:d5', [2, null], 'InnerLabelVisibility:ez:d6', [Visibility_$type, enumGetBox(Visibility_$type, 0)], 'IsInverted:bd:d7', [0, false], 'ItemsSource::d8', [IEnumerable_$type, null], 'LegendItemBadgeTemplate::d9', [DataTemplate.$, null], 'LegendItemTemplate::ea', [DataTemplate.$, null], 'Legend::eb', [IChartLegend_$type, null], 'LowerBezierControlPoint:ev:ec', [Point_$type, { $type: Point_$type, x: 0.5, y: 1 }], 'OuterLabelAlignment:au:ed', [OuterLabelAlignment_$type, enumGetBox(OuterLabelAlignment_$type, 0)], 'OuterLabelMemberPath:co:ee', [2, null], 'OuterLabelVisibility:e0:ef', [Visibility_$type, enumGetBox(Visibility_$type, 1)], 'OutlineThickness:bq:eh', [1, -1], 'Outlines:ai:eg', [BrushCollection.$, null], 'SelectedSliceStyle:ex:ei', [Style.$, null], 'ToolTip:b0:ej', [4, null], 'TransitionDuration:by:ek', [1, 0], 'UnselectedSliceStyle:ey:el', [Style.$, null], 'UpperBezierControlPoint:ew:em', [Point_$type, { $type: Point_$type, x: 0.5, y: 0 }], 'UseBezierCurve:be:en', [0, false], 'UseOuterLabelsForLegend:bf:eo', [0, false], 'UseUnselectedStyle:bg:ep', [0, false], 'ValueMemberPath:c9:eq', [2, null]]);
    return XamFunnelChart;
}(Control));
export { XamFunnelChart };
/**
 * @hidden
 */
var XamFunnelConnector = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(XamFunnelConnector, _super);
    function XamFunnelConnector(a, b) {
        var _this = _super.call(this) || this;
        _this.d = null;
        _this.b = null;
        _this.a = null;
        var c = new ServiceProvider();
        c.c("ConfigurationMessages", new MessageChannel());
        c.c("RenderingMessages", new MessageChannel());
        c.c("InteractionMessages", new MessageChannel());
        c.c("ModelUpdateMessages", new MessageChannel());
        a.av(b);
        var d = new XamFunnelController();
        d.at = a;
        d.ac = c;
        a.i = c;
        _this.b = d;
        _this.d = a;
        b.at = c;
        _this.a = b;
        c.c("Model", _this.a);
        return _this;
    }
    Object.defineProperty(XamFunnelConnector.prototype, "e", {
        get: function () {
            return this.d;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(XamFunnelConnector.prototype, "c", {
        get: function () {
            return this.b;
        },
        enumerable: false,
        configurable: true
    });
    XamFunnelConnector.prototype.g = function () {
        this.c.at.av(this.a);
    };
    XamFunnelConnector.prototype.h = function (a) {
        this.d = a;
        var b = this.b.ac;
        this.b.ac = null;
        this.b.ac = b;
        this.d.i = b;
    };
    XamFunnelConnector.prototype.f = function () {
        if (this.d != null) {
            this.d.i = null;
        }
    };
    XamFunnelConnector.prototype.i = function () {
        this.b.df();
    };
    XamFunnelConnector.$t = markType(XamFunnelConnector, 'XamFunnelConnector');
    return XamFunnelConnector;
}(Base));
export { XamFunnelConnector };
