//#region src/zod.ts
function resolveMessages(source) {
	if (typeof source === "function") return source;
	const msgs = source;
	return (key) => msgs[key];
}
function createZodErrorMap(source) {
	const m = resolveMessages(source);
	return (issue) => {
		switch (issue.code) {
			case "invalid_type":
				if (issue.input === void 0) return { message: m("required") };
				if (issue.expected === "date") return { message: m("invalid_date") };
				return { message: m("invalid_type") };
			case "too_small": return { message: issue.origin === "string" ? m("too_small_string") : m("too_small_number") };
			case "too_big": return { message: issue.origin === "string" ? m("too_big_string") : m("too_big_number") };
			case "invalid_format": {
				const format = issue.format;
				if (format === "email") return { message: m("invalid_string_email") };
				if (format === "url") return { message: m("invalid_string_url") };
				return { message: m("invalid_type") };
			}
			case "invalid_value": return { message: m("invalid_enum_value") };
			case "custom": return { message: m("custom") };
			default: return;
		}
	};
}
//#endregion
export { createZodErrorMap };
