/**
 * Onboarding ViewModel Builder
 *
 * Transforms API DTOs into ViewModels for client-side state management.
 * Deterministic, side-effect free.
 */

import { Result } from '@/lib/contracts/Result';
import { DomainError } from '@/lib/contracts/services/Service';
import { OnboardingViewModel } from '@/lib/view-models/OnboardingViewModel';

export class OnboardingViewModelBuilder {
  static build(apiDto: { isAlreadyOnboarded: boolean }): Result<OnboardingViewModel, DomainError> {
    try {
      return Result.ok({
        isAlreadyOnboarded: apiDto.isAlreadyOnboarded || false,
      });
    } catch (error) {
      const errorMessage = error instanceof Error ? error.message : 'Failed to build ViewModel';
      return Result.err({ type: 'unknown', message: errorMessage });
    }
  }
}