"use client";
//#region packages/@mantine/core/src/components/TagsInput/get-splitted-tags.ts
function splitTags(splitChars, value) {
	if (!splitChars) return [value];
	return value.split(new RegExp(`[${splitChars.join("")}]`)).map((tag) => tag.trim()).filter((tag) => tag !== "");
}
function getSplittedTags({ splitChars, allowDuplicates, maxTags, value, currentTags, isDuplicate, onDuplicate }) {
	const splitted = splitTags(splitChars, value);
	const merged = [];
	if (allowDuplicates) merged.push(...currentTags, ...splitted);
	else {
		merged.push(...currentTags);
		for (const tag of splitted) if ((isDuplicate ? (val) => isDuplicate(val, merged) : (val) => merged.some((t) => t.toLowerCase() === val.toLowerCase()))(tag)) onDuplicate?.(tag);
		else merged.push(tag);
	}
	return maxTags ? merged.slice(0, maxTags) : merged;
}
//#endregion
export { getSplittedTags };

//# sourceMappingURL=get-splitted-tags.mjs.map