import { StepId } from '../../domain/value-objects/StepId';
import type { NavigationResultDTO } from '../dto/NavigationResultDTO';
import type { ClickResultDTO } from '../dto/ClickResultDTO';
import type { WaitResultDTO } from '../dto/WaitResultDTO';
import type { ModalResultDTO } from '../dto/ModalResultDTO';
import type { AutomationResultDTO } from '../dto/AutomationResultDTO';
import type { FormFillResultDTO } from '../dto/FormFillResultDTO';

/**
 * Browser automation interface for Playwright-based automation.
 *
 * This interface defines the contract for browser automation using
 * standard DOM manipulation via Playwright. All automation is done
 * through browser DevTools protocol - no OS-level automation.
 */
export interface IBrowserAutomation {
  /**
   * Navigate to a URL.
   */
  navigateToPage(url: string): Promise<NavigationResultDTO>;
  
  /**
   * Fill a form field by name or selector.
   */
  fillFormField(fieldName: string, value: string): Promise<FormFillResultDTO>;
  
  /**
   * Click an element by selector or action name.
   */
  clickElement(target: string): Promise<ClickResultDTO>;
  
  /**
   * Wait for an element to appear.
   */
  waitForElement(target: string, maxWaitMs?: number): Promise<WaitResultDTO>;
  
  /**
   * Handle modal dialogs.
   */
  handleModal(stepId: StepId, action: string): Promise<ModalResultDTO>;
  
  /**
   * Execute a complete workflow step.
   */
  executeStep?(stepId: StepId, config: Record<string, unknown>): Promise<AutomationResultDTO>;
  
  /**
   * Initialize the browser connection.
   * Returns an AutomationResult indicating success or failure.
   */
  connect?(): Promise<AutomationResultDTO>;
  
  /**
   * Clean up browser resources.
   */
  disconnect?(): Promise<void>;
  
  /**
   * Check if browser is connected and ready.
   */
  isConnected?(): boolean;
}
