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