"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: Object.getOwnPropertyDescriptor(all, name).get
    });
}
_export(exports, {
    get badgeConfig () {
        return badgeConfig;
    },
    get badgeRoot () {
        return badgeRoot;
    }
});
const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
const _constants = require("../../utils/constants");
const _classnames = /*#__PURE__*/ _interop_require_default(require("classnames"));
const _base = require("./variations/_view/base");
const _base1 = require("./variations/_size/base");
const _base2 = require("./variations/_pilled/base");
const _base3 = require("./variations/_transparent/base");
const _base4 = require("./variations/_clear/base");
const _Badgestyles = require("./Badge.styles");
const _Badgetokens = require("./Badge.tokens");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
function _getRequireWildcardCache(nodeInterop) {
    if (typeof WeakMap !== "function") return null;
    var cacheBabelInterop = new WeakMap();
    var cacheNodeInterop = new WeakMap();
    return (_getRequireWildcardCache = function(nodeInterop) {
        return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
    })(nodeInterop);
}
function _interop_require_wildcard(obj, nodeInterop) {
    if (!nodeInterop && obj && obj.__esModule) {
        return obj;
    }
    if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
        return {
            default: obj
        };
    }
    var cache = _getRequireWildcardCache(nodeInterop);
    if (cache && cache.has(obj)) {
        return cache.get(obj);
    }
    var newObj = {
        __proto__: null
    };
    var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for(var key in obj){
        if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
            var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
            if (desc && (desc.get || desc.set)) {
                Object.defineProperty(newObj, key, desc);
            } else {
                newObj[key] = obj[key];
            }
        }
    }
    newObj.default = obj;
    if (cache) {
        cache.set(obj, newObj);
    }
    return newObj;
}
const badgeRoot = (Root)=>/*#__PURE__*/ (0, _react.forwardRef)((props, ref)=>{
        const { children, className, style, text, contentLeft, contentRight, size, view, customColor, customBackgroundColor, pilled = false, transparent = false, clear = false, maxWidth = 'auto', ...rest } = props;
        const pilledClass = pilled ? _Badgetokens.classes.badgePilled : undefined;
        const transparentClass = transparent ? _Badgetokens.classes.badgeTransparent : undefined;
        const clearClass = clear ? _Badgetokens.classes.badgeClear : undefined;
        const truncateClass = maxWidth !== 'auto' ? _Badgetokens.classes.badgeTruncate : undefined;
        const txt = !text && typeof children === 'string' ? children : text;
        const iconOnlyClass = !txt && contentLeft ? _Badgetokens.classes.iconOnly : undefined;
        const BadgeContent = ()=>{
            if (contentLeft) {
                return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/ _react.default.createElement(_Badgestyles.StyledContentLeft, null, contentLeft), txt ? /*#__PURE__*/ _react.default.createElement(_Badgestyles.StyledContentMain, {
                    className: _constants.GRADIENT_TEXT_CLASS
                }, txt) : children);
            }
            return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, txt ? /*#__PURE__*/ _react.default.createElement(_Badgestyles.StyledContentMain, {
                className: _constants.GRADIENT_TEXT_CLASS
            }, txt) : children, contentRight && /*#__PURE__*/ _react.default.createElement(_Badgestyles.StyledContentRight, null, contentRight));
        };
        return /*#__PURE__*/ _react.default.createElement(Root, {
            ref: ref,
            className: (0, _classnames.default)(pilledClass, transparentClass, clearClass, truncateClass, iconOnlyClass, className, {}),
            view: view,
            size: size,
            pilled: pilled,
            transparent: transparent,
            clear: clear,
            style: {
                ...style,
                maxWidth,
                [_Badgetokens.privateTokens.customBackground]: customBackgroundColor,
                [_Badgetokens.privateTokens.customColor]: customColor
            },
            ...rest
        }, /*#__PURE__*/ _react.default.createElement(BadgeContent, null));
    });
const badgeConfig = {
    name: 'Badge',
    tag: 'div',
    layout: badgeRoot,
    base: _Badgestyles.base,
    variations: {
        view: {
            css: _base.base
        },
        size: {
            css: _base1.base
        },
        pilled: {
            css: _base2.base,
            attrs: true
        },
        transparent: {
            css: _base3.base,
            attrs: true
        },
        clear: {
            css: _base4.base,
            attrs: true
        }
    },
    defaults: {
        view: 'primary',
        size: 'm'
    }
};
