//#region src/tui/tui-session-format.ts
/** Compact relative time for session picker rows (pi-style). */
function formatSessionAge(updatedAtMs) {
	if (updatedAtMs == null || !Number.isFinite(updatedAtMs)) return "";
	const diffMs = Date.now() - updatedAtMs;
	if (diffMs < 6e4) return "now";
	const diffMins = Math.floor(diffMs / 6e4);
	if (diffMins < 60) return `${diffMins}m`;
	const diffHours = Math.floor(diffMs / 36e5);
	if (diffHours < 24) return `${diffHours}h`;
	const diffDays = Math.floor(diffMs / 864e5);
	if (diffDays < 7) return `${diffDays}d`;
	if (diffDays < 30) return `${Math.floor(diffDays / 7)}w`;
	if (diffDays < 365) return `${Math.floor(diffDays / 30)}mo`;
	return `${Math.floor(diffDays / 365)}y`;
}
function sessionMetadataToTuiItem(meta) {
	const cd = meta.customData;
	const modelRef = typeof cd?.model === "string" ? cd.model : typeof cd?.modelRef === "string" ? cd.modelRef : null;
	return {
		key: meta.key,
		displayName: meta.name,
		updatedAt: Date.parse(meta.updatedAt),
		totalTokens: meta.estimatedTokens ?? null,
		messageCount: meta.messageCount,
		model: modelRef
	};
}
function formatSessionPickerDescription(session) {
	const parts = [];
	const age = formatSessionAge(session.updatedAt ?? null);
	if (age) parts.push(age);
	if (session.messageCount != null) parts.push(`${session.messageCount} msgs`);
	if (session.totalTokens != null) parts.push(`${session.totalTokens} tok`);
	if (session.model) parts.push(String(session.model));
	return parts.join(" · ");
}
//#endregion
export { formatSessionAge, formatSessionPickerDescription, sessionMetadataToTuiItem };

//# sourceMappingURL=tui-session-format.js.map