/**
 * PermissionPrompt - Render permission request
 * Emits via UiCommandChannel only (never private services).
 *
 * @module packages/tui/src/components/PermissionPrompt
 */

export interface PermissionPromptProps {
  tool_name: string
  reason: string
  risk_score: number
  on_allow: () => void
  on_deny: () => void
  on_always_allow?: () => void
}

export function PermissionPrompt({ tool_name, reason, risk_score, on_allow, on_deny, on_always_allow }: PermissionPromptProps): string {
  const risk_bar = '█'.repeat(Math.min(10, Math.ceil(risk_score / 10))) + '░'.repeat(Math.max(0, 10 - Math.ceil(risk_score / 10)))

  return [
    '═══ Permission Required ═══',
    `Tool:   ${tool_name}`,
    `Reason: ${reason}`,
    `Risk:   [${risk_bar}] ${risk_score}/100`,
    '',
    '[A] Allow  [D] Deny  [S] Allow Always',
    '═══════════════════════════'
  ].join('\n')
}
