/**
 * Login ViewModel Builder
 * 
 * Transforms API DTOs into LoginViewModel for client-side state management.
 * Deterministic, side-effect free, no business logic.
 */

import { LoginViewData } from '@/lib/builders/view-data/types/LoginViewData';
import { LoginViewModel, LoginFormState, LoginUIState } from '@/lib/view-models/auth/LoginViewModel';

export class LoginViewModelBuilder {
  static build(viewData: LoginViewData): LoginViewModel {
    const formState: LoginFormState = {
      fields: {
        email: { value: '', error: undefined, touched: false, validating: false },
        password: { value: '', error: undefined, touched: false, validating: false },
        rememberMe: { value: false, error: undefined, touched: false, validating: false },
      },
      isValid: true,
      isSubmitting: false,
      submitError: undefined,
      submitCount: 0,
    };

    const uiState: LoginUIState = {
      showPassword: false,
      showErrorDetails: false,
    };

    return new LoginViewModel(
      viewData.returnTo,
      viewData.hasInsufficientPermissions,
      formState,
      uiState,
      false,
      null
    );
  }
}