import { __extends, __values } from "tslib";
import * as React from 'react';
import { HorizontalAlignment_$type } from "igniteui-react-core";
import { VerticalAlignment_$type } from "igniteui-react-core";
import { TreemapNodeStyle } from "./TreemapNodeStyle";
import { TypeRegistrar } from "igniteui-react-core";
import { NamePatcher, getModifiedProps, isValidProp, brushToString, stringToBrush, ensureEnum, toSpinal, initializePropertiesFromCss } from "igniteui-react-core";
/**
 * Represents a style to apply to a treemap node.
*/
var IgrTreemapNodeStyle = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(IgrTreemapNodeStyle, _super);
    function IgrTreemapNodeStyle(props) {
        var _this = _super.call(this, props) || this;
        _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();
        if (_this._initializeAdapters) {
            _this._initializeAdapters();
        }
        return _this;
    }
    IgrTreemapNodeStyle.prototype.createImplementation = function () {
        return new TreemapNodeStyle();
    };
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "i", {
        /**
         * @hidden
         */
        get: function () {
            return this._implementation;
        } /**
                                     * @hidden
                                     */,
        enumerable: false,
        configurable: true
    });
    IgrTreemapNodeStyle._createFromInternal = function (internal) {
        if (!internal) {
            return null;
        }
        if (!internal.$type) {
            return null;
        }
        var name = internal.$type.name;
        var externalName = "Igr" + name;
        if (!TypeRegistrar.isRegistered(externalName)) {
            return null;
        }
        return TypeRegistrar.create(externalName);
    };
    IgrTreemapNodeStyle.prototype.onImplementationCreated = function () {
    };
    IgrTreemapNodeStyle.prototype.componentDidMount = function () {
        var e_1, _a;
        try {
            for (var _b = __values(Object.keys(this.props)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var p = _c.value;
                if (isValidProp(this, p)) {
                    this[p] = this.props[p];
                }
            }
        }
        catch (e_1_1) {
            e_1 = { error: e_1_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_1)
                    throw e_1.error;
            }
        }
    };
    IgrTreemapNodeStyle.prototype.shouldComponentUpdate = function (nextProps, nextState) {
        var e_2, _a;
        var mod = getModifiedProps(this.props, nextProps);
        try {
            for (var _b = __values(Object.keys(mod)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var p = _c.value;
                if (isValidProp(this, p)) {
                    this[p] = mod[p];
                }
            }
        }
        catch (e_2_1) {
            e_2 = { error: e_2_1 };
        }
        finally {
            try {
                if (_c && !_c.done && (_a = _b.return))
                    _a.call(_b);
            }
            finally {
                if (e_2)
                    throw e_2.error;
            }
        }
        return true;
    };
    IgrTreemapNodeStyle.prototype.render = function () {
        return null;
    };
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "headerHoverBackground", {
        /**
         * Gets or sets the background to use for the header when it is hovered.
        */
        get: function () {
            return brushToString(this.i.a7);
        },
        set: function (v) {
            this.i.a7 = stringToBrush(v);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "headerBackground", {
        /**
         * Gets or sets the background to use for the header.
        */
        get: function () {
            return brushToString(this.i.a6);
        },
        set: function (v) {
            this.i.a6 = stringToBrush(v);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "headerTextColor", {
        /**
         * Gets or sets the text color to use for the header.
        */
        get: function () {
            return brushToString(this.i.a9);
        },
        set: function (v) {
            this.i.a9 = stringToBrush(v);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "label", {
        /**
         * Gets or sets the label to use for the node.
        */
        get: function () {
            return this.i.ai;
        },
        set: function (v) {
            this.i.ai = v;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "textColor", {
        /**
         * Gets or sets the text color to use for the nodes.
        */
        get: function () {
            return brushToString(this.i.bb);
        },
        set: function (v) {
            this.i.bb = stringToBrush(v);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "headerHoverTextColor", {
        /**
         * Gets or sets the text color to use for the header.
        */
        get: function () {
            return brushToString(this.i.a8);
        },
        set: function (v) {
            this.i.a8 = stringToBrush(v);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "headerLabelLeftMargin", {
        /**
         * Gets or sets the left margin to use for the header.
        */
        get: function () {
            return this.i.p;
        },
        set: function (v) {
            this.i.p = +v;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "headerLabelTopMargin", {
        /**
         * Gets or sets the top margin to use for the header.
        */
        get: function () {
            return this.i.r;
        },
        set: function (v) {
            this.i.r = +v;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "headerLabelRightMargin", {
        /**
         * Gets or sets the right margin to use for the header.
        */
        get: function () {
            return this.i.q;
        },
        set: function (v) {
            this.i.q = +v;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "headerLabelBottomMargin", {
        /**
         * Gets or sets the bottom margin to use for the labels.
        */
        get: function () {
            return this.i.o;
        },
        set: function (v) {
            this.i.o = +v;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "labelLeftMargin", {
        /**
         * Gets or sets the left margin to use for the labels.
        */
        get: function () {
            return this.i.t;
        },
        set: function (v) {
            this.i.t = +v;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "labelTopMargin", {
        /**
         * Gets or sets the top margin to use for the labels.
        */
        get: function () {
            return this.i.v;
        },
        set: function (v) {
            this.i.v = +v;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "labelRightMargin", {
        /**
         * Gets or sets the right margin to use for the labels.
        */
        get: function () {
            return this.i.u;
        },
        set: function (v) {
            this.i.u = +v;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "labelBottomMargin", {
        /**
         * Gets or sets the bottom margin to use for the labels.
        */
        get: function () {
            return this.i.s;
        },
        set: function (v) {
            this.i.s = +v;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "headerHeight", {
        /**
         * Gets or sets the height to use for the header.
        */
        get: function () {
            return this.i.n;
        },
        set: function (v) {
            this.i.n = +v;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "labelHorizontalAlignment", {
        /**
         * Gets or sets the horizontal alignment to use for the node labels.
        */
        get: function () {
            return this.i.ax;
        },
        set: function (v) {
            this.i.ax = ensureEnum(HorizontalAlignment_$type, v);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "labelVerticalAlignment", {
        /**
         * Gets or sets the vertical alignment to use for the node labels.
        */
        get: function () {
            return this.i.bd;
        },
        set: function (v) {
            this.i.bd = ensureEnum(VerticalAlignment_$type, v);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "fill", {
        /**
         * Gets or sets the fill color to use for the nodes.
        */
        get: function () {
            return brushToString(this.i.a5);
        },
        set: function (v) {
            this.i.a5 = stringToBrush(v);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "outline", {
        /**
         * Gets or sets the outline to use for the nodes.
        */
        get: function () {
            return brushToString(this.i.ba);
        },
        set: function (v) {
            this.i.ba = stringToBrush(v);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "strokeThickness", {
        /**
         * Gets or sets the stroke thickness to use for the node outline.
        */
        get: function () {
            return this.i.w;
        },
        set: function (v) {
            this.i.w = +v;
        },
        enumerable: false,
        configurable: true
    });
    IgrTreemapNodeStyle.prototype.findByName = function (name) {
        if (this.findEphemera) {
            if (name && name.indexOf("@@e:") == 0) {
                return this.findEphemera(name);
            }
        }
        return null;
    };
    Object.defineProperty(IgrTreemapNodeStyle.prototype, "hasUserValues", {
        get: function () {
            return this._hasUserValues;
        },
        enumerable: false,
        configurable: true
    });
    IgrTreemapNodeStyle.prototype.__m = function (propertyName) {
        if (!this._inStyling) {
            this._hasUserValues.add(propertyName);
        }
    };
    IgrTreemapNodeStyle.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("TreemapNodeStyle");
        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;
    };
    return IgrTreemapNodeStyle;
}(React.Component));
export { IgrTreemapNodeStyle };
