/*
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, markType, INotifyPropertyChanged_$type, PropertyChangedEventArgs, runOn, delegateRemove, delegateCombine, enumGetBox, fromEnum } from "igniteui-webcomponents-core";
import { SRProvider } from "igniteui-webcomponents-core";
import { BaseControlTheme_$type } from "igniteui-webcomponents-core";
import { ControlDisplayDensity_$type } from "igniteui-webcomponents-core";
import { BrushUtil } from "igniteui-webcomponents-core";
import { ObservableCollection$1 } from "igniteui-webcomponents-core";
import { ColumnChooserInfo } from "./ColumnChooserInfo";
import { stringIsNullOrWhiteSpace } from "igniteui-webcomponents-core";
/**
 * @hidden
 */
var ColumnChooserView = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(ColumnChooserView, _super);
    function ColumnChooserView() {
        var _this = _super.call(this) || this;
        _this.d = null;
        _this.c = null;
        _this.e = null;
        _this.a = null;
        _this.b = null;
        return _this;
    }
    ColumnChooserView.prototype.h = function () {
    };
    ColumnChooserView.prototype.g = function (a) {
        if (a == null) {
            this.b = null;
            return;
        }
        this.b = a;
        this.e = this.b.rootWrapper.getChildAt(0);
        this.e.setStyleProperty("margin", "4px 0px 4px 0px");
        this.k();
        this.j();
        var b = Math.round(a.rootWrapper.width());
        var c = Math.round(a.rootWrapper.height());
        this.b.rootWrapper.setStyleProperty("position", "relative");
        this.i();
    };
    ColumnChooserView.prototype.i = function () {
        if (this.b != null) {
            this.b.rootWrapper.setStyleProperty("background-color", this.a.aq._fill);
        }
    };
    ColumnChooserView.prototype.j = function () {
        if (this.b != null) {
            var a = this.b.rootWrapper.getChildAt(1);
            a.setStyleProperty("width", "100%");
            if (this.a.v != null) {
                a.setStyleProperty("height", "calc(100% - 25px");
            }
            else {
                a.setStyleProperty("height", "calc(100% - 5px");
            }
        }
    };
    ColumnChooserView.prototype.k = function () {
        if (this.e != null && this.a.v != null) {
            this.e.setText(this.a.v);
            this.e.setStyleProperty("font", "16px \"Segoe UI\", Verdana");
        }
        this.l();
        this.m();
        this.j();
    };
    ColumnChooserView.prototype.l = function () {
        if (this.e != null && this.a.ar != null) {
            this.e.setStyleProperty("color", this.a.ar._fill);
        }
    };
    ColumnChooserView.prototype.m = function () {
        if (this.e != null && this.a.j != null) {
            this.e.setStyleProperty("font", this.a.j.fontString);
        }
    };
    ColumnChooserView.prototype.f = function () {
    };
    ColumnChooserView.$t = markType(ColumnChooserView, 'ColumnChooserView');
    return ColumnChooserView;
}(Base));
export { ColumnChooserView };
/**
 * @hidden
 */
