function _define_property(obj, key, value) {
    if (key in obj) {
        Object.defineProperty(obj, key, {
            value: value,
            enumerable: true,
            configurable: true,
            writable: true
        });
    } else {
        obj[key] = value;
    }
    return obj;
}
function _object_spread(target) {
    for(var i = 1; i < arguments.length; i++){
        var source = arguments[i] != null ? arguments[i] : {};
        var ownKeys = Object.keys(source);
        if (typeof Object.getOwnPropertySymbols === "function") {
            ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
                return Object.getOwnPropertyDescriptor(source, sym).enumerable;
            }));
        }
        ownKeys.forEach(function(key) {
            _define_property(target, key, source[key]);
        });
    }
    return target;
}
function ownKeys(object, enumerableOnly) {
    var keys = Object.keys(object);
    if (Object.getOwnPropertySymbols) {
        var symbols = Object.getOwnPropertySymbols(object);
        if (enumerableOnly) {
            symbols = symbols.filter(function(sym) {
                return Object.getOwnPropertyDescriptor(object, sym).enumerable;
            });
        }
        keys.push.apply(keys, symbols);
    }
    return keys;
}
function _object_spread_props(target, source) {
    source = source != null ? source : {};
    if (Object.getOwnPropertyDescriptors) {
        Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
    } else {
        ownKeys(Object(source)).forEach(function(key) {
            Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
        });
    }
    return target;
}
function _object_without_properties(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys, key, i;
    if (typeof Reflect !== "undefined" && Reflect.ownKeys) {
        sourceKeys = Reflect.ownKeys(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
        return target;
    }
    target = _object_without_properties_loose(source, excluded);
    if (Object.getOwnPropertySymbols) {
        sourceKeys = Object.getOwnPropertySymbols(source);
        for(i = 0; i < sourceKeys.length; i++){
            key = sourceKeys[i];
            if (excluded.indexOf(key) >= 0) continue;
            if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
            target[key] = source[key];
        }
    }
    return target;
}
function _object_without_properties_loose(source, excluded) {
    if (source == null) return {};
    var target = {}, sourceKeys = Object.getOwnPropertyNames(source), key, i;
    for(i = 0; i < sourceKeys.length; i++){
        key = sourceKeys[i];
        if (excluded.indexOf(key) >= 0) continue;
        if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
        target[key] = source[key];
    }
    return target;
}
import React from "react";
import styled from "styled-components";
import cls from "classnames";
import { applySkeletonPulseGradient, applySkeletonShimmerGradient, getSkeletonColor } from "../../../mixins";
import { classes, tokens } from "../tokens";
/**
 * Делает компонент скелетоном - у него заменяется фоновый цвет,
 * добавляется градиент и текст становится на 100% прозрачным.
 */ export var withSkeleton = function withSkeleton(Component) {
    return function(_0) {
        var skeleton = _0.skeleton, _0_animationType = _0.animationType, animationType = _0_animationType === void 0 ? 'shimmer' : _0_animationType, className = _0.className, props = _object_without_properties(_0, [
            "skeleton",
            "animationType",
            "className"
        ]);
        var animationClass = classes["".concat(animationType, "Animation")];
        var skeletonClass = skeleton ? 'apply-skeleton-gradient' : undefined;
        var skeletonGradientColor = getSkeletonColor({
            lighter: true
        });
        var Wrapper = styled.div.withConfig({
            displayName: "withSkeleton__Wrapper",
            componentId: "sc-e07f95f9-0"
        })([
            "display:contents;.apply-skeleton-gradient{&.",
            "{",
            ";}&.",
            "{",
            ";}}"
        ], classes.shimmerAnimation, applySkeletonShimmerGradient(skeletonGradientColor), classes.pulseAnimation, applySkeletonPulseGradient(tokens.fadeInColor, tokens.fadeOutColor));
        var componentProps = _object_spread_props(_object_spread({}, props), {
            className: cls(skeletonClass, animationClass, className)
        });
        return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(Wrapper, null, /*#__PURE__*/ React.createElement(Component, componentProps)));
    };
};
