// Weft Sandbox Core Types

export interface WeftConfig {
  artifact: {
    id: string;
    name: string;
    generatedAt: string;
    intentHash: string;
    originalSpec: string;
  };
  mockData: Record<string, unknown>;
  apiStubs: ApiStub[];
  navigation: {
    onSuccess?: string;
    onCancel?: string;
    onError?: string;
  };
}

export interface ApiStub {
  method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
  endpoint: string;
  description: string;
  requestSchema?: Record<string, string>;
  mockResponse: unknown;
  mockStatus?: number;
  mockDelay?: number;
}

export interface ActionLog {
  id: string;
  timestamp: Date;
  actionType: 'CLICK' | 'INPUT' | 'SUBMIT' | 'NAVIGATE' | 'API_CALL' | 'SELECT' | 'HOVER';
  element: {
    type: string;
    id?: string;
    text?: string;
    selector: string;
    value?: unknown;
  };
  wouldTrigger: {
    endpoint?: string;
    method?: string;
    payload?: unknown;
    navigation?: string;
  };
  mockResult?: unknown;
  duration?: number;
}

export interface SandboxState {
  isRunning: boolean;
  actionLogs: ActionLog[];
  currentMockData: Record<string, unknown>;
  errors: SandboxError[];
}

export interface SandboxError {
  id: string;
  timestamp: Date;
  type: 'runtime' | 'network' | 'validation' | 'render';
  message: string;
  stack?: string;
  context?: Record<string, unknown>;
}

export interface MockDataProvider {
  data: Record<string, unknown>;
  get(path: string): unknown;
  set(path: string, value: unknown): void;
  reset(): void;
  export(): Record<string, unknown>;
}

export interface ActionSummary {
  totalActions: number;
  byType: Record<string, number>;
  apiCallCount: number;
  uniqueEndpoints: string[];
  averageApiLatency: number;
}
