var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
    if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
    return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
};
import React from 'react';
import { RenderEnvironmentContext } from './RenderEnvironmentContext.js';
export function withRenderEnvironment(constructor) {
    var _a;
    var RenderEnvironmentDecorator = (_a = /** @class */ (function (_super) {
            __extends(class_1, _super);
            function class_1() {
                return _super !== null && _super.apply(this, arguments) || this;
            }
            class_1.prototype.render = function () {
                var _this = this;
                return (React.createElement(RenderEnvironmentContext.Consumer, null, function (_b) {
                    var globalObject = _b.globalObject, emotion = _b.emotion;
                    _this.globalObject = globalObject;
                    _this.emotion = emotion;
                    _this.cx = emotion.cx;
                    var originalRender = _super.prototype.render;
                    if (typeof originalRender === 'function') {
                        return originalRender.call(_this);
                    }
                    return null;
                }));
            };
            return class_1;
        }(constructor)),
        __setFunctionName(_a, "RenderEnvironmentDecorator"),
        _a.__KONTUR_REACT_UI__ = constructor.__KONTUR_REACT_UI__,
        _a.displayName = constructor.displayName,
        _a);
    var nameDescriptor = Object.getOwnPropertyDescriptor(RenderEnvironmentDecorator, 'name');
    if (!nameDescriptor || nameDescriptor.configurable) {
        Object.defineProperty(RenderEnvironmentDecorator, 'name', { value: constructor.name });
    }
    return RenderEnvironmentDecorator;
}
//# sourceMappingURL=RenderEnvironmentDecorator.js.map