/*
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 * as tslib_1 from "tslib";
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 var ISummaryChooserView_$type = /*@__PURE__*/ new Type(null, 'ISummaryChooserView');
/**
 * @hidden
 */
var SummaryChooserView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(SummaryChooserView, _super);
    function SummaryChooserView() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.b = false;
        _this.a = null;
        _this.c = null;
        _this._model = null;
        _this.d = null;
        return _this;
    }
    Object.defineProperty(SummaryChooserView.prototype, "model", {
        get: function () {
            return this._model;
        },
        set: function (a) {
            this._model = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SummaryChooserView.prototype, "renderer", {
        get: function () {
            return this.c;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SummaryChooserView.prototype, "container", {
        get: function () {
            return this.d;
        },
        enumerable: true,
        configurable: true
    });
    SummaryChooserView.prototype.provideContainer = function (a) {
        var _this = this;
        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", function (b) { return b.stopPropagation(); });
            this.c.getPortal(this.d, "CheckboxList", function (b) {
                var comp_ = b.componentRef;
                _this.a = (comp_.i);
                _this.model.a1(_this.a);
                _this.b = false;
            }, false);
        }
    };
    SummaryChooserView.prototype.onItemInserted = function () {
        this.e();
    };
    SummaryChooserView.prototype.onItemRemoved = function () {
        this.e();
    };
    SummaryChooserView.prototype.e = function () {
        if (this.model.n.aq > -1) {
            var a = this.model.r.count * this.model.n.aq;
            a += 4;
            this.d.setStyleProperty("height", a + "px");
        }
    };
    SummaryChooserView.$t = markType(SummaryChooserView, 'SummaryChooserView', Base.$, [ISummaryChooserView_$type]);
    return SummaryChooserView;
}(Base));
export { SummaryChooserView };
/**
 * @hidden
 */
var SummaryChooser = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(SummaryChooser, _super);
    function SummaryChooser() {
        var _this = _super.call(this) || this;
        _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;
        return _this;
    }
    Object.defineProperty(SummaryChooser.prototype, "r", {
        get: function () {
            return this.q;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SummaryChooser.prototype, "n", {
        get: function () {
            return this.m;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SummaryChooser.prototype, "p", {
        get: function () {
            if (this.o == null) {
                this.o = new SRProvider(this.c.renderer);
                this.o.cb("DataGrid");
            }
            return this.o;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SummaryChooser.prototype, "aa", {
        get: function () {
            if (this.s == null) {
                var a = this.p.b1("Column_Options_Summary_Average");
                return !stringIsNullOrWhiteSpace(a) ? a : "Average";
            }
            else {
                return this.s;
            }
        },
        set: function (a) {
            var b = this.s;
            this.s = a;
            if (b != this.s) {
                this.a0("AverageCaption", b, this.s);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SummaryChooser.prototype, "ag", {
        get: function () {
            if (this.t == null) {
                var a = this.p.b1("Column_Options_Summary_Count");
                return !stringIsNullOrWhiteSpace(a) ? a : "Count";
            }
            else {
                return this.t;
            }
        },
        set: function (a) {
            var b = this.t;
            this.t = a;
            if (b != this.t) {
                this.a0("CountCaption", b, this.t);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SummaryChooser.prototype, "ap", {
        get: function () {
            if (this.v == null) {
                var a = this.p.b1("Column_Options_Summary_Minimum");
                return !stringIsNullOrWhiteSpace(a) ? a : "Minimum";
            }
            else {
                return this.v;
            }
        },
        set: function (a) {
            var b = this.v;
            this.v = a;
            if (b != this.v) {
                this.a0("MinimumCaption", b, this.v);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SummaryChooser.prototype, "al", {
        get: function () {
            if (this.u == null) {
                var a = this.p.b1("Column_Options_Summary_Maximum");
                return !stringIsNullOrWhiteSpace(a) ? a : "Maximum";
            }
            else {
                return this.u;
            }
        },
        set: function (a) {
            var b = this.u;
            this.u = a;
            if (b != this.u) {
                this.a0("MaximumCaption", b, this.u);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SummaryChooser.prototype, "at", {
        get: function () {
            if (this.w == null) {
                var a = this.p.b1("Column_Options_Summary_Sum");
                return !stringIsNullOrWhiteSpace(a) ? a : "Sum";
            }
            else {
                return this.w;
            }
        },
        set: function (a) {
            var b = this.w;
            this.w = a;
            if (b != this.w) {
                this.a0("SumCaption", b, this.w);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SummaryChooser.prototype, "l", {
        get: function () {
            return this.j;
        },
        set: function (a) {
            var b = this.j;
            this.j = a;
            if (b != this.j) {
                this.a0("Density", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, this.j));
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SummaryChooser.prototype, "k", {
        get: function () {
            return this.i;
        },
        set: function (a) {
            var b = this.i;
            this.i = a;
            if (b != this.i) {
                this.a0("ActualDensity", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, this.i));
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SummaryChooser.prototype, "ba", {
        get: function () {
            return this.a8;
        },
        set: function (a) {
            var b = this.a8;
            this.a8 = a;
            if (b != this.a8) {
                this.a0("TextColor", b, a);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SummaryChooser.prototype, "h", {
        get: function () {
            return this.f;
        },
        set: function (a) {
            var b = this.f;
            this.f = a;
            if (b != this.f) {
                this.a0("BaseTheme", enumGetBox(BaseControlTheme_$type, b), enumGetBox(BaseControlTheme_$type, a));
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SummaryChooser.prototype, "g", {
        get: function () {
            return this.e;
        },
        set: function (a) {
            var b = this.e;
            this.e = a;
            if (b != this.e) {
                this.a0("ActualBaseTheme", enumGetBox(BaseControlTheme_$type, b), enumGetBox(BaseControlTheme_$type, a));
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(SummaryChooser.prototype, "a9", {
        get: function () {
            return this.a7;
        },
        set: function (a) {
            var b = this.a7;
            this.a7 = a;
            if (b != this.a7) {
                this.a0("Background", b, a);
            }
        },
        enumerable: true,
        configurable: true
    });
    SummaryChooser.prototype.a1 = function (a) {
        var _this = this;
        if (this.m != null) {
            var b = this.m;
            b.checkedChanged = delegateRemove(b.checkedChanged, runOn(this, this.az));
        }
        this.m = a;
        if (this.m != null) {
            var c = this.m;
            c.checkedChanged = delegateCombine(c.checkedChanged, runOn(this, this.az));
        }
        this.q = new List$1(SummaryChooserItem.$, 0);
        this.q.add(((function () {
            var $ret = new SummaryChooserItem();
            $ret.label = _this.aa;
            $ret.iD = "avg";
            return $ret;
        })()));
        this.q.add(((function () {
            var $ret = new SummaryChooserItem();
            $ret.label = _this.ag;
            $ret.iD = "count";
            return $ret;
        })()));
        this.q.add(((function () {
            var $ret = new SummaryChooserItem();
            $ret.label = _this.al;
            $ret.iD = "max";
            return $ret;
        })()));
        this.q.add(((function () {
            var $ret = new SummaryChooserItem();
            $ret.label = _this.ap;
            $ret.iD = "min";
            return $ret;
        })()));
        this.q.add(((function () {
            var $ret = new SummaryChooserItem();
            $ret.label = _this.at;
            $ret.iD = "sum";
            return $ret;
        })()));
        this.a6();
    };
    SummaryChooser.prototype.az = function (a, b) {
        var c = this.q._inner[b.b];
        c.isSelected = b.a;
        if (this.summaryChanged != null) {
            this.summaryChanged(this, ((function () {
                var $ret = new SummaryChangedEventArgs();
                $ret.b = c.iD;
                $ret.a = b.a;
                return $ret;
            })()));
        }
    };
    SummaryChooser.prototype.a6 = function () {
        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"];
        }
    };
    SummaryChooser.prototype.a0 = function (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;
        }
    };
    SummaryChooser.prototype.a2 = function (a) {
        this.c.provideContainer(a);
    };
    SummaryChooser.prototype.ay = function () {
        if (this.m != null) {
            this.m.destroy();
        }
        this.c.provideContainer(null);
    };
    SummaryChooser.prototype.a4 = function (a, b) {
        for (var c = 0; c < this.q.count; c++) {
            var d = this.q._inner[c];
            if (d.iD == a) {
                d.isSelected = b;
                if (this.m != null) {
                    this.m.bz(c, d, d);
                }
                break;
            }
        }
    };
    SummaryChooser.prototype.ax = function (a, b) {
        var 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();
    };
    SummaryChooser.prototype.a3 = function (a) {
        for (var b = 0; b < this.q.count; b++) {
            var 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();
    };
    SummaryChooser.prototype.a5 = function (a, b) {
        for (var c = 0; c < this.q.count; c++) {
            var d = this.q._inner[c];
            if (d.iD == a) {
                d.label = b;
                if (this.m != null) {
                    this.m.bz(c, d, d);
                }
                break;
            }
        }
    };
    SummaryChooser.prototype.b = function () {
        var a = new List$1(String_$type, 0);
        for (var b = 0; b < this.q.count; b++) {
            var c = this.q._inner[b];
            if (c.isSelected) {
                a.add(c.iD);
            }
        }
        return a.toArray();
    };
    SummaryChooser.prototype.a = function () {
        var a = new List$1(String_$type, 0);
        for (var b = 0; b < this.q.count; b++) {
            var c = this.q._inner[b];
            if (!c.isSelected) {
                a.add(c.iD);
            }
        }
        return a.toArray();
    };
    SummaryChooser.$t = markType(SummaryChooser, 'SummaryChooser');
    return SummaryChooser;
}(Base));
export { SummaryChooser };
//# sourceMappingURL=ISummaryChooserView_combined.js.map
