import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Typography } from '../Typography';
import { ChipStatusIcon } from './ChipStatusIcon';
import { chipClassnames } from './constants';
import { AdornmentWrapper, HiddenInput, Label, StyledCounter, Wrapper, } from './styles';
import { useLogic } from './useLogic';
export const Chip = (props) => {
    const { classnames, inputProps, label, status, icon, counter, endAdornment, hasStartAdornment, hasEndAdornment, maxCount, } = useLogic(props);
    const renderStartAdornment = () => {
        if (status) {
            return _jsx(ChipStatusIcon, { status: status });
        }
        if (icon) {
            return icon;
        }
        return null;
    };
    const renderEndAdornment = () => {
        if (counter) {
            return (_jsx(StyledCounter, { color: "transparent", content: counter, max: maxCount, withBorder: false }));
        }
        if (endAdornment) {
            return endAdornment;
        }
        return null;
    };
    return (_jsxs(Label, { children: [_jsx(HiddenInput, { ...inputProps }), _jsxs(Wrapper, { className: classnames, children: [hasStartAdornment && (_jsx(AdornmentWrapper, { component: "span", className: chipClassnames.startAdornment, children: renderStartAdornment() })), _jsx(Typography, { className: chipClassnames.label, component: "span", children: label }), hasEndAdornment && (_jsx(AdornmentWrapper, { component: "span", className: chipClassnames.endAdornment, children: renderEndAdornment() }))] })] }));
};
