import * as tslib_1 from "tslib";
import { IgcHTMLElement } from "igniteui-webcomponents-core";
import { BaseControlTheme_$type } from "igniteui-webcomponents-core";
import { ControlDisplayDensity_$type } from "igniteui-webcomponents-core";
import { IgcColumnComponent } from "./igc-column-component";
import { TypeRegistrar } from "igniteui-webcomponents-core";
import { NamePatcher, getAllPropertyNames, fromSpinal, toSpinal, ensureBool, brushToString, stringToBrush, ensureEnum, enumToString, initializePropertiesFromCss } from "igniteui-webcomponents-core";
import { FontInfo } from "igniteui-webcomponents-core";
var IgcGridColumnOptionsBaseComponent = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(IgcGridColumnOptionsBaseComponent, _super);
    function IgcGridColumnOptionsBaseComponent() {
        var _this = _super.call(this) || this;
        _this._settingAttributes = false;
        _this._attached = false;
        _this._queuedSetAttributes = [];
        _this._updatingFromAttribute = false;
        _this.__p = null;
        _this._hasUserValues = new Set();
        _this._stylingContainer = null;
        _this._stylingParent = null;
        _this._inStyling = false;
        if (_this._styling) {
            NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this));
        }
        _this._implementation = _this.createImplementation();
        _this._implementation.externalObject = _this;
        _this.onImplementationCreated();
        return _this;
    }
    IgcGridColumnOptionsBaseComponent.prototype.createImplementation = function () {
        return null;
    };
    Object.defineProperty(IgcGridColumnOptionsBaseComponent.prototype, "i", {
        /**
         * @hidden
         */
        get: function () {
            return this._implementation;
        } /**
                                     * @hidden
                                     */,
        enumerable: true,
        configurable: true
    });
    IgcGridColumnOptionsBaseComponent._createFromInternal = function (internal) {
        if (!internal) {
            return null;
        }
        if (!internal.$type) {
            return null;
        }
        var name = internal.$type.name;
        var externalName = "Igc" + name + "Component";
        if (!TypeRegistrar.isRegistered(externalName)) {
            return null;
        }
        return TypeRegistrar.create(externalName);
    };
    IgcGridColumnOptionsBaseComponent.prototype.onImplementationCreated = function () {
    };
    IgcGridColumnOptionsBaseComponent.prototype._enqueueSetAttribute = function (attrName, attrValue) {
        this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue });
    };
    IgcGridColumnOptionsBaseComponent.prototype._flushQueuedAttributes = function () {
        this._settingAttributes = true;
        for (var i = 0; i < this._queuedSetAttributes.length; i++) {
            this.setAttribute(this._queuedSetAttributes[i].attrName, this._queuedSetAttributes[i].attrValue);
        }
        this._settingAttributes = false;
        this._queuedSetAttributes.length = 0;
    };
    IgcGridColumnOptionsBaseComponent.prototype._a = function (attrName, attrValue) {
        if (this._updatingFromAttribute) {
            return;
        }
        if (attrValue) {
            attrValue = attrValue.toString();
        }
        this._settingAttributes = true;
        attrName = toSpinal(attrName);
        if (this._attached) {
            this.setAttribute(attrName, attrValue);
        }
        else {
            this._enqueueSetAttribute(attrName, attrValue);
        }
        this._settingAttributes = false;
    };
    IgcGridColumnOptionsBaseComponent.prototype.connectedCallback = function () {
        if (_super.prototype["connectedCallback"]) {
            _super.prototype["connectedCallback"].call(this);
        }
        if (!this._attached) {
            this._attached = true;
            this._flushQueuedAttributes();
        }
    };
    Object.defineProperty(IgcGridColumnOptionsBaseComponent, "observedAttributes", {
        get: function () {
            if (IgcGridColumnOptionsBaseComponent._observedAttributesIgcGridColumnOptionsBaseComponent == null) {
                var names = getAllPropertyNames(IgcGridColumnOptionsBaseComponent);
                for (var i = 0; i < names.length; i++) {
                    names[i] = toSpinal(names[i]);
                }
                IgcGridColumnOptionsBaseComponent._observedAttributesIgcGridColumnOptionsBaseComponent = names;
            }
            return IgcGridColumnOptionsBaseComponent._observedAttributesIgcGridColumnOptionsBaseComponent;
        },
        enumerable: true,
        configurable: true
    });
    IgcGridColumnOptionsBaseComponent.prototype.attributeChangedCallback = function (name, oldValue, newValue) {
        if (this._settingAttributes) {
            return;
        }
        var setName = fromSpinal(name);
        this._updatingFromAttribute = true;
        this[setName] = newValue;
        this._updatingFromAttribute = false;
    };
    Object.defineProperty(IgcGridColumnOptionsBaseComponent.prototype, "autoSize", {
        /**
         * Gets or sets the autoSize for which this AutoSizeOptions will apply.
        */
        get: function () {
            return this.i.ak;
        },
        set: function (v) {
            this.i.ak = ensureBool(v);
            this._a("autoSize", this.i.ak);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcGridColumnOptionsBaseComponent.prototype, "backgroundColor", {
        /**
         * Gets or sets the color to use for the background of the component.
        */
        get: function () {
            return brushToString(this.i.bm);
        },
        set: function (v) {
            this.i.bm = stringToBrush(v);
            this._a("backgroundColor", brushToString(this.i.bm));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcGridColumnOptionsBaseComponent.prototype, "baseTheme", {
        /**
         * Gets or sets the base built in theme to use for the component.
        */
        get: function () {
            return this.i.j;
        },
        set: function (v) {
            this.i.j = ensureEnum(BaseControlTheme_$type, v);
            this._a("baseTheme", enumToString(BaseControlTheme_$type, this.i.j));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcGridColumnOptionsBaseComponent.prototype, "actualBaseTheme", {
        /**
         * Gets the actual display baseTheme to use for the component.
        */
        get: function () {
            return this.i.i;
        },
        set: function (v) {
            this.i.i = ensureEnum(BaseControlTheme_$type, v);
            this._a("actualBaseTheme", enumToString(BaseControlTheme_$type, this.i.i));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcGridColumnOptionsBaseComponent.prototype, "buttonDensity", {
        /**
         * Gets or sets the display Density to use for the buttons in the component.
        */
        get: function () {
            return this.i.buttonDensity;
        },
        set: function (v) {
            this.i.buttonDensity = ensureEnum(ControlDisplayDensity_$type, v);
            this._a("buttonDensity", enumToString(ControlDisplayDensity_$type, this.i.buttonDensity));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcGridColumnOptionsBaseComponent.prototype, "actualButtonDensity", {
        /**
         * Gets the actual display buttonDensity to use for the component.
        */
        get: function () {
            return this.i.p;
        },
        set: function (v) {
            this.i.p = ensureEnum(ControlDisplayDensity_$type, v);
            this._a("actualButtonDensity", enumToString(ControlDisplayDensity_$type, this.i.p));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcGridColumnOptionsBaseComponent.prototype, "buttonTextStyle", {
        /**
         * Gets or sets the font to use for buttons.
        */
        get: function () {
            if (this.i.ab == null) {
                return null;
            }
            return this.i.ab.fontString;
        },
        set: function (v) {
            var fi = new FontInfo();
            fi.fontString = v;
            this.i.ab = fi;
            this._a("buttonTextStyle", this.i.ab != null ? this.i.ab.fontString : "");
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcGridColumnOptionsBaseComponent.prototype, "column", {
        /**
         * Gets or sets the column for which this ColumnOptions will apply.
        */
        get: function () {
            if (this.i.column == null) {
                return null;
            }
            if (!this.i.column.externalObject) {
                var e = IgcColumnComponent._createFromInternal(this.i.column);
                if (e) {
                    e._implementation = this.i.column;
                }
                this.i.column.externalObject = e;
            }
            return this.i.column.externalObject;
        },
        set: function (v) {
            if (v != null && this._stylingContainer && v._styling)
                v._styling(this._stylingContainer, this, this);
            v == null ? this.i.column = null : this.i.column = v.i;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcGridColumnOptionsBaseComponent.prototype, "density", {
        /**
         * Gets or sets the display density to use for the component.
        */
        get: function () {
            return this.i.density;
        },
        set: function (v) {
            this.i.density = ensureEnum(ControlDisplayDensity_$type, v);
            this._a("density", enumToString(ControlDisplayDensity_$type, this.i.density));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcGridColumnOptionsBaseComponent.prototype, "actualDensity", {
        /**
         * Gets the actual display density to use for the component.
        */
        get: function () {
            return this.i.q;
        },
        set: function (v) {
            this.i.q = ensureEnum(ControlDisplayDensity_$type, v);
            this._a("actualDensity", enumToString(ControlDisplayDensity_$type, this.i.q));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcGridColumnOptionsBaseComponent.prototype, "labelTextStyle", {
        /**
         * Gets or sets the font to use for labels.
        */
        get: function () {
            if (this.i.ag == null) {
                return null;
            }
            return this.i.ag.fontString;
        },
        set: function (v) {
            var fi = new FontInfo();
            fi.fontString = v;
            this.i.ag = fi;
            this._a("labelTextStyle", this.i.ag != null ? this.i.ag.fontString : "");
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcGridColumnOptionsBaseComponent.prototype, "textColor", {
        /**
         * Gets or sets the color to use for the text of the component.
        */
        get: function () {
            return brushToString(this.i.bp);
        },
        set: function (v) {
            this.i.bp = stringToBrush(v);
            this._a("textColor", brushToString(this.i.bp));
        },
        enumerable: true,
        configurable: true
    });
    IgcGridColumnOptionsBaseComponent.prototype.findByName = function (name) {
        if (this.column && this.column.name && this.column.name == name) {
            return this.column;
        }
        return null;
    };
    Object.defineProperty(IgcGridColumnOptionsBaseComponent.prototype, "hasUserValues", {
        get: function () {
            return this._hasUserValues;
        },
        enumerable: true,
        configurable: true
    });
    IgcGridColumnOptionsBaseComponent.prototype.__m = function (propertyName) {
        if (!this._inStyling) {
            this._hasUserValues.add(propertyName);
        }
    };
    IgcGridColumnOptionsBaseComponent.prototype._styling = function (container, component, parent) {
        if (this._inStyling) {
            return;
        }
        this._inStyling = true;
        this._stylingContainer = container;
        this._stylingParent = component;
        var genericPrefix = "";
        var typeName = this.i.$type.name;
        if (typeName.indexOf("Xam") === 0) {
            typeName = typeName.substring(3);
        }
        genericPrefix = toSpinal("GridColumnOptionsBaseComponent");
        var additionalPrefixes = [];
        var prefix = toSpinal(typeName);
        additionalPrefixes.push(prefix + "-");
        var b = this.i.$type.baseType;
        while (b && b.name != "Object" &&
            b.name != "Base" &&
            b.name != "Control" &&
            b.Name != "DependencyObject" &&
            b.Name != "FrameworkElement") {
            typeName = b.name;
            if (typeName.indexOf("Xam") === 0) {
                typeName = typeName.substring(3);
            }
            var basePrefix = toSpinal(typeName);
            additionalPrefixes.push(basePrefix + "-");
            b = b.baseType;
        }
        if (parent) {
            var parentTypeName = parent.i.$type.name;
            if (parentTypeName.indexOf("Xam") === 0) {
                parentTypeName = parentTypeName.substring(3);
            }
            var parentPrefix = toSpinal(parentTypeName);
            additionalPrefixes.push(parentPrefix + "-" + genericPrefix + "-");
            additionalPrefixes.push(parentPrefix + "-" + prefix + "-");
        }
        initializePropertiesFromCss(container, this, genericPrefix + "-", this.hasUserValues, false, additionalPrefixes);
        if (this.column && this.column._styling) {
            this.column._styling(container, component, this);
        }
        if (this._otherStyling) {
            this._otherStyling(container, component, parent);
        }
        this._inStyling = false;
    };
    IgcGridColumnOptionsBaseComponent._observedAttributesIgcGridColumnOptionsBaseComponent = null;
    return IgcGridColumnOptionsBaseComponent;
}(IgcHTMLElement));
export { IgcGridColumnOptionsBaseComponent };
//# sourceMappingURL=igc-grid-column-options-base-component.js.map
