//#region src/utils/strings.tsx
const capitalize = (str) => {
	if (str.length === 0) return str;
	return str.charAt(0).toUpperCase() + str.slice(1);
};
const makeEnumPretty = (enumValue, capitalizeAllWords = true) => {
	let formatted = enumValue.toLowerCase().split("_");
	if (capitalizeAllWords) formatted = formatted.map((word) => capitalize(word));
	else if (formatted.length > 0) formatted[0] = capitalize(formatted[0]);
	return formatted.join(" ");
};
function removeChars(value, beginIndex, endIndex) {
	return value.slice(0, beginIndex) + value.slice(endIndex || beginIndex + 1);
}
function isString(str) {
	return typeof str === "string";
}
function removeCommas(value) {
	return value.replace(/,/g, "");
}
function removeNonDigit(value) {
	return value.replace(/[^\d]/g, "").replace(/^0+/, "") || "0";
}
function addCommasToVariableDecimal(value, decimals) {
	const val = removeNonDigit(value.toString());
	return decimals === 0 ? addCommasToDigits(val) : addCommasToDigits(val.padStart(decimals + 1, "0").slice(0, -decimals) + "." + val.padStart(decimals + 1, "0").slice(-decimals));
}
function addCommasToDigits(value) {
	if (typeof value === "number") value = value.toString();
	const [int, decimal] = removeCommas(value).split(".");
	const intWithCommas = int.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
	return decimal ? `${intWithCommas}.${decimal}` : intWithCommas;
}
function removeLeadingZeros(value) {
	if (value.length > 1) return value.replace(/^0+(?=\d)/, "");
	return value;
}
function elide(value, elideArgs = 5) {
	const args = typeof elideArgs === "number" ? {
		maxChars: elideArgs,
		ellipsisPosition: "middle"
	} : elideArgs;
	let displayValue = value;
	if (value.length > args.maxChars) if (typeof args.ellipsisPosition === "number") displayValue = `${value.substr(0, args.ellipsisPosition)}...${value.substr(value.length - args.ellipsisPosition, value.length)}`;
	else if (args.ellipsisPosition === "start") displayValue = `...${value.substr(value.length - args.maxChars, value.length)}`;
	else if (args.ellipsisPosition === "middle") {
		const half = Math.floor(args.maxChars / 2);
		displayValue = `${value.substr(0, half)}...${value.substr(value.length - half, value.length)}`;
	} else displayValue = `${value.substr(0, args.maxChars)}...`;
	return displayValue;
}
//#endregion
export { addCommasToDigits, addCommasToVariableDecimal, capitalize, elide, isString, makeEnumPretty, removeChars, removeCommas, removeLeadingZeros, removeNonDigit };
