/**
* Lookup map from rule name to rule object.
*/
var RULES_MAP = {
	disallowComma: {
		name: "disallowComma",
		type: "disallow",
		validate: (_, key) => !key.includes(","),
		sanitize: (value) => value.replaceAll(",", "")
	},
	disallowLeadingDot: {
		name: "disallowLeadingDot",
		type: "disallow",
		validate: (input, key) => !(key === "." && input.selectionStart === 0),
		sanitize: (value) => value.replace(/^\.+/, "")
	},
	disallowMultipleDots: {
		name: "disallowMultipleDots",
		type: "disallow",
		validate: (input, key) => !(key === "." && input.value.split(".").length > 1),
		sanitize: (value) => {
			const [integer, ...decimals] = value.split(".");
			return decimals.length > 0 ? `${integer}.${decimals.join("")}` : integer;
		}
	},
	disallowDecimal: {
		name: "disallowDecimal",
		type: "disallow",
		validate: (_, key) => key !== ".",
		sanitize: (value) => value.replaceAll(".", "")
	},
	allowNumbersAndDot: {
		name: "allowNumbersAndDot",
		type: "allow",
		validate: (_, key) => /^[0-9.]$/.test(key),
		sanitize: (value) => value.replace(/[^0-9.]/g, "")
	},
	allowAlphanumeric: {
		name: "allowAlphanumeric",
		type: "allow",
		validate: (_, key) => /^[a-zA-Z0-9]$/.test(key),
		sanitize: (value) => value.replace(/[^a-zA-Z0-9]/g, "")
	},
	allowDash: {
		name: "allowDash",
		type: "allow",
		validate: (_, key) => key === "-",
		sanitize: (value) => value.replace(/[^-]/g, "")
	},
	allowUnderscore: {
		name: "allowUnderscore",
		type: "allow",
		validate: (_, key) => key === "_",
		sanitize: (value) => value.replace(/[^_]/g, "")
	}
};
//#endregion
export { RULES_MAP };
