/*
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 { Base, markType, INotifyPropertyChanged_$type, PropertyChangedEventArgs, Array_$type, enumGetBox, EnumUtil, typeGetValue, Number_$type, String_$type, fromEnum, typeCast, Date_$type, markDep, runOn, TypeRegistrar } from "igniteui-angular-core";
import { List$1 } from "igniteui-angular-core";
import { DataAbbreviationMode_$type } from "igniteui-angular-core";
import { Brush } from "igniteui-angular-core";
import { FontInfo } from "igniteui-angular-core";
import { Thickness } from "igniteui-angular-core";
import { Size } from "igniteui-angular-core";
import { Rect } from "igniteui-angular-core";
import { stringIsNullOrEmpty, stringEmpty } from "igniteui-angular-core";
import { DataLegendSeriesContext } from "igniteui-angular-core";
import { LegendItemBadgeShape_$type } from "igniteui-angular-core";
import { Control } from "igniteui-angular-core";
import { IDataLegend_$type } from "igniteui-angular-core";
import { IOnDemandRender_$type } from "igniteui-angular-core";
import { DependencyProperty } from "igniteui-angular-core";
import { DataLegendValueMode_$type } from "igniteui-angular-core";
import { FontUtil } from "igniteui-angular-core";
import { DataLegendHeaderDateMode_$type } from "igniteui-angular-core";
import { DataLegendHeaderTimeMode_$type } from "igniteui-angular-core";
import { DataLegendSummaryType_$type } from "igniteui-angular-core";
import { DataLegendUnitsMode_$type } from "igniteui-angular-core";
import { DataLegendLabelMode_$type } from "igniteui-angular-core";
import { BindingFormatter } from "igniteui-angular-core";
import { DataLegendVisualData } from "./DataLegendVisualData";
import { Extensions } from "igniteui-angular-core";
import { TextBlock } from "igniteui-angular-core";
import { DataLegendVisualDataRow } from "./DataLegendVisualDataRow";
import { DataLegendVisualDataColumn } from "./DataLegendVisualDataColumn";
import { IDataLegendSeries_$type } from "igniteui-angular-core";
import { RectData } from "igniteui-angular-core";
import { AppearanceHelper } from "igniteui-angular-core";
import { FrameworkElement } from "igniteui-angular-core";
import { DataLegendSummaryEventArgs } from "./DataLegendSummaryEventArgs";
import { DataLegendSummaryCalculationTotal } from "./DataLegendSummaryCalculationTotal";
import { DataLegendSummaryCalculationAverage } from "./DataLegendSummaryCalculationAverage";
import { DataLegendSummaryCalculationMin } from "./DataLegendSummaryCalculationMin";
import { DataLegendSummaryCalculationMax } from "./DataLegendSummaryCalculationMax";
import { DataLegendSummaryCalculationEmpty } from "./DataLegendSummaryCalculationEmpty";
import { DataLegendStylingRowEventArgs } from "./DataLegendStylingRowEventArgs";
import { DataLegendStylingColumnEventArgs } from "./DataLegendStylingColumnEventArgs";
import { Dictionary$2 } from "igniteui-angular-core";
import { DataLegendColumn } from "./DataLegendColumn";
import { RenderingContext } from "igniteui-angular-core";
import { DataLegendRenderContext } from "./DataLegendRenderContext";
import { Pool$1 } from "igniteui-angular-core";
import { ContentControl } from "igniteui-angular-core";
import { DataLegendSeriesValueInfo } from "igniteui-angular-core";
import { DataLegendSummaryColumn } from "igniteui-angular-core";
import { DataLegendSeriesGroup_$type } from "igniteui-angular-core";
import { DataAbbreviator } from "./DataAbbreviator";
import { NumberFormatSpecifier } from "igniteui-angular-core";
import { DateTimeFormatSpecifier } from "igniteui-angular-core";
import { PropertyMetadata } from "igniteui-angular-core";
import { isNaN_, isInfinity, truncate } from "igniteui-angular-core";
import { numberToString2 } from "igniteui-angular-core";
import { EventProxy } from "igniteui-angular-core";
import { Tuple$2 } from "igniteui-angular-core";
import { CanvasViewRenderer } from "igniteui-angular-core";
import { DataTemplatePassInfo } from "igniteui-angular-core";
import { DataTemplateMeasureInfo } from "igniteui-angular-core";
import { DataTemplateRenderInfo } from "igniteui-angular-core";
import { FontDefaults } from "igniteui-angular-core";
/**
 * @hidden
 */
export let DataLegendContent = /*@__PURE__*/ (() => {
    class DataLegendContent extends Base {
        constructor() {
            super(...arguments);
            this.a = new List$1(DataLegendRowInfo.$, 0);
            this.d = 0;
            this.c = 0;
        }
        get b() {
            return this.a;
        }
        f() {
            this.b.clear();
        }
        e(a) {
            this.b.add(a);
        }
    }
    DataLegendContent.$t = markType(DataLegendContent, 'DataLegendContent');
    return DataLegendContent;
})();
/**
 * @hidden
 */
export let DataLegendRowBase = /*@__PURE__*/ (() => {
    class DataLegendRowBase extends Base {
        constructor(a, b, c, d) {
            super();
            this.e = 0;
            this.b = false;
            this.d = false;
            this.a = false;
            this.c = false;
            this.e = d;
            this.d = b;
            this.a = c;
            this.c = !c && !b;
            this.b = true;
        }
    }
    DataLegendRowBase.$t = markType(DataLegendRowBase, 'DataLegendRowBase');
    return DataLegendRowBase;
})();
/**
 * @hidden
 */
export let DataLegendRowCell = /*@__PURE__*/ (() => {
    class DataLegendRowCell extends DataLegendRowBase {
        constructor(a, b, c, d) {
            super(a, b, c, d);
            this.s = 0;
            this.f = 0;
            this.r = 0;
            this.v = null;
            this.t = null;
            this.w = null;
            this.u = null;
            this.y = null;
            this.z = null;
            this.aa = null;
            this.g = null;
            this.i = null;
            this.h = null;
            this.ak = null;
            this.am = null;
            this.al = null;
            this.af = new Size();
            this.aj = new Size();
            this.ah = new Size();
            this.m = false;
            this.j = false;
            this.ab = null;
            this.ad = null;
            this.ac = null;
            this.ae = new Size();
            this.ai = new Size();
            this.ag = new Size();
            this.r = NaN;
            this.ak = new Thickness(0, 0);
            this.am = new Thickness(0, 0);
            this.al = new Thickness(0, 0);
            this.af = new Size(1, 0, 0);
            this.aj = new Size(1, 0, 0);
            this.ah = new Size(1, 0, 0);
            this.m = true;
            this.j = true;
            if (this.c) {
                this.y = a.br();
                this.aa = a.bt();
                this.z = a.bs();
                this.g = a.j();
                this.i = a.n();
                this.h = a.m();
            }
            else if (this.d) {
                let e = a.bq();
                let f = a.k();
                this.y = e;
                this.aa = e;
                this.z = e;
                this.g = f;
                this.i = f;
                this.h = f;
            }
            else {
                let g = a.bo();
                let h = a.i();
                this.y = g;
                this.aa = g;
                this.z = g;
                this.g = h;
                this.i = h;
                this.h = h;
            }
            this.ab = Rect.empty;
            this.ad = Rect.empty;
            this.ac = Rect.empty;
        }
        k() {
            return this.af.width > 0 && this.af.height > 0;
        }
        n() {
            return this.ah.width > 0 && this.ah.height > 0;
        }
        p() {
            return this.aj.width > 0 && this.aj.height > 0;
        }
        l() {
            return this.t != null;
        }
        o() {
            return this.u != null;
        }
        q() {
            return !stringIsNullOrEmpty(this.w) && this.aj.width > 0 && this.aj.height > 0;
        }
        x() {
            this.ae = new Size(1, 0, 0);
            this.ai = new Size(1, 0, 0);
            this.ag = new Size(1, 0, 0);
        }
    }
    DataLegendRowCell.$t = markType(DataLegendRowCell, 'DataLegendRowCell', DataLegendRowBase.$);
    return DataLegendRowCell;
})();
/**
 * @hidden
 */
export let DataLegendRowInfo = /*@__PURE__*/ (() => {
    class DataLegendRowInfo extends DataLegendRowBase {
        constructor(a, b, c, d) {
            super(a, b, c, d);
            this.k = null;
            this.j = false;
            this.m = null;
            this.f = null;
            this.g = null;
            this.n = null;
            this.q = null;
            this.i = null;
            this.p = null;
            this.t = new Size();
            this.l = null;
            this.h = 0;
            this.w = null;
            this.v = null;
            this.x = null;
            this.u = new Size();
            this.r = null;
            this.s = null;
            this.f = new Array(0);
            this.k = new List$1(DataLegendRowCell.$, 0);
            this.j = this.c;
            this.w = new Thickness(0, 0);
            this.v = new Thickness(0, 0);
            this.x = new Thickness(0, 0);
            this.t = new Size(1, 0, 0);
            this.u = new Size(1, 0, 0);
            if (this.c) {
                this.q = a.br();
                this.i = a.l();
            }
            else if (this.d) {
                let e = a.bq();
                let f = a.k();
                this.q = e;
                this.i = f;
            }
            else {
                let g = a.bo();
                let h = a.i();
                this.q = g;
                this.i = h;
            }
            this.s = Rect.empty;
            this.r = Rect.empty;
            this.h = 7;
        }
        o(a) {
            if (this.k == null) {
                return;
            }
            for (let b = 0; b < this.k.count; b++) {
                a(this.k._inner[b]);
            }
        }
    }
    DataLegendRowInfo.$t = markType(DataLegendRowInfo, 'DataLegendRowInfo', DataLegendRowBase.$);
    return DataLegendRowInfo;
})();
/**
 * @hidden
 */
