export const ledgerRowHeight = 108 export function ledgerWindow(total: number, top: number, height: number) { const visible = Math.max(1, Math.ceil(height / ledgerRowHeight)) const start = Math.min(Math.max(0, total - visible), Math.max(0, Math.floor(top / ledgerRowHeight) - 8)) const end = Math.min(total, start + visible + 16) return { start, end, padTop: start * ledgerRowHeight, padBottom: (total - end) * ledgerRowHeight } } export function ledgerCellPreview(value: string): string { if (value.length <= 400) return value let prefix = '', count = 0 for (const point of value) { if (count++ === 400) return prefix + '…' prefix += point } return prefix }