// @generated by scripts/build-runtime.mjs; do not edit. // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader. import { safeTerminalText } from "./chunk-W64NEHXT.ts"; import { syncConfigReviewFingerprint } from "./chunk-APZVBSM6.ts"; import { compareSyncInclude, sameSyncInclude } from "./chunk-YQ6UW7IF.ts"; // src/sync-attention.ts import { truncateToWidth } from "@earendil-works/pi-tui"; var STATUS_KEY = "sync"; var WIDGET_KEY = "sync:attention"; function syncAttentionMatchesConfig(attention, config) { return attention.decision.setupName === config.setupName && attention.decision.configIdentity === syncConfigReviewFingerprint(config) && sameSyncInclude(attention.decision.localInclude, config.include); } function createSyncAttentionController() { let state; return { set(decision, origin) { state = { decision, origin, offered: false }; }, current() { return state; }, markOffered() { if (!state || state.offered) return false; state = { ...state, offered: true }; return true; }, clear(ctx) { state = void 0; clearAttentionPresentation(ctx); }, reset(ctx) { state = void 0; clearAttentionPresentation(ctx); }, publish(ctx) { if (!state) { clearAttentionPresentation(ctx); return; } const presentation = attentionPresentation(state.decision); ctx.ui.setStatus(STATUS_KEY, presentation.status); if (ctx.mode !== "tui") return; ctx.ui.setWidget(WIDGET_KEY, (_tui, theme) => ({ render(width) { const safeWidth = Math.max(1, width); return presentation.lines.map( (line, index) => truncateToWidth(theme.fg(index === 0 ? "warning" : "muted", line), safeWidth, "\u2026") ); }, invalidate() { } })); } }; } function attentionPresentation(decision) { const setupName = safeTerminalText(decision.setupName); const comparison = compareSyncInclude(decision.localInclude, decision.remoteInclude); const difference = comparison.remoteOnly.length === 0 && comparison.localOnly.length === 0 ? "Only list order differs" : `Remote ${comparison.remoteOnly.length} \xB7 Device ${comparison.localOnly.length}`; return { status: "review needed", lines: [`Pi Sync needs review \xB7 ${setupName}`, difference, "No changes \xB7 Run /sync to review"] }; } function clearAttentionPresentation(ctx) { ctx.ui.setStatus(STATUS_KEY, void 0); ctx.ui.setWidget(WIDGET_KEY, void 0); } export { syncAttentionMatchesConfig, createSyncAttentionController }; //# sourceMappingURL=chunk-JNOOSPEW.ts.map