import { jsxs, jsx } from 'react/jsx-runtime';
import { forwardRef } from 'react';
import classNames from '../../_virtual/index.js';
import { checkEmpty } from '../../utils/checkEmpty/checkEmpty.js';
import Icon from '../Icon/Icon.js';
import Tooltip from '../Tooltip/Tooltip.js';

const Link = forwardRef(({ type = 'text', variant = 'primary', name = '', label, disabled = false, disableLinkIcon = false, required = false, placeholder = 'Attach Link', value, error, helperText, noBorder, className = '', onChange, onBlur, onFocus, autoComplete = 'off', autoFocus = false, minValue = -Infinity, maxValue = Infinity, transparentBackground = false, size = 'small', isLabelRequired = true, onClick, onKeyUp, isViewMode = false, ...props }, ref) => {
    const isValueFilled = !checkEmpty(value);
    const handleClickLink = () => {
        if (value && !error) {
            window.open(value, '_blank');
        }
    };
    return (jsxs("fieldset", { className: classNames('ff-link-input-fieldset', {
            'ff-link-input-fieldset--disabled': disabled,
        }), children: [jsxs("div", { className: classNames('ff-link-input-container', {
                    'ff-link-input-container--float': isValueFilled,
                    'ff-link-input-container--disabled': !!disabled,
                }), children: [isLabelRequired && (jsxs("label", { className: classNames(`ff-link-input-label-container ff-link-input-label-container--${size}`, {
                            'ff-link-input-label-container--danger': !!error,
                        }), htmlFor: name, children: [required && jsx("span", { className: "required-asterisk", children: "*" }), jsx("span", { className: classNames(`ff-link-input-label ff-link-input-label--${variant}`, {
                                    'ff-link-input-label--no-hover': !!value,
                                    'ff-link-input-label--disabled': !!disabled,
                                    'ff-link-input-label--danger': !!error,
                                }), children: label })] })), jsx("input", { ref: ref, name: name, value: value, type: type, spellCheck: false, id: name, className: classNames(`ff-link-input ff-link-input-${variant} default-input ff-link-input--${size}`, {
                            ['ff-link-input--transparentBackground']: !!transparentBackground,
                            'ff-link-input--no-hover': !!value,
                            'ff-link-input--disabled': !!disabled,
                            'ff-link-input--danger': !!error,
                            'ff-link-input--no-border': !!noBorder,
                            'ff-link-input--placeholder': !isLabelRequired,
                        }, `${className}`), placeholder: placeholder, disabled: isViewMode || disabled, onChange: onChange, onFocus: onFocus, onBlur: onBlur, autoComplete: autoComplete, autoFocus: autoFocus, min: minValue, max: maxValue, onClick: onClick, onKeyUp: onKeyUp, ...props }), jsx("div", { className: "input-link-icon", children: disableLinkIcon || error || !isValueFilled ? (jsx(Icon, { name: "link", disabled: true })) : (jsx(Tooltip, { title: "Click here to navigate", children: jsx("span", { children: jsx(Icon, { name: "link", disabled: false, onClick: handleClickLink }) }) })) })] }), helperText && error && (jsx("span", { className: classNames('ff-link-input-message', {
                    'ff-link-input-message--danger': !!error,
                }), children: helperText }))] }));
});

export { Link as default };
//# sourceMappingURL=Link.js.map
