/*
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, Type, markType, enumGetBox, runOn, delegateRemove, delegateCombine, String_$type } from "igniteui-webcomponents-core";
import { List$1 } from "igniteui-webcomponents-core";
import { SummaryChooserItem } from "./SummaryChooserItem";
import { SRProvider } from "igniteui-webcomponents-core";
import { ControlDisplayDensity_$type } from "igniteui-webcomponents-core";
import { BaseControlTheme_$type } from "igniteui-webcomponents-core";
import { BrushUtil } from "igniteui-webcomponents-core";
import { SummaryChangedEventArgs } from "./SummaryChangedEventArgs";
import { Thickness } from "igniteui-webcomponents-core";
import { stringIsNullOrWhiteSpace } from "igniteui-webcomponents-core";
/**
 * @hidden
 */
export let ISummaryChooserView_$type = /*@__PURE__*/ new Type(null, 'ISummaryChooserView');
/**
 * @hidden
 */
export let SummaryChooserView = /*@__PURE__*/ (() => {
    class SummaryChooserView extends Base {
        constructor() {
            super(...arguments);
            this.b = false;
            this.a = null;
            this.c = null;
            this._model = null;
            this.d = null;
        }
        get model() {
            return this._model;
        }
        set model(a) {
            this._model = a;
        }
        get renderer() {
            return this.c;
        }
        get container() {
            return this.d;
        }
        provideContainer(a) {
            if (a == null) {
                this.c = null;
                this.a = null;
                return;
            }
            this.c = a;
            if (this.a == null && !this.b) {
                this.b = true;
                this.d = this.c.createElement("div");
                this.d.addClass("ig-summary-chooser");
                this.d.setStyleProperty("padding", "0px 8px 4px");
                this.d.setStyleProperty("margin-top", "-3px");
                this.d.setStyleProperty("width", "150px");
                this.d.setStyleProperty("height", "154px");
                this.d.setStyleProperty("box-sizing", "border-box");
                this.d.listen("mousedown", (b) => b.stopPropagation());
                this.c.getPortal(this.d, "CheckboxList", (b) => {
                    let comp_ = b.componentRef;
                    this.a = (comp_.i);
                    this.model.a1(this.a);
                    this.b = false;
                }, false);
            }
        }
        onItemInserted() {
            this.e();
        }
        onItemRemoved() {
            this.e();
        }
        e() {
            if (this.model.n.aq > -1) {
                let a = this.model.r.count * this.model.n.aq;
                a += 4;
                this.d.setStyleProperty("height", a + "px");
            }
        }
    }
    SummaryChooserView.$t = /*@__PURE__*/ markType(SummaryChooserView, 'SummaryChooserView', Base.$, [ISummaryChooserView_$type]);
    return SummaryChooserView;
})();
/**
 * @hidden
 */
