import { isNotNil } from '@angular-ru/cdk/utils';

const REG_EXP_STRICT_NAME = /^[a-z,A-Z,_]{1}[a-z,A-Z,0-9,_,]*$/;
const REG_EXP_NO_CYRILLIC = /[^а-я,А-Я]+/g;
const REG_EXP_DIGITS_SEPARATED_BY_COMMA = /[0-9]+(,[0-9]+)*,?/g;
const REG_EXP_DIGITS = /[0-9]*/g;
const REG_EXP_CREDIT_CARD_NUMBER_WITH_SEPARATOR = /^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{4}$/g;

function ensureRegexp(regexp) {
    let prepared = regexp.charAt(0) === '/' ? regexp.slice(1) : regexp;
    prepared = prepared.charAt(prepared.length - 1) === '/' ? prepared.slice(0, prepared.length - 1) : prepared;
    return prepared;
}

const MIN_SIZE_REGEXP = 2;
function isRegexpStr(value) {
    var _a;
    return (((_a = value === null || value === void 0 ? void 0 : value.length) !== null && _a !== void 0 ? _a : 0) > MIN_SIZE_REGEXP && (value === null || value === void 0 ? void 0 : value.charAt(0)) === '/' && (value === null || value === void 0 ? void 0 : value.charAt((value === null || value === void 0 ? void 0 : value.length) - 1)) === '/');
}

function matchedByRegExp(regexp, value) {
    var _a;
    const matcher = regexp instanceof RegExp ? regexp : new RegExp(ensureRegexp(regexp), 'ig');
    return isNotNil((_a = value.match(matcher)) === null || _a === void 0 ? void 0 : _a[0]);
}

/**
 * Generated bundle index. Do not edit.
 */

export { REG_EXP_CREDIT_CARD_NUMBER_WITH_SEPARATOR, REG_EXP_DIGITS, REG_EXP_DIGITS_SEPARATED_BY_COMMA, REG_EXP_NO_CYRILLIC, REG_EXP_STRICT_NAME, ensureRegexp, isRegexpStr, matchedByRegExp };
//# sourceMappingURL=angular-ru-cdk-regexp.js.map
