//#region lib/ui/helpers/phone/formatters.ts
function e(e) {
	return e.replace(/\D/g, "");
}
function t(t, n) {
	let r = e(t);
	if (r.length === 0) return "";
	let i = 0, a = "", o = !1;
	for (let e = 0; e < n.length; e++) if (n[e] === "#") if (i < r.length) {
		if (!o) {
			for (let t = 0; t < e; t++) n[t] !== "#" && (a += n[t]);
			o = !0;
		}
		a += r[i], i++;
	} else break;
	else o && (a += n[e]);
	return a;
}
function n(t, n, r) {
	let i = e(t.substring(0, r)).length, a = 0, o = 0;
	for (let e = 0; e < n.length; e++) if (/\d/.test(n[e]) && (a++, a === i)) {
		o = e + 1;
		break;
	}
	return a < i && (o = n.length), o;
}
function r(e) {
	return (e.match(/#/g) || []).length;
}
function i(t) {
	let n = t.indexOf("#"), r = n > 0 ? t.substring(0, n) : "";
	return {
		literalPrefix: r,
		literalPrefixDigits: e(r)
	};
}
function a(e, t) {
	return t.length > 0 && e.startsWith(t) ? e.substring(t.length) : e;
}
function o(e, t, n) {
	let r = 0, i = 0;
	for (let a = 0; a < t.length; a++) if (/\d/.test(t[a])) {
		if (i < n.length) {
			i++;
			continue;
		}
		if (r++, r === e) return a + 1;
	}
	return t.length;
}
function s(n, s, c) {
	let { literalPrefixDigits: l } = i(s), u = a(e(n), l), d = r(s);
	if (u.length > d) return null;
	let f = a(e(n.substring(0, c)), l).length, p = t(u, s);
	return {
		formatted: p,
		nextCursor: o(f, p, l),
		literalPrefixDigits: l
	};
}
//#endregion
export { o as calculateCursorPosition, r as countDigitPlaceholders, e as extractDigits, s as formatPhoneDigits, t as formatWithPattern, n as getCursorPosition, i as getLiteralPrefixInfo, a as stripLiteralPrefix };

//# sourceMappingURL=formatters.js.map