/*
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 { GridColumnOptionsViewBase } from "./GridColumnOptionsViewBase";
import { ControlDisplayDensity_$type } from "igniteui-webcomponents-core";
import { GridColumnOptionsUtilities } from "./GridColumnOptionsUtilities";
import { EventArgs, runOn, delegateCombine, markType, enumGetBox, fromEnum, toNullable, typeCast } from "igniteui-webcomponents-core";
import { Size } from "igniteui-webcomponents-core";
import { GridColumnOptionsSectionBase } from "./GridColumnOptionsSectionBase";
import { StringComparer } from "igniteui-webcomponents-core";
import { ColumnComparisonConditionOperatorType_$type } from "./ColumnComparisonConditionOperatorType";
import { List$1 } from "igniteui-webcomponents-core";
import { ColumnComparisonFilterCondition } from "./ColumnComparisonFilterCondition";
import { ColumnFilterConditionGroup } from "./ColumnFilterConditionGroup";
import { PrimaryKeyValue } from "./PrimaryKeyValue";
import { SortDescription } from "igniteui-webcomponents-core";
import { Thickness } from "igniteui-webcomponents-core";
import { FilterApplyButtonClickEventArgs } from "./FilterApplyButtonClickEventArgs";
import { FilterCancelButtonClickEventArgs } from "./FilterCancelButtonClickEventArgs";
import { nullableEquals } from "igniteui-webcomponents-core";
/**
 * @hidden
 */
export let GridColumnFilterOptionsView = /*@__PURE__*/ (() => {
    class GridColumnFilterOptionsView extends GridColumnOptionsViewBase {
        constructor() {
            super(...arguments);
            this.y = null;
            this.z = null;
            this.u = null;
            this.x = null;
            this.aa = null;
            this.t = null;
            this.v = null;
            this.w = null;
            this.q = null;
            this.o = null;
            this.p = null;
            this.applyButtonClick = null;
            this.cancelButtonClick = null;
        }
        m() {
            super.m();
            let a = this.n;
            a.bf(this.q);
            a.bf(this.o);
            a.bf(this.p);
            if (null != this.w && null != this.x) {
                this.w.setStyleProperty("padding-bottom", "5px");
                this.w.setStyleProperty("margin", "0 -8px");
                switch (this.q.g) {
                    case 2:
                        this.x.setStyleProperty("margin", "0 -.25rem");
                        break;
                    case 1:
                    case 3:
                        this.x.setStyleProperty("margin", "0 -.5rem");
                        break;
                }
                this.x.setRawText(a.cf);
                this.x.setStyleProperty("font", a.aa.fontString);
            }
            if (null != this.aa) {
                this.aa.setRawText(a.co);
                this.aa.setStyleProperty("font", a.aa.fontString);
                GridColumnOptionsUtilities.j(this.aa, false);
            }
            if (null != this.t) {
                this.t.setRawText(a.b7);
            }
            if (null != this.v) {
                this.v.setRawText(a.cb);
            }
        }
        get n() {
            return this.b;
        }
        al(a) {
            this.o.disabled = !a;
        }
        am(a) {
            if (null != this.q) {
                this.q.disabled = !a;
            }
        }
        ah(a) {
            let b = this.e;
            let c = this.n;
            this.y = a;
            let d;
            let e;
            this.w = ((() => { let f = GridColumnOptionsUtilities.g(b, GridColumnFilterOptionsView.ab, 1, c.p, c.j, new Size(1, 24, 24), this.q, d, this.x, e, false, true); this.q = f.p6; d = f.p7; this.x = f.p8; e = f.p9; return f.ret; })());
            let f = this.q;
            f.clicked = delegateCombine(f.clicked, runOn(this, this.ae));
            this.y.append(this.w);
        }
        aj(a) {
            let b = this.e;
            this.z = a;
            this.aa = b.createElement("span");
            this.aa.setRawText(this.n.co);
            this.z.append(this.aa);
        }
        ai(a) {
            let b = this.e;
            let c = this.n;
            this.u = a;
            let d = b.createElement("hr");
            d.setStyleProperty("margin", "3px -7px");
            d.setStyleProperty("border-top", "1px solid #dde2eb");
            d.setStyleProperty("border-left", "0px");
            d.setStyleProperty("border-right", "0px");
            d.setStyleProperty("border-bottom", "0px");
            this.u.append(d);
            let e;
            let f = ((() => { let g = GridColumnOptionsUtilities.f(b, null, c.p, c.j, Size.empty, this.o, e, this.t); this.o = g.p5; e = g.p6; this.t = g.p7; return g.ret; })());
            f.setStyleProperty("margin-left", "1rem");
            let g = this.o;
            g.clicked = delegateCombine(g.clicked, runOn(this, this.ac));
            this.o.hg = "1";
            let h;
            let i = ((() => { let j = GridColumnOptionsUtilities.f(b, null, c.p, c.j, Size.empty, this.p, h, this.v); this.p = j.p5; h = j.p6; this.v = j.p7; return j.ret; })());
            let j = this.p;
            j.clicked = delegateCombine(j.clicked, runOn(this, this.ad));
            this.p.hg = "1";
            this.p.s = 2;
            let k = b.createElement("div");
            k.setStyleProperty("display", "flex");
            k.setStyleProperty("justify-content", "space-between");
            k.append(i);
            k.append(f);
            this.u.append(k);
        }
        ak(a) {
            this.h(a);
        }
        af() {
            if (null != this.applyButtonClick) {
                this.applyButtonClick(this, EventArgs.empty);
            }
        }
        ag() {
            if (null != this.cancelButtonClick) {
                this.cancelButtonClick(this, EventArgs.empty);
            }
        }
        ac(a, b) {
            this.af();
        }
        ad(a, b) {
            this.ag();
        }
        ae(a, b) {
            this.n.ct();
        }
    }
    GridColumnFilterOptionsView.$t = /*@__PURE__*/ markType(GridColumnFilterOptionsView, 'GridColumnFilterOptionsView', GridColumnOptionsViewBase.$);
    GridColumnFilterOptionsView.ab = "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z";
    return GridColumnFilterOptionsView;
})();
/**
 * @hidden
 */
