/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.0.0-canary-032998c
 * Released under the MIT license.
 */

import { jsx as _jsx } from "react/jsx-runtime";
import { forwardRef, } from 'react';
import { BASE_STYLES, COLOR_STYLES, extractStyles, filterBaseProps, tasty, TEXT_STYLES, } from '../../tasty/index.js';
import { useSlotProps } from '../../utils/react/index.js';
const STYLE_LIST = [...BASE_STYLES, ...TEXT_STYLES, ...COLOR_STYLES];
export const TEXT_PROP_MAP = {
    transform: 'textTransform',
    weight: 'fontWeight',
    italic: 'fontStyle',
};
const TextElement = tasty({
    qa: 'Text',
    as: 'span',
    styles: {
        display: {
            '': 'inline',
            'ellipsis | block': 'block',
        },
        margin: 0,
        padding: 0,
        whiteSpace: {
            '': 'inherit',
            'nowrap | ellipsis': 'nowrap',
        },
        textOverflow: {
            '': false,
            ellipsis: 'ellipsis',
        },
        overflow: {
            '': false,
            ellipsis: 'hidden',
        },
        width: {
            '': false,
            ellipsis: 'max 100%',
        },
    },
});
const Text = forwardRef(function CubeText(allProps, ref) {
    allProps = useSlotProps(allProps, 'text');
    const { as, qa, block, ellipsis, nowrap, ...props } = allProps;
    const styles = extractStyles(props, STYLE_LIST, {}, TEXT_PROP_MAP);
    return (_jsx(TextElement, { as: as || 'span', qa: qa || 'Text', mods: {
            nowrap,
            ellipsis: !!ellipsis,
            block: !!block,
        }, ...filterBaseProps(props, { eventProps: true }), ref: ref, styles: styles }));
});
const MinorText = tasty(Text, {
    styles: {
        color: '#minor',
    },
});
const DangerText = tasty(Text, {
    role: 'alert',
    styles: {
        color: '#danger-text',
    },
});
const SuccessText = tasty(Text, {
    styles: {
        color: '#success-text',
    },
});
const StrongText = tasty(Text, {
    as: 'strong',
    preset: 'strong',
});
const EmphasisText = tasty(Text, {
    as: 'em',
    preset: 'em',
});
const PlaceholderText = tasty(Text, {
    styles: {
        color: '#current.5',
    },
});
const HighlightText = tasty(Text, {
    as: 'mark',
    styles: {
        fill: '#dark.15',
        color: '#dark',
    },
});
const _Text = Object.assign(Text, {
    Minor: MinorText,
    Danger: DangerText,
    Success: SuccessText,
    Strong: StrongText,
    Emphasis: EmphasisText,
    Placeholder: PlaceholderText,
    Highlight: HighlightText,
});
_Text.displayName = 'Text';
export { _Text as Text };

        