import { ensureEnum, brushToString, stringToBrush, initializePropertiesFromCss, NamePatcher, toSpinal, enumToString, getAllPropertyNames, fromSpinal } from "igniteui-webcomponents-core";
import { FontInfo } from "igniteui-webcomponents-core";
import { WebComponentRenderer } from "igniteui-webcomponents-core";
import { TypeRegistrar } from "igniteui-webcomponents-core";
import { RegisterElementHelper } from "igniteui-webcomponents-core";
import { ColumnPinning } from './ColumnPinning';
import { BaseControlTheme_$type } from "igniteui-webcomponents-core";
import { ControlDisplayDensity_$type } from "igniteui-webcomponents-core";
import { IgcHTMLElement } from "igniteui-webcomponents-core";
export let IgcColumnPinningComponent = /*@__PURE__*/ (() => {
    class IgcColumnPinningComponent extends IgcHTMLElement {
        constructor() {
            super();
            this._disconnected = false;
            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._renderer = new WebComponentRenderer(this, document, true, null);
            this._implementation = this.createImplementation();
            this._container = this._renderer.createElement("div");
            this._renderer.updateRoot(this._container);
            //this._renderer.rootWrapper.append(this._container);
            this._container.setStyleProperty("display", "block");
            this._container.setStyleProperty("width", "100%");
            this._container.setStyleProperty("height", "100%");
            var columnPinning = this.i;
            this._columnPinning = columnPinning;
            this._renderer.addSizeWatcher(() => {
                this._columnPinning.notifySizeChanged();
            });
        }
        set height(value) {
            this._height = value;
            this.style.height = value;
            this.i.notifySizeChanged();
        }
        get height() {
            return this._height;
        }
        set width(value) {
            this._width = value;
            this.style.width = value;
            this.i.notifySizeChanged();
        }
        get width() {
            return this._width;
        }
        // supports angular themes or custom properties set in CSS
        updateStyle() {
            this._styling(this, this);
        }
        destroy() {
            this._columnPinning.destroy();
        }
        createImplementation() {
            return new ColumnPinning();
        }
        disconnectedCallback() {
            this._disconnected = true;
        }
        connectedCallback() {
            if (this._disconnected) {
                this._disconnected = false;
                return;
            }
            this.classList.add("ig-column-pinning");
            this.classList.add("igc-column-pinning");
            var rootWrapper = this._renderer.rootWrapper;
            var rootElement = rootWrapper.getNativeElement();
            this.appendChild(rootElement);
            this._attached = true;
            this.style.display = "block";
            this.style.height = this._height;
            this.style.width = this._width;
            let title = this._renderer.createElement("span");
            this._container.append(title);
            var checkboxList = this._renderer.createElement("igc-checkbox-list");
            this._container.append(checkboxList);
            this._columnPinning.provideContainer(this._renderer, checkboxList.getNativeElement().i);
            this._columnPinning.notifySizeChanged();
            this._flushQueuedAttributes();
            // supports themes or custom properties set in CSS 
            this._styling(this, this);
            this.afterContentInit();
        }
        afterContentInit() {
            this.i.notifySizeChanged();
        }
        /**
         * @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);
        }
        _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;
        }
        static get observedAttributes() {
            if (IgcColumnPinningComponent._observedAttributesIgcColumnPinningComponent == null) {
                let names = getAllPropertyNames(IgcColumnPinningComponent);
                for (let i = 0; i < names.length; i++) {
                    names[i] = toSpinal(names[i]);
                }
                IgcColumnPinningComponent._observedAttributesIgcColumnPinningComponent = names;
            }
            return IgcColumnPinningComponent._observedAttributesIgcColumnPinningComponent;
        }
        attributeChangedCallback(name, oldValue, newValue) {
            if (this._settingAttributes) {
                return;
            }
            let setName = fromSpinal(name);
            this._updatingFromAttribute = true;
            this[setName] = newValue;
            this._updatingFromAttribute = false;
        }
        static register() {
            if (!IgcColumnPinningComponent._isElementRegistered) {
                IgcColumnPinningComponent._isElementRegistered = true;
                RegisterElementHelper.registerElement(IgcColumnPinningComponent.htmlTagName, IgcColumnPinningComponent);
            }
        }
        /**
     * Gets or Sets the property name that contains the values.
    */
        get targetGrid() {
            if (this.i.b == null) {
                return null;
            }
            return this.i.b.externalObject;
        }
        set targetGrid(v) {
            if (v != null && this._stylingContainer && v._styling)
                v._styling(this._stylingContainer, this, this);
            v == null ? this.i.b = null : this.i.b = v.i;
        }
        /**
         * Gets or Sets the property name that contains the values.
        */
        get title() {
            return this.i.v;
        }
        set title(v) {
            this.i.v = v;
        }
        /**
         * Gets or Sets the property name that contains the values.
        */
        get titleStyle() {
            if (this.i.j == null) {
                return null;
            }
            return this.i.j.fontString;
        }
        set titleStyle(v) {
            let fi = new FontInfo();
            fi.fontString = v;
            this.i.j = fi;
            this._a("titleStyle", this.i.j != null ? this.i.j.fontString : "");
        }
        /**
         * Gets or Sets the property name that contains the values.
        */
        get titleColor() {
            return brushToString(this.i.ao);
        }
        set titleColor(v) {
            this.i.ao = stringToBrush(v);
            this._a("titleColor", brushToString(this.i.ao));
        }
        /**
         * Gets or Sets the property name that contains the values.
        */
        get filterPlaceholderText() {
            return this.i.s;
        }
        set filterPlaceholderText(v) {
            this.i.s = v;
        }
        /**
         * Gets or Sets the property name that contains the values.
        */
        get baseTheme() {
            return this.i.e;
        }
        set baseTheme(v) {
            this.i.e = ensureEnum(BaseControlTheme_$type, v);
            this._a("baseTheme", enumToString(BaseControlTheme_$type, this.i.e));
        }
        /**
         * Gets or Sets the property name that contains the values.
        */
        get density() {
            return this.i.g;
        }
        set density(v) {
            this.i.g = ensureEnum(ControlDisplayDensity_$type, v);
            this._a("density", enumToString(ControlDisplayDensity_$type, this.i.g));
        }
        /**
         * Gets or Sets the property name that contains the values.
        */
        get backgroundColor() {
            return brushToString(this.i.an);
        }
        set backgroundColor(v) {
            this.i.an = stringToBrush(v);
            this._a("backgroundColor", brushToString(this.i.an));
        }
        findByName(name) {
            if (this.targetGrid && this.targetGrid.name && this.targetGrid.name == name) {
                return this.targetGrid;
            }
            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("ColumnPinningComponent");
            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.targetGrid && this.targetGrid._styling) {
                this.targetGrid._styling(container, component, this);
            }
            if (this._otherStyling) {
                this._otherStyling(container, component, parent);
            }
            this._inStyling = false;
        }
    }
    IgcColumnPinningComponent._observedAttributesIgcColumnPinningComponent = null;
    IgcColumnPinningComponent.htmlTagName = "igc-column-pinning";
    IgcColumnPinningComponent._isElementRegistered = false;
    return IgcColumnPinningComponent;
})();
//# sourceMappingURL=igc-column-pinning-component.js.map
