import { StringResult } from './types';

export class BlinkIdUtilities {
  /**
   * Helper method for handling different string types,
   * based on the document information source.
   */
  static handleStringType<T>(raw: any): T | undefined {
    if (typeof raw === 'string') {
      return raw as T;
    }

    // Heuristically assume it's a StringResult if it's an object and matches expected shape
    if (typeof raw === 'object' && raw !== null && 'value' in raw) {
      return new StringResult(raw) as T;
    }

    return undefined;
  }
}