export let XamDataLegend = /*@__PURE__*/ (() => {
    class XamDataLegend extends Control {
        constructor() {
            super();
            this.bw = false;
            this.ch = NaN;
            this.ci = NaN;
            this.cj = 1;
            this.bx = false;
            this.bj = null;
            this.bb = null;
            this.be = null;
            this.bg = null;
            this.bd = null;
            this.bf = null;
            this.a7 = null;
            this.bi = null;
            this.bh = null;
            this.bc = null;
            this.ck = NaN;
            this.calculateColumnSummary = null;
            this.styleHeaderRow = null;
            this.styleSeriesRow = null;
            this.styleSummaryRow = null;
            this.styleSeriesColumn = null;
            this.styleSummaryColumn = null;
            this.propertyChanged = null;
            this.b8 = null;
            this.b7 = null;
            this.ca = null;
            this.b9 = null;
            this.a5 = null;
            this.ib = null;
            this._externalObject = null;
            this.bu = false;
            this.bv = false;
            this.ao = new DataLegendContent();
            this.cc = null;
            this.cd = new List$1(DataLegendSeriesContext.$, 0);
            this.b6 = new Dictionary$2(Number_$type, DataLegendColumn.$, 0);
            this.cr = 0;
            this.ak = null;
            this.al = null;
            this.cx = "";
            this.ai = null;
            this.aj = null;
            this.ib = Rect.empty;
            this.bx = true;
            this.ab = XamDataLegend.$;
            this.a5 = this.a4();
        }
        get cl() {
            return this.ch;
        }
        set cl(a) {
            let b = this.ch;
            this.ch = a;
            if (b != this.ch) {
                this.fx("ActualCursorPositionX", b, this.ch);
            }
        }
        get cm() {
            return this.ci;
        }
        set cm(a) {
            let b = this.ci;
            this.ci = a;
            if (b != this.ci) {
                this.fx("ActualCursorPositionY", b, this.ci);
            }
        }
        get cn() {
            return this.cj;
        }
        set cn(a) {
            let b = this.cj;
            this.cj = a;
            this.fx("ActualPixelScalingRatio", b, this.cj);
        }
        get bt() {
            return this.bj;
        }
        set bt(a) {
            let b = this.bj;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ah, a);
            }
            this.bj = a;
            if (b != this.bj) {
                this.fx("ValueTextStyle", b, this.bj);
            }
        }
        get bl() {
            return this.bb;
        }
        set bl(a) {
            let b = this.bb;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ah, a);
            }
            this.bb = a;
            if (b != this.bb) {
                this.fx("HeaderTextStyle", b, this.bb);
            }
        }
        get bo() {
            return this.be;
        }
        set bo(a) {
            let b = this.be;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ah, a);
            }
            this.be = a;
            if (b != this.be) {
                this.fx("SummaryTitleTextStyle", b, this.be);
            }
        }
        get bq() {
            return this.bg;
        }
        set bq(a) {
            let b = this.bg;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ah, a);
            }
            this.bg = a;
            if (b != this.bg) {
                this.fx("SummaryValueTextStyle", b, this.bg);
            }
        }
        get bn() {
            return this.bd;
        }
        set bn(a) {
            let b = this.bd;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ah, a);
            }
            this.bd = a;
            if (b != this.bd) {
                this.fx("SummaryLabelTextStyle", b, this.bd);
            }
        }
        get bp() {
            return this.bf;
        }
        set bp(a) {
            let b = this.bf;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ah, a);
            }
            this.bf = a;
            if (b != this.bf) {
                this.fx("SummaryUnitsTextStyle", b, this.bf);
            }
        }
        get bs() {
            return this.bi;
        }
        set bs(a) {
            let b = this.bi;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ah, a);
            }
            this.bi = a;
            if (b != this.bi) {
                this.fx("UnitsTextStyle", b, this.bi);
            }
        }
        get br() {
            return this.bh;
        }
        set br(a) {
            let b = this.bh;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ah, a);
            }
            this.bh = a;
            if (b != this.bh) {
                this.fx("TitleTextStyle", b, this.bh);
            }
        }
        get bm() {
            return this.bc;
        }
        set bm(a) {
            let b = this.bc;
            if (typeof a === 'string') {
                a = FontUtil.getFontInfoFromString(this.a5.ah, a);
            }
            this.bc = a;
            if (b != this.bc) {
                this.fx("LabelTextStyle", b, this.bc);
            }
        }
        get pixelScalingRatio() {
            return this.ck;
        }
        set pixelScalingRatio(a) {
            let b = this.ck;
            this.ck = a;
            this.fx("PixelScalingRatio", b, this.ck);
        }
        exportSerializedVisualData() {
            let a = this.exportVisualData();
            return a.serialize();
        }
        cp(a, b) {
            let c = Math.max(b.left, a);
            let d = Math.max(b.right, a);
            let e = Math.max(b.right, a);
            return Math.min(b.top, a);
        }
        co(a, b) {
            return Math.min(b.left, a);
        }
        ia(a, b) {
            let c = Rect.l_op_Equality(a, null) || a.isEmpty || !Extensions.b(a);
            let d = Rect.l_op_Equality(b, null) || b.isEmpty || !Extensions.b(b);
            if (c) {
                return b;
            }
            if (d) {
                return a;
            }
            if (c && c) {
                return Rect.empty;
            }
            let e = Math.min(a.top, b.top);
            let f = Math.min(a.left, b.left);
            let g = Math.max(a.right, b.right);
            let h = Math.max(a.bottom, b.bottom);
            return new Rect(0, f, e, g - f, h - e);
        }
        exportVisualData() {
            let a = new DataLegendVisualData();
            a.width = this.ao.d;
            a.height = this.ao.c;
            if (this.a5 == null) {
                return a;
            }
            let b = -1;
            let c = -1;
            let d = -1;
            let e = -1;
            let f = this.a5.ab;
            let g = this.a5.z;
            let h = this.a5.ad;
            let i = this.a5.ac;
            if (f.count < this.ao.b.count) {
                return a;
            }
            if (Rect.l_op_Equality(this.ib, null) || this.ib.isEmpty) {
                a.viewport = null;
            }
            else {
                a.viewport = new RectData(0, 0, this.ib.width, this.ib.height);
            }
            for (let j = 0; j < this.ao.b.count; j++) {
                let k = this.ao.b._inner[j];
                let l = new DataLegendVisualDataRow();
                l.seriesIndex = k.e;
                l.rowMarginTop = k.w.top;
                l.rowMarginBottom = k.w.bottom;
                l.rowMarginRight = k.w.right;
                l.rowMarginLeft = k.w.left;
                let m = Rect.empty;
                if (k.b) {
                    if (Extensions.b(k.s) && f.count > (b + 1)) {
                        b++;
                        let n = f._inner[b];
                        let o = this.bk(n, k.i);
                        let p = new DataLegendVisualDataColumn();
                        p.bounds = RectData.b(k.s);
                        p.text = n.al;
                        p.textColor = AppearanceHelper.b(k.q);
                        p.marginTop = k.x.top;
                        p.marginLeft = k.x.left;
                        p.marginRight = k.x.right;
                        p.marginBottom = k.x.bottom;
                        this.f7(p, o);
                        l.columns.add(p);
                        m = this.ia(m, k.s);
                    }
                    for (let q of fromEnum(k.k)) {
                        if (Extensions.b(q.ab) && g.count > (c + 1)) {
                            c++;
                            let r = g._inner[c];
                            let s = this.bk(r, q.g);
                            let t = new DataLegendVisualDataColumn();
                            t.bounds = RectData.b(q.ab);
                            t.text = r.al;
                            t.textColor = AppearanceHelper.b(q.y);
                            t.marginTop = q.ak.top;
                            t.marginLeft = q.ak.left;
                            t.marginRight = q.ak.right;
                            t.marginBottom = q.ak.bottom;
                            this.f7(t, s);
                            l.columns.add(t);
                            m = this.ia(m, q.ab);
                        }
                        if (Extensions.b(q.ad) && h.count > (d + 1)) {
                            d++;
                            let u = h._inner[d];
                            let v = this.bk(u, q.i);
                            let w = new DataLegendVisualDataColumn();
                            w.bounds = RectData.b(q.ad);
                            w.text = u.al;
                            w.textColor = AppearanceHelper.b(q.aa);
                            w.marginTop = q.am.top;
                            w.marginLeft = q.am.left;
                            w.marginRight = q.am.right;
                            w.marginBottom = q.am.bottom;
                            this.f7(w, v);
                            l.columns.add(w);
                            m = this.ia(m, q.ad);
                        }
                        if (Extensions.b(q.ac) && i.count > (e + 1)) {
                            e++;
                            let x = i._inner[e];
                            let y = this.bk(x, q.h);
                            let z = new DataLegendVisualDataColumn();
                            z.bounds = RectData.b(q.ac);
                            z.text = q.m ? q.u : null;
                            z.textColor = AppearanceHelper.b(q.z);
                            z.marginTop = q.al.top;
                            z.marginLeft = q.al.left;
                            z.marginRight = q.al.right;
                            z.marginBottom = q.al.bottom;
                            this.f7(z, y);
                            l.columns.add(z);
                            m = this.ia(m, q.ac);
                        }
                    }
                    if (k.j) {
                        m = this.ia(m, k.r);
                        l.badgeBounds = RectData.b(k.r);
                        l.badgeMarginTop = k.v.top;
                        l.badgeMarginBottom = k.v.bottom;
                        l.badgeMarginRight = k.v.right;
                        l.badgeMarginLeft = k.v.left;
                        if (k.e >= 0 && k.e < this.cc.count) {
                            let aa = this.cc._inner[k.e];
                            l.badgeShape = aa.getDataLegendBadgeShapeAndMarker();
                        }
                        else {
                            l.badgeShape = "None";
                        }
                    }
                    l.rowBounds = RectData.b(m);
                }
                a.rows.add(l);
            }
            return a;
        }
        f7(a, b) {
            if (b != null) {
                if (b.n != null) {
                    a.fontFamily = b.n;
                }
                if (!isNaN_(b.d)) {
                    a.fontSize = b.d;
                }
                a.fontWeight = stringIsNullOrEmpty(b.s) ? "Normal" : b.s;
                a.fontStyle = stringIsNullOrEmpty(b.q) ? "Normal" : b.q;
                if (b.o != null) {
                    a.fontStretch = b.q;
                }
            }
        }
        bk(a, b) {
            let c = a.dataContext;
            if (c != null) {
                b = a.dataContext;
            }
            if (b == null || stringIsNullOrEmpty(b.fontString)) {
                return b;
            }
            else {
                return FontUtil.toFontInfo(this.a5.ah, b.fontString);
            }
        }
        a0(a) {
            if (this.calculateColumnSummary != null) {
                let b = new DataLegendSummaryEventArgs(a.a, a.d);
                b.summaryValue = a.c;
                this.calculateColumnSummary(this, b);
                a.c = b.summaryValue;
                a.f = b.summaryUnits;
                a.e = b.summaryLabel;
            }
            return a;
        }
        a6() {
            switch (this.a1) {
                case 0:
                case 1: return new DataLegendSummaryCalculationTotal();
                case 2: return new DataLegendSummaryCalculationAverage();
                case 3: return new DataLegendSummaryCalculationMin();
                case 4: return new DataLegendSummaryCalculationMax();
                case 5: return new DataLegendSummaryCalculationEmpty();
                default: return new DataLegendSummaryCalculationEmpty();
            }
        }
        gb(a) {
            if (this.styleSummaryRow != null) {
                let b = this.ay(a);
                this.styleSummaryRow(this, b);
                this.f8(a, b);
            }
            if (a.b && a.k != null && this.styleSummaryColumn != null) {
                for (let c = 0; c < a.k.count; c++) {
                    let d = this.ax(a.k._inner[c]);
                    d.d = a.e;
                    d.f = a.m;
                    d.c = c;
                    this.styleSummaryColumn(this, d);
                    this.gc(a.k._inner[c], d);
                }
            }
        }
        ga(a) {
            if (this.styleSeriesRow != null) {
                let b = this.ay(a);
                this.styleSeriesRow(this, b);
                this.f8(a, b);
            }
            if (a.b && a.k != null && this.styleSeriesColumn != null) {
                for (let c = 0; c < a.k.count; c++) {
                    let d = this.ax(a.k._inner[c]);
                    d.d = a.e;
                    d.f = a.m;
                    d.c = c;
                    this.styleSeriesColumn(this, d);
                    this.gc(a.k._inner[c], d);
                }
            }
        }
        f9(a) {
            if (this.styleHeaderRow != null) {
                let b = this.ay(a);
                this.styleHeaderRow(this, b);
                this.f8(a, b);
            }
        }
        ay(a) {
            let b = new DataLegendStylingRowEventArgs();
            b.f = a.n;
            b.g = a.q;
            b.a = a.h;
            b.b = a.j;
            b.c = a.b;
            b.d = a.e;
            b.e = a.m;
            return b;
        }
        f8(a, b) {
            a.n = b.f;
            a.q = b.g;
            a.h = b.a;
            a.j = b.b;
            a.b = b.c;
        }
        ax(a) {
            let b = new DataLegendStylingColumnEventArgs();
            b.e = a.t;
            b.j = a.y;
            b.g = a.u;
            b.k = a.z;
            b.i = a.w;
            b.l = a.aa;
            b.b = a.r;
            b.h = a.v;
            b.a = a.f;
            return b;
        }
        gc(a, b) {
            a.y = b.j;
            a.t = b.e;
            a.j = !stringIsNullOrEmpty(a.t);
            a.u = b.g;
            a.z = b.k;
            a.m = !stringIsNullOrEmpty(a.u);
            a.w = b.i;
            a.aa = b.l;
        }
        f0(a, b, c) {
            switch (a) {
                case XamDataLegend.$$p[19]:
                    this.bx = c;
                    break;
                case XamDataLegend.$$p[15]:
                case XamDataLegend.$$p[3]:
                    this.gg();
                    break;
                case XamDataLegend.$$p[14]:
                case XamDataLegend.$$p[2]:
                    this.gf();
                    break;
                case XamDataLegend.$$p[32]:
                    let d = c;
                    let e = b;
                    this.fy(e, d);
                    break;
                case XamDataLegend.$$p[30]:
                    if (this.b0(this.targetCursorPositionX)) {
                        this.cl = this.targetCursorPositionX;
                    }
                    break;
                case XamDataLegend.$$p[31]:
                    if (this.b0(this.targetCursorPositionY)) {
                        this.cm = this.targetCursorPositionY;
                    }
                    break;
                case XamDataLegend.$$p[46]:
                case XamDataLegend.$$p[45]:
                    if (!stringIsNullOrEmpty(this.e5)) {
                        this.ak = ((() => {
                            let $ret = new BindingFormatter();
                            $ret.j = this.e5;
                            $ret.d = this.ah;
                            return $ret;
                        })());
                    }
                    else {
                        this.ak = null;
                    }
                    break;
                case XamDataLegend.$$p[7]:
                case XamDataLegend.$$p[6]:
                    if (!stringIsNullOrEmpty(this.dc)) {
                        this.ai = ((() => {
                            let $ret = new BindingFormatter();
                            $ret.j = this.dc;
                            $ret.d = this.ag;
                            return $ret;
                        })());
                    }
                    else {
                        this.ai = null;
                    }
                    break;
                case "PixelScalingRatio":
                    if (isNaN_(this.cn)) {
                        this.a5.au();
                    }
                    else {
                        this.cn = this.pixelScalingRatio;
                    }
                    break;
                case "ActualPixelScalingRatio":
                    this.a5.a5(c);
                    break;
            }
            this.f2();
        }
        fx(a, b, c) {
            this.f0(a, b, c);
            if (this.propertyChanged != null) {
                this.propertyChanged(this, new PropertyChangedEventArgs(a));
            }
        }
        fy(a, b) {
            this.a7 = b;
            if (a != null) {
                a.detachDataLegend(this);
            }
            if (b != null) {
                b.attachDataLegend(this);
                if (isNaN_(this.targetCursorPositionX)) {
                    this.cl = 1;
                }
                if (isNaN_(this.targetCursorPositionY)) {
                    this.cm = 0.5;
                }
            }
        }
        gg() {
            this.ca = this.cb(this.includedSeries);
            this.b9 = this.cb(this.excludedSeries);
        }
        gf() {
            this.b8 = this.cb(this.includedColumns);
            this.b7 = this.cb(this.excludedColumns);
            if (this.b8 != null) {
                let a = new List$1(String_$type, 1, this.b8.keys);
                for (let b of fromEnum(a)) {
                    let c = b + ":";
                    let d = this.b8.item(b);
                    if (!this.b8.containsKey(c)) {
                        this.b8.addItem(c, d);
                    }
                }
                this.fg(this.b8);
            }
            if (this.b7 != null) {
                let e = new List$1(String_$type, 1, this.b7.keys);
                for (let f of fromEnum(e)) {
                    let g = f + ":";
                    let h = this.b7.item(f);
                    if (!this.b7.containsKey(g)) {
                        this.b7.addItem(g, h);
                    }
                }
                this.fg(this.b7);
            }
        }
        fg(a) {
            let b = new List$1(String_$type, 1, a.keys);
            for (let c of fromEnum(b)) {
                let d = a.item(c);
                let e = c.toLowerCase();
                if (!a.containsKey(e)) {
                    a.addItem(e, d);
                }
                let f = c.toUpperCase();
                if (!a.containsKey(f)) {
                    a.addItem(f, d);
                }
                if (c.length > 0) {
                    let g = f.substr(0, 1) + e.substr(1);
                    if (!a.containsKey(g)) {
                        a.addItem(g, d);
                    }
                }
            }
        }
        cb(a) {
            if (a == null) {
                return null;
            }
            let b = new Dictionary$2(String_$type, Number_$type, 0);
            for (let c = 0; c < a.length; c++) {
                let d = a[c];
                if (!stringIsNullOrEmpty(d) && !b.containsKey(d.trim())) {
                    b.addItem(d.trim(), b.count);
                }
            }
            return b;
        }
        b0(a) {
            return a >= 0 && a <= 1;
        }
        notifyCursorPositionChanged(a) {
            let b = !isNaN_(this.targetCursorPositionX) || !isNaN_(this.targetCursorPositionY);
            let c = !isNaN_(a.x) && this.b0(a.x);
            let d = !isNaN_(a.y) && this.b0(a.y);
            if (!b && c && d) {
                this.cl = a.x;
                this.cm = a.y;
            }
        }
        notifySizeChanged() {
            this.a5.a3();
        }
        notifyVisualPropertiesChanged(a) {
        }
        notifySeriesCollectionChanged() {
            this.f2();
        }
        notifySeriesDataChanged() {
            if (this.bx) {
                this.f2();
            }
        }
        updatePropertyByName(a, b) {
            switch (a) {
                case XamDataLegend.$$p[15]:
                    this.includedSeries = b;
                    break;
                case XamDataLegend.$$p[3]:
                    this.excludedSeries = b;
                    break;
                case XamDataLegend.$$p[14]:
                    this.includedColumns = b;
                    break;
                case XamDataLegend.$$p[2]:
                    this.excludedColumns = b;
                    break;
                case XamDataLegend.$$p[39]:
                    this.an = EnumUtil.getEnumValue(DataAbbreviationMode_$type, b);
                    break;
                case XamDataLegend.$$p[42]:
                    this.ct = typeGetValue(b);
                    break;
                case XamDataLegend.$$p[43]:
                    this.cu = typeGetValue(b);
                    break;
                case XamDataLegend.$$p[44]:
                    this.a3 = EnumUtil.getEnumValue(DataLegendValueMode_$type, b);
                    break;
                case XamDataLegend.$$p[40]:
                    this.ex = b;
                    break;
                case XamDataLegend.$$p[47]:
                    this.b3 = b;
                    break;
                case XamDataLegend.$$p[46]:
                    this.e5 = b;
                    break;
                case XamDataLegend.$$p[45]:
                    this.ah = b;
                    break;
                case XamDataLegend.$$p[48]:
                    this.ir = b;
                    break;
                case XamDataLegend.$$p[49]:
                    this.b4 = b;
                    break;
                case XamDataLegend.$$p[53]:
                    this.fe = b;
                    break;
                case XamDataLegend.$$p[52]:
                    this.b5 = b;
                    break;
                case XamDataLegend.$$p[51]:
                    this.is = b;
                    break;
                case XamDataLegend.$$p[50]:
                    this.h9 = b;
                    break;
                case "ValueTextStyle":
                    this.bt = b;
                    break;
                case XamDataLegend.$$p[7]:
                    this.dc = b;
                    break;
                case XamDataLegend.$$p[6]:
                    this.ag = b;
                    break;
                case XamDataLegend.$$p[4]:
                    this.c8 = b;
                    break;
                case XamDataLegend.$$p[5]:
                    this.ap = EnumUtil.getEnumValue(DataLegendHeaderDateMode_$type, b);
                    break;
                case XamDataLegend.$$p[8]:
                    this.aq = EnumUtil.getEnumValue(DataLegendHeaderTimeMode_$type, b);
                    break;
                case XamDataLegend.$$p[13]:
                    this.dh = b;
                    break;
                case XamDataLegend.$$p[11]:
                    this.h0 = b;
                    break;
                case XamDataLegend.$$p[12]:
                    this.ij = b;
                    break;
                case XamDataLegend.$$p[9]:
                    this.ii = b;
                    break;
                case XamDataLegend.$$p[10]:
                    this.bz = b;
                    break;
                case "HeaderTextStyle":
                    this.bl = b;
                    break;
                case XamDataLegend.$$p[23]:
                    this.h4 = b;
                    break;
                case "SummaryTitleTextStyle":
                    this.bo = b;
                    break;
                case XamDataLegend.$$p[26]:
                    this.a1 = EnumUtil.getEnumValue(DataLegendSummaryType_$type, b);
                    break;
                case XamDataLegend.$$p[25]:
                    this.d8 = b;
                    break;
                case XamDataLegend.$$p[24]:
                    this.im = b;
                    break;
                case XamDataLegend.$$p[22]:
                    this.il = b;
                    break;
                case XamDataLegend.$$p[29]:
                    this.h6 = b;
                    break;
                case "SummaryValueTextStyle":
                    this.bq = b;
                    break;
                case XamDataLegend.$$p[21]:
                    this.d3 = b;
                    break;
                case XamDataLegend.$$p[20]:
                    this.h3 = b;
                    break;
                case "SummaryLabelTextStyle":
                    this.bn = b;
                    break;
                case XamDataLegend.$$p[28]:
                    this.ee = b;
                    break;
                case XamDataLegend.$$p[27]:
                    this.h5 = b;
                    break;
                case "SummaryUnitsTextStyle":
                    this.bp = b;
                    break;
                case XamDataLegend.$$p[0]:
                    this.ih = b;
                    break;
                case XamDataLegend.$$p[1]:
                    this.a8 = EnumUtil.getEnumValue(LegendItemBadgeShape_$type, b);
                    break;
                case XamDataLegend.$$p[35]:
                    this.a2 = EnumUtil.getEnumValue(DataLegendUnitsMode_$type, b);
                    break;
                case XamDataLegend.$$p[38]:
                    this.er = b;
                    break;
                case XamDataLegend.$$p[36]:
                    this.h8 = b;
                    break;
                case XamDataLegend.$$p[37]:
                    this.ip = b;
                    break;
                case "UnitsTextStyle":
                    this.bs = b;
                    break;
                case XamDataLegend.$$p[34]:
                    this.io = b;
                    break;
                case XamDataLegend.$$p[33]:
                    this.h7 = b;
                    break;
                case "TitleTextStyle":
                    this.br = b;
                    break;
                case XamDataLegend.$$p[16]:
                    this.ar = EnumUtil.getEnumValue(DataLegendLabelMode_$type, b);
                    break;
                case XamDataLegend.$$p[17]:
                    this.h1 = b;
                    break;
                case XamDataLegend.$$p[18]:
                    this.ik = b;
                    break;
                case "LabelTextStyle":
                    this.bm = b;
                    break;
            }
        }
        a4() {
            return new DataLegendView(this);
        }
        destroy() {
            this.provideContainer(null);
        }
        get externalObject() {
            return this._externalObject;
        }
        set externalObject(a) {
            this._externalObject = a;
        }
        flush() {
            this.a5.ar();
        }
        onAttachedToUI() {
            this.a5.a1();
        }
        onDetachedFromUI() {
            this.a5.a4();
        }
        provideContainer(a) {
            this.a5.a2(a);
        }
        f2() {
            if (this.bu) {
                return;
            }
            this.bu = this.a5.w();
        }
        get shouldOnDemandRender() {
            return this.bv;
        }
        set shouldOnDemandRender(a) {
            this.bv = a;
        }
        doRender(a, b) {
            if (this.ib.isEmpty) {
                let c = this.getDesiredSize();
                this.ib = new Rect(0, 0, 0, c.width, c.height);
            }
            this.f3(this.ao, true);
            this.a5.a7(a, b);
        }
        ensureUpdated() {
            let a = this.getDesiredSize();
        }
        fp() {
            if (!this.bu) {
                if (this.ao == null) {
                    this.f2();
                }
                else {
                    return;
                }
            }
            this.ge();
        }
        getDesiredSize() {
            this.fp();
            if (this.ao == null) {
                return new Size(1, 0, 0);
            }
            return new Size(1, this.ao.d, this.ao.c);
        }
        ge() {
            if (this.a7 == null) {
                this.fm();
                return;
            }
            let a = this.a7;
            let b = a.getDataLegendSeries();
            let c = this.cf(b);
            this.fr(c);
        }
        cf(a) {
            let b = new Dictionary$2(Number_$type, IDataLegendSeries_$type, 0);
            for (let c = 0; c < a.length; c++) {
                let d = a[c].title == null ? null : a[c].title.toString();
                let e = this.ca == null || this.ca.containsKey(a[c].dataLegendKey) || this.ca.containsKey(a[c].index.toString()) || this.ca.containsKey(d);
                let f = this.b9 != null && (this.b9.containsKey(a[c].dataLegendKey) || this.b9.containsKey(a[c].index.toString()) || this.b9.containsKey(d));
                if (a[c].isValueOverlay && (!e || this.ca == null)) {
                    continue;
                }
                if (e && !f) {
                    let g = this.cs(a[c]);
                    b.addItem(g, a[c]);
                }
            }
            let h = new List$1(Number_$type, 1, b.keys);
            h.y();
            let i = new List$1(IDataLegendSeries_$type, 0);
            for (let j of fromEnum(h)) {
                i.add(b.item(j));
            }
            return i;
        }
        cs(a) {
            if (this.ca == null) {
                return a.index;
            }
            let b = a.dataLegendKey;
            if (this.ca.containsKey(b)) {
                return this.ca.item(b);
            }
            let c = a.index.toString();
            if (this.ca.containsKey(c)) {
                return this.ca.item(c);
            }
            let d = a.title == null ? null : a.title.toString();
            if (this.ca.containsKey(d)) {
                return this.ca.item(d);
            }
            return a.index;
        }
        fo() {
            this.bu = false;
            let a = new Size(1, 0, 0);
            if (this.ao != null) {
                a = new Size(1, this.ao.d, this.ao.c);
            }
            this.ge();
            let b = new Size(1, 0, 0);
            if (this.ao != null) {
                b = new Size(1, this.ao.d, this.ao.c);
            }
            if (!a.equals(b)) {
                this.a5.am(b.width, b.height);
            }
            this.f3(this.ao, this.bv);
        }
        fs(message_) {
        }
        f3(a, b) {
            let c = new DataLegendRenderContext();
            for (let d = 0; d < a.b.count; d++) {
                let e = a.b._inner[d];
                this.f5(a, e, c);
            }
            this.a5.p.count = c.b;
            this.a5.q.count = c.c;
            this.a5.s.count = c.e;
            this.a5.r.count = c.d;
            this.a5.o.count = c.a;
            if (!b) {
                this.a5.aq(a);
            }
        }
        f5(a, b, c) {
            if (b.t.width > 0 && b.t.height > 0 && !b.a && !b.d && b.j) {
                let d = this.a5.p.item(c.b);
                c.b += 1;
                this.f4(d, a, b, c);
            }
            this.a5.a9();
            if (!b.s.isEmpty && b.s.width > 0 && b.s.height > 0) {
                let e = this.a5.q.item(c.c);
                c.c += 1;
                this.f6(e, b.n, b.q, b.i, b.s);
            }
            for (let f of fromEnum(b.k)) {
                if (!f.ad.isEmpty && f.q()) {
                    let g = this.a5.s.item(c.e);
                    c.e += 1;
                    this.f6(g, f.w, f.aa, f.i, f.ad);
                }
                if (!f.ac.isEmpty && f.o() && f.m) {
                    let h = this.a5.r.item(c.d);
                    c.d += 1;
                    this.f6(h, f.u, f.z, f.h, f.ac);
                }
                if (!f.ab.isEmpty && f.l() && f.j) {
                    let i = this.a5.o.item(c.a);
                    c.a += 1;
                    this.f6(i, f.t, f.y, f.g, f.ab);
                }
            }
            this.a5.an();
        }
        f6(a, b, c, d, e) {
            a.al = b;
            this.a5.a8(a, e.left, e.top);
            this.a5.ao(a, d);
            this.a5.ap(a, d);
            a.ao = c;
        }
        f4(a, b, c, d) {
            a.ah = c.p;
            a.content = c.l;
            a.width = c.t.width;
            a.height = c.t.height;
            this.a5.a8(a, c.r.left, c.r.top);
        }
        fr(a) {
            if (this.by()) {
                this.ao.f();
                this.cc = a;
                this.cd.clear();
                this.cr = 0;
                this.b6.clear();
            }
            else {
                return;
            }
            for (let b = 0; b < a.count; b++) {
                let c = a._inner[b];
                let d = b;
                let e = typeCast(DataLegendSeriesContext.$, c.getDataLegendSeriesContextAt(this.cl, this.cm));
                if (e != null) {
                    let f = new List$1(DataLegendSeriesValueInfo.$, 0);
                    for (let g = 0; g < e.f.count; g++) {
                        let h = e.f._inner[g];
                        let i = this.b8 == null || this.b8.containsKey(h.p) || this.b8.containsKey(h.q) || this.b8.containsKey("ALL");
                        let j = this.b7 != null && (this.b7.containsKey(h.p) || this.b7.containsKey(h.q) || this.b7.containsKey("ALL"));
                        let k = this.b8 == null && this.b7 == null && h.k;
                        if (i && (!j && !k)) {
                            h.o = f.count;
                            f.add(h);
                            if (!this.b6.containsKey(h.o)) {
                                this.b6.addItem(h.o, new DataLegendColumn());
                            }
                            this.b6.item(h.o).i = h.o;
                            this.b6.item(h.o).d.q(d, h.r);
                            this.b6.item(h.o).b.q(d, h.q);
                            this.b6.item(h.o).e.q(d, h.l);
                            this.b6.item(h.o).c.q(d, h);
                            this.b6.item(h.o).h.add(d);
                        }
                    }
                    e.f = f;
                    this.cd.add(e);
                    this.cr = Math.max(this.cr, e.f.count);
                }
            }
            for (let l of fromEnum(this.b6.values)) {
                l.f.clear();
                l.a.clear();
                let m = l.e.p(l.h);
                let n = this.ce(m);
                for (let o = 0; o < n.count; o++) {
                    let p = n._inner[o];
                    let q = l.h._inner[o];
                    l.a.q(q, p);
                    let r = l.c.item(q);
                    let s = this.d1(p, r);
                    l.f.q(q, s);
                    let t = !stringIsNullOrEmpty(p.l);
                    if (t) {
                        l.g = true;
                    }
                }
            }
            this.fh(this.ao, a);
            for (let u = 0; u < a.count; u++) {
                this.gd(a._inner[u], this.a8);
                this.fi(this.ao, a._inner[u], u);
            }
            this.fj(this.ao, a);
            this.bw = this.b1();
            this.fl(this.ao);
        }
        b1() {
            let a = false;
            for (let b = 0; b < this.ao.b.count; b++) {
                let c = this.ao.b._inner[b];
                if (c.c && c.j && c.h != 7) {
                    a = true;
                    break;
                }
            }
            return a;
        }
        fl(a) {
            let b = 0;
            let c = 0;
            for (let d = 0; d < a.b.count; d++) {
                let e = a.b._inner[d];
                this.ft(e);
            }
            let f = 0;
            let g = new Size(1, 0, 0);
            let h = new Size(1, 0, 0);
            let i = new Dictionary$2(Number_$type, Size.$, 0);
            let j = new Dictionary$2(Number_$type, Size.$, 0);
            let k = new Dictionary$2(Number_$type, Size.$, 0);
            for (let l of fromEnum(a.b)) {
                for (let m = 0; m < l.k.count; m++) {
                    let n = l.k._inner[m];
                    if (!i.containsKey(m)) {
                        i.addItem(m, new Size(1, 0, 0));
                    }
                    i.item(m, this.ig(i.item(m), n.aj, n.am));
                    if (!j.containsKey(m)) {
                        j.addItem(m, new Size(1, 0, 0));
                    }
                    j.item(m, this.ig(j.item(m), n.ah, n.al));
                    if (!k.containsKey(m)) {
                        k.addItem(m, new Size(1, 0, 0));
                    }
                    k.item(m, this.ig(k.item(m), n.af, n.ak));
                }
            }
            for (let o = 0; o < a.b.count; o++) {
                let p = a.b._inner[o];
                h = this.ie(h, p.t, p.v);
                g = this.ig(g, p.u, p.x);
                for (let q = 0; q < p.k.count; q++) {
                    p.k._inner[q].ai = i.item(q);
                    p.k._inner[q].ag = j.item(q);
                    p.k._inner[q].ae = k.item(q);
                }
                if (p.d) {
                    let r = p.u.width + p.x.left + p.x.right;
                    f = Math.max(f, r + p.w.left);
                }
                else if (p.c) {
                    let s = p.u.width + p.x.left + p.x.right;
                    let t = p.t.width + p.v.left + p.v.right;
                    f = Math.max(f, s + p.w.left + t);
                }
            }
            let u = 0;
            let v = 0;
            for (let w = 0; w < a.b.count; w++) {
                let x = a.b._inner[w];
                let y = this.ic(v, x, f, g, h);
                v = y.height;
                u = Math.max(u, y.width);
            }
            c = v;
            b = u;
            a.d = b;
            a.c = c;
        }
        ie(a, b, c) {
            return new Size(1, Math.max(a.width, b.width + c.left + c.right), Math.max(a.height, b.height + c.top + c.bottom));
        }
        ig(a, b, c) {
            return new Size(1, Math.max(a.width, b.width + c.left + c.right), Math.max(a.height, b.height + c.top + c.bottom));
        }
        ic(a, b, c, d, e) {
            let f = 0;
            let g = 0;
            g = Math.max(b.t.height, g);
            g = Math.max(b.u.height, g);
            for (let h of fromEnum(b.k)) {
                g = Math.max(h.aj.height, g);
                if (h.m) {
                    g = Math.max(h.ah.height, g);
                }
                if (h.j) {
                    g = Math.max(h.af.height, g);
                }
            }
            f += b.w.left;
            a += b.w.top;
            if (!b.a && !b.d && this.bw) {
                f += b.v.left;
                let i = 0;
                if (g > b.t.height) {
                    i = (g - b.t.height) / 2;
                }
                b.r = new Rect(0, f, a + i, b.t.width, b.t.height);
                f += (b.r.width) + b.v.right;
            }
            else {
                b.r = new Rect(0, 0, 0, 0, 0);
            }
            f += b.x.left;
            let j = 0;
            if (g > b.u.height) {
                j = (g - b.u.height) / 2;
            }
            b.s = new Rect(0, f, a + j, b.u.width + b.x.right, b.u.height);
            f = Math.max(c, b.s.right);
            for (let k of fromEnum(b.k)) {
                let l = " C=" + k.s + " SR=" + numberToString2(f, "000");
                if ((k.l() && k.j) && k.ae.width > 0) {
                    let m = 0;
                    if (g > k.af.height) {
                        m = (g - k.af.height) / 2;
                    }
                    k.ab = new Rect(0, f + k.ak.left, a + m, k.af.width, k.af.height);
                    f += k.ae.width;
                    l += " label L=" + numberToString2(k.ab.left, "000") + " R=" + numberToString2(k.ab.right, "000");
                }
                if (k.q()) {
                    l += " v MW=" + numberToString2(k.ai.width, "000");
                    f += k.am.left;
                    f += (k.ai.width - (k.aj.width + k.am.right));
                    let n = 0;
                    if (g > k.aj.height) {
                        n = (g - k.aj.height) / 2;
                    }
                    k.ad = new Rect(0, f, a + n, k.aj.width, k.aj.height);
                    l += " v ML=" + numberToString2(k.am.left, "00") + " MR=" + numberToString2(k.am.right, "00");
                    l += " v BL=" + numberToString2(k.ad.left, "000") + " BR=" + numberToString2(k.ad.right, "000");
                    f += k.ad.width;
                    f += k.am.right;
                }
                if ((k.o() && k.m) && k.ag.width > 0) {
                    let o = 0;
                    if (g > k.ah.height) {
                        o = (g - k.ah.height) / 2;
                    }
                    k.ac = new Rect(0, f + k.al.left, a + o, k.ah.width, k.ah.height);
                    f += k.ag.width;
                    l += " unit L=" + numberToString2(k.ac.left, "000") + " R=" + numberToString2(k.ac.right, "000");
                }
                this.fs("maxRight " + numberToString2(c, "0") + l);
            }
            f += b.w.right;
            a += g;
            a += b.w.bottom;
            return new Size(1, f, a);
        }
        ft(a) {
            a.u = a.n == null ? new Size(1, 0, 0) : this.a5.bu(a.n, a.i);
            for (let b of fromEnum(a.k)) {
                b.aj = b.w == null ? new Size(1, 0, 0) : this.a5.bu(b.w, b.i);
                b.ah = b.u == null ? new Size(1, 0, 0) : this.a5.bu(b.u, b.h);
                b.af = b.t == null ? new Size(1, 0, 0) : this.a5.bu(b.t, b.g);
            }
        }
        d0(a, b, c, d) {
            if (this.a2 == 2) {
                return null;
            }
            let e = "";
            if (stringIsNullOrEmpty(this.er)) {
                e = b;
            }
            else {
                e = this.er;
            }
            if (d) {
                if (stringIsNullOrEmpty(e)) {
                    e = c;
                }
                else {
                    e = c + e;
                }
            }
            let f = this.b6.item(a).d;
            let g = this.b6.item(a).g;
            if (g && stringIsNullOrEmpty(e)) {
                e = " ";
            }
            else if (f.count > 0 && stringIsNullOrEmpty(e)) {
                e = " ";
            }
            else if (!d) {
                return null;
            }
            return e;
        }
        dx(a, b, c) {
            if (this.ar == 2) {
                return null;
            }
            let d = this.cr > 1;
            let e = this.ar == 1;
            let f = this.b6.item(a).b.count > 0;
            if (f && (d || e)) {
                if (stringIsNullOrEmpty(b)) {
                    return " ";
                }
                else if (c) {
                    return b;
                }
            }
            return null;
        }
        fj(a, b) {
            if (this.a1 == 5) {
                return;
            }
            if (b == null || b.count <= 1) {
                return;
            }
            let c = new Dictionary$2(Number_$type, DataLegendSummaryColumn.$, 0);
            let d = 0;
            let e = new List$1(DataLegendSeriesGroup_$type, 0);
            for (let f of fromEnum(this.cd)) {
                d = Math.max(d, f.f.count);
                if (!e.contains(f.b)) {
                    e.add(f.b);
                }
                for (let g = 0; g < f.f.count; g++) {
                    let h = f.f._inner[g];
                    if (!c.containsKey(g)) {
                        c.addItem(g, new DataLegendSummaryColumn());
                    }
                    let i = c.item(g);
                    i.n = h.n;
                    i.m = h.m;
                    i.e = h.e;
                    i.h = h.h;
                    i.f = h.f;
                    i.f = h.g;
                    i.d = h.d;
                    i.x = h.x;
                    i.ai(h.l);
                    i.ag(h.q);
                    i.ah(h.r);
                    if (stringIsNullOrEmpty(i.t)) {
                        i.t = h.t;
                    }
                    if (stringIsNullOrEmpty(i.u)) {
                        i.u = h.u;
                    }
                    if (stringIsNullOrEmpty(i.v)) {
                        i.v = h.v;
                    }
                    if (stringIsNullOrEmpty(i.w)) {
                        i.w = h.w;
                    }
                    if (stringIsNullOrEmpty(i.p)) {
                        i.p = h.p;
                    }
                }
            }
            if (this.a1 == 0) {
                if (e.count > 1) {
                    return;
                }
                if (!e.contains(0)) {
                    return;
                }
            }
            let j = this.a6();
            let k = new DataLegendRowInfo(this.a5, true, false, -1);
            k.n = this.d8 != null ? this.d8 : j.title;
            k.q = this.h4 || k.q;
            k.i = this.bo || k.i;
            for (let l = 0; l < d; l++) {
                let m = c.item(l);
                let n = j.calculate(m.aa, m.p);
                n = this.a0(n);
                let o = this.an;
                let p = o == 0 || o == 2 || o == 8;
                let q = -1;
                for (let r of fromEnum(this.b6.item(l).a.values)) {
                    if (r.b()) {
                        q = Math.max(q, r.h);
                        if (p) {
                            o = r.a;
                        }
                    }
                }
                let s = this.cu >= 0 ? this.cu : q;
                let t = this.ct >= 0 ? this.ct : q;
                let u = this.am(n.c, o, s, t);
                u.i = s;
                u.h = t;
                let v = this.d1(u, m);
                let w = new DataLegendRowCell(this.a5, true, false, -1);
                w.s = k.k.count;
                w.t = this.dx(w.s, " ", m.b);
                if (!stringIsNullOrEmpty(this.d3)) {
                    w.t = this.d3;
                }
                if (n.e != null) {
                    w.t = n.e;
                }
                w.j = !stringIsNullOrEmpty(w.t);
                w.y = this.h3 || w.y;
                w.g = this.bn || w.g;
                w.w = v;
                w.i = this.bq || w.i;
                w.aa = this.h2(this.h6, w.aa, null);
                w.r = n.c;
                w.f = u.a;
                w.v = m.p;
                let x = m.z.length >= 1 ? m.z[0] : " ";
                w.u = this.d0(w.s, x, u.l, m.d);
                if (n.f != null) {
                    w.u = n.f;
                }
                w.m = !stringIsNullOrEmpty(w.u);
                w.z = this.h5 || w.z;
                w.h = this.bp || w.h;
                k.k.add(w);
            }
            this.gb(k);
            if (k.b) {
                this.fk(k);
                this.fz(k);
                a.e(k);
            }
        }
        am(a, b, c, d) {
            if (b == 8 || b == 0) {
                b = this.an;
            }
            if (d < 0) {
                d = this.ct;
            }
            if (c < 0) {
                c = this.cu;
            }
            return DataAbbreviator.a(a, b, c, d);
        }
        cq(a, b, c, d) {
            return this.am(a, b, c, d).d;
        }
        c7(a, b, c, d) {
            return this.am(a, b, c, d).l;
        }
        c6(a, b, c, d) {
            let e = this.am(a, b, c, d);
            return e.m + e.l;
        }
        ce(a) {
            let b = this.cu;
            let c = this.ct;
            let d = this.an;
            let e = DataAbbreviator.h(a, d, b, c);
            return e;
        }
        cg(a) {
            let b = new List$1(Number_$type, 0);
            if (a < 0) {
                return b;
            }
            for (let c = 0; c < this.cd.count; c++) {
                let d = this.cd._inner[c];
                if (d.f.count > a) {
                    let e = d.f._inner[a].l;
                    if (!isNaN_(e)) {
                        b.add(e);
                    }
                }
            }
            return b;
        }
        fk(a) {
        }
        h2(a, b, c) {
            if (a != null) {
                return a;
            }
            if (this.b5 && c != null) {
                return c;
            }
            return b;
        }
        dy(a, b) {
            return stringIsNullOrEmpty(a) ? b : a;
        }
        d1(a, b) {
            let c = a.d;
            if (b == null || isNaN_(c) || isInfinity(c)) {
                return this.fe;
            }
            let d;
            let e = b.d ? a.d : a.g;
            if (this.ak != null) {
                d = this.ak.i(e);
            }
            else {
                let f = this.a3;
                if (f == 0) {
                    f = 1;
                }
                let g = new NumberFormatSpecifier();
                g.useGrouping = this.b3;
                g.locale = this.dy(this.ex, null);
                g.currencyCode = this.ez;
                if (b.d) {
                    g.minimumFractionDigits = a.i;
                    g.maximumFractionDigits = a.h;
                    if (b.n >= 0 && b.n > a.i) {
                        g.minimumFractionDigits = b.n;
                    }
                    else if (this.cu >= 0) {
                        g.minimumFractionDigits = this.cu;
                    }
                    if (b.m >= 0 && b.m > a.h) {
                        g.maximumFractionDigits = b.m;
                    }
                    else if (this.ct >= 0) {
                        g.maximumFractionDigits = this.ct;
                    }
                }
                else {
                    g.minimumFractionDigits = b.n;
                    g.maximumFractionDigits = b.m;
                }
                if (g.minimumFractionDigits > g.maximumFractionDigits) {
                    g.maximumFractionDigits = g.minimumFractionDigits;
                }
                if (f == 2 && b.e) {
                    g.style = "currency";
                }
                if (this.al == null) {
                    this.al = new BindingFormatter();
                }
                this.al.j = "{0}";
                this.al.d = [g];
                d = this.al.i(e);
                if (e > 0) {
                    d = b.v + d;
                }
                else if (e < 0) {
                    d = b.t + d;
                }
                if (e >= 0) {
                    d += b.w;
                }
                else {
                    d += b.u;
                }
            }
            return d;
        }
        fi(a, b, c) {
            if (this.b4 == false) {
                return;
            }
            let d = this.cd._inner[c];
            let e = this.dz(b);
            let f = new DataLegendRowInfo(this.a5, false, false, c);
            f.f = d.a();
            f.m = e;
            f.n = e;
            f.q = this.h7 || f.q;
            f.i = this.br || f.i;
            for (let g = 0; g < d.f.count; g++) {
                let h = d.f._inner[g];
                let i = this.b6.item(g).a.item(c);
                let j = this.b6.item(g).f.item(c);
                let k = new DataLegendRowCell(this.a5, false, false, c);
                k.s = f.k.count;
                k.i = this.bt || k.i;
                k.w = j;
                k.aa = this.h2(this.h9, k.aa, h.x);
                k.v = h.p;
                k.r = h.l;
                k.f = i.a;
                k.u = this.d0(k.s, h.r, i.l, h.d);
                k.m = !stringIsNullOrEmpty(k.u);
                k.z = this.h8 || k.z;
                k.h = this.bs || k.h;
                k.t = this.dx(k.s, h.q, h.b);
                k.j = !stringIsNullOrEmpty(k.t);
                k.y = this.h1 || k.y;
                k.g = this.bm || k.g;
                f.k.add(k);
            }
            f.h = this.a9(b);
            this.fk(f);
            this.fz(f);
            this.ga(f);
            if (f.b) {
                if (f.j) {
                    this.gd(b, f.h);
                    let l = this.gh(b);
                    let m = this.cw(b);
                    f.p = l;
                    f.l = m;
                }
                a.e(f);
            }
        }
        cw(a) {
            return a.getDataLegendBadgeContext();
        }
        a9(a) {
            if (this.a8 != 0) {
                return this.a8;
            }
            return a.legendItemBadgeShape;
        }
        gd(a, b) {
            if (b == 0) {
                return;
            }
            if (a.legendItemBadgeShape != b) {
                a.legendItemBadgeShape = b;
            }
        }
        by() {
            return !isNaN_(this.cl) && !isNaN_(this.cm);
        }
        gh(a) {
            return a.getDataLegendBadge();
        }
        dz(a) {
            return a.getDataLegendSeriesTitle();
        }
        fh(a, b) {
            if (this.bz == false) {
                return;
            }
            let c = this.dw(b);
            if (c == null) {
                c = this.cx;
            }
            else {
                this.cx = c;
            }
            if (stringIsNullOrEmpty(c)) {
                return;
            }
            let d = new DataLegendRowInfo(this.a5, false, true, -1);
            d.n = c;
            d.q = this.h0 || d.q;
            d.i = this.bl || d.i;
            this.fk(d);
            this.fz(d);
            this.f9(d);
            if (d.b) {
                a.e(d);
            }
        }
        iq(a) {
            let b = new Thickness(0, 0);
            if (a.top >= 0) {
                b.top = a.top;
            }
            if (a.bottom >= 0) {
                b.bottom = a.bottom;
            }
            if (a.left >= 0) {
                b.left = a.left;
            }
            if (a.right >= 0) {
                b.right = a.right;
            }
            return b;
        }
        fz(a) {
            if (a.c) {
                a.x = this.iq(this.io);
                a.w = this.iq(this.ir);
            }
            else if (a.a) {
                a.x = this.iq(this.ij);
                a.w = this.iq(this.ii);
            }
            else {
                a.x = this.iq(this.im);
                a.w = this.iq(this.il);
            }
            for (let b of fromEnum(a.k)) {
                b.am = this.iq(this.is);
                b.al = this.iq(this.ip);
                b.ak = this.iq(this.ik);
            }
            if (a.c) {
                a.v = this.iq(this.ih);
                a.t = new Size(1, 20, 15);
            }
        }
        dw(a) {
            if (this.dh != null) {
                return this.dh;
            }
            let b = true;
            let c = null;
            for (let d = 0; d < a.count; d++) {
                let e = a._inner[d];
                let f = this.du(e);
                if (f == null) {
                    continue;
                }
                if (c == null) {
                    c = f;
                }
                else {
                    if (!Base.equalsStatic(c, f)) {
                        b = false;
                        break;
                    }
                }
            }
            if (b || !stringIsNullOrEmpty(c)) {
                return c;
            }
            return null;
        }
        du(a) {
            if (this.by()) {
                let b = a.getDataLegendAxisLabelFromCursorPosition(this.cl, this.cm);
                if (typeCast(Date_$type, b) !== null) {
                    let c = b;
                    b = this.dv(c);
                }
                return b == null ? "" : b.toString();
            }
            else {
                return null;
            }
        }
        dv(a) {
            if (this.ai != null) {
                let b = this.ai.i(a);
                return b;
            }
            else {
                let c = new DateTimeFormatSpecifier();
                c.dateStyle = "short";
                c.timeStyle = "full";
                let d = this.ap;
                if (d == 0) {
                    d = 1;
                }
                if (d == 3) {
                    c.dateStyle = "medium";
                }
                if (d == 1) {
                    c.dateStyle = "short";
                }
                if (d == 4) {
                    c.dateStyle = "full";
                }
                if (d == 2) {
                    c.dateStyle = "long";
                }
                if (d == 5) {
                    c.dateStyle = null;
                }
                let e = this.aq;
                if (e == 0) {
                    e = 1;
                }
                if (e == 3) {
                    c.timeStyle = "medium";
                }
                if (e == 1) {
                    c.timeStyle = "short";
                }
                if (e == 4) {
                    c.timeStyle = "full";
                }
                if (e == 2) {
                    c.timeStyle = "long";
                }
                if (e == 5) {
                    c.timeStyle = null;
                }
                c.locale = this.dy(this.c8, "en-US");
                if (this.aj == null) {
                    this.aj = new BindingFormatter();
                }
                this.aj.j = "{0}";
                this.aj.d = [c];
                let f = this.aj.i(a);
                return f;
            }
        }
        fm() {
        }
    }
    XamDataLegend.$t = markType(XamDataLegend, 'XamDataLegend', Control.$, [INotifyPropertyChanged_$type, IDataLegend_$type, IOnDemandRender_$type]);
    XamDataLegend.$$p = markDep(DependencyProperty, PropertyMetadata, XamDataLegend, 'fx', ['BadgeMargin:ih:gi', [Thickness.$, new Thickness(1, 0, 0, 0, 0)], 'BadgeShape:a8:gj', [LegendItemBadgeShape_$type, enumGetBox(LegendItemBadgeShape_$type, 0)], 'ExcludedColumns::gk', [Array_$type, null], 'ExcludedSeries::gl', [Array_$type, null], 'HeaderFormatCulture:c8:gm', [2, stringEmpty()], 'HeaderFormatDate:ap:gn', [DataLegendHeaderDateMode_$type, enumGetBox(DataLegendHeaderDateMode_$type, 0)], 'HeaderFormatSpecifiers:ag:go', [Array_$type, null], 'HeaderFormatString:dc:gp', [2, null], 'HeaderFormatTime:aq:gq', [DataLegendHeaderTimeMode_$type, enumGetBox(DataLegendHeaderTimeMode_$type, 0)], 'HeaderRowMargin:ii:gr', [Thickness.$, new Thickness(0, 5)], 'HeaderRowVisible:bz:gs', [0, true], 'HeaderTextColor:h0:gt', [Brush.$, null], 'HeaderTextMargin:ij:gu', [Thickness.$, new Thickness(1, 2, 0, 0, 0)], 'HeaderText:dh:gv', [2, null], 'IncludedColumns::gw', [Array_$type, null], 'IncludedSeries::gx', [Array_$type, null], 'LabelDisplayMode:ar:gy', [DataLegendLabelMode_$type, enumGetBox(DataLegendLabelMode_$type, 0)], 'LabelTextColor:h1:gz', [Brush.$, null], 'LabelTextMargin:ik:g0', [Thickness.$, new Thickness(1, 12, 0, 0, 0)], 'ShouldUpdateWhenSeriesDataChanges:b2:g1', [0, true], 'SummaryLabelTextColor:h3:g2', [Brush.$, null], 'SummaryLabelText:d3:g3', [2, null], 'SummaryRowMargin:il:g4', [Thickness.$, new Thickness(0, 5)], 'SummaryTitleTextColor:h4:g5', [Brush.$, null], 'SummaryTitleTextMargin:im:g6', [Thickness.$, new Thickness(1, 2, 0, 4, 0)], 'SummaryTitleText:d8:g7', [2, null], 'SummaryType:a1:g8', [DataLegendSummaryType_$type, enumGetBox(DataLegendSummaryType_$type, 0)], 'SummaryUnitsTextColor:h5:g9', [Brush.$, null], 'SummaryUnitsText:ee:ha', [2, null], 'SummaryValueTextColor:h6:hb', [Brush.$, null], 'TargetCursorPositionX::hc', [1, NaN], 'TargetCursorPositionY::hd', [1, NaN], 'Target::he', [4, null], 'TitleTextColor:h7:hf', [Brush.$, null], 'TitleTextMargin:io:hg', [Thickness.$, new Thickness(1, 0, 0, 4, 0)], 'UnitsDisplayMode:a2:hh', [DataLegendUnitsMode_$type, enumGetBox(DataLegendUnitsMode_$type, 0)], 'UnitsTextColor:h8:hi', [Brush.$, null], 'UnitsTextMargin:ip:hj', [Thickness.$, new Thickness(1, 0, 0, 0, 0)], 'UnitsText:er:hk', [2, null], 'ValueFormatAbbreviation:an:hl', [DataAbbreviationMode_$type, enumGetBox(DataAbbreviationMode_$type, 0)], 'ValueFormatCulture:ex:hm', [2, stringEmpty()], 'ValueFormatCurrencyCode:ez:hn', [2, null], 'ValueFormatMaxFractions:ct:ho', [1, -1], 'ValueFormatMinFractions:cu:hp', [1, -1], 'ValueFormatMode:a3:hq', [DataLegendValueMode_$type, enumGetBox(DataLegendValueMode_$type, 0)], 'ValueFormatSpecifiers:ah:hr', [Array_$type, null], 'ValueFormatString:e5:hs', [2, null], 'ValueFormatUseGrouping:b3:ht', [0, true], 'ValueRowMargin:ir:hu', [Thickness.$, new Thickness(0, 5)], 'ValueRowVisible:b4:hv', [0, true], 'ValueTextColor:h9:hw', [Brush.$, null], 'ValueTextMargin:is:hx', [Thickness.$, new Thickness(1, 2, 0, 2, 0)], 'ValueTextUseSeriesColors:b5:hy', [0, false], 'ValueTextWhenMissingData:fe:hz', [2, "N/A"]]);
    return XamDataLegend;
})();
/**
 * @hidden
 */
