"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const create_react_context_1 = __importDefault(require("create-react-context"));
const React = __importStar(require("react"));
const jss_1 = require("./jss");
const defaultGradientColors = ['#85A9C4', '#C5C7C6', '#DFD2C0', '#F1B87C'];
const GradientColorsContext = create_react_context_1.default(defaultGradientColors);
class GradientProvider extends React.Component {
    render() {
        return (React.createElement(GradientColorsContext.Provider, { value: this.props.themeColors }, this.props.children));
    }
}
exports.GradientProvider = GradientProvider;
var GradientType;
(function (GradientType) {
    GradientType[GradientType["normal"] = 0] = "normal";
    GradientType[GradientType["withOverlay"] = 1] = "withOverlay";
    GradientType[GradientType["withDarkOverlay"] = 2] = "withDarkOverlay";
})(GradientType = exports.GradientType || (exports.GradientType = {}));
function computeGradient(type, themeGradientColors) {
    switch (type) {
        case GradientType.normal:
            return jss_1.getGradientCSSBackground(themeGradientColors);
        case GradientType.withOverlay:
            return jss_1.getGradientWithOverlay(themeGradientColors, .3);
        case GradientType.withDarkOverlay:
            return jss_1.getGradientWithOverlay(themeGradientColors, .5);
    }
}
exports.withGradient = (gradientType) => (WrappedComponent) => {
    class WithGradient extends React.Component {
        render() {
            return (React.createElement(GradientColorsContext.Consumer, null, (themeGradientColors) => this.renderChildren(themeGradientColors)));
        }
        renderChildren(themeGradientColors) {
            const themeGradient = computeGradient(gradientType || GradientType.normal, themeGradientColors);
            return React.createElement(WrappedComponent, Object.assign({ themeGradient: themeGradient }, this.props));
        }
    }
    WithGradient.displayName = `WithGradient(${WrappedComponent.displayName || WrappedComponent.name})`;
    return WithGradient;
};
//# sourceMappingURL=gradient.js.map