import './TextField_3e2yx.css';
import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
import React__default, { forwardRef, useRef, useState, useEffect, useLayoutEffect } from 'react';
import { cx } from '../../utils/index.js';
import { base as base$2 } from './variations/_size/base.js';
import { base as base$1 } from './variations/_view/base.js';
import { base as base$3 } from './variations/_disabled/base.js';
import { base as base$4 } from './variations/_read-only/base.js';
import { base as base$5 } from './variations/_label-placement/base.js';
import { base as base$6 } from './variations/_hint-view/base.js';
import { base as base$7 } from './variations/_hint-size/base.js';
import { base as base$8 } from './variations/_chip-view/base.js';
import { OuterLabelWrapper, StyledIndicatorWrapper, Label, StyledHintWrapper, StyledIndicator, TitleCaption, InputWrapper, StyledContentLeft, InputLabelWrapper, StyledTextBefore, StyledChips, InputContainer, Input, InputPlaceholderValue, InputPlaceholder, StyledTextAfter, StyledContentRightWrapper, StyledContentRight, StyledHelpers, StyledLeftHelper, StyledRightHelper, StyledOptionalText } from './TextField.styles.js';
import { classes } from './TextField.tokens.js';
import { HintComponent } from './ui/Hint/Hint.js';
import { getInputWidth } from './getInputWidth.js';
import { useForkRef } from '../../hooks/useForkRef.js';
import { safeUseId } from '../../utils/react.js';
import { useOutsideClick } from '../../hooks/useOutsideClick.js';
import { useKeyNavigation } from './hooks/useKeyNavigation.js';
import { TextFieldChipNew } from './ui/TextFieldChipNew/TextFieldChipNew.js';
import { TextFieldChip } from './ui/TextFieldChip/TextFieldChip.js';