var ColumnChooser = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(ColumnChooser, _super);
    function ColumnChooser() {
        var _this = _super.call(this) || this;
        _this.c = null;
        _this.h = null;
        _this.propertyChanged = null;
        _this.m = false;
        _this.k = null;
        _this.a = null;
        _this.o = null;
        _this.i = null;
        _this.ap = BrushUtil.g(255, 0, 153, 255);
        _this.n = null;
        _this.d = 1;
        _this.f = 2;
        _this.ao = BrushUtil.g(255, 248, 248, 248);
        _this.m = false;
        var a = new ColumnChooserView();
        a.a = _this;
        _this.c = a;
        _this.c.h();
        return _this;
    }
    ColumnChooser.prototype.notifySizeChanged = function () {
        this.c.f();
    };
    ColumnChooser.prototype.destroy = function () {
        if (this.h != null) {
            var a = this.h;
            a.checkedChanged = delegateRemove(a.checkedChanged, runOn(this, this.ac));
            var b = this.h;
            b.selectAllCheckboxChanged = delegateRemove(b.selectAllCheckboxChanged, runOn(this, this.ad));
        }
        this.provideContainer(null, null);
        if (this.a != null) {
            var c = this.a.actualColumns;
            c.collectionChanged = delegateRemove(c.collectionChanged, runOn(this, this.z));
            var d = this.a;
            d.columnHiddenChanged = delegateRemove(d.columnHiddenChanged, runOn(this, this.am));
        }
    };
    ColumnChooser.prototype.provideContainer = function (a, b) {
        this.h = b;
        if (this.h != null) {
            var c = this.h;
            c.checkedChanged = delegateCombine(c.checkedChanged, runOn(this, this.ac));
            var d = this.h;
            d.selectAllCheckboxChanged = delegateCombine(d.selectAllCheckboxChanged, runOn(this, this.ad));
        }
        this.aa();
        this.c.g(a);
    };
    Object.defineProperty(ColumnChooser.prototype, "l", {
        get: function () {
            if (this.k == null) {
                this.k = new SRProvider(this.c.b);
                this.k.cb("DataGrid");
            }
            return this.k;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnChooser.prototype, "b", {
        get: function () {
            return this.a;
        },
        set: function (a) {
            var b = this.a;
            this.a = a;
            if (b != this.a) {
                this.ag("TargetGrid", b, this.a);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnChooser.prototype, "v", {
        get: function () {
            return this.o;
        },
        set: function (a) {
            var b = this.o;
            this.o = a;
            if (b != this.o) {
                this.ag("Title", b, this.o);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnChooser.prototype, "j", {
        get: function () {
            return this.i;
        },
        set: function (a) {
            var b = this.i;
            this.i = a;
            if (b != this.i) {
                this.ag("TitleStyle", b, this.i);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnChooser.prototype, "ar", {
        get: function () {
            return this.ap;
        },
        set: function (a) {
            var b = this.ap;
            this.ap = a;
            if (b != this.ap) {
                this.ag("TitleColor", b, this.ap);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnChooser.prototype, "s", {
        get: function () {
            return this.n != null ? this.n : !stringIsNullOrWhiteSpace(this.l.b1("Filter_Columns_List")) ? this.l.b1("Filter_Columns_List") : "Filter columns list ...";
        },
        set: function (a) {
            var b = this.n;
            this.n = a;
            if (b != this.n) {
                this.ag("FilterPlaceholderText", b, this.n);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnChooser.prototype, "e", {
        get: function () {
            return this.d;
        },
        set: function (a) {
            var b = this.d;
            this.d = a;
            if (b != this.d) {
                this.ag("BaseTheme", enumGetBox(BaseControlTheme_$type, b), enumGetBox(BaseControlTheme_$type, this.d));
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnChooser.prototype, "g", {
        get: function () {
            return this.f;
        },
        set: function (a) {
            var b = this.f;
            this.f = a;
            if (b != this.f) {
                this.ag("Density", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, this.f));
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(ColumnChooser.prototype, "aq", {
        get: function () {
            return this.ao;
        },
        set: function (a) {
            var b = this.ao;
            this.ao = a;
            if (b != this.ao) {
                this.ag("BackgroundColor", b, this.ao);
            }
        },
        enumerable: true,
        configurable: true
    });
    ColumnChooser.prototype.ag = function (a, b, c) {
        if (this.propertyChanged != null) {
            this.propertyChanged(this, new PropertyChangedEventArgs(a));
        }
        this.ah(a, b, c);
    };
    ColumnChooser.prototype.ah = function (a, b, c) {
        switch (a) {
            case "TargetGrid":
                if (b != null) {
                    var d = b.actualColumns;
                    d.collectionChanged = delegateRemove(d.collectionChanged, runOn(this, this.z));
                    var e = b;
                    e.columnHiddenChanged = delegateRemove(e.columnHiddenChanged, runOn(this, this.am));
                }
                if (this.a != null) {
                    var f = this.a.actualColumns;
                    f.collectionChanged = delegateCombine(f.collectionChanged, runOn(this, this.z));
                    var g = this.a;
                    g.columnHiddenChanged = delegateCombine(g.columnHiddenChanged, runOn(this, this.am));
                }
                this.aa();
                break;
            case "Title":
                this.c.k();
                break;
            case "TitleStyle":
                this.c.m();
                break;
            case "TitleColor":
                this.c.l();
                break;
            case "FilterPlaceholderText":
                if (this.h != null) {
                    this.h.a6 = this.s;
                }
                break;
            case "BaseTheme":
                this.ak();
                break;
            case "Density":
                this.aj();
                break;
            case "BackgroundColor":
                if (this.h != null) {
                    this.h.cr = this.aq;
                }
                this.c.i();
                break;
        }
    };
    ColumnChooser.prototype.ak = function () {
        if (this.h != null) {
            this.h.l = this.e;
        }
    };
    ColumnChooser.prototype.aj = function () {
        if (this.h != null) {
            this.h.n = this.g;
        }
    };
    ColumnChooser.prototype.am = function (a, b) {
        if (this.m == false) {
            this.aa();
        }
        this.m = false;
    };
    ColumnChooser.prototype.z = function (a, b) {
        this.aa();
    };
    ColumnChooser.prototype.aa = function () {
        var e_1, _a;
        if (this.a != null && this.h != null) {
            this.h.l = this.e;
            this.h.n = this.g;
            this.h.cr = this.aq;
            var a = void 0;
            var b = new ObservableCollection$1(ColumnChooserInfo.$, 0);
            try {
                for (var _b = tslib_1.__values(fromEnum(this.a.actualColumns)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var c = _c.value;
                    a = new ColumnChooserInfo();
                    var d = c.h4;
                    if (c.h8 != null) {
                        d = c.h8;
                    }
                    a.columnName = d;
                    a.isNotHidden = !c.gh;
                    b.add(a);
                }
            }
            catch (e_1_1) {
                e_1 = { error: e_1_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_1)
                        throw e_1.error;
                }
            }
            if (this.s != null) {
                this.h.a6 = this.s;
            }
            this.h.itemsSource = b;
            var e = "";
            var f = "";
            e = "columnName";
            f = "isNotHidden";
            this.h.bj = f;
            this.h.a2 = e;
            this.h.ao = true;
        }
    };
    ColumnChooser.prototype.an = function (a) {
        if (this.h != null) {
            this.h.updateHrMargin(a);
        }
    };
    ColumnChooser.prototype.al = function () {
        var e_2, _a;
        this.h.ch();
        if (this.a != null) {
            try {
                for (var _b = tslib_1.__values(fromEnum(this.a.actualColumns)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var a = _c.value;
                    this.m = true;
                    a.gh = false;
                }
            }
            catch (e_2_1) {
                e_2 = { error: e_2_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_2)
                        throw e_2.error;
                }
            }
        }
    };
    ColumnChooser.prototype.ae = function () {
        var e_3, _a;
        this.h.bs();
        if (this.a != null) {
            try {
                for (var _b = tslib_1.__values(fromEnum(this.a.actualColumns)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var a = _c.value;
                    this.m = true;
                    a.gh = true;
                }
            }
            catch (e_3_1) {
                e_3 = { error: e_3_1 };
            }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return))
                        _a.call(_b);
                }
                finally {
                    if (e_3)
                        throw e_3.error;
                }
            }
        }
    };
    ColumnChooser.prototype.ad = function (a, b) {
        this.m = true;
        if (b.a) {
            this.al();
        }
        else {
            this.ae();
        }
    };
    ColumnChooser.prototype.ac = function (a, b) {
        this.m = true;
        var c = this.h.h.actualDataSource.getItemAtIndex(b.b);
        var d = this.a.actualColumns.count;
        for (var e = 0; e < d; e++) {
            if (this.a.actualColumns._inner[e].h4 == c.columnName || this.a.actualColumns._inner[e].il == c.columnName || this.a.actualColumns._inner[e].h8 == c.columnName) {
                this.a.actualColumns._inner[e].gh = !b.a;
            }
        }
    };
    ColumnChooser.$t = markType(ColumnChooser, 'ColumnChooser', Base.$, [INotifyPropertyChanged_$type]);
    return ColumnChooser;
}(Base));
export { ColumnChooser };
//# sourceMappingURL=ColumnChooserView_combined.js.map
