import { _objectSpread2 } from "../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { formatDate } from "./formatDate.js";
import { formatWeekday } from "./formatWeekday.js";
import { getRelativeDay, getRelativeDayLabel } from "./relativeDay.js";
//#region src/components/pisellDateTimeDisplay/utils/formatDateOrRelative.ts
/**
* 获取「日期部分」的展示文案（相对日内置在 datetime）
* - 若开启 showRelativeDay 且日期为今天/昨天/明天，返回相对日文案（如「今天」「Yesterday」）
* - 否则返回「星期, 日期」格式（用于时间区间跨天等场景）
*
* 供 PisellDateTimeDisplay、PisellTimeRangeDisplay 等统一使用，相对时间逻辑只在此处维护
*/
function getDatePartDisplay(params) {
	const { date, dateFormat, weekdayFormat, referenceDate, dateFormatOverride } = params;
	if (dateFormat === null || dateFormat === void 0 ? void 0 : dateFormat.showRelativeDay) {
		const rel = getRelativeDay(date, referenceDate);
		if (rel) {
			var _labels$rel;
			const labels = dateFormat.relativeDayLabels;
			return (_labels$rel = labels === null || labels === void 0 ? void 0 : labels[rel]) !== null && _labels$rel !== void 0 ? _labels$rel : getRelativeDayLabel(rel, date.locale());
		}
	}
	const mergedDateConfig = _objectSpread2(_objectSpread2({}, dateFormat), dateFormatOverride);
	return `${formatWeekday(date, _objectSpread2(_objectSpread2({}, weekdayFormat), {}, { trailingComma: true }))} ${formatDate(date, mergedDateConfig)}`;
}
//#endregion
export { getDatePartDisplay };