export let SummaryChooser = /*@__PURE__*/ (() => {
    class SummaryChooser extends Base {
        constructor() {
            super();
            this.c = null;
            this.m = null;
            this.q = null;
            this.o = null;
            this.s = null;
            this.t = null;
            this.v = null;
            this.u = null;
            this.w = null;
            this.j = 0;
            this.i = 0;
            this.a8 = BrushUtil.g(255, 24, 29, 31);
            this.f = 0;
            this.e = 1;
            this.a7 = BrushUtil.g(255, 248, 248, 248);
            this.summaryChanged = null;
            this.c = new SummaryChooserView();
            this.c.model = this;
        }
        get r() {
            return this.q;
        }
        get n() {
            return this.m;
        }
        get p() {
            if (this.o == null) {
                this.o = new SRProvider(this.c.renderer);
                this.o.cb("DataGrid");
            }
            return this.o;
        }
        get aa() {
            if (this.s == null) {
                let a = this.p.b1("Column_Options_Summary_Average");
                return !stringIsNullOrWhiteSpace(a) ? a : "Average";
            }
            else {
                return this.s;
            }
        }
        set aa(a) {
            let b = this.s;
            this.s = a;
            if (b != this.s) {
                this.a0("AverageCaption", b, this.s);
            }
        }
        get ag() {
            if (this.t == null) {
                let a = this.p.b1("Column_Options_Summary_Count");
                return !stringIsNullOrWhiteSpace(a) ? a : "Count";
            }
            else {
                return this.t;
            }
        }
        set ag(a) {
            let b = this.t;
            this.t = a;
            if (b != this.t) {
                this.a0("CountCaption", b, this.t);
            }
        }
        get ap() {
            if (this.v == null) {
                let a = this.p.b1("Column_Options_Summary_Minimum");
                return !stringIsNullOrWhiteSpace(a) ? a : "Minimum";
            }
            else {
                return this.v;
            }
        }
        set ap(a) {
            let b = this.v;
            this.v = a;
            if (b != this.v) {
                this.a0("MinimumCaption", b, this.v);
            }
        }
        get al() {
            if (this.u == null) {
                let a = this.p.b1("Column_Options_Summary_Maximum");
                return !stringIsNullOrWhiteSpace(a) ? a : "Maximum";
            }
            else {
                return this.u;
            }
        }
        set al(a) {
            let b = this.u;
            this.u = a;
            if (b != this.u) {
                this.a0("MaximumCaption", b, this.u);
            }
        }
        get at() {
            if (this.w == null) {
                let a = this.p.b1("Column_Options_Summary_Sum");
                return !stringIsNullOrWhiteSpace(a) ? a : "Sum";
            }
            else {
                return this.w;
            }
        }
        set at(a) {
            let b = this.w;
            this.w = a;
            if (b != this.w) {
                this.a0("SumCaption", b, this.w);
            }
        }
        get l() {
            return this.j;
        }
        set l(a) {
            let b = this.j;
            this.j = a;
            if (b != this.j) {
                this.a0("Density", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, this.j));
            }
        }
        get k() {
            return this.i;
        }
        set k(a) {
            let b = this.i;
            this.i = a;
            if (b != this.i) {
                this.a0("ActualDensity", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, this.i));
            }
        }
        get ba() {
            return this.a8;
        }
        set ba(a) {
            let b = this.a8;
            this.a8 = a;
            if (b != this.a8) {
                this.a0("TextColor", b, a);
            }
        }
        get h() {
            return this.f;
        }
        set h(a) {
            let b = this.f;
            this.f = a;
            if (b != this.f) {
                this.a0("BaseTheme", enumGetBox(BaseControlTheme_$type, b), enumGetBox(BaseControlTheme_$type, a));
            }
        }
        get g() {
            return this.e;
        }
        set g(a) {
            let b = this.e;
            this.e = a;
            if (b != this.e) {
                this.a0("ActualBaseTheme", enumGetBox(BaseControlTheme_$type, b), enumGetBox(BaseControlTheme_$type, a));
            }
        }
        get a9() {
            return this.a7;
        }
        set a9(a) {
            let b = this.a7;
            this.a7 = a;
            if (b != this.a7) {
                this.a0("Background", b, a);
            }
        }
        a1(a) {
            if (this.m != null) {
                let b = this.m;
                b.checkedChanged = delegateRemove(b.checkedChanged, runOn(this, this.az));
            }
            this.m = a;
            if (this.m != null) {
                let c = this.m;
                c.checkedChanged = delegateCombine(c.checkedChanged, runOn(this, this.az));
            }
            this.q = new List$1(SummaryChooserItem.$, 0);
            this.q.add(((() => {
                let $ret = new SummaryChooserItem();
                $ret.label = this.aa;
                $ret.iD = "avg";
                return $ret;
            })()));
            this.q.add(((() => {
                let $ret = new SummaryChooserItem();
                $ret.label = this.ag;
                $ret.iD = "count";
                return $ret;
            })()));
            this.q.add(((() => {
                let $ret = new SummaryChooserItem();
                $ret.label = this.al;
                $ret.iD = "max";
                return $ret;
            })()));
            this.q.add(((() => {
                let $ret = new SummaryChooserItem();
                $ret.label = this.ap;
                $ret.iD = "min";
                return $ret;
            })()));
            this.q.add(((() => {
                let $ret = new SummaryChooserItem();
                $ret.label = this.at;
                $ret.iD = "sum";
                return $ret;
            })()));
            this.a6();
        }
        az(a, b) {
            let c = this.q._inner[b.b];
            c.isSelected = b.a;
            if (this.summaryChanged != null) {
                this.summaryChanged(this, ((() => {
                    let $ret = new SummaryChangedEventArgs();
                    $ret.b = c.iD;
                    $ret.a = b.a;
                    return $ret;
                })()));
            }
        }
        a6() {
            if (this.m != null) {
                this.m.n = this.k;
                this.m.cw = this.ba;
                this.m.l = this.g;
                this.m.ao = false;
                this.m.am = false;
                this.m.aj = false;
                this.m.updateHrMargin(new Thickness(1, -7, 3, -7, 3));
                this.m.itemsSource = this.q;
                this.m.a2 = "label";
                this.m.bj = "isSelected";
                this.m.b = ["label"];
            }
        }
        a0(a, b, c) {
            switch (a) {
                case "AverageCaption":
                    this.a5("sum", this.aa);
                    break;
                case "CountCaption":
                    this.a5("count", this.aa);
                    break;
                case "MinimumCaption":
                    this.a5("min", this.aa);
                    break;
                case "MaximumCaption":
                    this.a5("max", this.aa);
                    break;
                case "SumCaption":
                    this.a5("sum", this.aa);
                    break;
                case "ActualDensity":
                case "ActualBaseTheme":
                case "Background":
                case "TextColor":
                    this.a6();
                    break;
                case "Density":
                    this.k = this.l == 0 ? this.k : this.l;
                    break;
                case "BaseTheme":
                    this.g = this.h == 0 ? this.g : this.h;
                    break;
            }
        }
        a2(a) {
            this.c.provideContainer(a);
        }
        ay() {
            if (this.m != null) {
                this.m.destroy();
            }
            this.c.provideContainer(null);
        }
        a4(a, b) {
            for (let c = 0; c < this.q.count; c++) {
                let d = this.q._inner[c];
                if (d.iD == a) {
                    d.isSelected = b;
                    if (this.m != null) {
                        this.m.bz(c, d, d);
                    }
                    break;
                }
            }
        }
        ax(a, b) {
            let c = new SummaryChooserItem();
            c.iD = a;
            c.label = b;
            this.q.add(c);
            if (this.m != null) {
                this.m.bx(this.q.count - 1, c);
            }
            this.c.onItemInserted();
        }
        a3(a) {
            for (let b = 0; b < this.q.count; b++) {
                let c = this.q._inner[b];
                if (c.iD == a) {
                    this.q.removeAt(b);
                    if (this.m != null) {
                        this.m.by(b, c);
                    }
                    break;
                }
            }
            this.c.onItemRemoved();
        }
        a5(a, b) {
            for (let c = 0; c < this.q.count; c++) {
                let d = this.q._inner[c];
                if (d.iD == a) {
                    d.label = b;
                    if (this.m != null) {
                        this.m.bz(c, d, d);
                    }
                    break;
                }
            }
        }
        b() {
            let a = new List$1(String_$type, 0);
            for (let b = 0; b < this.q.count; b++) {
                let c = this.q._inner[b];
                if (c.isSelected) {
                    a.add(c.iD);
                }
            }
            return a.toArray();
        }
        a() {
            let a = new List$1(String_$type, 0);
            for (let b = 0; b < this.q.count; b++) {
                let c = this.q._inner[b];
                if (!c.isSelected) {
                    a.add(c.iD);
                }
            }
            return a.toArray();
        }
    }
    SummaryChooser.$t = /*@__PURE__*/ markType(SummaryChooser, 'SummaryChooser');
    return SummaryChooser;
})();
//# sourceMappingURL=ISummaryChooserView_combined.js.map