var _excluded = ["id", "className", "style", "contentLeft", "contentRight", "label", "labelPlacement", "keepPlaceholder", "textBefore", "textAfter", "placeholder", "leftHelper", "rightHelper", "enumerationType", "requiredPlacement", "hasRequiredIndicator", "titleCaption", "chipView", "chipValidator", "hintTrigger", "hintText", "hintView", "hintSize", "hintTargetIcon", "hintTargetPlacement", "hintPlacement", "hintHasArrow", "hintOffset", "hintWidth", "hintContentLeft", "hintPortal", "appearance", "view", "size", "readOnly", "disabled", "required", "clear", "optional", "optionalText", "hasDivider", "value", "chips", "chipType", "_chips", "_chipClickArea", "_onChipCloseClick", "onChange", "onChangeChips", "onSearch", "onKeyDown", "onFocus", "onBlur", "onPaste", "onScroll", "_onEnterDisabled", "_forceChipManipulationWithReadonly", "_interaction_disabled"];
var base = "b1hj3vpd";
var HINT_DEFAULT_OFFSET = [0, 0];
var textFieldRoot = function textFieldRoot(Root) {
  return /*#__PURE__*/forwardRef(function (_ref, ref) {
    var _inputRef$current, _inputRef$current4;
    var id = _ref.id,
      className = _ref.className,
      style = _ref.style,
      contentLeft = _ref.contentLeft,
      contentRight = _ref.contentRight,
      label = _ref.label,
      labelPlacement = _ref.labelPlacement,
      keepPlaceholder = _ref.keepPlaceholder,
      textBefore = _ref.textBefore,
      textAfter = _ref.textAfter,
      placeholder = _ref.placeholder,
      leftHelper = _ref.leftHelper,
      rightHelper = _ref.rightHelper,
      _ref$enumerationType = _ref.enumerationType,
      enumerationType = _ref$enumerationType === void 0 ? 'plain' : _ref$enumerationType,
      _ref$requiredPlacemen = _ref.requiredPlacement,
      requiredPlacement = _ref$requiredPlacemen === void 0 ? 'right' : _ref$requiredPlacemen,
      _ref$hasRequiredIndic = _ref.hasRequiredIndicator,
      hasRequiredIndicator = _ref$hasRequiredIndic === void 0 ? false : _ref$hasRequiredIndic,
      titleCaption = _ref.titleCaption,
      _ref$chipView = _ref.chipView,
      chipView = _ref$chipView === void 0 ? 'default' : _ref$chipView,
      chipValidator = _ref.chipValidator,
      _ref$hintTrigger = _ref.hintTrigger,
      hintTrigger = _ref$hintTrigger === void 0 ? 'hover' : _ref$hintTrigger,
      hintText = _ref.hintText,
      _ref$hintView = _ref.hintView,
      hintView = _ref$hintView === void 0 ? 'default' : _ref$hintView,
      _ref$hintSize = _ref.hintSize,
      hintSize = _ref$hintSize === void 0 ? 'm' : _ref$hintSize,
      hintTargetIcon = _ref.hintTargetIcon,
      _ref$hintTargetPlacem = _ref.hintTargetPlacement,
      hintTargetPlacement = _ref$hintTargetPlacem === void 0 ? 'outer' : _ref$hintTargetPlacem,
      _ref$hintPlacement = _ref.hintPlacement,
      hintPlacement = _ref$hintPlacement === void 0 ? 'auto' : _ref$hintPlacement,
      hintHasArrow = _ref.hintHasArrow,
      _ref$hintOffset = _ref.hintOffset,
      hintOffset = _ref$hintOffset === void 0 ? HINT_DEFAULT_OFFSET : _ref$hintOffset,
      hintWidth = _ref.hintWidth,
      hintContentLeft = _ref.hintContentLeft,
      hintPortal = _ref.hintPortal,
      appearance = _ref.appearance,
      view = _ref.view,
      size = _ref.size,
      _ref$readOnly = _ref.readOnly,
      readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
      _ref$disabled = _ref.disabled,
      disabled = _ref$disabled === void 0 ? false : _ref$disabled,
      _ref$required = _ref.required,
      required = _ref$required === void 0 ? false : _ref$required,
      _ref$clear = _ref.clear,
      clear = _ref$clear === void 0 ? false : _ref$clear,
      optional = _ref.optional,
      _ref$optionalText = _ref.optionalText,
      optionalText = _ref$optionalText === void 0 ? 'optional' : _ref$optionalText,
      hasDivider = _ref.hasDivider,
      outerValue = _ref.value,
      values = _ref.chips,
      _ref$chipType = _ref.chipType,
      chipType = _ref$chipType === void 0 ? 'default' : _ref$chipType,
      _chips = _ref._chips,
      _chipClickArea = _ref._chipClickArea,
      _onChipCloseClick = _ref._onChipCloseClick,
      onChange = _ref.onChange,
      onChangeChips = _ref.onChangeChips,
      onSearch = _ref.onSearch,
      onKeyDown = _ref.onKeyDown,
      onFocus = _ref.onFocus,
      onBlur = _ref.onBlur,
      onPaste = _ref.onPaste,
      onScroll = _ref.onScroll,
      _onEnterDisabled = _ref._onEnterDisabled,
      _forceChipManipulationWithReadonly = _ref._forceChipManipulationWithReadonly,
      _ref$_interaction_dis = _ref._interaction_disabled,
      _interaction_disabled = _ref$_interaction_dis === void 0 ? false : _ref$_interaction_dis,
      rest = _objectWithoutProperties(_ref, _excluded);
    var contentRef = useRef(null);
    var inputContainerRef = useRef(null);
    var inputRef = useRef(null);
    var inputForkRef = useForkRef(inputRef, ref);
    var chipsRefs = useRef([]);
    var hintRef = useRef(null);
    var controlledRefs = {
      contentRef: contentRef,
      inputRef: inputRef,
      chipsRefs: chipsRefs
    };
    var _useState = useState(Boolean(outerValue) || Boolean(inputRef === null || inputRef === void 0 || (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.value) || Boolean(rest === null || rest === void 0 ? void 0 : rest.defaultValue)),
      _useState2 = _slicedToArray(_useState, 2),
      hasValue = _useState2[0],
      setHasValue = _useState2[1];
    var _useState3 = useState(false),
      _useState4 = _slicedToArray(_useState3, 2),
      hasFocus = _useState4[0],
      setHasFocus = _useState4[1];
    var _useState5 = useState([]),
      _useState6 = _slicedToArray(_useState5, 2),
      chips = _useState6[0],
      setChips = _useState6[1];
    var _useState7 = useState(false),
      _useState8 = _slicedToArray(_useState7, 2),
      isHintVisible = _useState8[0],
      setIsHintVisible = _useState8[1];
    var uniqId = safeUseId();
    var innerId = id || uniqId;
    var labelId = safeUseId();
    var helperTextId = safeUseId();
    var isChipEnumeration = enumerationType === 'chip';
    var isChipsVisible = isChipEnumeration && Boolean((chips === null || chips === void 0 ? void 0 : chips.length) || (_chips === null || _chips === void 0 ? void 0 : _chips.length));
    var withHasChips = isChipsVisible ? classes.hasChips : undefined;
    var hasLabelValue = Boolean(label);
    var hasInnerLabel = size !== 'xs' && labelPlacement === 'inner' && !isChipsVisible && hasLabelValue;
    var hasOuterLabel = labelPlacement === 'outer' && hasLabelValue;
    var innerKeepPlaceholder = keepPlaceholder && labelPlacement === 'inner';
    var hasPlaceholder = Boolean(placeholder) && (innerKeepPlaceholder || !hasInnerLabel);
    var hasTextAfter = Boolean(textAfter);
    var hasTextBefore = textBefore && !isChipEnumeration;
    if (labelPlacement === 'inner') {
      if (!hasValue && !hasPlaceholder && !hasFocus) {
        hasTextAfter = false;
        hasTextBefore = false;
      }
    }
    var hasPlaceholderPadding = hasInnerLabel && keepPlaceholder && size !== 'xs';
    var innerLabelValue = hasInnerLabel || hasOuterLabel ? label : undefined;
    var innerLabelPlacementValue = labelPlacement === 'inner' && !hasInnerLabel ? undefined : labelPlacement;
    var innerPlaceholderValue = hasPlaceholder ? placeholder : undefined;
    var placeholderShown = Boolean(innerPlaceholderValue) && !hasValue;
    var clearClass = clear || appearance === 'clear' ? classes.clear : undefined;
    var hasDividerClass = hasDivider ? classes.hasDivider : undefined;
    var hasInnerHintClass = hintText && hintTargetPlacement === 'outer' ? classes.hasHint : undefined;
    var hasHintClass = hintText ? classes.hasHint : undefined;
    var requiredPlacementClass = requiredPlacement === 'right' ? classes.requiredAlignRight : undefined;
    var labelPlacementClass = innerLabelPlacementValue ? classes["".concat(innerLabelPlacementValue, "LabelPlacement")] : undefined;
    var hasValueClass = hasValue ? classes.hasValue : undefined;
    var keepPlaceholderClass = hasPlaceholder && placeholderShown && classes.keepPlaceholder;
    var wrapperWithoutLeftContent = !contentLeft && isChipsVisible && chipType === 'default' ? classes.hasEmptyContentLeft : undefined;
    var wrapperWithoutRightContent = !contentRight && isChipsVisible && chipType === 'default' ? classes.hasEmptyContentRight : undefined;
    var contentRightCompensationMargin = !hasOuterLabel && hintText && hintTargetPlacement === 'inner' ? classes.contentRightCompensationMargin : undefined;
    useOutsideClick(function () {
      setIsHintVisible(false);
    }, [hintRef]);
    var hintInnerRef = useRef(null);
    var hintForkRef = useForkRef(hintRef, hintInnerRef);
    var handleInput = function handleInput(event) {
      var _ref2 = event.target,
        value = _ref2.value;
      setHasValue(Boolean(value));
    };
    var handleFocus = function handleFocus(event) {
      setHasFocus(true);
      onFocus === null || onFocus === void 0 || onFocus(event);
    };
    var handleBlur = function handleBlur(event) {
      setHasFocus(false);
      event.currentTarget.scrollLeft = 0;
      onBlur === null || onBlur === void 0 || onBlur(event);
    };
    var handleHintShow = function handleHintShow() {
      return setIsHintVisible(true);
    };
    var handleHintHide = function handleHintHide() {
      return setIsHintVisible(false);
    };
    var handleHintClick = function handleHintClick(event) {
      var _hintInnerRef$current;
      if (!hintText || hintTrigger !== 'click') {
        return;
      }
      event.stopPropagation();
      var targetIsPopover = event.target === hintInnerRef.current;
      var rootHasTarget = (_hintInnerRef$current = hintInnerRef.current) === null || _hintInnerRef$current === void 0 ? void 0 : _hintInnerRef$current.contains(event.target);
      if (!targetIsPopover && !rootHasTarget) {
        setIsHintVisible(true);
      }
    };
    var handleChange = function handleChange(event) {
      if (disabled || readOnly || _interaction_disabled) {
        return;
      }
      var _event$target = event.target,
        maxLength = _event$target.maxLength,
        value = _event$target.value;
      if (maxLength !== -1 && value.length > maxLength) {
        return;
      }
      if (onChange) {
        onChange(event);
      }
      if (hasTextAfter) {
        var textWidth = getInputWidth(event.currentTarget, inputContainerRef.current);
        event.currentTarget.style.width = "".concat(textWidth, "px");
      }
    };
    var handlePaste = function handlePaste(event) {
      if (disabled || readOnly || _interaction_disabled) {
        return;
      }
      if (onPaste) {
        onPaste(event);
      }
      if (hasTextAfter) {
        setTimeout(function () {
          if (!inputRef.current) {
            return;
          }
          var textWidth = getInputWidth(inputRef.current, inputContainerRef.current);
          inputRef.current.style.width = "".concat(textWidth, "px");
        });
      }
    };
    var handleScroll = function handleScroll(e) {
      if (!hasFocus && e !== null && e !== void 0 && e.currentTarget) {
        e.currentTarget.scrollLeft = 0;
      }
      if (onScroll) {
        onScroll(e);
      }
    };
    var updateChips = function updateChips(newChips, newValues) {
      setChips(newChips);
      onChangeChips === null || onChangeChips === void 0 || onChangeChips(newValues);
    };
    var _useKeyNavigation = useKeyNavigation({
        controlledRefs: controlledRefs,
        disabled: disabled,
        readOnly: readOnly,
        chips: chips,
        newCustomChips: _chips,
        enumerationType: enumerationType,
        updateChips: updateChips,
        onSearch: onSearch,
        onChange: onChange,
        onEnterDisabled: _onEnterDisabled,
        onChipCloseClick: _onChipCloseClick,
        _interaction_disabled: _interaction_disabled
      }),
      handleInputKeydown = _useKeyNavigation.handleInputKeydown,
      handleChipKeyDown = _useKeyNavigation.handleChipKeyDown,
      onChipClear = _useKeyNavigation.onChipClear,
      handleContentKeyDown = _useKeyNavigation.handleContentKeyDown;
    var onChipClick = function onChipClick(event) {
      return event.stopPropagation();
    };
    var handleInputFocus = function handleInputFocus() {
      if (readOnly || disabled || !(inputRef !== null && inputRef !== void 0 && inputRef.current) || _interaction_disabled) {
        return;
      }
      inputRef.current.focus();
    };
    var getRef = function getRef(element, index) {
      if (element && chipsRefs !== null && chipsRefs !== void 0 && chipsRefs.current) {
        chipsRefs.current[index] = element;
      }
    };
    var handleOnKeyDown = function handleOnKeyDown(event) {
      handleInputKeydown(event);
      if (onKeyDown) {
        onKeyDown(event);
      }
    };
    useEffect(function () {
      if (hasTextAfter && inputRef.current) {
        var textWidth = getInputWidth(inputRef.current, inputContainerRef.current);
        inputRef.current.style.width = "".concat(textWidth, "px");
      } else {
        var _inputRef$current2;
        (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 || _inputRef$current2.style.removeProperty('width');
      }
    }, [hasTextAfter, outerValue]);
    useEffect(function () {
      if (!isChipEnumeration && !(values !== null && values !== void 0 && values.length)) {
        return;
      }
      var newChips = (values === null || values === void 0 ? void 0 : values.map(function (value, index) {
        return {
          id: "".concat(index, "_").concat(value),
          text: value
        };
      })) || [];
      setChips(newChips);
    }, [isChipEnumeration, values]);
    useEffect(function () {
      setHasValue(Boolean(rest === null || rest === void 0 ? void 0 : rest.defaultValue));
    }, [rest.defaultValue]);
    useEffect(function () {
      var _inputRef$current3;
      setHasValue(Boolean(outerValue) || Boolean(inputRef === null || inputRef === void 0 || (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : _inputRef$current3.value));
    }, [outerValue, inputRef === null || inputRef === void 0 || (_inputRef$current4 = inputRef.current) === null || _inputRef$current4 === void 0 ? void 0 : _inputRef$current4.value]);
    useLayoutEffect(function () {
      if (!hasFocus && inputRef.current) {
        inputRef.current.scrollLeft = 0;
      }
    }, [hasFocus]);
    var innerOptional = Boolean(required ? false : optional);
    var hasPlaceholderOptional = innerOptional && !innerLabelValue && !hasOuterLabel;
    var optionalTextNode = innerOptional ? /*#__PURE__*/React__default.createElement(StyledOptionalText, null, Boolean(hasPlaceholderOptional ? innerPlaceholderValue : innerLabelValue) && '\xa0', optionalText) : null;
    var classTextEllipsis =
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    // eslint-disable-next-line no-underscore-dangle
    !rest._textEllipsisDisable && !textAfter && !hasFocus ? classes.inputTextEllipsis : undefined;
    return /*#__PURE__*/React__default.createElement(Root, _extends({
      view: view,
      size: size,
      disabled: disabled,
      readOnly: !disabled && readOnly,
      labelPlacement: innerLabelPlacementValue,
      onClick: handleInputFocus,
      "data-root": true,
      className: cx(labelPlacementClass, clearClass, hasDividerClass, hasInnerHintClass, classes.textFieldGroupItem, className),
      style: style
    }, hintText && {
      hintView: hintView,
      hintSize: hintSize
    }), (hasOuterLabel || titleCaption) && /*#__PURE__*/React__default.createElement(OuterLabelWrapper, {
      isInnerLabel: labelPlacement === 'inner'
    }, hasOuterLabel && /*#__PURE__*/React__default.createElement(StyledIndicatorWrapper, null, /*#__PURE__*/React__default.createElement(Label, {
      id: labelId,
      htmlFor: id
    }, innerLabelValue), hintText && /*#__PURE__*/React__default.createElement(StyledHintWrapper, null, /*#__PURE__*/React__default.createElement(HintComponent, {
      ref: hintForkRef,
      hintText: hintText,
      hintTrigger: hintTrigger,
      isHintVisible: isHintVisible,
      hintTargetIcon: hintTargetIcon,
      hintPlacement: hintPlacement,
      hintHasArrow: hintHasArrow,
      hintOffset: hintOffset,
      hintWidth: hintWidth,
      hintPortal: hintPortal,
      hintContentLeft: hintContentLeft,
      handleHintShow: handleHintShow,
      handleHintHide: handleHintHide,
      handleHintClick: handleHintClick
    })), required && hasRequiredIndicator && /*#__PURE__*/React__default.createElement(StyledIndicator, {
      className: cx(classes.outerLabelPlacement, requiredPlacementClass, hasHintClass)
    }), optionalTextNode), titleCaption && /*#__PURE__*/React__default.createElement(TitleCaption, {
      "data-root": true
    }, titleCaption)), /*#__PURE__*/React__default.createElement(InputWrapper
    // Ref для внутреннего использования. Не отдается наружу.
    , {
      ref: rest.inputWrapperRef,
      className: cx(withHasChips, wrapperWithoutLeftContent, wrapperWithoutRightContent, classes.inputWrapper)
    }, !hasOuterLabel && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, required && hasRequiredIndicator && /*#__PURE__*/React__default.createElement(StyledIndicator, {
      className: cx(classes.innerLabelPlacement, requiredPlacementClass)
    }), hintText && hintTargetPlacement === 'outer' && /*#__PURE__*/React__default.createElement(StyledHintWrapper, {
      className: classes.innerLabelPlacement
    }, /*#__PURE__*/React__default.createElement(HintComponent, {
      ref: hintForkRef,
      hintText: hintText,
      hintTrigger: hintTrigger,
      isHintVisible: isHintVisible,
      hintTargetIcon: hintTargetIcon,
      hintPlacement: hintPlacement,
      hintHasArrow: hintHasArrow,
      hintOffset: hintOffset,
      hintWidth: hintWidth,
      hintPortal: hintPortal,
      hintContentLeft: hintContentLeft,
      size: size,
      handleHintShow: handleHintShow,
      handleHintHide: handleHintHide,
      handleHintClick: handleHintClick,
      isInnerLabel: true
    }))), contentLeft && /*#__PURE__*/React__default.createElement(StyledContentLeft, {
      "data-root": true
    }, contentLeft), /*#__PURE__*/React__default.createElement(InputLabelWrapper, {
      tabIndex: -1,
      ref: contentRef,
      onKeyDown: handleContentKeyDown,
      className: cx(withHasChips, classes.inputScrollableWrapper)
    }, Boolean(textBefore && isChipEnumeration) && /*#__PURE__*/React__default.createElement(StyledTextBefore, null, textBefore), Boolean(_chips === null || _chips === void 0 ? void 0 : _chips.length) && /*#__PURE__*/React__default.createElement(TextFieldChipNew, {
      chips: _chips,
      getRef: getRef,
      handleChipKeyDown: handleChipKeyDown,
      onChipClear: onChipClear,
      onChipCloseClick: _onChipCloseClick,
      chipClickArea: _chipClickArea,
      view: chipView || view,
      readOnly: readOnly,
      chipType: chipType
      // TODO: #1547
      // @ts-ignore
      ,
      _forceChipManipulationWithReadonly: _forceChipManipulationWithReadonly
    }), isChipEnumeration && Boolean(chips === null || chips === void 0 ? void 0 : chips.length) && /*#__PURE__*/React__default.createElement(StyledChips, {
      className: classes.chipsWrapper
    }, chips === null || chips === void 0 ? void 0 : chips.map(function (_ref3, index) {
      var chipId = _ref3.id,
        text = _ref3.text;
      var validationView = chipValidator === null || chipValidator === void 0 ? void 0 : chipValidator(String(text));
      var resView = (validationView === null || validationView === void 0 ? void 0 : validationView.view) || chipView;
      return /*#__PURE__*/React__default.createElement(TextFieldChip, {
        id: chipId,
        ref: function ref(element) {
          return getRef(element, index);
        },
        key: "".concat(chipId, "_").concat(index),
        disabled: disabled,
        readOnly: readOnly,
        value: text,
        text: text,
        onKeyDown: function onKeyDown(event) {
          return handleChipKeyDown(event, chipId, index);
        },
        onClear: function onClear() {
          return onChipClear(chipId, index);
        },
        onClick: onChipClick,
        chipType: chipType,
        view: resView,
        rootWrapper: Root
        // TODO: #1547
        // @ts-ignore
        ,
        _forceChipManipulationWithReadonly: _forceChipManipulationWithReadonly
      });
    })), /*#__PURE__*/React__default.createElement(InputContainer, {
      ref: inputContainerRef,
      hasDynamicWidth: hasTextAfter
    }, hasTextBefore && /*#__PURE__*/React__default.createElement(StyledTextBefore, null, textBefore), /*#__PURE__*/React__default.createElement(Input, _extends({
      ref: inputForkRef,
      id: innerId,
      value: outerValue,
      required: enumerationType === 'chip' ? chips.length === 0 && required : required,
      "aria-labelledby": labelId,
      "aria-describedby": helperTextId,
      placeholder: innerPlaceholderValue,
      hasFocus: hasFocus,
      className: cx(hasValueClass, keepPlaceholderClass, classTextEllipsis, readOnly && classes.readOnlyInput),
      disabled: disabled,
      readOnly: !disabled && (readOnly || _interaction_disabled),
      onInput: handleInput,
      onChange: handleChange,
      onKeyDown: handleOnKeyDown,
      onFocus: handleFocus,
      onBlur: handleBlur,
      onPaste: handlePaste,
      onScroll: handleScroll
    }, rest)), hasInnerLabel && /*#__PURE__*/React__default.createElement(Label, {
      "data-root": true,
      id: labelId,
      htmlFor: innerId
    }, /*#__PURE__*/React__default.createElement(InputPlaceholderValue, {
      className: cx(classTextEllipsis)
    }, innerLabelValue), optionalTextNode), placeholderShown && !hasValue && /*#__PURE__*/React__default.createElement(InputPlaceholder, {
      hasPadding: hasPlaceholderPadding
    }, hasTextBefore && /*#__PURE__*/React__default.createElement(StyledTextBefore, {
      isHidden: true
    }, textBefore), innerPlaceholderValue && /*#__PURE__*/React__default.createElement(InputPlaceholderValue, {
      className: cx(classTextEllipsis)
    }, innerPlaceholderValue), hasPlaceholderOptional && optionalTextNode), hasTextAfter && /*#__PURE__*/React__default.createElement(StyledTextAfter, null, textAfter))), /*#__PURE__*/React__default.createElement(StyledContentRightWrapper, {
      className: cx(contentRightCompensationMargin)
    }, contentRight && /*#__PURE__*/React__default.createElement(StyledContentRight, {
      "data-root": true
    }, contentRight), !hasOuterLabel && hintText && hintTargetPlacement === 'inner' && /*#__PURE__*/React__default.createElement(HintComponent, {
      ref: hintForkRef,
      hintText: hintText,
      hintTrigger: hintTrigger,
      isHintVisible: isHintVisible,
      hintTargetIcon: hintTargetIcon,
      hintPlacement: hintPlacement,
      hintHasArrow: hintHasArrow,
      hintOffset: hintOffset,
      hintWidth: hintWidth,
      hintPortal: hintPortal,
      hintContentLeft: hintContentLeft,
      size: size,
      handleHintShow: handleHintShow,
      handleHintHide: handleHintHide,
      handleHintClick: handleHintClick,
      isInnerLabel: true
    }))), (leftHelper || rightHelper) && /*#__PURE__*/React__default.createElement(StyledHelpers, {
      id: helperTextId,
      className: hasFocus ? classes.hasFocus : undefined
    }, leftHelper && /*#__PURE__*/React__default.createElement(StyledLeftHelper, {
      "data-root": true
    }, leftHelper), rightHelper && /*#__PURE__*/React__default.createElement(StyledRightHelper, {
      "data-root": true
    }, rightHelper)));
  });
};
var textFieldConfig = {
  name: 'TextField',
  tag: 'div',
  layout: textFieldRoot,
  base: base,
  variations: {
    view: {
      css: base$1
    },
    size: {
      css: base$2
    },
    disabled: {
      css: base$3,
      attrs: true
    },
    readOnly: {
      css: base$4,
      attrs: true
    },
    labelPlacement: {
      css: base$5
    },
    hintView: {
      css: base$6
    },
    hintSize: {
      css: base$7
    },
    chipView: {
      css: base$8
    }
  },
  defaults: {
    size: 'm',
    view: 'default'
  }
};

export { base, textFieldConfig, textFieldRoot };
