/*!
 * KoliBri - The accessible HTML-Standard
 */
import { a as watchValidator, q as a11yHint, u as uiUxHint } from './prop.validators.js';

const READABLE_CHARS = /[a-zA-Z0-9äöüÄÖÜß]/g;
const ONLY_NUMBERS = /^\d+$/;
function countReadableChars(str) {
    var _a;
    return typeof str === 'string' ? ((_a = str.match(READABLE_CHARS)) === null || _a === void 0 ? void 0 : _a.length) || 0 : 0;
}
function hasEnoughReadableChars(str, min = 1) {
    return countReadableChars(str) >= min;
}
function containsOnlyNumbers(str) {
    return ONLY_NUMBERS.test(str);
}
function getValidationOptions(options) {
    var _a;
    return Object.assign(Object.assign({}, options), { hooks: {
            afterPatch: (value, state, component, key) => {
                var _a, _b;
                if (typeof ((_a = options.hooks) === null || _a === void 0 ? void 0 : _a.afterPatch) === 'function') {
                    (_b = options.hooks) === null || _b === void 0 ? void 0 : _b.afterPatch(value, state, component, key);
                }
                if (typeof value === 'string' && hasEnoughReadableChars(value, 3) === false && containsOnlyNumbers(value) === false) {
                    a11yHint(`The heading or label ("${value}") is inaccessible. A label should consist of at least three readable characters.`);
                }
                if (typeof value === 'string' && value.length > 80) {
                    uiUxHint(`A heading or label should not be longer than 80 characters.`);
                }
            },
            beforePatch: (_a = options.hooks) === null || _a === void 0 ? void 0 : _a.beforePatch,
        } });
}
const LABEL_VALUES = new Set(['string']);
const validateLabel = (component, value, options = {}) => {
    watchValidator(component, '_label', (value) => typeof value === 'string', LABEL_VALUES, value, getValidationOptions(options));
};
const validateLabelWithExpertSlot = validateLabel;

export { validateLabelWithExpertSlot as a, containsOnlyNumbers as c, hasEnoughReadableChars as h, validateLabel as v };
//# sourceMappingURL=label.js.map

//# sourceMappingURL=label.js.map