"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Color = require("color");
var find = require("lodash/find");
var get = require("lodash/get");
var isObject = require("lodash/isObject");
exports.lighten = function (color) {
    return Color(color)
        .fade(0.3)
        .string();
};
exports.darken = function (color) {
    return Color(color)
        .darken(0.2)
        .string();
};
exports.fade = function (color) {
    return Color(color)
        .fade(0.95)
        .string();
};
exports.blacken = function (color) {
    return Color(color)
        .darken(0.6)
        .string();
};
exports.normal = function (props) { return get(props.theme, 'weights.0'); };
exports.bold = function (props) { return get(props.theme, 'weights.1'); };
exports.px = function (n) { return (typeof n === 'number' ? n + 'px' : n); };
exports.randomString = function (length) {
    if (length === void 0) { length = 16; }
    var text = '';
    var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    for (var i = 0; i < length; i++) {
        text += possible.charAt(Math.floor(Math.random() * possible.length));
    }
    return text;
};
exports.stopEvent = function (e) {
    e.preventDefault();
    e.stopPropagation();
};
exports.getColorFromTheme = function (theme) { return function (colorString) {
    return get(theme, "colors." + colorString);
}; };
exports.getColoringType = function (props) {
    var type = find(Object.keys(props), function (b) { return !!props[b] && !!find(Object.keys(props.theme.colors), function (k) { return k === b; }); });
    return type;
};
exports.getColor = function (props, key, shade) {
    if (get(props, key)) {
        return get(props, key);
    }
    var type = exports.getColoringType(props);
    if (type) {
        var color = exports.getColorFromTheme(props.theme)(type);
        if (isObject(color)) {
            return color[shade];
        }
        else {
            return color;
        }
    }
};
exports.monospace = function (props) {
    return props.monospace ? { fontFamily: props.theme.monospace } : null;
};
