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";
export let IgcGridColumnOptionsBaseComponent = /*@__PURE__*/ (() => {
    class IgcGridColumnOptionsBaseComponent extends IgcHTMLElement {
        constructor() {
            super();
            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();
        }
        createImplementation() {
            return null;
        }
        /**
         * @hidden
         */
        get i() {
            return this._implementation;
        } /**
                                     * @hidden
                                     */
        static _createFromInternal(internal) {
            if (!internal) {
                return null;
            }
            if (!internal.$type) {
                return null;
            }
            let name = internal.$type.name;
            let externalName = "Igc" + name + "Component";
            if (!TypeRegistrar.isRegistered(externalName)) {
                return null;
            }
            return TypeRegistrar.create(externalName);
        }
        onImplementationCreated() {
        }
        _enqueueSetAttribute(attrName, attrValue) {
            this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue });
        }
        _flushQueuedAttributes() {
            this._settingAttributes = true;
            for (let i = 0; i < this._queuedSetAttributes.length; i++) {
                this.setAttribute(this._queuedSetAttributes[i].attrName, this._queuedSetAttributes[i].attrValue);
            }
            this._settingAttributes = false;
            this._queuedSetAttributes.length = 0;
        }
        _a(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;
        }
        connectedCallback() {
            if (super["connectedCallback"]) {
                super["connectedCallback"]();
            }
            if (!this._attached) {
                this._attached = true;
                this._flushQueuedAttributes();
            }
        }
        static get observedAttributes() {
            if (IgcGridColumnOptionsBaseComponent._observedAttributesIgcGridColumnOptionsBaseComponent == null) {
                let names = getAllPropertyNames(IgcGridColumnOptionsBaseComponent);
                for (let i = 0; i < names.length; i++) {
                    names[i] = toSpinal(names[i]);
                }
                IgcGridColumnOptionsBaseComponent._observedAttributesIgcGridColumnOptionsBaseComponent = names;
            }
            return IgcGridColumnOptionsBaseComponent._observedAttributesIgcGridColumnOptionsBaseComponent;
        }
        attributeChangedCallback(name, oldValue, newValue) {
            if (this._settingAttributes) {
                return;
            }
            let setName = fromSpinal(name);
            this._updatingFromAttribute = true;
            this[setName] = newValue;
            this._updatingFromAttribute = false;
        }
        /**
         * Gets or sets the autoSize for which this AutoSizeOptions will apply.
        */
        get autoSize() {
            return this.i.ak;
        }
        set autoSize(v) {
            this.i.ak = ensureBool(v);
            this._a("autoSize", this.i.ak);
        }
        /**
         * Gets or sets the color to use for the background of the component.
        */
        get backgroundColor() {
            return brushToString(this.i.bm);
        }
        set backgroundColor(v) {
            this.i.bm = stringToBrush(v);
            this._a("backgroundColor", brushToString(this.i.bm));
        }
        /**
         * Gets or sets the base built in theme to use for the component.
        */
        get baseTheme() {
            return this.i.j;
        }
        set baseTheme(v) {
            this.i.j = ensureEnum(BaseControlTheme_$type, v);
            this._a("baseTheme", enumToString(BaseControlTheme_$type, this.i.j));
        }
        /**
         * Gets the actual display baseTheme to use for the component.
        */
        get actualBaseTheme() {
            return this.i.i;
        }
        set actualBaseTheme(v) {
            this.i.i = ensureEnum(BaseControlTheme_$type, v);
            this._a("actualBaseTheme", enumToString(BaseControlTheme_$type, this.i.i));
        }
        /**
         * Gets or sets the display Density to use for the buttons in the component.
        */
        get buttonDensity() {
            return this.i.buttonDensity;
        }
        set buttonDensity(v) {
            this.i.buttonDensity = ensureEnum(ControlDisplayDensity_$type, v);
            this._a("buttonDensity", enumToString(ControlDisplayDensity_$type, this.i.buttonDensity));
        }
        /**
         * Gets the actual display buttonDensity to use for the component.
        */
        get actualButtonDensity() {
            return this.i.p;
        }
        set actualButtonDensity(v) {
            this.i.p = ensureEnum(ControlDisplayDensity_$type, v);
            this._a("actualButtonDensity", enumToString(ControlDisplayDensity_$type, this.i.p));
        }
        /**
         * Gets or sets the font to use for buttons.
        */
        get buttonTextStyle() {
            if (this.i.ab == null) {
                return null;
            }
            return this.i.ab.fontString;
        }
        set buttonTextStyle(v) {
            let fi = new FontInfo();
            fi.fontString = v;
            this.i.ab = fi;
            this._a("buttonTextStyle", this.i.ab != null ? this.i.ab.fontString : "");
        }
        /**
         * Gets or sets the column for which this ColumnOptions will apply.
        */
        get column() {
            if (this.i.column == null) {
                return null;
            }
            if (!this.i.column.externalObject) {
                let e = IgcColumnComponent._createFromInternal(this.i.column);
                if (e) {
                    e._implementation = this.i.column;
                }
                this.i.column.externalObject = e;
            }
            return this.i.column.externalObject;
        }
        set column(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;
        }
        /**
         * Gets or sets the display density to use for the component.
        */
        get density() {
            return this.i.density;
        }
        set density(v) {
            this.i.density = ensureEnum(ControlDisplayDensity_$type, v);
            this._a("density", enumToString(ControlDisplayDensity_$type, this.i.density));
        }
        /**
         * Gets the actual display density to use for the component.
        */
        get actualDensity() {
            return this.i.q;
        }
        set actualDensity(v) {
            this.i.q = ensureEnum(ControlDisplayDensity_$type, v);
            this._a("actualDensity", enumToString(ControlDisplayDensity_$type, this.i.q));
        }
        /**
         * Gets or sets the font to use for labels.
        */
        get labelTextStyle() {
            if (this.i.ag == null) {
                return null;
            }
            return this.i.ag.fontString;
        }
        set labelTextStyle(v) {
            let fi = new FontInfo();
            fi.fontString = v;
            this.i.ag = fi;
            this._a("labelTextStyle", this.i.ag != null ? this.i.ag.fontString : "");
        }
        /**
         * Gets or sets the color to use for the text of the component.
        */
        get textColor() {
            return brushToString(this.i.bp);
        }
        set textColor(v) {
            this.i.bp = stringToBrush(v);
            this._a("textColor", brushToString(this.i.bp));
        }
        findByName(name) {
            if (this.column && this.column.name && this.column.name == name) {
                return this.column;
            }
            return null;
        }
        get hasUserValues() {
            return this._hasUserValues;
        }
        __m(propertyName) {
            if (!this._inStyling) {
                this._hasUserValues.add(propertyName);
            }
        }
        _styling(container, component, parent) {
            if (this._inStyling) {
                return;
            }
            this._inStyling = true;
            this._stylingContainer = container;
            this._stylingParent = component;
            let genericPrefix = "";
            let typeName = this.i.$type.name;
            if (typeName.indexOf("Xam") === 0) {
                typeName = typeName.substring(3);
            }
            genericPrefix = toSpinal("GridColumnOptionsBaseComponent");
            let additionalPrefixes = [];
            let prefix = toSpinal(typeName);
            additionalPrefixes.push(prefix + "-");
            let 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);
                }
                let basePrefix = toSpinal(typeName);
                additionalPrefixes.push(basePrefix + "-");
                b = b.baseType;
            }
            if (parent) {
                let parentTypeName = parent.i.$type.name;
                if (parentTypeName.indexOf("Xam") === 0) {
                    parentTypeName = parentTypeName.substring(3);
                }
                let 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;
})();
//# sourceMappingURL=igc-grid-column-options-base-component.js.map
