{"version":3,"file":"visual-truncate.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/components/visual-truncate.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,oBAAoB;IACpC,kCAAkC;IAClC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,wDAAwD;IACxD,YAAY,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,MAAM,EACb,QAAQ,GAAE,MAAU,GAClB,oBAAoB,CAkBtB","sourcesContent":["/**\n * Shared utility for truncating text to visual lines (accounting for line wrapping).\n * Used by both tool-execution.ts and bash-execution.ts for consistent behavior.\n */\n\nimport { Text } from \"@earendil-works/pi-tui\";\n\nexport interface VisualTruncateResult {\n\t/** The visual lines to display */\n\tvisualLines: string[];\n\t/** Number of visual lines that were skipped (hidden) */\n\tskippedCount: number;\n}\n\n/**\n * Truncate text to a maximum number of visual lines (from the end).\n * This accounts for line wrapping based on terminal width.\n *\n * @param text - The text content (may contain newlines)\n * @param maxVisualLines - Maximum number of visual lines to show\n * @param width - Terminal/render width\n * @param paddingX - Horizontal padding for Text component (default 0).\n *                   Use 0 when result will be placed in a Box (Box adds its own padding).\n *                   Use 1 when result will be placed in a plain Container.\n * @returns The truncated visual lines and count of skipped lines\n */\nexport function truncateToVisualLines(\n\ttext: string,\n\tmaxVisualLines: number,\n\twidth: number,\n\tpaddingX: number = 0,\n): VisualTruncateResult {\n\tif (!text) {\n\t\treturn { visualLines: [], skippedCount: 0 };\n\t}\n\n\t// Create a temporary Text component to render and get visual lines\n\tconst tempText = new Text(text, paddingX, 0);\n\tconst allVisualLines = tempText.render(width);\n\n\tif (allVisualLines.length <= maxVisualLines) {\n\t\treturn { visualLines: allVisualLines, skippedCount: 0 };\n\t}\n\n\t// Take the last N visual lines\n\tconst truncatedLines = allVisualLines.slice(-maxVisualLines);\n\tconst skippedCount = allVisualLines.length - maxVisualLines;\n\n\treturn { visualLines: truncatedLines, skippedCount };\n}\n"]}