export function formatLarkTitle(envelope) {
    const title = typeof envelope.data.title === 'string' ? String(envelope.data.title) : 'Issue update';
    if (envelope.event === 'issue_task_start')
        return `Task started: ${title}`;
    if (envelope.event === 'issue_task_done')
        return `Task done: ${title}`;
    return `Issue status: ${title}`;
}
export function formatLarkContent(envelope) {
    const lines = [
        `Event: ${envelope.event}`,
        `Workspace: ${envelope.workspaceId}`,
        envelope.data.issueId ? `Issue: ${envelope.data.issueId}` : '',
        envelope.data.taskId ? `Task: ${envelope.data.taskId}` : '',
        envelope.data.to ? `Status: ${String(envelope.data.from ?? '')} -> ${String(envelope.data.to)}` : '',
        envelope.data.message ? String(envelope.data.message) : '',
        formatResult(envelope.data.result),
    ];
    return lines.filter(Boolean).join('\n');
}
export function formatResult(result) {
    if (!result)
        return '';
    return [
        `Success: ${result.success}`,
        result.summary ? `Summary: ${result.summary}` : '',
        result.error ? `Error: ${result.error}` : '',
    ].filter(Boolean).join('\n');
}
export function truncateLine(value, maxLength) {
    const compact = value.replace(/\s+/g, ' ').trim();
    return compact.length > maxLength ? `${compact.slice(0, maxLength - 3)}...` : compact;
}
//# sourceMappingURL=format.js.map