/** Show the remaining-count hint when this many characters (or fewer) are left. */ export function remainingThreshold(maxLength: number): number { return Math.max(8, Math.min(50, Math.round(maxLength / 10))); } export function characterRemainingVisible(length: number, maxLength: number): boolean { return maxLength - length <= remainingThreshold(maxLength); } export function characterRemainingLabel(remaining: number, maxLength: number): string { return remaining <= 0 ? `已达 ${maxLength} 字上限` : `还剩 ${remaining} 字`; } /** Stable live text: one announcement on entering the threshold, one at the cap. */ export function characterRemainingAnnouncement(remaining: number, maxLength: number): string { return remaining <= 0 ? `已达 ${maxLength} 字上限` : "接近字数上限"; }