import { classes } from "../CodeInput.tokens";
import { ANIMATION_TIMEOUT } from "../../../utils/constants";
export var handleItemError = function handleItemError(param) {
    var currentSymbol = param.currentSymbol, itemErrorBehavior = param.itemErrorBehavior, index = param.index, newCode = param.newCode, inputRefs = param.inputRefs, inputContainerRef = param.inputContainerRef, codeSetter = param.codeSetter;
    var _inputContainerRef_current;
    if (!inputRefs.current[index] || currentSymbol === ' ') {
        return;
    }
    var circleElement = (_inputContainerRef_current = inputContainerRef.current) === null || _inputContainerRef_current === void 0 ? void 0 : _inputContainerRef_current.querySelector(".".concat(classes.itemCircle, "-").concat(index));
    switch(itemErrorBehavior){
        case 'forbid-enter':
            newCode[index] = '';
            codeSetter(newCode);
            break;
        case 'remove-symbol':
        default:
            newCode[index] = '';
            codeSetter(newCode);
            if (circleElement) {
                circleElement.classList.add(classes.itemCircleError, classes.itemCircleErrorAnimation);
            }
            setTimeout(function() {
                if (circleElement) {
                    circleElement.classList.remove(classes.itemCircleError, classes.itemCircleErrorAnimation);
                }
            }, ANIMATION_TIMEOUT);
    }
};
