// @ts-nocheck
import { __assign, __rest } from "tslib";
import './Text.css';
import React from 'react';
import { Link } from 'react-router-dom';
// eslint-disable-next-line import/no-named-default
import { default as parseFunc } from 'html-react-parser';
import { cn } from '../../../utils/bem';
import { forwardRefWithAs } from '../../../utils/types/PropsWithAsAttributes';
export var typographyPropAlign = ['left', 'center', 'right'];
export var typographyPropDisplay = ['block', 'inlineBlock', 'inline'];
export var typographyPropSize = ['m', 'xs', 's', 'l', 'xl'];
export var typographyPropSizeDefault = typographyPropSize[0];
export var typographyPropSpacing = ['xs', 's', 'm', 'l'];
export var typographyPropView = ['default', 'primary', 'alert', 'web'];
export var typographyPropViewDefault = typographyPropView[0];
export var typographyPropWeight = [
    'black',
    'bold',
    'light',
    'regular',
    'semibold',
    'thin',
];
export var typographyPropTransform = ['uppercase'];
export var cnText = cn('Text');
export var Text = forwardRefWithAs(function (props, ref) {
    var _a = props.as, as = _a === void 0 ? 'div' : _a, align = props.align, display = props.display, _b = props.size, size = _b === void 0 ? typographyPropSizeDefault : _b, spacing = props.spacing, transform = props.transform, _c = props.view, view = _c === void 0 ? typographyPropViewDefault : _c, weight = props.weight, className = props.className, children = props.children, nowrap = props.nowrap, parse = props.parse, otherProps = __rest(props, ["as", "align", "display", "size", "spacing", "transform", "view", "weight", "className", "children", "nowrap", "parse"]);
    var target = otherProps.target;
    var Tag = as;
    if (Tag === 'link') {
        return (React.createElement(Link, __assign({}, otherProps, { className: cnText({
                align: align,
                display: display,
                size: size,
                spacing: spacing,
                transform: transform,
                view: view,
                weight: weight,
                nowrap: nowrap
            }, [className]), ref: ref }), parse && typeof children === 'string' ? parseFunc(children) : children));
    }
    var componentProps = {
        rel: target === '_blank' ? 'noreferrer noopener' : undefined
    };
    return (React.createElement(Tag, __assign({}, otherProps, componentProps, { className: cnText({
            align: align,
            display: display,
            size: size,
            spacing: spacing,
            transform: transform,
            view: view,
            weight: weight,
            nowrap: nowrap
        }, [className]), ref: ref }), parse && typeof children === 'string' ? parseFunc(children) : children));
});
