/*!
 * KoliBri - The accessible HTML-Standard
 */
import { getMsgType } from "../../schema";
import { createRelatedUniqueId } from "../../utils/dev.utils";
export const getRenderStates = (state) => {
    const msg = state._msg;
    const description = typeof msg === 'string' ? msg : msg === null || msg === void 0 ? void 0 : msg._description;
    const type = getMsgType(msg);
    const hasMessage = Boolean(description && description.length > 0);
    const isMessageValidError = type === 'error' && hasMessage;
    const hasError = isMessageValidError && state._touched === true;
    const hasHint = typeof state._hint === 'string' && state._hint.length > 0;
    const ariaDescribedBy = [];
    if (hasMessage && !state._hideMsg) {
        ariaDescribedBy.push(createRelatedUniqueId(state._id, 'msg'));
    }
    if (hasHint === true) {
        ariaDescribedBy.push(createRelatedUniqueId(state._id, 'hint'));
    }
    if (state._hasCounter) {
        ariaDescribedBy.push(createRelatedUniqueId(state._id, 'counter'));
    }
    if (hasError === true) {
        ariaDescribedBy.push(createRelatedUniqueId(state._id, 'error'));
    }
    return { hasError, hasHint, ariaDescribedBy };
};
//# sourceMappingURL=getRenderStates.js.map