export let DataLegendView = /*@__PURE__*/ (() => {
    class DataLegendView extends Base {
        constructor(a) {
            super();
            this.z = null;
            this.ab = null;
            this.ad = null;
            this.ac = null;
            this.aa = null;
            this.o = null;
            this.q = null;
            this.s = null;
            this.r = null;
            this.p = null;
            this.a = null;
            this.ai = null;
            this.ah = null;
            this.t = null;
            this.b = null;
            this.ae = 1;
            this.ak = -1;
            this.aj = -1;
            this.x = new Dictionary$2(FontInfo.$, Tuple$2.$.specialize(Number_$type, FontInfo.$), 0);
            this.v = false;
            this.y = new List$1(FrameworkElement.$, 0);
            this.af = 0;
            this.f = null;
            this.h = null;
            this.g = null;
            this.d = null;
            this.e = null;
            this.c = null;
            this.u = null;
            this.a = a;
            this.q = ((() => {
                let $ret = new Pool$1(TextBlock.$);
                $ret.create = runOn(this, this.bl);
                $ret.activate = runOn(this, this.ba);
                $ret.disactivate = runOn(this, this.bc);
                $ret.destroy = runOn(this, this.bb);
                return $ret;
            })());
            this.s = ((() => {
                let $ret = new Pool$1(TextBlock.$);
                $ret.create = runOn(this, this.bn);
                $ret.activate = runOn(this, this.bg);
                $ret.disactivate = runOn(this, this.bi);
                $ret.destroy = runOn(this, this.bh);
                return $ret;
            })());
            this.r = ((() => {
                let $ret = new Pool$1(TextBlock.$);
                $ret.create = runOn(this, this.bm);
                $ret.activate = runOn(this, this.bd);
                $ret.disactivate = runOn(this, this.bf);
                $ret.destroy = runOn(this, this.be);
                return $ret;
            })());
            this.p = ((() => {
                let $ret = new Pool$1(ContentControl.$);
                $ret.create = runOn(this, this.bj);
                $ret.activate = runOn(this, this.ay);
                $ret.disactivate = runOn(this, this.a0);
                $ret.destroy = runOn(this, this.az);
                return $ret;
            })());
            this.o = ((() => {
                let $ret = new Pool$1(TextBlock.$);
                $ret.create = runOn(this, this.bk);
                $ret.activate = runOn(this, this.av);
                $ret.disactivate = runOn(this, this.ax);
                $ret.destroy = runOn(this, this.aw);
                return $ret;
            })());
            this.z = new List$1(TextBlock.$, 0);
            this.ab = new List$1(TextBlock.$, 0);
            this.ad = new List$1(TextBlock.$, 0);
            this.ac = new List$1(TextBlock.$, 0);
            this.aa = new List$1(ContentControl.$, 0);
        }
        ar() {
            this.a.fo();
        }
        bl() {
            let a = new TextBlock();
            this.ab.add(a);
            return a;
        }
        ba(a) {
            a._visibility = 0;
        }
        bc(a) {
            a._visibility = 1;
        }
        bb(a) {
            this.ab.remove(a);
        }
        bn() {
            let a = new TextBlock();
            this.ad.add(a);
            return a;
        }
        bg(a) {
            a._visibility = 0;
        }
        bi(a) {
            a._visibility = 1;
        }
        bh(a) {
            this.ad.remove(a);
        }
        bm() {
            let a = new TextBlock();
            this.ac.add(a);
            return a;
        }
        bd(a) {
            a._visibility = 0;
        }
        bf(a) {
            a._visibility = 1;
        }
        be(a) {
            this.ac.remove(a);
        }
        bk() {
            let a = new TextBlock();
            this.z.add(a);
            return a;
        }
        av(a) {
            a._visibility = 0;
        }
        ax(a) {
            a._visibility = 1;
        }
        aw(a) {
            this.z.remove(a);
        }
        bj() {
            let a = new ContentControl();
            this.aa.add(a);
            return a;
        }
        ay(a) {
            a._visibility = 0;
        }
        a0(a) {
            a._visibility = 1;
        }
        az(a) {
        }
        au() {
            let a = this.a.pixelScalingRatio;
            let b = this.a.cn;
            if (!isNaN_(a) && a != 0) {
                return;
            }
            if (window.devicePixelRatio != undefined && window.devicePixelRatio != b) {
                this.a.cn = window.devicePixelRatio;
            }
        }
        a3() {
            this.au();
            let a = Math.round(this.ah.rootWrapper.width());
            let b = Math.round(this.ah.rootWrapper.height());
            this.a.ib = new Rect(0, 0, 0, a, b);
            if (this.b != null) {
                this.b.bl = this.a.ib;
            }
            this.a.f2();
        }
        al() {
            if (this.b != null) {
                this.b.ao = null;
                this.b.av();
            }
        }
        a2(a) {
            if (a == null) {
                this.ai = null;
                this.ah = null;
                this.t = null;
                this.al();
                return;
            }
            this.ae = (isNaN_(this.a.pixelScalingRatio) ? this.a.cn : this.a.pixelScalingRatio);
            let b = a;
            this.ah = b;
            let c = this.ae;
            let d = Math.round(b.rootWrapper.width());
            let e = Math.round(b.rootWrapper.height());
            let f = d * c;
            let g = e * c;
            this.ah.rootWrapper.setStyleProperty("position", "relative");
            let h = this.ah.createElement("canvas");
            h.setStyleProperty("position", "absolute");
            this.ah.append(h);
            this.ak = truncate(Math.round(f));
            this.aj = truncate(Math.round(g));
            h.setAttribute("width", f.toString());
            h.setAttribute("height", g.toString());
            h.setStyleProperty("width", d.toString() + "px");
            h.setStyleProperty("height", e.toString() + "px");
            this.a.ib = new Rect(0, 0, 0, d, e);
            this.ai = h;
            let i = this.ah.get2DCanvasContext(this.ai);
            this.t = new RenderingContext(new CanvasViewRenderer(), i);
            this.al();
            if (TypeRegistrar.isRegistered("CanvasGestureDOMEventProxy")) {
                this.b = typeCast(EventProxy.$, TypeRegistrar.create("CanvasGestureDOMEventProxy", this.ah.rootWrapper, this.ah, false));
            }
            if (this.b != null) {
            }
        }
        at(a, b) {
            this.a3();
        }
        as(a) {
        }
        a6() {
            let a = this.a.ib.width;
            let b = this.a.ib.height;
            let c = Math.round(a * this.ae);
            let d = Math.round(b * this.ae);
            if (this.ak != c || this.aj != d) {
                this.ai.setAttribute("width", c.toString());
                this.ai.setAttribute("height", d.toString());
                this.ai.setStyleProperty("width", a.toString() + "px");
                this.ai.setStyleProperty("height", b.toString() + "px");
                this.ak = truncate(Math.round(c));
                this.aj = truncate(Math.round(d));
            }
            this.a7(this.t, this.ae);
        }
        a7(a, b) {
            if (a.d && b != 1) {
                a.z();
                a.aa(b, b);
            }
            if (a == this.t) {
                a.k(this.a.ib.left, this.a.ib.top, this.a.ib.width, this.a.ib.height);
            }
            let c = new DataTemplatePassInfo();
            c.passID = "LegendItem";
            for (let d = 0; d < this.aa.count; d++) {
                let e = this.aa._inner[d];
                if (e == null) {
                    continue;
                }
                let f = e.ah;
                if (f == null) {
                    continue;
                }
                let g = new DataTemplateMeasureInfo();
                g.passInfo = c;
                g.context = this.t.g();
                g.width = e.width;
                g.height = e.height;
                g.data = e.content;
                g.renderContext = a;
                f.measure(g);
                let h = new DataTemplateRenderInfo();
                h.availableWidth = e.width;
                h.availableHeight = e.height;
                h.passInfo = c;
                h.context = a.g();
                h.renderContext = a;
                h.data = e.content;
                h.xPosition = e.n;
                h.yPosition = e.o;
                a.z();
                a.af(e.n, e.o);
                f.render(h);
                a.y();
            }
            for (let i = 0; i < this.ab.count; i++) {
                let j = this.ab._inner[i];
                a.ac(j.dataContext);
                a.w(j);
            }
            for (let k = 0; k < this.z.count; k++) {
                let l = this.z._inner[k];
                a.ac(l.dataContext);
                a.w(l);
            }
            for (let m = 0; m < this.ad.count; m++) {
                let n = this.ad._inner[m];
                a.ac(n.dataContext);
                a.w(n);
            }
            for (let o = 0; o < this.ac.count; o++) {
                let p = this.ac._inner[o];
                a.ac(p.dataContext);
                a.w(p);
            }
            if (a.d && b != 1) {
                a.y();
            }
        }
        w() {
            if (this.ah != null) {
                this.ah.setTimeout(runOn(this.a, this.a.fo), 0);
                return true;
            }
            return false;
        }
        bu(a, b) {
            this.t.ac(b);
            let c = new TextBlock();
            c.al = a;
            let d = this.t.ag(c, this.ag(b), true);
            return new Size(1, d.c, d.b);
        }
        ag(a) {
            if (this.x.containsKey(a)) {
                let b = this.x.item(a);
                if (b.d.g == a.g) {
                    return b.c;
                }
            }
            let c = FontUtil.getCurrentFontHeight(this.ah, a);
            let d = new Tuple$2(Number_$type, FontInfo.$, c, a);
            this.x.item(a, d);
            return c;
        }
        a8(a, b, c) {
            if (this.v) {
                this.y.add(a);
            }
            a.n = b;
            a.o = c;
        }
        aq(a) {
            this.a6();
        }
        ao(a, b) {
            a.dataContext = b;
        }
        bt() {
            return FontDefaults.dataLegendFontBrush;
        }
        br() {
            return FontDefaults.dataLegendFontBrush;
        }
        bs() {
            return FontDefaults.dataLegendFontBrush;
        }
        bp() {
            return FontDefaults.dataLegendFontBrush;
        }
        bq() {
            return FontDefaults.dataLegendFontBrush;
        }
        bo() {
            return FontDefaults.dataLegendFontBrush;
        }
        l() {
            if (this.f == null) {
                this.f = ((() => {
                    let $ret = new FontInfo();
                    $ret.n = FontDefaults.dataLegendFontFamily;
                    $ret.d = FontDefaults.dataLegendFontSize;
                    $ret.q = FontDefaults.dataLegendFontStyle;
                    $ret.s = FontDefaults.dataLegendFontWeight;
                    $ret.o = FontDefaults.dataLegendFontStretch;
                    $ret.r = FontDefaults.dataLegendFontVariant;
                    return $ret;
                })());
            }
            return this.f;
        }
        n() {
            if (this.h == null) {
                this.h = ((() => {
                    let $ret = new FontInfo();
                    $ret.n = FontDefaults.dataLegendFontFamily;
                    $ret.d = FontDefaults.dataLegendFontSize;
                    $ret.q = FontDefaults.dataLegendFontStyle;
                    $ret.s = FontDefaults.dataLegendFontWeight;
                    $ret.o = FontDefaults.dataLegendFontStretch;
                    $ret.r = FontDefaults.dataLegendFontVariant;
                    return $ret;
                })());
            }
            return this.h;
        }
        m() {
            if (this.g == null) {
                this.g = ((() => {
                    let $ret = new FontInfo();
                    $ret.n = FontDefaults.dataLegendFontFamily;
                    $ret.d = FontDefaults.dataLegendFontSize;
                    $ret.q = FontDefaults.dataLegendFontStyle;
                    $ret.s = FontDefaults.dataLegendFontWeight;
                    $ret.o = FontDefaults.dataLegendFontStretch;
                    $ret.r = FontDefaults.dataLegendFontVariant;
                    return $ret;
                })());
            }
            return this.g;
        }
        j() {
            if (this.d == null) {
                this.d = ((() => {
                    let $ret = new FontInfo();
                    $ret.n = FontDefaults.dataLegendFontFamily;
                    $ret.d = FontDefaults.dataLegendFontSize;
                    $ret.q = FontDefaults.dataLegendFontStyle;
                    $ret.s = FontDefaults.dataLegendFontWeight;
                    $ret.o = FontDefaults.dataLegendFontStretch;
                    $ret.r = FontDefaults.dataLegendFontVariant;
                    return $ret;
                })());
            }
            return this.d;
        }
        k() {
            if (this.e == null) {
                this.e = ((() => {
                    let $ret = new FontInfo();
                    $ret.n = FontDefaults.dataLegendFontFamily;
                    $ret.d = FontDefaults.dataLegendFontSize;
                    $ret.q = FontDefaults.dataLegendFontStyle;
                    $ret.s = FontDefaults.dataLegendFontWeight;
                    $ret.o = FontDefaults.dataLegendFontStretch;
                    $ret.r = FontDefaults.dataLegendFontVariant;
                    return $ret;
                })());
            }
            return this.e;
        }
        i() {
            if (this.c == null) {
                this.c = ((() => {
                    let $ret = new FontInfo();
                    $ret.n = FontDefaults.dataLegendFontFamily;
                    $ret.d = FontDefaults.dataLegendFontSize;
                    $ret.q = FontDefaults.dataLegendFontStyle;
                    $ret.s = FontDefaults.dataLegendHeaderFontWeight;
                    $ret.o = FontDefaults.dataLegendFontStretch;
                    $ret.r = FontDefaults.dataLegendFontVariant;
                    return $ret;
                })());
            }
            return this.c;
        }
        am(a, b) {
            let model_ = this.a;
            let ext_ = model_.externalObject;
            if (ext_ != null) {
                let width_ = a;
                let height_ = b;
                this.ah.rootWrapper.setStyleProperty("min-height", b + "px");
                this.ah.rootWrapper.setStyleProperty("min-width", a + "px");
                this.a.notifySizeChanged();
            }
        }
        a5(a) {
            this.ae = a;
        }
        a1() {
            if (this.b != null) {
                this.b.at(this.ai, "");
            }
        }
        a4() {
            if (this.b != null) {
                this.b.bh(this.ai, "");
            }
        }
        ap(a, b) {
            a.ag = true;
            let c = this.t.ag(a, this.ag(b), true);
        }
        a9() {
            this.y.clear();
            this.v = true;
            this.af = 0;
        }
        an() {
            for (let a = 0; a < this.y.count; a++) {
                this.af = Math.max(this.af, this.y._inner[a].ah);
            }
            if (this.af > 0) {
                for (let b = 0; b < this.y.count; b++) {
                    this.y._inner[b].ah = this.af;
                }
            }
            this.v = false;
            this.af = 0;
        }
    }
    DataLegendView.$t = markType(DataLegendView, 'DataLegendView');
    return DataLegendView;
})();
