"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "handleItemError", {
    enumerable: true,
    get: function() {
        return handleItemError;
    }
});
const _CodeInputtokens = require("../CodeInput.tokens");
const _constants = require("../../../utils/constants");
const handleItemError = ({ currentSymbol, itemErrorBehavior, index, newCode, inputRefs, inputContainerRef, codeSetter })=>{
    if (!inputRefs.current[index] || currentSymbol === ' ') {
        return;
    }
    const circleElement = inputContainerRef.current?.querySelector(`.${_CodeInputtokens.classes.itemCircle}-${index}`);
    switch(itemErrorBehavior){
        case 'forbid-enter':
            newCode[index] = '';
            codeSetter(newCode);
            break;
        case 'remove-symbol':
        default:
            newCode[index] = '';
            codeSetter(newCode);
            if (circleElement) {
                circleElement.classList.add(_CodeInputtokens.classes.itemCircleError, _CodeInputtokens.classes.itemCircleErrorAnimation);
            }
            setTimeout(()=>{
                if (circleElement) {
                    circleElement.classList.remove(_CodeInputtokens.classes.itemCircleError, _CodeInputtokens.classes.itemCircleErrorAnimation);
                }
            }, _constants.ANIMATION_TIMEOUT);
    }
};
