import * as tslib_1 from "tslib";
import { IgcHTMLElement } from "igniteui-webcomponents-core";
import { delegateCombine, delegateRemove } from "igniteui-webcomponents-core";
import { ColumnSortDirection_$type } from "./ColumnSortDirection";
import { SortIndicatorStyle_$type } from "./SortIndicatorStyle";
import { IgcSortIndicatorRenderCompletedEventArgs } from "./igc-sort-indicator-render-completed-event-args";
import { GridSortIndicator } from "./GridSortIndicator";
import { TypeRegistrar } from "igniteui-webcomponents-core";
import { NamePatcher, getAllPropertyNames, fromSpinal, toSpinal, ensureEnum, enumToString, brushToString, stringToBrush, ensureBool, initializePropertiesFromCss } from "igniteui-webcomponents-core";
import { RegisterElementHelper } from "igniteui-webcomponents-core";
/**
 * An advanced grid for displaying data.
*/
var IgcDataGridSortIndicatorComponent = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(IgcDataGridSortIndicatorComponent, _super);
    function IgcDataGridSortIndicatorComponent() {
        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;
        _this._renderCompleted = null;
        _this._renderCompleted_wrapped = null;
        if (_this._styling) {
            NamePatcher.ensureStylablePatched(Object.getPrototypeOf(_this));
        }
        _this._implementation = _this.createImplementation();
        _this._implementation.externalObject = _this;
        _this.onImplementationCreated();
        return _this;
    }
    IgcDataGridSortIndicatorComponent.prototype.createImplementation = function () {
        return new GridSortIndicator();
    };
    Object.defineProperty(IgcDataGridSortIndicatorComponent.prototype, "i", {
        /**
         * @hidden
         */
        get: function () {
            return this._implementation;
        } /**
                                     * @hidden
                                     */,
        enumerable: true,
        configurable: true
    });
    IgcDataGridSortIndicatorComponent._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);
    };
    IgcDataGridSortIndicatorComponent.prototype.onImplementationCreated = function () {
    };
    IgcDataGridSortIndicatorComponent.prototype._enqueueSetAttribute = function (attrName, attrValue) {
        this._queuedSetAttributes.push({ attrName: attrName, attrValue: attrValue });
    };
    IgcDataGridSortIndicatorComponent.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;
    };
    IgcDataGridSortIndicatorComponent.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;
    };
    IgcDataGridSortIndicatorComponent.prototype.connectedCallback = function () {
        if (_super.prototype["connectedCallback"]) {
            _super.prototype["connectedCallback"].call(this);
        }
        if (!this._attached) {
            this._attached = true;
            this._flushQueuedAttributes();
        }
    };
    Object.defineProperty(IgcDataGridSortIndicatorComponent, "observedAttributes", {
        get: function () {
            if (IgcDataGridSortIndicatorComponent._observedAttributesIgcDataGridSortIndicatorComponent == null) {
                var names = getAllPropertyNames(IgcDataGridSortIndicatorComponent);
                for (var i = 0; i < names.length; i++) {
                    names[i] = toSpinal(names[i]);
                }
                IgcDataGridSortIndicatorComponent._observedAttributesIgcDataGridSortIndicatorComponent = names;
            }
            return IgcDataGridSortIndicatorComponent._observedAttributesIgcDataGridSortIndicatorComponent;
        },
        enumerable: true,
        configurable: true
    });
    IgcDataGridSortIndicatorComponent.prototype.attributeChangedCallback = function (name, oldValue, newValue) {
        if (this._settingAttributes) {
            return;
        }
        var setName = fromSpinal(name);
        this._updatingFromAttribute = true;
        this[setName] = newValue;
        this._updatingFromAttribute = false;
    };
    IgcDataGridSortIndicatorComponent.register = function () {
        if (!IgcDataGridSortIndicatorComponent._isElementRegistered) {
            IgcDataGridSortIndicatorComponent._isElementRegistered = true;
            RegisterElementHelper.registerElement(IgcDataGridSortIndicatorComponent.htmlTagName, IgcDataGridSortIndicatorComponent);
        }
    };
    Object.defineProperty(IgcDataGridSortIndicatorComponent.prototype, "sortDirection", {
        get: function () {
            return this.i.b;
        },
        set: function (v) {
            this.i.b = ensureEnum(ColumnSortDirection_$type, v);
            this._a("sortDirection", enumToString(ColumnSortDirection_$type, this.i.b));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcDataGridSortIndicatorComponent.prototype, "iconColor", {
        get: function () {
            return brushToString(this.i.a0);
        },
        set: function (v) {
            this.i.a0 = stringToBrush(v);
            this._a("iconColor", brushToString(this.i.a0));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcDataGridSortIndicatorComponent.prototype, "isAnimationEnabled", {
        get: function () {
            return this.i.l;
        },
        set: function (v) {
            this.i.l = ensureBool(v);
            this._a("isAnimationEnabled", this.i.l);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcDataGridSortIndicatorComponent.prototype, "pixelScalingRatio", {
        /**
         * Gets or sets the scaling value used to affect the pixel density of the control.
         * A higher scaling ratio will produce crisper visuals at the expense of memory.  Lower values will cause the control
         * to appear blurry.
        */
        get: function () {
            return this.i.w;
        },
        set: function (v) {
            this.i.w = +v;
            this._a("pixelScalingRatio", this.i.w);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcDataGridSortIndicatorComponent.prototype, "actualPixelScalingRatio", {
        /**
         * Gets the actual pixel scaling ratio used to affect the pixel density of the control.
         * A higher scaling ratio will produce crisper visuals at the expense of memory.  Lower values will cause the control
         * to appear blurry.
        */
        get: function () {
            return this.i.p;
        },
        set: function (v) {
            this.i.p = +v;
            this._a("actualPixelScalingRatio", this.i.p);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgcDataGridSortIndicatorComponent.prototype, "sortIndicatorStyle", {
        get: function () {
            return this.i.f;
        },
        set: function (v) {
            this.i.f = ensureEnum(SortIndicatorStyle_$type, v);
            this._a("sortIndicatorStyle", enumToString(SortIndicatorStyle_$type, this.i.f));
        },
        enumerable: true,
        configurable: true
    });
    IgcDataGridSortIndicatorComponent.prototype.findByName = function (name) {
        return null;
    };
    Object.defineProperty(IgcDataGridSortIndicatorComponent.prototype, "hasUserValues", {
        get: function () {
            return this._hasUserValues;
        },
        enumerable: true,
        configurable: true
    });
    IgcDataGridSortIndicatorComponent.prototype.__m = function (propertyName) {
        if (!this._inStyling) {
            this._hasUserValues.add(propertyName);
        }
    };
    IgcDataGridSortIndicatorComponent.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("DataGridSortIndicatorComponent");
        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._otherStyling) {
            this._otherStyling(container, component, parent);
        }
        this._inStyling = false;
    };
    IgcDataGridSortIndicatorComponent.prototype.getDesiredScale = function () {
        var iv = this.i.v();
        return (iv);
    };
    IgcDataGridSortIndicatorComponent.prototype.notifySizeChanged = function (width, height) {
        this.i.ar(width, height);
    };
    IgcDataGridSortIndicatorComponent.prototype.notifyCellSizeChanged = function () {
        this.i.aq();
    };
    Object.defineProperty(IgcDataGridSortIndicatorComponent.prototype, "renderCompleted", {
        get: function () {
            return this._renderCompleted;
        },
        set: function (ev) {
            var _this = this;
            if (this._renderCompleted_wrapped !== null) {
                this.i.renderCompleted = delegateRemove(this.i.renderCompleted, this._renderCompleted_wrapped);
                this._renderCompleted_wrapped = null;
                this._renderCompleted = null;
            }
            this._renderCompleted = ev;
            this._renderCompleted_wrapped = function (o, e) {
                var outerArgs = new IgcSortIndicatorRenderCompletedEventArgs();
                outerArgs._provideImplementation(e);
                if (_this.beforeRenderCompleted) {
                    _this.beforeRenderCompleted(_this, outerArgs);
                }
                if (_this._renderCompleted) {
                    _this._renderCompleted(_this, outerArgs);
                }
            };
            this.i.renderCompleted = delegateCombine(this.i.renderCompleted, this._renderCompleted_wrapped);
        },
        enumerable: true,
        configurable: true
    });
    IgcDataGridSortIndicatorComponent._observedAttributesIgcDataGridSortIndicatorComponent = null;
    IgcDataGridSortIndicatorComponent.htmlTagName = "igc-data-grid-sort-indicator";
    IgcDataGridSortIndicatorComponent._isElementRegistered = false;
    return IgcDataGridSortIndicatorComponent;
}(IgcHTMLElement));
export { IgcDataGridSortIndicatorComponent };
//# sourceMappingURL=igc-data-grid-sort-indicator-component.js.map