export let GridColumnFilterOptions = /*@__PURE__*/ (() => {
    class GridColumnFilterOptions extends GridColumnOptionsSectionBase {
        constructor() {
            super();
            this.b2 = null;
            this.b6 = "Apply";
            this.ca = "Cancel";
            this.ce = "Clear column filters";
            this.cj = "Search";
            this.by = 0;
            this.bx = 0;
            this.cn = "Text filter";
            this.applyButtonClick = null;
            this.cancelButtonClick = null;
        }
        f() {
            return new GridColumnFilterOptionsView();
        }
        bq() {
            if (null == this.column) {
                return false;
            }
            if (!this.column.gf) {
                return false;
            }
            if (this.c == null || this.c.actualDataSource == null || !this.c.actualDataSource.isGroupingSupported) {
                return false;
            }
            return true;
        }
        a5() {
            super.a5();
            this.cy();
            this.c4();
        }
        a6(a, b) {
            super.a6(a, b);
            switch (b.propertyName) {
                case "Filter":
                    this.c4();
                    break;
            }
        }
        onViewInitialized() {
            super.onViewInitialized();
            let a = this.bw;
            a.applyButtonClick = delegateCombine(a.applyButtonClick, runOn(this, this.c8));
            let b = this.bw;
            b.cancelButtonClick = delegateCombine(b.cancelButtonClick, runOn(this, this.c9));
        }
        bc(a, b, c) {
            super.bc(a, b, c);
            switch (a) {
                case "ApplyButtonCaption":
                case "CancelButtonCaption":
                case "ClearColumnFiltersCaption":
                case "TextFilterCaption":
                    this.bw.m();
                    break;
                case "ActualBaseTheme":
                case "ActualDensity":
                case "ActualFilterListDensity":
                case "FilterListPlaceholderText":
                case "BackgroundColor":
                case "TextColor":
                    this.c6();
                    break;
                case "FilterListDensity":
                    this.bz = this.b1 == 0 ? this.q : this.b1;
                    break;
            }
        }
        get bw() {
            return this.e;
        }
        get b7() {
            return this.b6;
        }
        set b7(a) {
            if (0 == StringComparer.b.compare(a, this.b6)) {
                return;
            }
            let b = this.b6;
            this.b6 = a;
            this.ba("ApplyButtonCaption", b, this.b6);
        }
        get cb() {
            return this.ca;
        }
        set cb(a) {
            if (0 == StringComparer.b.compare(a, this.ca)) {
                return;
            }
            let b = this.ca;
            this.ca = a;
            this.ba("CancelButtonCaption", b, this.ca);
        }
        get cf() {
            return this.ce;
        }
        set cf(a) {
            if (0 == StringComparer.b.compare(a, this.ce)) {
                return;
            }
            let b = this.ce;
            this.ce = a;
            this.ba("ClearColumnFiltersCaption", b, this.ce);
        }
        get ck() {
            return this.cj;
        }
        set ck(a) {
            if (0 == StringComparer.b.compare(a, this.cj)) {
                return;
            }
            let b = this.cj;
            this.cj = a;
            this.ba("FilterListPlaceholderText", b, this.cj);
        }
        get b1() {
            return this.by;
        }
        set b1(a) {
            let b = this.by;
            this.by = a;
            if (b != this.by) {
                this.ba("FilterListDensity", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, a));
            }
        }
        get bz() {
            return this.bx;
        }
        set bz(a) {
            let b = this.bx;
            this.bx = a;
            if (b != this.bx) {
                this.ba("ActualFilterListDensity", enumGetBox(ControlDisplayDensity_$type, b), enumGetBox(ControlDisplayDensity_$type, a));
            }
        }
        get co() {
            return this.cn;
        }
        set co(a) {
            if (0 == StringComparer.b.compare(a, this.cn)) {
                return;
            }
            let b = this.cn;
            this.cn = a;
            this.ba("TextFilterCaption", b, this.cn);
        }
        c4() {
            let a = this.b2.ah();
            this.bw.al(!a);
            let b = this.b3();
            this.bw.am(b);
        }
        cr() {
            if (0 == this.b2.g.count) {
                this.ct();
                return;
            }
            let a;
            let b;
            if (this.b2.p == 0) {
                b = false;
                a = 10;
            }
            else {
                b = true;
                a = 5;
            }
            let c = new List$1(ColumnComparisonFilterCondition.$, 0);
            let d = this.b2.g;
            for (let e = 0; e < d.count; e++) {
                let f = d._inner[e];
                let g = f.value[0];
                let h = GridColumnFilterOptions.bt(a, g);
                c.add(h);
            }
            if (c.count == 1) {
                this.column.eo = c._inner[0];
            }
            else {
                let i = new ColumnFilterConditionGroup();
                i.f = b;
                for (let j of fromEnum(c)) {
                    i.h(j);
                }
                this.column.eo = i;
            }
        }
        provideClearFiltersSection(a) {
            this.bw.ah(a);
        }
        provideFilterSection(a) {
            this.bw.aj(a);
        }
        provideFilterCheckboxListSection(a) {
            this.b2 = a;
            this.c6();
            let b = this.b2;
            b.selectAllCheckboxChanged = delegateCombine(b.selectAllCheckboxChanged, runOn(this, this.cs));
            let c = this.b2;
            c.checkedChanged = delegateCombine(c.checkedChanged, runOn(this, this.cv));
        }
        provideFilterButtonSection(a) {
            this.bw.ai(a);
        }
        provideMainDiv(a) {
            this.bw.ak(a);
        }
        ct() {
            this.column.eo = null;
            this.c5();
        }
        static bt(a, b) {
            let c = new ColumnComparisonFilterCondition();
            c.e = a;
            c.j = b;
            return c;
        }
        b3() {
            let a = this.column;
            if (null == a) {
                return false;
            }
            return null != a.eo;
        }
        cy() {
            let a = this.column;
            let b = this.c;
            let c = (null != a) ? a.h4 : null;
            let d = (null != b) ? b.actualDataSource.clone() : null;
            if (null != d) {
                this.c7(b.actualDataSource, d);
                d.summaryDescriptions.clear();
                d.groupDescriptions.clear();
                let e = new SortDescription();
                e.propertyName = c;
                e.direction = 0;
                d.groupDescriptions.add(e);
                let f = b.z(a);
                let g = d.filterExpressions;
                for (let h = g.j.count - 1; h >= 0; h--) {
                    let i = g.j.item(h);
                    if (i.isAutoGenerated) {
                        if (null != f) {
                            g.j.item(h, f);
                        }
                        else {
                            d.filterExpressions.removeAt(h);
                        }
                        break;
                    }
                }
                this.b2.itemsSource = d;
                this.b2.a2 = c;
                this.b2.b = [c];
                d.isSectionHeaderNormalRow = true;
                d.isSectionExpandedDefault = false;
                d.isSectionCollapsable = true;
                d.isSectionContentVisible = false;
                this.c5();
            }
        }
        c7(a, b) {
            if (a != null && a.actualSchema != null && b != null && b.actualSchema != null) {
                let c = b.actualSchema.propertyTypes;
                let d = a.actualSchema.propertyTypes;
                for (let e = 0; e < c.length; e++) {
                    if (c[e] != d[e]) {
                        c[e] = d[e];
                    }
                }
            }
        }
        c5() {
            let a = this.column;
            let b = (null != a) ? a.h4 : null;
            let c = true;
            let d = toNullable(ColumnComparisonConditionOperatorType_$type, null);
            let e = this.b4();
            for (let f = e.count - 1; f >= 0; f--) {
                let g = e._inner[f];
                switch (g.e) {
                    case 5:
                    case 10: break;
                    default:
                        e.removeAt(f);
                        continue;
                }
                if (nullableEquals(d, null)) {
                    d = toNullable(ColumnComparisonConditionOperatorType_$type, g.e);
                }
                else if (d.value != g.e) {
                    c = false;
                    break;
                }
            }
            if (e.count == 0 || !c) {
                this.b2.ch();
                return;
            }
            switch (d.value) {
                case 5:
                    this.b2.bs();
                    break;
                case 10:
                    this.b2.ch();
                    break;
            }
            let h = this.b2.g;
            for (let i of fromEnum(e)) {
                h.add(new PrimaryKeyValue([b], [i.j]));
            }
            this.c4();
        }
        b4() {
            let a = new List$1(ColumnComparisonFilterCondition.$, 0);
            let b = this.column;
            if (null == b) {
                return a;
            }
            if (null != b.eo) {
                let c = GridColumnFilterOptions.cu(b.eo, a);
                a = c.p1;
            }
            return a;
        }
        static cu(a, b) {
            let c = typeCast(ColumnFilterConditionGroup.$, a);
            if (null != c) {
                for (let d = 0; d < c.g; d++) {
                    let e = c.item(d);
                    let f = GridColumnFilterOptions.cu(e, b);
                    b = f.p1;
                }
            }
            else if (null != a) {
                b.add1(a);
            }
            return {
                p1: b
            };
        }
        c6() {
            if (null != this.b2) {
                this.b2.n = this.bz;
                this.b2.a6 = this.ck;
                this.b2.cr = this.bm;
                this.b2.cw = this.bp;
                this.b2.l = this.i;
                this.b2.updateHrMargin(new Thickness(1, -7, 3, -7, 3));
            }
        }
        cs(a, b) {
            this.c4();
        }
        cv(a, b) {
            this.c4();
        }
        c8(a, b) {
            this.cr();
            this.cw();
        }
        c9(a, b) {
            this.cx();
        }
        cw() {
            if (null != this.applyButtonClick) {
                this.applyButtonClick(this, new FilterApplyButtonClickEventArgs());
            }
        }
        cx() {
            if (null != this.cancelButtonClick) {
                this.cancelButtonClick(this, new FilterCancelButtonClickEventArgs());
            }
        }
    }
    GridColumnFilterOptions.$t = /*@__PURE__*/ markType(GridColumnFilterOptions, 'GridColumnFilterOptions', GridColumnOptionsSectionBase.$);
    return GridColumnFilterOptions;
})();
//# sourceMappingURL=GridColumnFilterOptionsView_combined.js.map
